feat: created onboarding store and added modals slice
parent
a07fea677b
commit
eaa9817d14
@ -0,0 +1,15 @@
|
||||
import { useSelector } from 'react-redux';
|
||||
import { getTermsOfServicePrivacyModalState } from '../../state/onboarding/selectors/modals';
|
||||
import { TermsOfServicePrivacyDialog } from '../dialog/TermsOfServicePrivacyDialog';
|
||||
|
||||
export const ModalContainer = () => {
|
||||
const termsOfServicePrivacyModalState = useSelector(getTermsOfServicePrivacyModalState);
|
||||
|
||||
return (
|
||||
<>
|
||||
{termsOfServicePrivacyModalState && (
|
||||
<TermsOfServicePrivacyDialog {...termsOfServicePrivacyModalState} />
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
@ -0,0 +1,28 @@
|
||||
import { PayloadAction, createSlice } from '@reduxjs/toolkit';
|
||||
import { TermsOfServicePrivacyDialogProps } from '../../../components/dialog/TermsOfServicePrivacyDialog';
|
||||
|
||||
export type TermsOfServicePrivacyModalState = TermsOfServicePrivacyDialogProps | null;
|
||||
|
||||
export type ModalsState = {
|
||||
termsOfServicePrivacyModalState: TermsOfServicePrivacyModalState | null;
|
||||
};
|
||||
|
||||
const initialState: ModalsState = {
|
||||
termsOfServicePrivacyModalState: null,
|
||||
};
|
||||
|
||||
export const modalsSlice = createSlice({
|
||||
name: 'modals',
|
||||
initialState,
|
||||
reducers: {
|
||||
updateTermsOfServicePrivacyModal(
|
||||
state,
|
||||
action: PayloadAction<TermsOfServicePrivacyModalState>
|
||||
) {
|
||||
return { ...state, termsOfServicePrivacyModalState: action.payload };
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const { updateTermsOfServicePrivacyModal } = modalsSlice.actions;
|
||||
export default modalsSlice.reducer;
|
@ -0,0 +1,12 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
import { ModalsState, TermsOfServicePrivacyModalState } from '../ducks/modals';
|
||||
import { OnboardingStoreState } from '../store';
|
||||
|
||||
const getModals = (state: OnboardingStoreState): ModalsState => {
|
||||
return state.modals;
|
||||
};
|
||||
|
||||
export const getTermsOfServicePrivacyModalState = createSelector(
|
||||
getModals,
|
||||
(state: ModalsState): TermsOfServicePrivacyModalState => state.termsOfServicePrivacyModalState
|
||||
);
|
@ -0,0 +1,9 @@
|
||||
import { configureStore } from '@reduxjs/toolkit';
|
||||
import modalsReducer from './ducks/modals';
|
||||
|
||||
export const onboardingStore = configureStore({
|
||||
reducer: { modals: modalsReducer },
|
||||
});
|
||||
|
||||
export type OnboardingStoreState = ReturnType<typeof onboardingStore.getState>;
|
||||
export type OnboardingStoreDispatch = typeof onboardingStore.dispatch;
|
Loading…
Reference in New Issue