import { createSlice } from "@reduxjs/toolkit"; const initialState = { currentUser: null, isAuthenticated: false, }; export const authSlice = createSlice({ name: "auth", initialState, reducers: { login: (state, action) => { return { ...state, currentUser: action.payload, isAuthenticated: true }; }, logout: () => { return initialState; }, }, }); export const { login, logout } = authSlice.actions; export default authSlice.reducer;