31 lines
886 B
TypeScript
31 lines
886 B
TypeScript
import { createSlice, createSelector } from '@reduxjs/toolkit'
|
|
import type { PayloadAction } from '@reduxjs/toolkit'
|
|
|
|
interface IPrivacyPolicy {
|
|
checked: boolean
|
|
dateOfCheck: string
|
|
}
|
|
|
|
const initialState: IPrivacyPolicy = {
|
|
checked: false,
|
|
dateOfCheck: '',
|
|
}
|
|
|
|
const privacyPolicySlice = createSlice({
|
|
name: 'privacyPolicy',
|
|
initialState,
|
|
reducers: {
|
|
updateChecked(state, action: PayloadAction<boolean>) {
|
|
return { ...state, checked: action.payload, dateOfCheck: new Date().toISOString() }
|
|
},
|
|
},
|
|
extraReducers: (builder) => builder.addCase('reset', () => initialState),
|
|
})
|
|
|
|
export const { actions } = privacyPolicySlice
|
|
export const selectPrivacyPolicy = createSelector(
|
|
(state: { privacyPolicy: IPrivacyPolicy }) => state.privacyPolicy,
|
|
(privacyPolicy) => privacyPolicy
|
|
)
|
|
export default privacyPolicySlice.reducer
|