From 6acec23daeb748882c344a947d5156a8bdee3095 Mon Sep 17 00:00:00 2001 From: Jason Syrotuck Date: Thu, 19 Oct 2023 11:14:52 -0700 Subject: [PATCH] sync common folders --- .../verifiableCredentialActionCreator.js | 32 +++++++++++++++++++ .../actions/verfiableCredentialActions.js | 6 ++++ .../core-web/common/constants/actionTypes.js | 3 ++ .../core-web/common/constants/reducerTypes.js | 4 +++ services/core-web/common/reducers.js | 2 ++ .../reducers/verifiableCredentialReducer.js | 32 +++++++++++++++++++ .../verifiableCredentialSelectors.js | 3 ++ 7 files changed, 82 insertions(+) create mode 100644 services/core-web/common/actionCreators/verifiableCredentialActionCreator.js create mode 100644 services/core-web/common/actions/verfiableCredentialActions.js create mode 100644 services/core-web/common/reducers/verifiableCredentialReducer.js create mode 100644 services/core-web/common/selectors/verifiableCredentialSelectors.js diff --git a/services/core-web/common/actionCreators/verifiableCredentialActionCreator.js b/services/core-web/common/actionCreators/verifiableCredentialActionCreator.js new file mode 100644 index 0000000000..554621c74f --- /dev/null +++ b/services/core-web/common/actionCreators/verifiableCredentialActionCreator.js @@ -0,0 +1,32 @@ +import { notification } from "antd"; +import { ENVIRONMENT } from "@mds/common"; +import { request, success, error } from "../actions/genericActions"; +import * as reducerTypes from "../constants/reducerTypes"; +import * as verfiableCredentialActions from "../actions/verfiableCredentialActions"; +import { createRequestHeader } from "../utils/RequestHeaders"; +import { showLoading, hideLoading } from "react-redux-loading-bar"; +import CustomAxios from "../customAxios"; + +export const createVCWalletInvitation = (party_guid) => (dispatch) => { + dispatch(showLoading("modal")); + dispatch(request(reducerTypes.CREATE_VC_WALLET_CONNECTION_INVITATION)); + return CustomAxios() + .post( + `${ENVIRONMENT.apiUrl}/verifiable-credentials/oob-invitation/${party_guid}`, + null, + createRequestHeader() + ) + .then((response) => { + dispatch(success(reducerTypes.CREATE_VC_WALLET_CONNECTION_INVITATION)); + dispatch(verfiableCredentialActions.storeVCConnectionInvitation(response.data)); + dispatch(hideLoading("modal")); + }) + .catch((err) => { + notification.error({ + message: err.response ? err.response.data.message : String.ERROR, + duration: 10, + }); + dispatch(error(reducerTypes.CREATE_VC_WALLET_CONNECTION_INVITATION)); + dispatch(hideLoading("modal")); + }); +}; diff --git a/services/core-web/common/actions/verfiableCredentialActions.js b/services/core-web/common/actions/verfiableCredentialActions.js new file mode 100644 index 0000000000..a8feda8c1f --- /dev/null +++ b/services/core-web/common/actions/verfiableCredentialActions.js @@ -0,0 +1,6 @@ +import * as ActionTypes from "../constants/actionTypes"; + +export const storeVCConnectionInvitation = (payload) => ({ + type: ActionTypes.STORE_VC_WALLET_CONNECTION_INVITATION, + payload, +}); diff --git a/services/core-web/common/constants/actionTypes.js b/services/core-web/common/constants/actionTypes.js index ec6ffdecb7..3b2a0d218d 100755 --- a/services/core-web/common/constants/actionTypes.js +++ b/services/core-web/common/constants/actionTypes.js @@ -187,3 +187,6 @@ export const CLEAR_TAILINGS_STORAGE_FACILITY = "CLEAR_TAILINGS_STORAGE_FACILITY" // Dams export const STORE_DAM = "STORE_DAM"; + +// Verifiable Credentials +export const STORE_VC_WALLET_CONNECTION_INVITATION = "STORE_VC_WALLET_CONNECTION_INVITATION"; diff --git a/services/core-web/common/constants/reducerTypes.js b/services/core-web/common/constants/reducerTypes.js index e398a056ca..562a6b3870 100644 --- a/services/core-web/common/constants/reducerTypes.js +++ b/services/core-web/common/constants/reducerTypes.js @@ -305,3 +305,7 @@ export const GET_DAM = "GET_DAM"; // Alerts export const GET_GLOBAL_ALERTS = "GET_GLOBAL_ALERTS"; + +//Verficable Credentials +export const VERIFIABLE_CREDENTIALS = "VERIFIABLE_CREDENTIALS"; +export const CREATE_VC_WALLET_CONNECTION_INVITATION = "CREATE_VC_WALLET_CONNECTION_INVITATION"; diff --git a/services/core-web/common/reducers.js b/services/core-web/common/reducers.js index 1d020b3c38..c13cca3a57 100644 --- a/services/core-web/common/reducers.js +++ b/services/core-web/common/reducers.js @@ -24,6 +24,7 @@ import tailingsReducerObject from "./reducers/tailingsReducer"; import userReducerObject from "./reducers/userReducer"; import varianceReducerObject from "./reducers/varianceReducer"; import workInformationReducerObject from "./reducers/workInformationReducer"; +import verifiableCredentialReducerObject from "./reducers/verifiableCredentialReducer"; export const complianceReducer = complianceReducerObject; export const authenticationReducer = authenticationReducerObject; @@ -50,3 +51,4 @@ export const noticeOfDepartureReducer = noticeOfDepartureReducerObject; export const activityReducer = activityReducerObject; export const tailingsReducer = tailingsReducerObject; export const damReducer = damReducerObject; +export const verifiableCredentialReducer = verifiableCredentialReducerObject; diff --git a/services/core-web/common/reducers/verifiableCredentialReducer.js b/services/core-web/common/reducers/verifiableCredentialReducer.js new file mode 100644 index 0000000000..2569c421d1 --- /dev/null +++ b/services/core-web/common/reducers/verifiableCredentialReducer.js @@ -0,0 +1,32 @@ +import * as actionTypes from "../constants/actionTypes"; +import { VERIFIABLE_CREDENTIALS } from "../constants/reducerTypes"; + +/** + * @file verifiableCredentialReducer.js + * all data associated with verificable credential records. + */ + +const initialState = { + vcWalletConnectionInvitation: {}, +}; + +const verifiableCredentialReducer = (state = initialState, action) => { + switch (action.type) { + case actionTypes.STORE_VC_WALLET_CONNECTION_INVITATION: + return { + ...state, + vcWalletConnectionInvitation: action.payload, + }; + default: + return state; + } +}; + +const verifiableCredentialReducerObject = { + [VERIFIABLE_CREDENTIALS]: verifiableCredentialReducer, +}; + +export const getVCWalletConnectionInvitation = (state) => + state[VERIFIABLE_CREDENTIALS].vcWalletConnectionInvitation; + +export default verifiableCredentialReducerObject; diff --git a/services/core-web/common/selectors/verifiableCredentialSelectors.js b/services/core-web/common/selectors/verifiableCredentialSelectors.js new file mode 100644 index 0000000000..fe624704b2 --- /dev/null +++ b/services/core-web/common/selectors/verifiableCredentialSelectors.js @@ -0,0 +1,3 @@ +import * as verifiableCredentialReducer from "../reducers/verifiableCredentialReducer"; + +export const { getVCWalletConnectionInvitation } = verifiableCredentialReducer;