Skip to content

Commit

Permalink
refactor(redux): refactor user slice
Browse files Browse the repository at this point in the history
  • Loading branch information
danilych committed Feb 10, 2024
1 parent a05dbc1 commit 3314f88
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions app/redux/slices/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,7 @@ export const fetchUser = createAsyncThunk(

const initialState = {
user: {
userData: {
id: "",
name: "",
email: "",
firstName: "",
lastName: "",
phoneNumber: "",
aboutMe: "",
enctyptedID: "",
dateOfBirth: "",
},
data: null,
status: 'loading',
},
}
Expand All @@ -36,17 +26,17 @@ const userSlice = createSlice({
state.user.status = 'loading'

// @ts-ignore
state.user.userData = null
state.user.data = null
})
builder.addCase(fetchUser.fulfilled, (state, action) => {
state.user.status = 'loaded'
state.user.userData = action.payload
state.user.data = action.payload
})
builder.addCase(fetchUser.rejected, (state, action) => {
state.user.status = 'error'

// @ts-ignore
state.user.userData = null
state.user.data = null
})
},
})
Expand Down

0 comments on commit 3314f88

Please sign in to comment.