aboutsummaryrefslogtreecommitdiff
path: root/src/store/reducers
diff options
context:
space:
mode:
authorIvan Chen <ivan@thetaggid.com>2021-01-12 12:38:46 -0500
committerGitHub <noreply@github.com>2021-01-12 12:38:46 -0500
commit6892c63b899b46fedc9d99b8274a17e9043fe361 (patch)
tree454d836c5848b4d9b2e082ae19e4e64679ccd49d /src/store/reducers
parentd955c6bc31be3b2e3e289a8dec8b5970251d4090 (diff)
[TMA-527/506/523] Custom Moment Categories (#174)
* 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
Diffstat (limited to 'src/store/reducers')
-rw-r--r--src/store/reducers/momentCategoryReducer.tsx9
-rw-r--r--src/store/reducers/userXReducer.ts12
2 files changed, 8 insertions, 13 deletions
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<MomentCategoryType> = 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<MomentCategoryType> = action.payload.data;
- for (let category of categories) {
- state[<ScreenType>action.payload.screenType][
- action.payload.userId
- ].momentCategories[category] = true;
- }
+ const categories: string[] = action.payload.data;
+ state[<ScreenType>action.payload.screenType][
+ action.payload.userId
+ ].momentCategories = categories;
},
userXMomentsFetched: (state, action) => {