File size: 555 Bytes
79278ec
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import { createSlice } from "@reduxjs/toolkit";
import { IAuthState } from "./types";

const initialState: IAuthState = {
  isAuth: false,
  userName: "",
};

const authSlice = createSlice({
  name: "authSlice",
  initialState,
  reducers: {
    setIsAuth: (state, action: { payload: boolean }) => {
      state.isAuth = action.payload;
    },
    setUserName: (state, action: { payload: string }) => {
      state.userName = action.payload;
    },
  },
});

export const { setIsAuth, setUserName } = authSlice.actions;

export default authSlice.reducer;