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

const initialState = {
  userid: null,
  loggedIn: false,
  name: null,
  img: null,
  signInUI: false,
  signUpUI: false,
  forgetPasswordUI: false,
};
const accountStore = createSlice({
  name: "AccountStoreAction",
  initialState: initialState,
  reducers: {
    updateLoggedIn(state, action) {
      state.loggedIn = action.payload.loggedIn;
      state.userid = action.payload.userid;
      state.name = action.payload.name;
    },
    clearReset(state) {
      state.account = initialState;
    },
    openSignInUI(state) {
      state.signInUI = true;
    },
    closeSignInUI(state) {
      state.signInUI = false;
    },
    openSignUpUI(state) {
      state.signUpUI = true;
    },
    closeSignUpUI(state) {
      state.signUpUI = false;
    },
    openForgetPasswordUI(state) {
      state.forgetPasswordUI = true;
    },
    closeForgetPasswordUI(state) {
      state.forgetPasswordUI = false;
    },
  },
});

export const accountStoreActions = accountStore.actions;

export default accountStore;
