Skip to content

Commit

Permalink
sync common folders
Browse files Browse the repository at this point in the history
  • Loading branch information
Jsyro committed Oct 19, 2023
1 parent 8f88665 commit 6acec23
Show file tree
Hide file tree
Showing 7 changed files with 82 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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"));
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import * as ActionTypes from "../constants/actionTypes";

export const storeVCConnectionInvitation = (payload) => ({
type: ActionTypes.STORE_VC_WALLET_CONNECTION_INVITATION,
payload,
});
3 changes: 3 additions & 0 deletions services/core-web/common/constants/actionTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
4 changes: 4 additions & 0 deletions services/core-web/common/constants/reducerTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
2 changes: 2 additions & 0 deletions services/core-web/common/reducers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -50,3 +51,4 @@ export const noticeOfDepartureReducer = noticeOfDepartureReducerObject;
export const activityReducer = activityReducerObject;
export const tailingsReducer = tailingsReducerObject;
export const damReducer = damReducerObject;
export const verifiableCredentialReducer = verifiableCredentialReducerObject;
32 changes: 32 additions & 0 deletions services/core-web/common/reducers/verifiableCredentialReducer.js
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import * as verifiableCredentialReducer from "../reducers/verifiableCredentialReducer";

export const { getVCWalletConnectionInvitation } = verifiableCredentialReducer;

0 comments on commit 6acec23

Please sign in to comment.