import { createReducer, on } from '@ngrx/store';
import { initialState } from './user.store';
import { UserActions } from './user.actions';
import { UserStore } from '../../interfaces/user.interface';

export const userReducers = createReducer<UserStore>(
  initialState,

  on(
    UserActions.set_user,
    (state, action): UserStore => ({ ...state, ...action.user }),
  ),
  on(UserActions.clear_user, (): UserStore => ({}) as UserStore),
);
