Skip to content

Commit

Permalink
Revert "fix userSlice"
Browse files Browse the repository at this point in the history
This reverts commit 974a223.
  • Loading branch information
GodYazza committed Sep 18, 2024
1 parent 974a223 commit 3db3e55
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions web/src/app/features/user/userSlice.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
import { createSlice, PayloadAction } from '@reduxjs/toolkit';
import { Role } from "@/app/type/role";
import {Role} from "@/app/type/role";

// Todo: Remove this duplicate type definition...
export type UserType = 'student' | 'sponsor' | 'alumni' | 'admin';

// Define the user state interface
export interface UserState {
id: string;
email: string;
username: string;
activated: boolean;
firstName: string;
lastName: string;
phoneNumber: string;
desc?: string;
userType?: Role; // Allow for null (unauthenticated)
activated: boolean,
firstName: string,
lastName: string,
phoneNumber: string,
desc?: string
UserType?: Role // Allow for null (unauthenticated)
// ... other user data (name, email, etc.) as needed
}

Expand All @@ -26,21 +29,16 @@ const initialState: UserState = {
phoneNumber: '',
};

// Create a slice with reducers
const userSlice = createSlice({
name: 'user',
initialState,
reducers: {
resetUser() {
return initialState;
},
setUserType(state, action: PayloadAction<Role | undefined>) {
state.userType = action.payload;
},
// ... other reducers for user actions (e.g., login, logout, update profile)
},
});

// Export the actions and the reducer
export const { setUserType, resetUser } = userSlice.actions;
export default userSlice.reducer;

0 comments on commit 3db3e55

Please sign in to comment.