/* eslint-disable import/order */
/* eslint-disable @typescript-eslint/consistent-type-imports */
import { createSlice, type PayloadAction } from "@reduxjs/toolkit";
import { entrepriseState } from "./type";
import { Entreprise } from "@/types/entreprise";

const initialState: entrepriseState = {
    status: "idle",
    error: null,
    entrepriseSelected: null,
};

const entrepriseSlice = createSlice({
  name: "entreprise",
  initialState,
  reducers: {
    selectentreprise: (state, action: PayloadAction<Entreprise>) => {
      state.entrepriseSelected = action.payload;
    },
    deselectentreprise: (state, action: PayloadAction<null>) => {
      state.entrepriseSelected = action.payload;
    }
  },
});


export const { selectentreprise, deselectentreprise } = entrepriseSlice.actions
export default entrepriseSlice.reducer;


