22 lines
600 B
TypeScript
22 lines
600 B
TypeScript
import { Student } from "@/data";
|
|
import { UserAction, UserActions } from "@/state/actions/user";
|
|
import { StudentAction, StudentActions } from "@/state/actions/student";
|
|
|
|
export type StudentState = Student | null;
|
|
|
|
const initialStudentState: StudentState = null;
|
|
|
|
const studentReducer = (state: StudentState = initialStudentState, action: UserAction | StudentAction): StudentState => {
|
|
switch (action.type) {
|
|
case StudentActions.Set:
|
|
return action.student;
|
|
|
|
case UserActions.Logout:
|
|
return null;
|
|
}
|
|
|
|
return state;
|
|
}
|
|
|
|
export default studentReducer;
|