Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import {
- APP__HANDLINE_CREATE_CATEGORY_FORM,
- APP__HANDLINE_CREATE_TASK_FORM,
- APP__SET_ACTIVE_CATEGORY_ID,
- // AppTypes,
- } from "../types/app-types";
- import { IAppReducer } from "../interface/reducers-interface/appReducerInterface";
- const initialState = {
- appData: {
- showCreateCategoryForm: false,
- showCreateTaskForm: false,
- activeCategoryID: 0,
- },
- };
- interface IhandlerCategoryForm {
- type: typeof APP__HANDLINE_CREATE_CATEGORY_FORM;
- payload: boolean;
- }
- interface IhandlerTaskForm {
- type: typeof APP__HANDLINE_CREATE_TASK_FORM;
- payload: boolean;
- }
- interface IselectActiveCategory {
- type: typeof APP__SET_ACTIVE_CATEGORY_ID;
- payload: number;
- }
- export type AppTypes = IhandlerCategoryForm | IhandlerTaskForm | IselectActiveCategory;
- export type initialStateType = typeof initialState;
- export const appReducer = (state = initialState, action: AppTypes): initialStateType => {
- switch (action.type) {
- case APP__HANDLINE_CREATE_CATEGORY_FORM:
- return { ...state, appData: { ...state.appData, showCreateCategoryForm: action.payload } };
- case APP__HANDLINE_CREATE_TASK_FORM:
- return { ...state, appData: { ...state.appData, showCreateTaskForm: action.payload } };
- case APP__SET_ACTIVE_CATEGORY_ID:
- return { ...state, appData: { ...state.appData, activeCategoryID: action.payload } };
- default:
- return state;
- }
- };
Advertisement
Add Comment
Please, Sign In to add comment