import { avicultureGetProfile } from "../../../features/aviculture/services/aviculture-get-profile";
import { avicultureNewRequest } from "../../../features/aviculture/services/aviculture-new-request";
import { avicultureGetRequests } from "../../../features/aviculture/services/aviculture-requests";
import { avicultureGetHatchings } from "../../../features/aviculture/services/aviculture-get-hatchings";
import { avicultureGetChickenPrice } from "../../../features/aviculture/services/aviculture-get-chicken-price";
import { avicultureGetHallsInfo } from "../../../features/aviculture/services/aviculture-get-halls-info";
import { avicultureGetHallInspects } from "../../../features/aviculture/services/aviculture-get-hall-inspects";
import { avicultureGetSlaughters } from "../../../features/aviculture/services/aviculture-get-slaughters";
import { avicultureGetReports } from "../../../features/aviculture/services/aviculture-get-reports";
import { avicultureHatchingRequestsService } from "../../../features/aviculture/services/aviculture-hatching-requests";
import { avicultureRequestsStateProcessService } from "../../../features/aviculture/services/aviculture-requests-state-process";

export const avicultureExtraReducers = {
  [avicultureNewRequest.fulfilled]: (state, { payload }) => {
    state.pending = false;
  },
  [avicultureNewRequest.pending]: (state) => {
    state.pending = true;
  },
  [avicultureGetRequests.fulfilled]: (state, { payload }) => {
    state.avicultureRequests = payload.data;
    state.pending = false;
  },
  [avicultureRequestsStateProcessService.fulfilled]: (state, { payload }) => {
    state.avicultureRequestsStateProcess = payload.data;
    state.pending = true;
  },
  [avicultureRequestsStateProcessService.pending]: (state, { payload }) => {
    state.pending = false;
  },
  [avicultureGetRequests.pending]: (state) => {
    state.pending = true;
  },
  [avicultureGetHatchings.fulfilled]: (state, { payload }) => {
    state.avicultureHatchings = payload.data;
    state.pending = false;
  },
  [avicultureGetHatchings.pending]: (state) => {
    state.pending = true;
  },
  [avicultureGetProfile.fulfilled]: (state, { payload }) => {
    state.profile = payload.data;
    state.pending = false;
  },
  [avicultureGetProfile.pending]: (state) => {
    state.pending = true;
  },
  [avicultureGetChickenPrice.fulfilled]: (state, { payload }) => {
    state.avicultureChickenPrice = payload.data;
    state.pending = false;
  },
  [avicultureGetChickenPrice.pending]: (state) => {
    state.pending = true;
  },
  [avicultureGetHallsInfo.fulfilled]: (state, { payload }) => {
    state.avicultureHallsInfo = payload.data;
    state.pending = false;
  },
  [avicultureGetHallsInfo.pending]: (state) => {
    state.pending = true;
  },
  [avicultureGetHallInspects.fulfilled]: (state, { payload }) => {
    state.avicultureHallInspects = payload.data;
    state.pending = false;
  },
  [avicultureGetHallInspects.pending]: (state) => {
    state.pending = true;
  },
  [avicultureGetSlaughters.fulfilled]: (state, { payload }) => {
    payload.data.sort((a, b) => b.quantitySum - a.quantitySum);
    state.avicultureSlaughters = payload.data;
    state.pending = false;
  },
  [avicultureGetSlaughters.pending]: (state) => {
    state.pending = true;
  },
  [avicultureGetReports.fulfilled]: (state, { payload }) => {
    state.reports = payload.data;
    state.pending = false;
  },
  [avicultureGetReports.pending]: (state) => {
    state.pending = true;
  },
  [avicultureHatchingRequestsService.fulfilled]: (state, { payload }) => {
    state.avicultureHatchingRequests = payload.data;
  },
};
