import { createSlice } from "@reduxjs/toolkit";
import { ReferralInterface } from "@src/api/interface/referralInterface";
import { referralData } from "../actions/referralAction";

const initialState: ReferralInterface = {
  referralList: [],
  success: false,
  loading: false,
};

const rentalVehicleSlice = createSlice({
  name: "refer",
  initialState,
  reducers: {},
  extraReducers: (builder) => {
    builder.addCase(referralData.pending, (state) => {
      state.loading = true;
    });
    builder.addCase(referralData.fulfilled, (state, action) => {
      state.referralList = action.payload;

      state.loading = false;
    });
    builder.addCase(referralData.rejected, (state) => {
      state.loading = false;
      state.success = false;
    });
  },
});

export default rentalVehicleSlice.reducer;
