-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(flow): login state management with redux
- Loading branch information
1 parent
e1ffe37
commit 2c351ae
Showing
14 changed files
with
74 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { createSlice } from '@reduxjs/toolkit'; | ||
|
||
import type { UserState } from '@/types'; | ||
|
||
const initialState: UserState = { | ||
isLoggedIn: false, | ||
userName: 'Test User', | ||
userId: 'testId', | ||
userInfo: 'test information', | ||
authorization: 'test authorization', | ||
}; | ||
|
||
const slice = createSlice({ | ||
name: 'auth', | ||
initialState, | ||
reducers: { | ||
toggleLogin: (state) => { | ||
state.isLoggedIn = !state.isLoggedIn; | ||
}, | ||
setName: (state, action) => { | ||
state.userName = action.payload; | ||
}, | ||
setId: (state, action) => { | ||
state.userId = action.payload; | ||
}, | ||
setInfo: (state, action) => { | ||
state.userInfo = action.payload; | ||
}, | ||
setAuth: (state, action) => { | ||
state.authorization = action.payload; | ||
}, | ||
}, | ||
}); | ||
|
||
export const { toggleLogin, setName, setId, setInfo, setAuth } = slice.actions; | ||
export const authReducer = slice.reducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
export * from './auth/authSlice'; | ||
export * from './catFacts/catFactsSlice'; | ||
export * from './counter/counterSlice'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export * from './props'; | ||
export * from './redux'; | ||
export * from './user'; |
File renamed without changes.