import {createSlice} from '@reduxjs/toolkit';

const initialState = {
  token: '',
};

const userSlice = createSlice({
  name: 'user',
  initialState,
  reducers: {
    setUser(state, action) {
      return {
        ...state,
        ...action.payload,
        token: action?.payload?.usertoken,
      };
    },
    resetUserState() {
      return initialState;
    },
  },
});

export const {setUser, resetUserState} = userSlice.actions;
export default userSlice.reducer;
