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/actions/momentCategories.tsx | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) (limited to 'src/store/actions') diff --git a/src/store/actions/momentCategories.tsx b/src/store/actions/momentCategories.tsx index a522c3e0..987fc9e5 100644 --- a/src/store/actions/momentCategories.tsx +++ b/src/store/actions/momentCategories.tsx @@ -1,13 +1,8 @@ import {RootState} from '../rootReducer'; -import { - deleteMomentCategories, - loadMomentCategories, - postMomentCategories, -} from '../../services'; +import {loadMomentCategories, postMomentCategories} from '../../services'; import {Action, ThunkAction} from '@reduxjs/toolkit'; import {momentCategoriesFetched} from '../reducers'; import {getTokenOrLogout} from '../../utils'; -import {MomentCategoryType} from '../../types'; /** * Load all categories for user @@ -23,7 +18,7 @@ export const loadUserMomentCategories = ( const categories = await loadMomentCategories(userId, token); dispatch({ type: momentCategoriesFetched.type, - payload: {categories, add: true}, + payload: {categories}, }); } catch (error) { console.log(error); @@ -33,28 +28,20 @@ export const loadUserMomentCategories = ( /** * Handle addition / deletion of categories for a user * @param categories List of categories - * @param add boolean, if true, we add new categories, else we delete * @param userId id of the user for whom categories should be updated */ export const updateMomentCategories = ( - categories: Array, - add: boolean, - userId: string, + categories: string[], ): ThunkAction, RootState, unknown, Action> => async ( dispatch, ) => { try { const token = await getTokenOrLogout(dispatch); - let success = false; - if (add) { - success = await postMomentCategories(categories, token); - } else { - success = await deleteMomentCategories(categories, userId, token); - } + const success = await postMomentCategories(categories, token); if (success) { dispatch({ type: momentCategoriesFetched.type, - payload: {categories, add}, + payload: {categories}, }); } } catch (error) { -- cgit v1.2.3-70-g09d2