fix => services for fetchSlaughterBroadcastAndProducts
This commit is contained in:
@@ -130,7 +130,6 @@ export const CreateGuilds = ({ guild, updateTable }) => {
|
|||||||
hasInquiry
|
hasInquiry
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
console.log(guildsDataArray);
|
|
||||||
dispatch(updateGuildByNationalIdNewService(guildsDataArray)).then(
|
dispatch(updateGuildByNationalIdNewService(guildsDataArray)).then(
|
||||||
(result) => {
|
(result) => {
|
||||||
if (result.payload.error) {
|
if (result.payload.error) {
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ export const ProvinceDispenserEditToGuild = ({
|
|||||||
priceInfo,
|
priceInfo,
|
||||||
coldHouseKey,
|
coldHouseKey,
|
||||||
coldHouseItemKey,
|
coldHouseItemKey,
|
||||||
remainWeight,
|
|
||||||
fetchDashboardData,
|
fetchDashboardData,
|
||||||
}) => {
|
}) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useContext, useEffect, useState } from "react";
|
import { useContext, useEffect, useState } from "react";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { AppContext } from "../../../../contexts/AppContext";
|
import { AppContext } from "../../../../contexts/AppContext";
|
||||||
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
||||||
|
|
||||||
@@ -25,6 +25,7 @@ import {
|
|||||||
slaughterEditAllocateStewardService,
|
slaughterEditAllocateStewardService,
|
||||||
} from "../../../slaughter-house/services/slaughter-allocate-steward";
|
} from "../../../slaughter-house/services/slaughter-allocate-steward";
|
||||||
import { fetchSlaughterBroadcastAndProducts } from "../../../slaughter-house/services/handle-fetch-slaughter-products";
|
import { fetchSlaughterBroadcastAndProducts } from "../../../slaughter-house/services/handle-fetch-slaughter-products";
|
||||||
|
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
|
||||||
|
|
||||||
export const ProvinceDispenserStewardEditOperation = ({
|
export const ProvinceDispenserStewardEditOperation = ({
|
||||||
item,
|
item,
|
||||||
@@ -47,6 +48,9 @@ export const ProvinceDispenserStewardEditOperation = ({
|
|||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
|
|
||||||
const [value, setValue] = useState("own");
|
const [value, setValue] = useState("own");
|
||||||
|
const selectedSubUser = useSelector(
|
||||||
|
(state) => state.userSlice.selectedSubUser
|
||||||
|
);
|
||||||
|
|
||||||
const handleChange = (event) => {
|
const handleChange = (event) => {
|
||||||
setValue(event.target.value);
|
setValue(event.target.value);
|
||||||
@@ -156,7 +160,11 @@ export const ProvinceDispenserStewardEditOperation = ({
|
|||||||
msg: "عملیات با موفقیت انجام شد.",
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
severity: "success",
|
severity: "success",
|
||||||
});
|
});
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
fetchDashboardData();
|
fetchDashboardData();
|
||||||
fetchApiData(1);
|
fetchApiData(1);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
Popover,
|
Popover,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import TuneIcon from "@mui/icons-material/Tune";
|
import TuneIcon from "@mui/icons-material/Tune";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { Grid } from "../../../../components/grid/Grid";
|
import { Grid } from "../../../../components/grid/Grid";
|
||||||
import { slaughterDeleteAllocatedService } from "../../../slaughter-house/services/salughter-delete-allocated";
|
import { slaughterDeleteAllocatedService } from "../../../slaughter-house/services/salughter-delete-allocated";
|
||||||
import { OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
import { OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
||||||
@@ -16,6 +16,7 @@ import { ProvinceDispenserStewardEditOperation } from "../province-dispenser-ste
|
|||||||
import { fetchSlaughterBroadcastAndProducts } from "../../../slaughter-house/services/handle-fetch-slaughter-products";
|
import { fetchSlaughterBroadcastAndProducts } from "../../../slaughter-house/services/handle-fetch-slaughter-products";
|
||||||
import EditIcon from "@mui/icons-material/Edit";
|
import EditIcon from "@mui/icons-material/Edit";
|
||||||
import DeleteIcon from "@mui/icons-material/Delete";
|
import DeleteIcon from "@mui/icons-material/Delete";
|
||||||
|
|
||||||
export const ProvinceDispenserStewardSaleInOperation = ({
|
export const ProvinceDispenserStewardSaleInOperation = ({
|
||||||
fetchApiData,
|
fetchApiData,
|
||||||
item,
|
item,
|
||||||
@@ -27,7 +28,9 @@ export const ProvinceDispenserStewardSaleInOperation = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const selectedSubUser = useSelector(
|
||||||
|
(state) => state.userSlice.selectedSubUser
|
||||||
|
);
|
||||||
const handleClick = (event) => {
|
const handleClick = (event) => {
|
||||||
setAnchorEl(event.currentTarget);
|
setAnchorEl(event.currentTarget);
|
||||||
};
|
};
|
||||||
@@ -62,7 +65,11 @@ export const ProvinceDispenserStewardSaleInOperation = ({
|
|||||||
steward_allocation_key: item.key,
|
steward_allocation_key: item.key,
|
||||||
})
|
})
|
||||||
).then(() => {
|
).then(() => {
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
fetchApiData(1);
|
fetchApiData(1);
|
||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
import TuneIcon from "@mui/icons-material/Tune";
|
import TuneIcon from "@mui/icons-material/Tune";
|
||||||
import EditOutlinedIcon from "@mui/icons-material/EditOutlined";
|
import EditOutlinedIcon from "@mui/icons-material/EditOutlined";
|
||||||
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
|
import DeleteOutlineIcon from "@mui/icons-material/DeleteOutline";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { Grid } from "../../../../components/grid/Grid";
|
import { Grid } from "../../../../components/grid/Grid";
|
||||||
import { OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
import { OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
||||||
import { ProvinceStewardEditSaleOutOperation } from "../province-steward-edit-sale-out-operation/ProvinceStewardEditSaleOutOperation";
|
import { ProvinceStewardEditSaleOutOperation } from "../province-steward-edit-sale-out-operation/ProvinceStewardEditSaleOutOperation";
|
||||||
@@ -28,7 +28,9 @@ export const ProvinceDispenserStewardSaleOutOperation = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const selectedSubUser = useSelector(
|
||||||
|
(state) => state.userSlice.selectedSubUser
|
||||||
|
);
|
||||||
const handleClick = (event) => {
|
const handleClick = (event) => {
|
||||||
setAnchorEl(event.currentTarget);
|
setAnchorEl(event.currentTarget);
|
||||||
};
|
};
|
||||||
@@ -60,7 +62,11 @@ export const ProvinceDispenserStewardSaleOutOperation = ({
|
|||||||
const handleDeleteClick = () => {
|
const handleDeleteClick = () => {
|
||||||
handleClose();
|
handleClose();
|
||||||
dispatch(stewardDeleteOutSellService(item?.key)).then(() => {
|
dispatch(stewardDeleteOutSellService(item?.key)).then(() => {
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
fetchApiData(1);
|
fetchApiData(1);
|
||||||
setAnchorEl(null);
|
setAnchorEl(null);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import { useContext } from "react";
|
import { useContext } from "react";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { AppContext } from "../../../../contexts/AppContext";
|
import { AppContext } from "../../../../contexts/AppContext";
|
||||||
import { Yup } from "../../../../lib/yup/yup";
|
import { Yup } from "../../../../lib/yup/yup";
|
||||||
import { useFormik } from "formik";
|
import { useFormik } from "formik";
|
||||||
@@ -20,6 +20,9 @@ export const ProvinceStewardEditSaleOutOperation = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
|
const selectedSubUser = useSelector(
|
||||||
|
(state) => state.userSlice.selectedSubUser
|
||||||
|
);
|
||||||
|
|
||||||
const validationSchema = Yup.object({
|
const validationSchema = Yup.object({
|
||||||
weight: Yup.number().min(1, "یک مقدار مثبت وارد کنید!"),
|
weight: Yup.number().min(1, "یک مقدار مثبت وارد کنید!"),
|
||||||
@@ -45,7 +48,11 @@ export const ProvinceStewardEditSaleOutOperation = ({
|
|||||||
msg: "وزن با موفقیت ویرایش شد.",
|
msg: "وزن با موفقیت ویرایش شد.",
|
||||||
severity: "success",
|
severity: "success",
|
||||||
});
|
});
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
fetchApiData(1);
|
fetchApiData(1);
|
||||||
fetchDashboardData();
|
fetchDashboardData();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { Button, IconButton, Popover } from "@mui/material";
|
import { Button, IconButton, Popover } from "@mui/material";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { Grid } from "../../../../components/grid/Grid";
|
import { Grid } from "../../../../components/grid/Grid";
|
||||||
import { DRAWER, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
import { DRAWER, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
||||||
import { slaughterDeleteInventoryFreeBarService } from "../../services/slaughter-delete-inventory-free-bar";
|
import { slaughterDeleteInventoryFreeBarService } from "../../services/slaughter-delete-inventory-free-bar";
|
||||||
@@ -16,7 +16,9 @@ export const SlaughterFreeBarsAlivesOperations = ({
|
|||||||
type,
|
type,
|
||||||
}) => {
|
}) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const selectedSubUser = useSelector(
|
||||||
|
(state) => state.userSlice.selectedSubUser
|
||||||
|
);
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
|
|
||||||
const handleClick = (event) => {
|
const handleClick = (event) => {
|
||||||
@@ -129,7 +131,11 @@ export const SlaughterFreeBarsAlivesOperations = ({
|
|||||||
slaughterDeleteInventoryFreeBarService(item.key)
|
slaughterDeleteInventoryFreeBarService(item.key)
|
||||||
).then(() => {
|
).then(() => {
|
||||||
updateTable();
|
updateTable();
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import {
|
|||||||
ListItemIcon,
|
ListItemIcon,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { DRAWER, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
import { DRAWER, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
||||||
import { slaughterDeleteInventoryFreeBarService } from "../../services/slaughter-delete-inventory-free-bar";
|
import { slaughterDeleteInventoryFreeBarService } from "../../services/slaughter-delete-inventory-free-bar";
|
||||||
import { SlaughterSubmitFreeBar } from "../slaughter-submit-free-bar/SlaughterSubmitFreeBar";
|
import { SlaughterSubmitFreeBar } from "../slaughter-submit-free-bar/SlaughterSubmitFreeBar";
|
||||||
@@ -26,7 +26,9 @@ export const SlaughterFreeBarsOperations = ({
|
|||||||
type,
|
type,
|
||||||
}) => {
|
}) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const selectedSubUser = useSelector(
|
||||||
|
(state) => state.userSlice.selectedSubUser
|
||||||
|
);
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
|
|
||||||
const handleClick = (event) => {
|
const handleClick = (event) => {
|
||||||
@@ -158,7 +160,11 @@ export const SlaughterFreeBarsOperations = ({
|
|||||||
slaughterDeleteInventoryFreeBarService(item.key)
|
slaughterDeleteInventoryFreeBarService(item.key)
|
||||||
).then(() => {
|
).then(() => {
|
||||||
updateTable();
|
updateTable();
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useContext, useEffect } from "react";
|
import React, { useContext, useEffect } from "react";
|
||||||
import { Grid } from "../../../../components/grid/Grid";
|
import { Grid } from "../../../../components/grid/Grid";
|
||||||
import { Button, InputAdornment } from "@mui/material";
|
import { Button, InputAdornment } from "@mui/material";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { NumberInput } from "../../../../components/number-format-custom/NumberFormatCustom";
|
import { NumberInput } from "../../../../components/number-format-custom/NumberFormatCustom";
|
||||||
import { useFormik } from "formik";
|
import { useFormik } from "formik";
|
||||||
import { Yup } from "../../../../lib/yup/yup";
|
import { Yup } from "../../../../lib/yup/yup";
|
||||||
@@ -24,6 +24,9 @@ export const SlaughterHouseColdHouseBarsEdit = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
|
const selectedSubUser = useSelector(
|
||||||
|
(state) => state.userSlice.selectedSubUser
|
||||||
|
);
|
||||||
|
|
||||||
const validationSchema = Yup.object({
|
const validationSchema = Yup.object({
|
||||||
weight: Yup.number()
|
weight: Yup.number()
|
||||||
@@ -50,7 +53,11 @@ export const SlaughterHouseColdHouseBarsEdit = ({
|
|||||||
msg: "عملیات با موفقیت انجام شد.",
|
msg: "عملیات با موفقیت انجام شد.",
|
||||||
severity: "success",
|
severity: "success",
|
||||||
});
|
});
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
fetchApiData();
|
fetchApiData();
|
||||||
updateTable();
|
updateTable();
|
||||||
fetchData();
|
fetchData();
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import { fetchSlaughterBroadcastAndProducts } from "../../services/handle-fetch-
|
|||||||
export const SlaughterInventoryFreeBuyBarsAlives = ({
|
export const SlaughterInventoryFreeBuyBarsAlives = ({
|
||||||
title,
|
title,
|
||||||
barState,
|
barState,
|
||||||
fetchDashboardData,
|
handleUpdate,
|
||||||
withDate,
|
withDate,
|
||||||
selectedDate1,
|
selectedDate1,
|
||||||
selectedDate2,
|
selectedDate2,
|
||||||
@@ -87,7 +87,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({
|
|||||||
|
|
||||||
const updateTable = () => {
|
const updateTable = () => {
|
||||||
fetchApiData(page !== 0 ? page : 1);
|
fetchApiData(page !== 0 ? page : 1);
|
||||||
fetchDashboardData();
|
handleUpdate();
|
||||||
dispatch(
|
dispatch(
|
||||||
fetchSlaughterBroadcastAndProducts({
|
fetchSlaughterBroadcastAndProducts({
|
||||||
role_key: checkPathStartsWith("slaughter")
|
role_key: checkPathStartsWith("slaughter")
|
||||||
|
|||||||
@@ -411,7 +411,7 @@ export const SlaughterInventoryFreeBuyBars = () => {
|
|||||||
<SlaughterInventoryFreeBuyBarsAlives
|
<SlaughterInventoryFreeBuyBarsAlives
|
||||||
title={"بار زنده در انتظار ورود به انبار (خارج استان)"}
|
title={"بار زنده در انتظار ورود به انبار (خارج استان)"}
|
||||||
barState={"notentered"}
|
barState={"notentered"}
|
||||||
fetchDashboardData={fetchDashboardData}
|
handleUpdate={updateTable}
|
||||||
searchValue={searchValue}
|
searchValue={searchValue}
|
||||||
withDate={withDate}
|
withDate={withDate}
|
||||||
selectedDate1={selectedDate1}
|
selectedDate1={selectedDate1}
|
||||||
@@ -421,7 +421,7 @@ export const SlaughterInventoryFreeBuyBars = () => {
|
|||||||
<SlaughterInventoryFreeBuyBarsAlives
|
<SlaughterInventoryFreeBuyBarsAlives
|
||||||
title={"بار زنده وارد شده به انبار (خارج استان)"}
|
title={"بار زنده وارد شده به انبار (خارج استان)"}
|
||||||
barState={"entered"}
|
barState={"entered"}
|
||||||
fetchDashboardData={fetchDashboardData}
|
handleUpdate={updateTable}
|
||||||
searchValue={searchValue}
|
searchValue={searchValue}
|
||||||
withDate={withDate}
|
withDate={withDate}
|
||||||
selectedDate1={selectedDate1}
|
selectedDate1={selectedDate1}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import { Grid } from "../../../../components/grid/Grid";
|
|||||||
import { CLOSE_MODAL, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
import { CLOSE_MODAL, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
|
||||||
import { AppContext } from "../../../../contexts/AppContext";
|
import { AppContext } from "../../../../contexts/AppContext";
|
||||||
import { SPACING } from "../../../../data/spacing";
|
import { SPACING } from "../../../../data/spacing";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { slaughterInventoryFinalSubmitService } from "../../services/slaughter-inventory-final-submit";
|
import { slaughterInventoryFinalSubmitService } from "../../services/slaughter-inventory-final-submit";
|
||||||
import { slaughterDeleteAllocatedService } from "../../services/salughter-delete-allocated";
|
import { slaughterDeleteAllocatedService } from "../../services/salughter-delete-allocated";
|
||||||
import { SlaughterAllocateToGuild } from "../slaughter-allocate-to-guild/SlaughterAllocateToGuild";
|
import { SlaughterAllocateToGuild } from "../slaughter-allocate-to-guild/SlaughterAllocateToGuild";
|
||||||
@@ -31,7 +31,9 @@ export const SlaughterManageInventoryAllocationOperations = ({
|
|||||||
remainWeight,
|
remainWeight,
|
||||||
}) => {
|
}) => {
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
|
const selectedSubUser = useSelector(
|
||||||
|
(state) => state?.userSlice?.selectedSubUser
|
||||||
|
);
|
||||||
const handleClick = (event) => {
|
const handleClick = (event) => {
|
||||||
setAnchorEl(event.currentTarget);
|
setAnchorEl(event.currentTarget);
|
||||||
};
|
};
|
||||||
@@ -150,7 +152,11 @@ export const SlaughterManageInventoryAllocationOperations = ({
|
|||||||
})
|
})
|
||||||
).then(() => {
|
).then(() => {
|
||||||
dispatch(CLOSE_MODAL());
|
dispatch(CLOSE_MODAL());
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
fetchApiData(1);
|
fetchApiData(1);
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
Typography,
|
Typography,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { AppContext } from "../../../../contexts/AppContext";
|
import { AppContext } from "../../../../contexts/AppContext";
|
||||||
import { DRAWER } from "../../../../lib/redux/slices/appSlice";
|
import { DRAWER } from "../../../../lib/redux/slices/appSlice";
|
||||||
import { slaughterDeleteOutOfProvinceSell } from "../../services/slaughter-delete-out-province-sell";
|
import { slaughterDeleteOutOfProvinceSell } from "../../services/slaughter-delete-out-province-sell";
|
||||||
@@ -31,7 +31,9 @@ export const SlaughterOutProvinceSalesOperations = ({
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
const [anchorEl, setAnchorEl] = useState(null);
|
const [anchorEl, setAnchorEl] = useState(null);
|
||||||
|
const selectedSubUser = useSelector(
|
||||||
|
(state) => state.userSlice.selectedSubUser
|
||||||
|
);
|
||||||
const openPopover = (event) => {
|
const openPopover = (event) => {
|
||||||
setAnchorEl(event.currentTarget);
|
setAnchorEl(event.currentTarget);
|
||||||
};
|
};
|
||||||
@@ -70,7 +72,11 @@ export const SlaughterOutProvinceSalesOperations = ({
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
updateTable();
|
updateTable();
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
openNotif({
|
openNotif({
|
||||||
vertical: "top",
|
vertical: "top",
|
||||||
horizontal: "center",
|
horizontal: "center",
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ import {
|
|||||||
FormControlLabel,
|
FormControlLabel,
|
||||||
TextField,
|
TextField,
|
||||||
Typography,
|
Typography,
|
||||||
|
FormControl,
|
||||||
|
InputLabel,
|
||||||
|
Select,
|
||||||
|
MenuItem,
|
||||||
} from "@mui/material";
|
} from "@mui/material";
|
||||||
import { useFormik } from "formik";
|
import { useFormik } from "formik";
|
||||||
import { Yup } from "../../../../lib/yup/yup";
|
import { Yup } from "../../../../lib/yup/yup";
|
||||||
@@ -19,7 +23,7 @@ import {
|
|||||||
slaughterSubmitBuyerDataService,
|
slaughterSubmitBuyerDataService,
|
||||||
} from "../../services/slaughter-house-submit-buyer";
|
} from "../../services/slaughter-house-submit-buyer";
|
||||||
import { AppContext } from "../../../../contexts/AppContext";
|
import { AppContext } from "../../../../contexts/AppContext";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { DRAWER } from "../../../../lib/redux/slices/appSlice";
|
import { DRAWER } from "../../../../lib/redux/slices/appSlice";
|
||||||
import {
|
import {
|
||||||
slaughterGetCitiesService,
|
slaughterGetCitiesService,
|
||||||
@@ -28,6 +32,10 @@ import {
|
|||||||
import { provinceGetNationalDocumentsService } from "../../../province/services/province-get-national-documents";
|
import { provinceGetNationalDocumentsService } from "../../../province/services/province-get-national-documents";
|
||||||
import { LabelField } from "../../../../components/label-field/LabelField";
|
import { LabelField } from "../../../../components/label-field/LabelField";
|
||||||
import { extractProvinceFromAddress } from "../../../../utils/address";
|
import { extractProvinceFromAddress } from "../../../../utils/address";
|
||||||
|
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
|
||||||
|
import { useLocation } from "react-router-dom";
|
||||||
|
import { inspectorGetKillHousesService } from "../../../inspector/services/inspector-get-kill-houses";
|
||||||
|
import { slaughterGetStewardsForAllocateService } from "../../services/slaughter-get-guilds-for-allocate";
|
||||||
|
|
||||||
// userType enums = steward | steward_true | steward_legal | _true | _legal
|
// userType enums = steward | steward_true | steward_legal | _true | _legal
|
||||||
|
|
||||||
@@ -40,6 +48,12 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
userType,
|
userType,
|
||||||
}) => {
|
}) => {
|
||||||
const IS_STEWARD = userType === "steward";
|
const IS_STEWARD = userType === "steward";
|
||||||
|
const IS_ADMINX = getRoleFromUrl() === "AdminX";
|
||||||
|
const { pathname } = useLocation();
|
||||||
|
const IS_OUT_PROVINCE = pathname.includes("out-province");
|
||||||
|
const { inspectorGetKillHouses } = useSelector(
|
||||||
|
(state) => state.inspectorSlice
|
||||||
|
);
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
const [userData, setUserData] = useState(null);
|
const [userData, setUserData] = useState(null);
|
||||||
const [notFound, setNotFound] = useState(false);
|
const [notFound, setNotFound] = useState(false);
|
||||||
@@ -48,16 +62,20 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [provinceData, setProvinceData] = useState([]);
|
const [provinceData, setProvinceData] = useState([]);
|
||||||
const [cityData, setCityData] = useState([]);
|
const [cityData, setCityData] = useState([]);
|
||||||
|
const [killhouses, setKillhouses] = useState([]);
|
||||||
|
const [stewardsData, setStewardsData] = useState([]);
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
mobile: "",
|
mobile: "",
|
||||||
firstName: "",
|
firstName: "",
|
||||||
lastName: "",
|
lastName: "",
|
||||||
unitName: "",
|
unit_name: "",
|
||||||
province: "",
|
province: "",
|
||||||
city: "",
|
city: "",
|
||||||
nationalId: "",
|
nationalId: "",
|
||||||
|
role_key: "",
|
||||||
|
type: "",
|
||||||
},
|
},
|
||||||
validationSchema: Yup.object({
|
validationSchema: Yup.object({
|
||||||
mobile: Yup.string()
|
mobile: Yup.string()
|
||||||
@@ -71,7 +89,7 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
lastName: Yup.string()
|
lastName: Yup.string()
|
||||||
.required("این فیلد اجباری است!")
|
.required("این فیلد اجباری است!")
|
||||||
.typeError("لطفا فیلد را به درستی وارد کنید!"),
|
.typeError("لطفا فیلد را به درستی وارد کنید!"),
|
||||||
unitName: Yup.string()
|
unit_name: Yup.string()
|
||||||
.required("این فیلد اجباری است!")
|
.required("این فیلد اجباری است!")
|
||||||
.typeError("لطفا فیلد را به درستی وارد کنید!"),
|
.typeError("لطفا فیلد را به درستی وارد کنید!"),
|
||||||
province: Yup.string()
|
province: Yup.string()
|
||||||
@@ -86,10 +104,42 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
: Yup.string()
|
: Yup.string()
|
||||||
.required("این فیلد اجباری است!")
|
.required("این فیلد اجباری است!")
|
||||||
.matches(/^\d{10,11}$/, "شناسه باید 10 یا 11 رقم و فقط عدد باشد"),
|
.matches(/^\d{10,11}$/, "شناسه باید 10 یا 11 رقم و فقط عدد باشد"),
|
||||||
|
role_key:
|
||||||
|
IS_ADMINX && IS_OUT_PROVINCE
|
||||||
|
? Yup.string().required("این فیلد اجباری است!")
|
||||||
|
: Yup.string(),
|
||||||
|
type:
|
||||||
|
IS_ADMINX && IS_OUT_PROVINCE
|
||||||
|
? Yup.string().oneOf(["Steward", "KillHouse"]).required()
|
||||||
|
: Yup.string().nullable(),
|
||||||
}),
|
}),
|
||||||
validateOnMount: true,
|
validateOnMount: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
const d = inspectorGetKillHouses?.map((item) => {
|
||||||
|
return { name: item.name, key: item.key, killer: item.killer };
|
||||||
|
});
|
||||||
|
setKillhouses(d);
|
||||||
|
}, [inspectorGetKillHouses]);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (IS_OUT_PROVINCE && IS_ADMINX) {
|
||||||
|
if (formik.values.type === "KillHouse") {
|
||||||
|
dispatch(inspectorGetKillHousesService());
|
||||||
|
} else {
|
||||||
|
dispatch(
|
||||||
|
slaughterGetStewardsForAllocateService({
|
||||||
|
free: true,
|
||||||
|
})
|
||||||
|
).then((r) => {
|
||||||
|
setStewardsData(r.payload.data || []);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
formik.validateForm();
|
||||||
|
}
|
||||||
|
}, [formik.values.type]);
|
||||||
|
|
||||||
const formik2 = useFormik({
|
const formik2 = useFormik({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
personType: defaultPersonType || "real", // real | legal
|
personType: defaultPersonType || "real", // real | legal
|
||||||
@@ -153,7 +203,12 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
province: userData.province || "",
|
province: userData.province || "",
|
||||||
city: userData.city || "",
|
city: userData.city || "",
|
||||||
nationalId: userData.nationalId || "",
|
nationalId: userData.nationalId || "",
|
||||||
unitName: data?.unitName || "",
|
unit_name: userData?.unitName || "",
|
||||||
|
...(IS_ADMINX &&
|
||||||
|
IS_OUT_PROVINCE && {
|
||||||
|
type: formik.values?.type,
|
||||||
|
role_key: formik.values?.role_key,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
formik.setValues(formData);
|
formik.setValues(formData);
|
||||||
@@ -163,8 +218,10 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
"mobile",
|
"mobile",
|
||||||
"firstName",
|
"firstName",
|
||||||
"lastName",
|
"lastName",
|
||||||
"unitName",
|
"unit_name",
|
||||||
"city",
|
"city",
|
||||||
|
"type",
|
||||||
|
"role_key",
|
||||||
];
|
];
|
||||||
const locks = fieldKeys.reduce((acc, key) => {
|
const locks = fieldKeys.reduce((acc, key) => {
|
||||||
const value = userData[key];
|
const value = userData[key];
|
||||||
@@ -189,7 +246,12 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
province: data.province || "",
|
province: data.province || "",
|
||||||
city: data.city || "",
|
city: data.city || "",
|
||||||
nationalId: (IS_STEWARD ? defaultNationalCode : data.nationalId) || "",
|
nationalId: (IS_STEWARD ? defaultNationalCode : data.nationalId) || "",
|
||||||
unitName: data?.unitName || "",
|
unit_name: data?.unitName || "",
|
||||||
|
...(IS_ADMINX &&
|
||||||
|
IS_OUT_PROVINCE && {
|
||||||
|
type: formik.values?.type,
|
||||||
|
role_key: formik.values?.role_key,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
formik.setValues(formData);
|
formik.setValues(formData);
|
||||||
@@ -261,10 +323,15 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
mobile: "",
|
mobile: "",
|
||||||
firstName: d.name || "",
|
firstName: d.name || "",
|
||||||
lastName: d.name || "",
|
lastName: d.name || "",
|
||||||
unitName: d.name || "",
|
unitName: (IS_STEWARD ? d.unitName : d.unitName) || "",
|
||||||
province: d.state || extractedProvince || "",
|
province: d.state || extractedProvince || "",
|
||||||
city: "", // User will select city manually
|
city: "", // User will select city manually
|
||||||
nationalId: d.nationalCode || nationalCode,
|
nationalId: d.nationalCode || nationalCode,
|
||||||
|
...(IS_ADMINX &&
|
||||||
|
IS_OUT_PROVINCE && {
|
||||||
|
type: formik.values?.type,
|
||||||
|
role_key: formik.values?.role_key,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
setUserData(aggregatedUserData);
|
setUserData(aggregatedUserData);
|
||||||
formik2.setFieldValue(
|
formik2.setFieldValue(
|
||||||
@@ -396,6 +463,11 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
layerTwo.nationalcode ||
|
layerTwo.nationalcode ||
|
||||||
selectedGuild?.nationalId ||
|
selectedGuild?.nationalId ||
|
||||||
nationalCode,
|
nationalCode,
|
||||||
|
...(IS_ADMINX &&
|
||||||
|
IS_OUT_PROVINCE && {
|
||||||
|
type: formik.values?.type,
|
||||||
|
role_key: formik.values?.role_key,
|
||||||
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
setUserData(aggregatedUserData);
|
setUserData(aggregatedUserData);
|
||||||
@@ -414,6 +486,8 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log(formik.errors);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid
|
<Grid
|
||||||
container
|
container
|
||||||
@@ -442,7 +516,7 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
mobile: "",
|
mobile: "",
|
||||||
firstName: "",
|
firstName: "",
|
||||||
lastName: "",
|
lastName: "",
|
||||||
unitName: "",
|
unit_name: "",
|
||||||
province: "",
|
province: "",
|
||||||
city: "",
|
city: "",
|
||||||
nationalId: "",
|
nationalId: "",
|
||||||
@@ -535,6 +609,103 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
helperText={formik.touched.nationalId && formik.errors.nationalId}
|
helperText={formik.touched.nationalId && formik.errors.nationalId}
|
||||||
InputProps={{ readOnly: Boolean(lockedFields.nationalId) }}
|
InputProps={{ readOnly: Boolean(lockedFields.nationalId) }}
|
||||||
/>
|
/>
|
||||||
|
{IS_OUT_PROVINCE && IS_ADMINX ? (
|
||||||
|
<>
|
||||||
|
<LabelField label="انتخاب نوع واحد">
|
||||||
|
<RadioGroup
|
||||||
|
row
|
||||||
|
name="type"
|
||||||
|
value={formik.values.type}
|
||||||
|
onChange={(e) => {
|
||||||
|
const value = e.target.value;
|
||||||
|
formik.setFieldValue("type", value);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormControlLabel
|
||||||
|
value="Steward"
|
||||||
|
control={<Radio />}
|
||||||
|
label="مباشر"
|
||||||
|
/>
|
||||||
|
<FormControlLabel
|
||||||
|
value="KillHouse"
|
||||||
|
control={<Radio />}
|
||||||
|
label="کشتارگاه"
|
||||||
|
/>
|
||||||
|
</RadioGroup>
|
||||||
|
</LabelField>
|
||||||
|
{formik.values.type === "Steward" ? (
|
||||||
|
<Autocomplete
|
||||||
|
fullWidth
|
||||||
|
disablePortal
|
||||||
|
id="role_key"
|
||||||
|
options={stewardsData.map((item) => {
|
||||||
|
return {
|
||||||
|
key: item?.key,
|
||||||
|
label: `${item?.name || ""} - ${
|
||||||
|
item?.user?.fullname || ""
|
||||||
|
} (${item?.user?.mobile || ""})`,
|
||||||
|
};
|
||||||
|
})}
|
||||||
|
onChange={(event, value) => {
|
||||||
|
formik.setFieldValue("role_key", value?.key || "");
|
||||||
|
}}
|
||||||
|
value={
|
||||||
|
formik.values.role_key
|
||||||
|
? {
|
||||||
|
key: formik.values.role_key,
|
||||||
|
label:
|
||||||
|
stewardsData.find(
|
||||||
|
(item) => item.key === formik.values.role_key
|
||||||
|
)?.name || "",
|
||||||
|
}
|
||||||
|
: null
|
||||||
|
}
|
||||||
|
isOptionEqualToValue={(option, value) =>
|
||||||
|
option.key === value.key
|
||||||
|
}
|
||||||
|
label="انتخاب مباشر"
|
||||||
|
renderInput={(params) => (
|
||||||
|
<TextField fullWidth {...params} label={"انتخاب مباشر"} />
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
) : formik.values.type === "KillHouse" ? (
|
||||||
|
<FormControl
|
||||||
|
fullWidth
|
||||||
|
error={
|
||||||
|
formik.errors.selectedOption &&
|
||||||
|
formik.touched.selectedOption
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<InputLabel>انتخاب کشتارگاه یا کشتارکن</InputLabel>
|
||||||
|
<Select
|
||||||
|
label="انتخاب کشتارگاه یا کشتارکن"
|
||||||
|
id="role_key"
|
||||||
|
name="role_key"
|
||||||
|
// value={formik.values.role_key}
|
||||||
|
onChange={(e) => {
|
||||||
|
const [key] = e.target.value.split("#");
|
||||||
|
formik.setFieldValue("role_key", key);
|
||||||
|
}}
|
||||||
|
onBlur={formik.handleBlur}
|
||||||
|
>
|
||||||
|
{killhouses?.map((option) => (
|
||||||
|
<MenuItem
|
||||||
|
key={option}
|
||||||
|
value={`${option.key + "#" + option.killer}`}
|
||||||
|
>
|
||||||
|
{option.killer
|
||||||
|
? `کشتارکن ${option.name}`
|
||||||
|
: `کشتارگاه ${option.name}`}
|
||||||
|
</MenuItem>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
{formik.errors.role_key && formik.touched.role_key && (
|
||||||
|
<div>{formik.errors.role_key}</div>
|
||||||
|
)}
|
||||||
|
</FormControl>
|
||||||
|
) : null}
|
||||||
|
</>
|
||||||
|
) : null}
|
||||||
<TextField
|
<TextField
|
||||||
fullWidth
|
fullWidth
|
||||||
id="mobile"
|
id="mobile"
|
||||||
@@ -574,16 +745,16 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
/>
|
/>
|
||||||
<TextField
|
<TextField
|
||||||
fullWidth
|
fullWidth
|
||||||
id="unitName"
|
id="unit_name"
|
||||||
label="نام واحد"
|
label="نام واحد"
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
value={formik.values.unitName}
|
value={formik.values.unit_name}
|
||||||
onChange={formik.handleChange}
|
onChange={formik.handleChange}
|
||||||
onBlur={formik.handleBlur}
|
onBlur={formik.handleBlur}
|
||||||
helperText={formik.touched.unitName && formik.errors.unitName}
|
helperText={formik.touched.unit_name && formik.errors.unit_name}
|
||||||
disabled={Boolean(lockedFields.unitName)}
|
disabled={Boolean(lockedFields.unit_name)}
|
||||||
InputProps={{ readOnly: Boolean(lockedFields.unitName) }}
|
InputProps={{ readOnly: Boolean(lockedFields.unit_name) }}
|
||||||
error={Boolean(formik.errors.unitName)}
|
error={Boolean(formik.errors.unit_name)}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Autocomplete
|
<Autocomplete
|
||||||
@@ -676,7 +847,9 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
city: formik.values.city,
|
city: formik.values.city,
|
||||||
province: formik.values.province,
|
province: formik.values.province,
|
||||||
national_id: formik.values.nationalId,
|
national_id: formik.values.nationalId,
|
||||||
unit_name: formik.values.unitName,
|
unit_name: formik.values.unit_name,
|
||||||
|
type: formik.values.type,
|
||||||
|
role_key: formik.values.role_key,
|
||||||
};
|
};
|
||||||
|
|
||||||
dispatch(slaughterEditBuyerDataService(submitData)).then(
|
dispatch(slaughterEditBuyerDataService(submitData)).then(
|
||||||
@@ -711,17 +884,23 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
|
|||||||
last_name: formik.values.lastName,
|
last_name: formik.values.lastName,
|
||||||
city: formik.values.city,
|
city: formik.values.city,
|
||||||
province: formik.values.province,
|
province: formik.values.province,
|
||||||
|
unit_name: formik.values.unit_name,
|
||||||
national_id:
|
national_id:
|
||||||
formik2.values.personType === "legal"
|
formik2.values.personType === "legal"
|
||||||
? null
|
? null
|
||||||
: formik.values.nationalId,
|
: formik.values.nationalId,
|
||||||
|
type: formik.values.type,
|
||||||
|
role_key: formik.values.role_key,
|
||||||
...(formik2.values.personType === "legal" && {
|
...(formik2.values.personType === "legal" && {
|
||||||
isRealPerson: false,
|
isRealPerson: false,
|
||||||
info_value: formik2.values.nationalCode,
|
info_value: formik2.values.nationalCode,
|
||||||
unit_name: formik.values.unitName,
|
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// if (IS_STEWARD) {
|
||||||
|
// submitData.name = formik.values.unitName;
|
||||||
|
// delete submitData.unit_name;
|
||||||
|
// }
|
||||||
dispatch(slaughterSubmitBuyerDataService(submitData)).then(
|
dispatch(slaughterSubmitBuyerDataService(submitData)).then(
|
||||||
(r) => {
|
(r) => {
|
||||||
updateTable();
|
updateTable();
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import { formatJustDate, formatTime } from "../../../../utils/formatTime";
|
|||||||
import { SlaughterOutProvinceRegistrationCodeInput } from "../slaughter-out-province-registration-code-input/SlaughterOutProvinceRegistrationCodeInput";
|
import { SlaughterOutProvinceRegistrationCodeInput } from "../slaughter-out-province-registration-code-input/SlaughterOutProvinceRegistrationCodeInput";
|
||||||
import { SlaughterOutProvinceSalesOperations } from "../slaughter-out-province-sales-operations/SlaughterOutProvinceSalesOperations";
|
import { SlaughterOutProvinceSalesOperations } from "../slaughter-out-province-sales-operations/SlaughterOutProvinceSalesOperations";
|
||||||
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
|
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
|
||||||
|
import { fetchSlaughterBroadcastAndProducts } from "../../services/handle-fetch-slaughter-products";
|
||||||
|
|
||||||
export const SlaughterSellCarcassOutProvinceSell = () => {
|
export const SlaughterSellCarcassOutProvinceSell = () => {
|
||||||
const [, , selectedDate1, setSelectedDate1, selectedDate2, setSelectedDate2] =
|
const [, , selectedDate1, setSelectedDate1, selectedDate2, setSelectedDate2] =
|
||||||
@@ -77,6 +78,13 @@ export const SlaughterSellCarcassOutProvinceSell = () => {
|
|||||||
|
|
||||||
const updateTable = () => {
|
const updateTable = () => {
|
||||||
fetchApiData(page !== 0 ? page : 1);
|
fetchApiData(page !== 0 ? page : 1);
|
||||||
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: checkPathStartsWith("slaughter")
|
||||||
|
? selectedSubUser?.key || ""
|
||||||
|
: "",
|
||||||
|
})
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
@@ -346,7 +346,11 @@ export const SlaughterSellCarcassOutProvinceSellSubmitSell = ({
|
|||||||
} else {
|
} else {
|
||||||
updateTable();
|
updateTable();
|
||||||
}
|
}
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
dispatch(
|
dispatch(
|
||||||
DRAWER({ right: false, bottom: false, content: null })
|
DRAWER({ right: false, bottom: false, content: null })
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Formik, Form, Field } from "formik";
|
|||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
import { Grid } from "../../../../components/grid/Grid";
|
import { Grid } from "../../../../components/grid/Grid";
|
||||||
import { AppContext } from "../../../../contexts/AppContext";
|
import { AppContext } from "../../../../contexts/AppContext";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import {
|
import {
|
||||||
guildSubmitOutOfProvinceService,
|
guildSubmitOutOfProvinceService,
|
||||||
slaughterSubmitOutOfProvinceService,
|
slaughterSubmitOutOfProvinceService,
|
||||||
@@ -36,7 +36,9 @@ export const SlaughterSubmitOutProvinceSell = ({
|
|||||||
}) => {
|
}) => {
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
|
const selectedSubUser = useSelector(
|
||||||
|
(state) => state.userSlice.selectedSubUser
|
||||||
|
);
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
clearance_code: item?.clearanceCode || "",
|
clearance_code: item?.clearanceCode || "",
|
||||||
number_of_carcasses: item?.numberOfCarcasses || "",
|
number_of_carcasses: item?.numberOfCarcasses || "",
|
||||||
@@ -100,7 +102,11 @@ export const SlaughterSubmitOutProvinceSell = ({
|
|||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
dispatch(DRAWER({ right: false, bottom: false, content: null }));
|
dispatch(DRAWER({ right: false, bottom: false, content: null }));
|
||||||
openNotif({
|
openNotif({
|
||||||
vertical: "top",
|
vertical: "top",
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import {
|
|||||||
OPEN_MODAL,
|
OPEN_MODAL,
|
||||||
} from "../../../../lib/redux/slices/appSlice";
|
} from "../../../../lib/redux/slices/appSlice";
|
||||||
import { SPACING } from "../../../../data/spacing";
|
import { SPACING } from "../../../../data/spacing";
|
||||||
import { useDispatch } from "react-redux";
|
import { useDispatch, useSelector } from "react-redux";
|
||||||
import { AppContext } from "../../../../contexts/AppContext";
|
import { AppContext } from "../../../../contexts/AppContext";
|
||||||
|
|
||||||
import { slaughterEditFreeSaleService } from "../../services/slaughter-edit-free-sale";
|
import { slaughterEditFreeSaleService } from "../../services/slaughter-edit-free-sale";
|
||||||
@@ -17,9 +17,12 @@ import { fetchSlaughterBroadcastAndProducts } from "../../services/handle-fetch-
|
|||||||
|
|
||||||
export const SlaughterSubmitRealInventoryFreeBar = ({ item, updateTable }) => {
|
export const SlaughterSubmitRealInventoryFreeBar = ({ item, updateTable }) => {
|
||||||
const [loss, setLoss] = useState("0");
|
const [loss, setLoss] = useState("0");
|
||||||
|
|
||||||
const [openNotif] = useContext(AppContext);
|
const [openNotif] = useContext(AppContext);
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
const selectedSubUser = useSelector(
|
||||||
|
(state) => state.userSlice.selectedSubUser
|
||||||
|
);
|
||||||
|
|
||||||
const formik = useFormik({
|
const formik = useFormik({
|
||||||
initialValues: {
|
initialValues: {
|
||||||
realNumber: item.numberOfCarcasses ? item.numberOfCarcasses : "",
|
realNumber: item.numberOfCarcasses ? item.numberOfCarcasses : "",
|
||||||
@@ -36,7 +39,7 @@ export const SlaughterSubmitRealInventoryFreeBar = ({ item, updateTable }) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let difference = item?.liveWeight - formik.values.realWeight;
|
const difference = item?.liveWeight - formik.values.realWeight;
|
||||||
if (difference < item?.liveWeight) {
|
if (difference < item?.liveWeight) {
|
||||||
setLoss(((difference / item?.liveWeight) * 100).toPrecision(4));
|
setLoss(((difference / item?.liveWeight) * 100).toPrecision(4));
|
||||||
} else {
|
} else {
|
||||||
@@ -182,7 +185,11 @@ export const SlaughterSubmitRealInventoryFreeBar = ({ item, updateTable }) => {
|
|||||||
dispatch(CLOSE_MODAL());
|
dispatch(CLOSE_MODAL());
|
||||||
updateTable(1);
|
updateTable(1);
|
||||||
handleAlert();
|
handleAlert();
|
||||||
dispatch(fetchSlaughterBroadcastAndProducts());
|
dispatch(
|
||||||
|
fetchSlaughterBroadcastAndProducts({
|
||||||
|
role_key: selectedSubUser?.key || "",
|
||||||
|
})
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
|
|||||||
@@ -88,7 +88,9 @@ export const StewardShowAllocations = forwardRef(
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateTable = () => {
|
const updateTable = () => {
|
||||||
|
console.log("--------------------------------------");
|
||||||
fetchApiData(1);
|
fetchApiData(1);
|
||||||
|
handleUpdate();
|
||||||
};
|
};
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user