import { AnyAction, createSlice } from "@reduxjs/toolkit";
import Types from "../types";

type ActionType = {
  type: string
  payload: string| null
};

export type InitStateAuth = {
  // username: string
  // password: string
  token: string | null
}

const initialState : InitStateAuth = {
  // username: "",
  // password: "",
  token: null
}

function authReducer(state = initialState, action: ActionType) {
  const payload = action.payload
  switch (action.type) {
    case Types.LOGIN_SUCCESS: 
      return  {
        ...state, 
        token: payload,
      };
    default:
      return state
      
  }
}
// export default authReducer
export default authReducer
