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

type ActionType = {
  type: string
  payload: AnyAction
};

export interface InitStateAuth {
  username: string
  password: string
  token: string | null
}

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


function productReducer(state = initialState, action: ActionType) {
  const payload = action.payload
  switch (action.type) {
    case 'LOGIN_SUCCESS': 
      return  {
        ...state, 
        auth: payload,
      };
    default:
      return state
      
  }
}


// export default authReducer
export default productReducer
