123456789101112131415161718192021222324252627282930313233343536 |
- import { createReducer } from '@reduxjs/toolkit';
- import { IAuthorizationState } from '../../../typescript/redux/authorization/interfaces';
- import {
- actionLogInSuccess,
- actionLogInReject,
- actionLogOutSuccess,
- actionLogOutReject,
- } from '../action';
- const initialState:IAuthorizationState = {
- token: '',
- number: '',
- name: '',
- lastName: '',
- country:'',
- avatarUrl: '',
- };
- const reducerAuthorization = createReducer(initialState, {
- [actionLogInSuccess.type]: (state, { payload:token }: {payload: string}) => {
- return {...state,token};
- },
- [actionLogInReject.type]: (state, _) => {
- return state;
- },
- [actionLogOutSuccess.type]: (_state, _) => {
- return initialState;
- },
- [actionLogOutReject.type]: (state, _) => {
- return state;
- },
- });
- export default reducerAuthorization;
|