From 6892c63b899b46fedc9d99b8274a17e9043fe361 Mon Sep 17 00:00:00 2001 From: Ivan Chen Date: Tue, 12 Jan 2021 12:38:46 -0500 Subject: [TMA-527/506/523] Custom Moment Categories (#174) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * changed logic to allow ≥ 1 categories * now using array of strings for moment categories * updated error strings * formatting and check for picker cancellation * initial UI done * cleaned up logic, added custom icon * renamed onboarding stack to match main stack * removed unused import * deterministic color picker * custom category defaults to selected instead of added * removed function in route --- src/store/reducers/momentCategoryReducer.tsx | 9 +++------ src/store/reducers/userXReducer.ts | 12 +++++------- 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'src/store/reducers') diff --git a/src/store/reducers/momentCategoryReducer.tsx b/src/store/reducers/momentCategoryReducer.tsx index d1f448f9..b6909b87 100644 --- a/src/store/reducers/momentCategoryReducer.tsx +++ b/src/store/reducers/momentCategoryReducer.tsx @@ -1,19 +1,16 @@ import {createSlice} from '@reduxjs/toolkit'; import {INITIAL_CATEGORIES_STATE} from '../initialStates'; -import {MomentCategoryType} from '../../types'; const momentCategoriesSlice = createSlice({ name: 'momentCategories', initialState: INITIAL_CATEGORIES_STATE, reducers: { /** - * One stop to add / delete / update categories for a user + * Replace a new copy of moment categories for a user */ momentCategoriesFetched: (state, action) => { - const categories: Array = action.payload.categories; - for (let category of categories) { - state.momentCategories[category] = action.payload.add; - } + const categories: string[] = action.payload.categories; + state.momentCategories = categories; }, }, }); diff --git a/src/store/reducers/userXReducer.ts b/src/store/reducers/userXReducer.ts index fa1598b2..3b00cf88 100644 --- a/src/store/reducers/userXReducer.ts +++ b/src/store/reducers/userXReducer.ts @@ -1,4 +1,4 @@ -import {MomentCategoryType, ScreenType} from '../../types/types'; +import {ScreenType} from '../../types/types'; import {EMPTY_SCREEN_TO_USERS_LIST, EMPTY_USER_X} from '../initialStates'; import {createSlice} from '@reduxjs/toolkit'; @@ -24,12 +24,10 @@ const userXSlice = createSlice({ }, userXMomentCategoriesFetched: (state, action) => { - const categories: Array = action.payload.data; - for (let category of categories) { - state[action.payload.screenType][ - action.payload.userId - ].momentCategories[category] = true; - } + const categories: string[] = action.payload.data; + state[action.payload.screenType][ + action.payload.userId + ].momentCategories = categories; }, userXMomentsFetched: (state, action) => { -- cgit v1.2.3-70-g09d2