import { getRequestsAwaitingInspection } from "../../../components/requests-awaiting-inspections/service";
import { getRequestsAwaitingPayment } from "../../../components/requests-awaiting-payment/service";
import { cityVetGetProfileService } from "../../../features/city-vet/services/city-vet-profile";
import { guildGetFreeBars } from "../../../features/guild/services/guild-get-free-bars";
import { guildGetFreeSaleBarService } from "../../../features/guild/services/guild-get-free-sale-bar";
import { guildGetStewardsService } from "../../../features/guild/services/guild-get-guilds";
import { guildGetInventoryAllocatedService } from "../../../features/guild/services/guild-get-inventory-allocated";
import { guildGetInventoryStockService } from "../../../features/guild/services/guild-get-inventory-stock";
import { guildGetProfile } from "../../../features/guild/services/guild-get-profile";
import { guildGetStewards } from "../../../features/guild/services/guild-get-stewards";
import { guildGetAllocationData } from "../../../features/guild/services/guildGetAllocationData";
import { senfGetInventoryAllocatedService } from "../../../features/guild/services/senf-get-inventory-allocated";
import { senfGetInventoryStockService } from "../../../features/guild/services/senf-get-inventory-stock";
import { senfGetAllocationDashboardService } from "../../../features/guild/services/senf-get-allocation-dashboard";
import { guildSalesInfoDashboardService } from "../../../features/guild/services/guild-sales-info-dashboard";

export const generalExtraReducers = {
  [guildGetProfile.fulfilled]: (state, { payload }) => {
    state.guildProfile = payload.data;
  },
  [getRequestsAwaitingPayment.fulfilled]: (state, { payload }) => {
    state.pending = false;
    state.awaitingPaymentRequests = payload.data;
  },
  [getRequestsAwaitingPayment.pending]: (state) => {
    state.pending = true;
  },
  [getRequestsAwaitingInspection.fulfilled]: (state, { payload }) => {
    state.pending = false;
    state.awaitingInspectionRequests = payload.data;
  },
  [getRequestsAwaitingInspection.pending]: (state) => {
    state.pending = true;
  },
  [cityVetGetProfileService.fulfilled]: (state, { payload }) => {
    state.cityVetGetProfile = payload.data;
  },
  [guildGetInventoryStockService.fulfilled]: (state, { payload }) => {
    state.guildGetInventoryStock = payload.data;
  },
  [guildGetFreeSaleBarService.fulfilled]: (state, { payload }) => {
    state.guildFreeSaleBars = payload.data;
  },
  [senfGetInventoryStockService.fulfilled]: (state, { payload }) => {
    state.senfGetInventoryStock = payload.data;
  },
  [senfGetAllocationDashboardService.fulfilled]: (state, { payload }) => {
    state.senfGetInventoryStock = payload.data;
  },
  [guildGetStewards.fulfilled]: (state, { payload }) => {
    state.guildStewards = payload.data;
  },
  [guildGetInventoryAllocatedService.fulfilled]: (state, { payload }) => {
    state.guildGetInventoryAllocated = payload.data;
  },
  [guildGetFreeBars.fulfilled]: (state, { payload }) => {
    state.guildFreeBars = payload.data;
  },
  [senfGetInventoryAllocatedService.fulfilled]: (state, { payload }) => {
    state.senfGetInventoryAllocated = payload.data;
  },
  [guildGetStewardsService.fulfilled]: (state, { payload }) => {
    state.guildGetStewardsState = payload.data.map((item) => ({
      label: `${item?.guildsName} (${item?.user?.city}) / ${item?.user?.fullname} (${item?.user?.mobile})`,
      value: item.key,
    }));
  },
  [guildGetAllocationData.fulfilled]: (state, { payload }) => {
    state.guildGetGuildData = payload.data;
    state.pending = false;
  },
  [guildSalesInfoDashboardService.fulfilled]: (state, { payload }) => {
    state.guildSalesInfoDashboard = payload.data;
  },
};
