You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
739 B
TypeScript
37 lines
739 B
TypeScript
import { createSlice } from '@reduxjs/toolkit';
|
|
|
|
export interface UserState {
|
|
userInfo?: {
|
|
name?: string;
|
|
avatar?: string;
|
|
job?: string;
|
|
organization?: string;
|
|
location?: string;
|
|
email?: string;
|
|
permissions: Record<string, string[]>;
|
|
};
|
|
userLoading?: boolean;
|
|
}
|
|
|
|
const initialState: UserState = {
|
|
userInfo: {
|
|
permissions: {}
|
|
},
|
|
userLoading: false
|
|
};
|
|
|
|
const userSlice = createSlice({
|
|
name: 'user',
|
|
initialState,
|
|
reducers: {
|
|
updateUserInfo(state, action) {
|
|
state.userInfo = action.payload.userInfo || initialState.userInfo;
|
|
state.userLoading = action.payload.userLoading;
|
|
}
|
|
}
|
|
});
|
|
|
|
export const { updateUserInfo } = userSlice.actions;
|
|
|
|
export default userSlice.reducer;
|