Requeste api implelented
This commit is contained in:
+29
-5
@@ -3,20 +3,44 @@ import type { PayloadAction } from "@reduxjs/toolkit";
|
||||
|
||||
export interface UserState {
|
||||
id: string;
|
||||
name: string;
|
||||
userId: number | null;
|
||||
username: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
gender: string;
|
||||
mobile: string;
|
||||
email: string;
|
||||
address: string;
|
||||
bankAccountNumber: string;
|
||||
bankName: string;
|
||||
branchCode: string;
|
||||
profilePicture: string;
|
||||
filePath: string;
|
||||
imageBlob: string;
|
||||
role: string;
|
||||
organizerId: string;
|
||||
organizerStatus: string;
|
||||
profileStatus: boolean;
|
||||
}
|
||||
|
||||
const initialState: UserState = {
|
||||
id: "",
|
||||
name: "",
|
||||
userId: null,
|
||||
username: "",
|
||||
firstName: "",
|
||||
lastName: "",
|
||||
gender: "",
|
||||
mobile: "",
|
||||
email: "",
|
||||
address: "",
|
||||
bankAccountNumber: "",
|
||||
bankName: "",
|
||||
branchCode: "",
|
||||
profilePicture: "",
|
||||
filePath: "",
|
||||
imageBlob: "",
|
||||
role: "",
|
||||
organizerId: "",
|
||||
organizerStatus: "",
|
||||
profileStatus: false,
|
||||
};
|
||||
@@ -26,12 +50,12 @@ export const userSlice = createSlice({
|
||||
initialState,
|
||||
reducers: {
|
||||
// ✅ set all user details at once (e.g. after login)
|
||||
setUser: (state, action: PayloadAction<UserState>) => {
|
||||
setUserData: (state, action: PayloadAction<UserState>) => {
|
||||
return { ...action.payload };
|
||||
},
|
||||
|
||||
// ✅ update only selected fields (e.g. profile update)
|
||||
updateUser: (state, action: PayloadAction<Partial<UserState>>) => {
|
||||
updateUserData: (state, action: PayloadAction<Partial<UserState>>) => {
|
||||
return { ...state, ...action.payload };
|
||||
},
|
||||
|
||||
@@ -41,6 +65,6 @@ export const userSlice = createSlice({
|
||||
});
|
||||
|
||||
// Action creators
|
||||
export const { setUser, updateUser, clearUser } = userSlice.actions;
|
||||
export const { setUserData, updateUserData, clearUser } = userSlice.actions;
|
||||
|
||||
export default userSlice.reducer;
|
||||
|
||||
Reference in New Issue
Block a user