system-praktyk-front/src/state/reducer/student.ts
2020-09-27 22:06:53 +02:00

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;