import { getPoultryRequestsTotalQuantityService } from "../../../features/city/services/get-poultry-requests-total-quantity";
import { provinceGetFieldOfWorks } from "../../../features/province/services/ProvinceGetFieldOfWorks";
import { provinceGetCasesOverview } from "../../../features/province/services/get-cases-overview";
import { getCitiesService } from "../../../features/province/services/get-cities";
import { getGuildsSettingsService } from "../../../features/province/services/get-guilds-settings";
import { getManagePoultriesService } from "../../../features/province/services/get-manage-poultries";
import { getPolicyProvinceFeeService } from "../../../features/province/services/get-policy-province-fee";
import { getProvinceBuyerStewardAllocationService } from "../../../features/province/services/get-province-buyer-steward-allocation";
import { getProvinceBuyersAllocationsService } from "../../../features/province/services/get-province-buyers-allocations";
import { getProvinceFeeTotalOverviewService } from "../../../features/province/services/get-province-fee-total-overview";
import { getProvinceNewRequests } from "../../../features/province/services/get-province-new-requests";
import { getProvinceStewardAllocationsService } from "../../../features/province/services/get-province-steward.allocation";
import { manageProcessBuyReqService } from "../../../features/province/services/manage-process-buy-req";
import { provinceCasesGetTableDetails } from "../../../features/province/services/province-cases-get-table-details";
import { provinceChainsGetCompanies } from "../../../features/province/services/province-chains-get-companies";
import { provinceFreeSaleBuyers } from "../../../features/province/services/province-free-sales-get-buyers";
import { provinceGetActiveRequestsService } from "../../../features/province/services/province-get-active-requests";
import { provinceGetAllRequests } from "../../../features/province/services/province-get-all-requests";
import { provinceGetAllocatedRequestsService } from "../../../features/province/services/province-get-allocated-requests";
import { provinceGetArchiveAutoAllocationsService } from "../../../features/province/services/province-get-archive-auto-allocations";
import { provinceGetAutoAllocationsService } from "../../../features/province/services/province-get-auto-allocations";
import { provinceGetBuyersService } from "../../../features/province/services/province-get-buyers";
import { provinceGetCars } from "../../../features/province/services/province-get-cars";
import { provinceGetCaseStatusService } from "../../../features/province/services/province-get-case-status";
import { provinceGetCitiesService } from "../../../features/province/services/province-get-cities";
import { provinceGetDeletedAllocatedRequestsService } from "../../../features/province/services/province-get-deleted-allocated-requests";
import { provinceGetFilesStateService } from "../../../features/province/services/province-get-files-state";
import { provinceGetFreeSalesRequestsService } from "../../../features/province/services/province-get-free-sales-requests";
import { provinceGetGuildsService } from "../../../features/province/services/province-get-guilds";
import { provinceGetGuildsNumbersNamesService } from "../../../features/province/services/province-get-guilds-numbers-names";
import { provinceGetKillhousesService } from "../../../features/province/services/province-get-killhouses";
import { provinceGetKillhousesGuildsService } from "../../../features/province/services/province-get-killhouses-guilds";
import { provinceGetManageUsersService } from "../../../features/province/services/province-get-manage-users";
import { provinceGetOnlyKillHousesService } from "../../../features/province/services/province-get-only-kill-houses";
import {
  parentConpanyGetPaymentByWeightOverview,
  provinceGetPaymentByWeightOverview,
} from "../../../features/province/services/province-get-payment-by-weight-overview";
import { provinceGetPolicyAvicultureCommitService } from "../../../features/province/services/province-get-policy-aviculture-commit";
import { provinceGetPoultriesService } from "../../../features/province/services/province-get-poultries";
import { provinceGetPricing } from "../../../features/province/services/province-get-pricing";
import { provinceGetProducts } from "../../../features/province/services/province-get-producrs";
import { provinceGetProfile } from "../../../features/province/services/province-get-profile";
import { provinceGetRejectedRequests } from "../../../features/province/services/province-get-rejected-requests";
import { provinceGetSlaughterSurveillanceService } from "../../../features/province/services/province-get-slaughter-surverillance-service";
import { provinceGetSlaughterhousesQuotaService } from "../../../features/province/services/province-get-slaughterhouses-quota";
import { provinceGetSmsLincenseService } from "../../../features/province/services/province-get-sms-license";
import { provinceGetStewardsService } from "../../../features/province/services/province-get-stewards";
import { provinceGetTotalReportAgentShareService } from "../../../features/province/services/province-get-total-report-agent-share";
import { provinceGetUserByKey } from "../../../features/province/services/province-get-user-by-key";
import { provinceGetUserProfiles } from "../../../features/province/services/province-get-user-profiles";
import { provincePaymentGetKillersOfKillhousesInfo } from "../../../features/province/services/province-payment-get-killers-of-killhouses-info";
import { provincePolicyGetWeightRange } from "../../../features/province/services/province-policy-get-weight-range";
import { provinceGetTypeActivity } from "../../../features/province/services/provinceGetTypeActivity";
import { totalReportDailyBroadCastService } from "../../../features/slaughter-house/services/salughter-total-report-daily-broad-cast";
import { totalReportDailyStewardBroadCastService } from "../../../features/slaughter-house/services/total-report-daily-steward-broadcast";
import { getKillhouseRemainWeight } from "../../../features/province/components/province-dispensers-stock-slug/service";

export const provinceExtraReducers = {
  [getProvinceNewRequests.fulfilled]: (state, { payload }) => {
    state.provinceNewRequests = payload.data;
    state.pending = false;
  },
  [provinceGetProfile.fulfilled]: (state, { payload }) => {
    state.profile = payload.data;
    state.pending = false;
  },
  [getProvinceNewRequests.pending]: (state) => {
    state.pending = true;
  },
  [provinceGetAllRequests.fulfilled]: (state, { payload }) => {
    state.provinceAllRequests = payload.data;
    state.pending = false;
  },
  [provinceGetAllRequests.pending]: (state) => {
    state.pending = true;
  },
  [provinceGetPricing.fulfilled]: (state, { payload }) => {
    state.provincePrices = payload.data;
    state.pending = false;
  },
  [provinceGetPricing.pending]: (state) => {
    state.pending = true;
  },
  [provinceGetRejectedRequests.fulfilled]: (state, { payload }) => {
    state.provinceRejectedRequests = payload.data;
    state.pending = false;
  },
  [provinceGetRejectedRequests.pending]: (state) => {
    state.pending = true;
  },
  [provinceGetCars.fulfilled]: (state, { payload }) => {
    state.provinceCars = payload.data;
    state.pending = false;
  },
  [getProvinceBuyersAllocationsService.fulfilled]: (state, { payload }) => {
    state.getProvinceBuyersAllocations = payload.data;
    state.pending = false;
  },
  [getProvinceStewardAllocationsService.fulfilled]: (state, { payload }) => {
    state.getProvinceStewardAllocations = payload.data;
    state.pending = false;
  },
  [provinceGetCars.pending]: (state) => {
    state.pending = true;
  },
  [provinceGetUserProfiles.fulfilled]: (state, { payload }) => {
    state.provinceUsers = payload.data;
    state.pending = false;
  },
  [provinceGetUserProfiles.pending]: (state) => {
    state.pending = true;
  },
  [provinceGetUserByKey.fulfilled]: (state, { payload }) => {
    state.provinceUserInfo = payload.data;
    state.pending = false;
  },
  [provinceGetUserByKey.pending]: (state) => {
    state.pending = true;
  },
  [getPoultryRequestsTotalQuantityService.fulfilled]: (state, { payload }) => {
    state.poultryRequestsTotalQuantity = payload.data;
  },
  [provinceGetSmsLincenseService.fulfilled]: (state, { payload }) => {
    state.provinceGetSmsLincense = payload.data;
  },
  [provinceGetActiveRequestsService.fulfilled]: (state, { payload }) => {
    state.provinceGetActiveRequests = payload.data;
  },
  [provinceGetCaseStatusService.fulfilled]: (state, { payload }) => {
    state.provinceGetCaseStatus = payload.data;
  },
  [provinceGetCitiesService.fulfilled]: (state, { payload }) => {
    state.provinceGetCities = payload.data;
  },
  [provinceGetTypeActivity.fulfilled]: (state, { payload }) => {
    state.provinceTypeActivity = payload.data;
  },
  [provinceGetFieldOfWorks.fulfilled]: (state, { payload }) => {
    state.provinceGetAreActivity = payload.data;
  },
  [provinceGetOnlyKillHousesService.fulfilled]: (state, { payload }) => {
    state.provinceGetOnlyKillHouses = payload.data;
  },
  [provinceGetPoultriesService.fulfilled]: (state, { payload }) => {
    state.provinceGetPoultries = payload.data;
  },
  [provinceGetFreeSalesRequestsService.fulfilled]: (state, { payload }) => {
    state.provinceGetFreeSalesRequests = payload.data;
  },
  [provinceGetSlaughterhousesQuotaService.fulfilled]: (state, { payload }) => {
    state.provinceGetSlaughterhousesQuota = payload.data;
  },
  [provinceGetFilesStateService.fulfilled]: (state, { payload }) => {
    state.provinceGetFilesState = payload.data;
  },
  [provinceGetAutoAllocationsService.fulfilled]: (state, { payload }) => {
    state.provinceGetAutoAllocations = payload.data;
  },
  [provinceGetBuyersService.fulfilled]: (state, { payload }) => {
    state.provinceGetBuyersOptions = payload.data.map((item) => {
      return {
        label: item.name,
        value: item.key,
      };
    });
    state.provinceGetBuyers = payload.data;
  },
  [provinceGetAllocatedRequestsService.fulfilled]: (state, { payload }) => {
    state.provinceGetAllocatedRequests = payload.data;
  },
  [provinceGetDeletedAllocatedRequestsService.fulfilled]: (
    state,
    { payload }
  ) => {
    state.provinceGetDeletedAllocatedRequests = payload.data;
  },
  [provinceGetArchiveAutoAllocationsService.fulfilled]: (
    state,
    { payload }
  ) => {
    state.provinceGetArchiveAutoAllocations = payload.data;
  },
  [provinceGetManageUsersService.fulfilled]: (state, { payload }) => {
    state.provinceGetManageUsers = payload.data;
  },
  [getGuildsSettingsService.fulfilled]: (state, { payload }) => {
    state.getGuildsSettings = payload.data;
  },
  [getManagePoultriesService.fulfilled]: (state, { payload }) => {
    state.getManagePoultries = payload.data;
  },
  [provinceGetKillhousesService.fulfilled]: (state, { payload }) => {
    state.provinceGetKillhouses = payload.data;
  },
  [totalReportDailyBroadCastService.fulfilled]: (state, { payload }) => {
    state.totalReportDailyBroadCast = payload.data;
  },
  [totalReportDailyStewardBroadCastService.fulfilled]: (state, { payload }) => {
    state.totalReportStewardDailyBroadCast = payload.data;
  },
  [provinceGetKillhousesGuildsService.fulfilled]: (state, { payload }) => {
    state.provinceGetKillhousesGuilds = payload.data;
  },
  [provinceGetGuildsNumbersNamesService.fulfilled]: (state, { payload }) => {
    state.provinceGetGuildsNumbersNames = payload.data;
  },
  [getPolicyProvinceFeeService.fulfilled]: (state, { payload }) => {
    state.getPolicyProvinceFee = payload.data;
  },
  [getProvinceFeeTotalOverviewService.fulfilled]: (state, { payload }) => {
    state.getProvinceFeeTotalOverview = payload.data;
  },
  [manageProcessBuyReqService.fulfilled]: (state, { payload }) => {
    state.manageProcessBuyReq = payload.data;
  },
  [provinceGetTotalReportAgentShareService.fulfilled]: (state, { payload }) => {
    state.provinceGetTotalReportAgentShare = payload.data;
  },
  [provinceGetProducts.fulfilled]: (state, { payload }) => {
    state.provinceProductList = payload.data;
  },
  [provinceGetPolicyAvicultureCommitService.fulfilled]: (
    state,
    { payload }
  ) => {
    state.provinceGetPolicyAvicultureCommit = payload.data;
  },
  [getProvinceBuyerStewardAllocationService.fulfilled]: (
    state,
    { payload }
  ) => {
    state.getProvinceBuyerStewardAllocation = payload.data;
  },
  [provinceCasesGetTableDetails.fulfilled]: (state, { payload }) => {
    state.casesTableDetails = payload.data;
  },
  [provinceGetSlaughterSurveillanceService.fulfilled]: (state, { payload }) => {
    state.slaughterSurveillance = payload.data;
  },
  [provinceGetStewardsService.fulfilled]: (state, { payload }) => {
    state.provinceGetStewards = payload.data;
    state.provinceGetStewardsOptions = payload.data.map((item) => {
      return {
        label: `${item.guilds.guildsName}/مالک ${item.guilds.user.fullname}/${item.guilds.user.mobile}`,
        value: item.key,
      };
    });
  },
  [getCitiesService.fulfilled]: (state, { payload }) => {
    state.getCities = payload.data;
    state.getCitiesOptions = payload.data.map((item) => {
      return {
        label: `${item.unitName} (${item.address.city.name})`,
        value: item.unitName,
      };
    });
  },
  [provinceGetGuildsService.fulfilled]: (state, { payload }) => {
    state.provinceGetGuildsOptions = payload?.data?.map((item) => {
      return {
        label: `${item.guildsName} (${item.user.mobile})`,
        value: item.key,
      };
    });
    state.provinceGetGuilds = payload?.data;
  },
  [provinceGetCasesOverview.fulfilled]: (state, { payload }) => {
    state.casesOverview = payload.data;
  },
  [provinceChainsGetCompanies.fulfilled]: (state, { payload }) => {
    state.chainCompanies = payload.data;
  },
  [provinceGetPaymentByWeightOverview.fulfilled]: (state, { payload }) => {
    state.provincePaymentByWeightOverview = payload.data;
  },
  [parentConpanyGetPaymentByWeightOverview.fulfilled]: (state, { payload }) => {
    state.parentCompanyPaymentByWeightOverview = payload.data;
  },
  [provinceFreeSaleBuyers.fulfilled]: (state, { payload }) => {
    state.provinceFreeSaleAllBuyers = payload.data;
  },
  [provincePolicyGetWeightRange.fulfilled]: (state, { payload }) => {
    state.weightRange = payload.data?.map((item) => {
      const { fromAge, toAge, fromWeight, toWeight } = item;
      return { fromAge, toAge, fromWeight, toWeight };
    });
  },
  [provincePaymentGetKillersOfKillhousesInfo.fulfilled]: (
    state,
    { payload }
  ) => {
    state.provincePaymentKillersOfKillhouses = payload.data.wageInfo;
  },
  [getKillhouseRemainWeight.fulfilled]: (state, { payload }) => {
    state.killhouseRemainWeight = payload.data;
  },
};
