Move the safety number viewer into modal

This commit is contained in:
Josh Perez 2021-10-06 16:27:14 -04:00 committed by GitHub
parent 8c34d6ebc2
commit 048e1e4cd7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
14 changed files with 132 additions and 167 deletions

View file

@ -7,6 +7,7 @@ export type GlobalModalsStateType = {
readonly contactModalState?: ContactModalStateType;
readonly isProfileEditorVisible: boolean;
readonly profileEditorHasError: boolean;
readonly safetyNumberModalContactId?: string;
};
// Actions
@ -16,6 +17,7 @@ const SHOW_CONTACT_MODAL = 'globalModals/SHOW_CONTACT_MODAL';
const TOGGLE_PROFILE_EDITOR = 'globalModals/TOGGLE_PROFILE_EDITOR';
export const TOGGLE_PROFILE_EDITOR_ERROR =
'globalModals/TOGGLE_PROFILE_EDITOR_ERROR';
const TOGGLE_SAFETY_NUMBER_MODAL = 'globalModals/TOGGLE_SAFETY_NUMBER_MODAL';
export type ContactModalStateType = {
contactId: string;
@ -39,11 +41,17 @@ export type ToggleProfileEditorErrorActionType = {
type: typeof TOGGLE_PROFILE_EDITOR_ERROR;
};
type ToggleSafetyNumberModalActionType = {
type: typeof TOGGLE_SAFETY_NUMBER_MODAL;
payload: string | undefined;
};
export type GlobalModalsActionType =
| HideContactModalActionType
| ShowContactModalActionType
| ToggleProfileEditorActionType
| ToggleProfileEditorErrorActionType;
| ToggleProfileEditorErrorActionType
| ToggleSafetyNumberModalActionType;
// Action Creators
@ -52,6 +60,7 @@ export const actions = {
showContactModal,
toggleProfileEditor,
toggleProfileEditorHasError,
toggleSafetyNumberModal,
};
function hideContactModal(): HideContactModalActionType {
@ -81,6 +90,15 @@ function toggleProfileEditorHasError(): ToggleProfileEditorErrorActionType {
return { type: TOGGLE_PROFILE_EDITOR_ERROR };
}
function toggleSafetyNumberModal(
safetyNumberModalContactId?: string
): ToggleSafetyNumberModalActionType {
return {
type: TOGGLE_SAFETY_NUMBER_MODAL,
payload: safetyNumberModalContactId,
};
}
// Reducer
export function getEmptyState(): GlobalModalsStateType {
@ -122,5 +140,12 @@ export function reducer(
};
}
if (action.type === TOGGLE_SAFETY_NUMBER_MODAL) {
return {
...state,
safetyNumberModalContactId: action.payload,
};
}
return state;
}