import { createSlice } from "@reduxjs/toolkit";
import { LoginState } from "./state";
import { loginAsync } from "./operations";

const initialState: LoginState = {
  apps: {
    LoginApiCallStatus: "none",
  },
};

export const loginSlice = createSlice({
  name: "login",
  initialState,
  reducers: {},
  extraReducers: (builder) => {
    builder.addCase(loginAsync.pending, (state) => {
      state.apps.LoginApiCallStatus = "pending";
    });
    builder.addCase(loginAsync.fulfilled, (state) => {
      state.apps.LoginApiCallStatus = "fulfilled";
    });
    builder.addCase(loginAsync.rejected, (state) => {
      state.apps.LoginApiCallStatus = "rejected";
    });
  },
});

export default loginSlice.reducer;
