diff options
| author | Ashm Walia <40498934+ashmgarv@users.noreply.github.com> | 2020-12-22 08:50:27 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-12-22 11:50:27 -0500 |
| commit | a954d6b6b88485dddc0ccfda634ffd102cb34ccd (patch) | |
| tree | 560f152dd92ccb482a2bbf6b094060525373322c /src/store/reducers | |
| parent | 49ed044f5103cf6288fcf5b3ff6d3d720795860c (diff) | |
[TMA 446] Create category (#144)
* Added welcome page
* Working code
* Small fix
* Some more cleanup
* Fixes
* Cleanup
* Fix again
* Use gradient for white bg as well
* Fixed type
Diffstat (limited to 'src/store/reducers')
| -rw-r--r-- | src/store/reducers/index.ts | 1 | ||||
| -rw-r--r-- | src/store/reducers/momentCategoryReducer.tsx | 22 | ||||
| -rw-r--r-- | src/store/reducers/userXReducer.ts | 17 |
3 files changed, 39 insertions, 1 deletions
diff --git a/src/store/reducers/index.ts b/src/store/reducers/index.ts index 0e378bc5..e09b41ee 100644 --- a/src/store/reducers/index.ts +++ b/src/store/reducers/index.ts @@ -5,3 +5,4 @@ export * from './userSocialsReducer'; export * from './taggUsersReducer'; export * from './userBlockReducer'; export * from './userXReducer'; +export * from './momentCategoryReducer'; diff --git a/src/store/reducers/momentCategoryReducer.tsx b/src/store/reducers/momentCategoryReducer.tsx new file mode 100644 index 00000000..d1f448f9 --- /dev/null +++ b/src/store/reducers/momentCategoryReducer.tsx @@ -0,0 +1,22 @@ +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 + */ + momentCategoriesFetched: (state, action) => { + const categories: Array<MomentCategoryType> = action.payload.categories; + for (let category of categories) { + state.momentCategories[category] = action.payload.add; + } + }, + }, +}); + +export const {momentCategoriesFetched} = momentCategoriesSlice.actions; +export const momentCategoriesReducer = momentCategoriesSlice.reducer; diff --git a/src/store/reducers/userXReducer.ts b/src/store/reducers/userXReducer.ts index 154dd7dc..bb142864 100644 --- a/src/store/reducers/userXReducer.ts +++ b/src/store/reducers/userXReducer.ts @@ -1,4 +1,4 @@ -import {ScreenType} from '../../types/types'; +import {MomentCategoryType, ScreenType} from '../../types/types'; import {EMPTY_SCREEN_TO_USERS_LIST, EMPTY_USER_X} from '../initialStates'; import {createSlice} from '@reduxjs/toolkit'; @@ -23,31 +23,45 @@ const userXSlice = createSlice({ action.payload.user; }, + 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; + } + }, + userXMomentsFetched: (state, action) => { state[<ScreenType>action.payload.screenType][ action.payload.userId ].moments = action.payload.data; }, + userXFollowersFetched: (state, action) => { state[<ScreenType>action.payload.screenType][ action.payload.userId ].followers = action.payload.data; }, + userXFollowingFetched: (state, action) => { state[<ScreenType>action.payload.screenType][ action.payload.userId ].following = action.payload.data; }, + userXAvatarFetched: (state, action) => { state[<ScreenType>action.payload.screenType][ action.payload.userId ].avatar = action.payload.data; }, + userXCoverFetched: (state, action) => { state[<ScreenType>action.payload.screenType][ action.payload.userId ].cover = action.payload.data; }, + userXSocialsFetched: (state, action) => { state[<ScreenType>action.payload.screenType][ action.payload.userId @@ -72,6 +86,7 @@ export const { userXMomentsFetched, userXProfileFetched, userXSocialsFetched, + userXMomentCategoriesFetched, resetScreen, } = userXSlice.actions; export const userXReducer = userXSlice.reducer; |
