fix => services for fetchSlaughterBroadcastAndProducts

This commit is contained in:
2026-01-28 14:43:26 +03:30
parent 6ad291867e
commit fa3543f43e
19 changed files with 317 additions and 54 deletions

View File

@@ -130,7 +130,6 @@ export const CreateGuilds = ({ guild, updateTable }) => {
hasInquiry
);
});
console.log(guildsDataArray);
dispatch(updateGuildByNationalIdNewService(guildsDataArray)).then(
(result) => {
if (result.payload.error) {

View File

@@ -39,7 +39,6 @@ export const ProvinceDispenserEditToGuild = ({
priceInfo,
coldHouseKey,
coldHouseItemKey,
remainWeight,
fetchDashboardData,
}) => {
const dispatch = useDispatch();

View File

@@ -1,5 +1,5 @@
import { useContext, useEffect, useState } from "react";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { AppContext } from "../../../../contexts/AppContext";
import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl";
@@ -25,6 +25,7 @@ import {
slaughterEditAllocateStewardService,
} from "../../../slaughter-house/services/slaughter-allocate-steward";
import { fetchSlaughterBroadcastAndProducts } from "../../../slaughter-house/services/handle-fetch-slaughter-products";
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
export const ProvinceDispenserStewardEditOperation = ({
item,
@@ -47,6 +48,9 @@ export const ProvinceDispenserStewardEditOperation = ({
const [openNotif] = useContext(AppContext);
const [value, setValue] = useState("own");
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const handleChange = (event) => {
setValue(event.target.value);
@@ -156,7 +160,11 @@ export const ProvinceDispenserStewardEditOperation = ({
msg: "عملیات با موفقیت انجام شد.",
severity: "success",
});
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
fetchDashboardData();
fetchApiData(1);
};

View File

@@ -8,7 +8,7 @@ import {
Popover,
} from "@mui/material";
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 { slaughterDeleteAllocatedService } from "../../../slaughter-house/services/salughter-delete-allocated";
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 EditIcon from "@mui/icons-material/Edit";
import DeleteIcon from "@mui/icons-material/Delete";
export const ProvinceDispenserStewardSaleInOperation = ({
fetchApiData,
item,
@@ -27,7 +28,9 @@ export const ProvinceDispenserStewardSaleInOperation = ({
}) => {
const [anchorEl, setAnchorEl] = useState(null);
const dispatch = useDispatch();
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
@@ -62,7 +65,11 @@ export const ProvinceDispenserStewardSaleInOperation = ({
steward_allocation_key: item.key,
})
).then(() => {
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
fetchApiData(1);
setAnchorEl(null);
});

View File

@@ -10,7 +10,7 @@ import {
import TuneIcon from "@mui/icons-material/Tune";
import EditOutlinedIcon from "@mui/icons-material/EditOutlined";
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 { OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
import { ProvinceStewardEditSaleOutOperation } from "../province-steward-edit-sale-out-operation/ProvinceStewardEditSaleOutOperation";
@@ -28,7 +28,9 @@ export const ProvinceDispenserStewardSaleOutOperation = ({
}) => {
const [anchorEl, setAnchorEl] = useState(null);
const dispatch = useDispatch();
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
@@ -60,7 +62,11 @@ export const ProvinceDispenserStewardSaleOutOperation = ({
const handleDeleteClick = () => {
handleClose();
dispatch(stewardDeleteOutSellService(item?.key)).then(() => {
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
fetchApiData(1);
setAnchorEl(null);
});

View File

@@ -1,5 +1,5 @@
import { useContext } from "react";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { AppContext } from "../../../../contexts/AppContext";
import { Yup } from "../../../../lib/yup/yup";
import { useFormik } from "formik";
@@ -20,6 +20,9 @@ export const ProvinceStewardEditSaleOutOperation = ({
}) => {
const dispatch = useDispatch();
const [openNotif] = useContext(AppContext);
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const validationSchema = Yup.object({
weight: Yup.number().min(1, "یک مقدار مثبت وارد کنید!"),
@@ -45,7 +48,11 @@ export const ProvinceStewardEditSaleOutOperation = ({
msg: "وزن با موفقیت ویرایش شد.",
severity: "success",
});
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
fetchApiData(1);
fetchDashboardData();
};

View File

@@ -1,6 +1,6 @@
import { Button, IconButton, Popover } from "@mui/material";
import { useState } from "react";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { Grid } from "../../../../components/grid/Grid";
import { DRAWER, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
import { slaughterDeleteInventoryFreeBarService } from "../../services/slaughter-delete-inventory-free-bar";
@@ -16,7 +16,9 @@ export const SlaughterFreeBarsAlivesOperations = ({
type,
}) => {
const dispatch = useDispatch();
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const [anchorEl, setAnchorEl] = useState(null);
const handleClick = (event) => {
@@ -129,7 +131,11 @@ export const SlaughterFreeBarsAlivesOperations = ({
slaughterDeleteInventoryFreeBarService(item.key)
).then(() => {
updateTable();
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
});
}}
>

View File

@@ -8,7 +8,7 @@ import {
ListItemIcon,
} from "@mui/material";
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 { slaughterDeleteInventoryFreeBarService } from "../../services/slaughter-delete-inventory-free-bar";
import { SlaughterSubmitFreeBar } from "../slaughter-submit-free-bar/SlaughterSubmitFreeBar";
@@ -26,7 +26,9 @@ export const SlaughterFreeBarsOperations = ({
type,
}) => {
const dispatch = useDispatch();
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const [anchorEl, setAnchorEl] = useState(null);
const handleClick = (event) => {
@@ -158,7 +160,11 @@ export const SlaughterFreeBarsOperations = ({
slaughterDeleteInventoryFreeBarService(item.key)
).then(() => {
updateTable();
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
});
}}
>

View File

@@ -1,7 +1,7 @@
import React, { useContext, useEffect } from "react";
import { Grid } from "../../../../components/grid/Grid";
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 { useFormik } from "formik";
import { Yup } from "../../../../lib/yup/yup";
@@ -24,6 +24,9 @@ export const SlaughterHouseColdHouseBarsEdit = ({
}) => {
const dispatch = useDispatch();
const [openNotif] = useContext(AppContext);
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const validationSchema = Yup.object({
weight: Yup.number()
@@ -50,7 +53,11 @@ export const SlaughterHouseColdHouseBarsEdit = ({
msg: "عملیات با موفقیت انجام شد.",
severity: "success",
});
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
fetchApiData();
updateTable();
fetchData();

View File

@@ -25,7 +25,7 @@ import { fetchSlaughterBroadcastAndProducts } from "../../services/handle-fetch-
export const SlaughterInventoryFreeBuyBarsAlives = ({
title,
barState,
fetchDashboardData,
handleUpdate,
withDate,
selectedDate1,
selectedDate2,
@@ -87,7 +87,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({
const updateTable = () => {
fetchApiData(page !== 0 ? page : 1);
fetchDashboardData();
handleUpdate();
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: checkPathStartsWith("slaughter")

View File

@@ -411,7 +411,7 @@ export const SlaughterInventoryFreeBuyBars = () => {
<SlaughterInventoryFreeBuyBarsAlives
title={"بار زنده در انتظار ورود به انبار (خارج استان)"}
barState={"notentered"}
fetchDashboardData={fetchDashboardData}
handleUpdate={updateTable}
searchValue={searchValue}
withDate={withDate}
selectedDate1={selectedDate1}
@@ -421,7 +421,7 @@ export const SlaughterInventoryFreeBuyBars = () => {
<SlaughterInventoryFreeBuyBarsAlives
title={"بار زنده وارد شده به انبار (خارج استان)"}
barState={"entered"}
fetchDashboardData={fetchDashboardData}
handleUpdate={updateTable}
searchValue={searchValue}
withDate={withDate}
selectedDate1={selectedDate1}

View File

@@ -17,7 +17,7 @@ import { Grid } from "../../../../components/grid/Grid";
import { CLOSE_MODAL, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
import { AppContext } from "../../../../contexts/AppContext";
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 { slaughterDeleteAllocatedService } from "../../services/salughter-delete-allocated";
import { SlaughterAllocateToGuild } from "../slaughter-allocate-to-guild/SlaughterAllocateToGuild";
@@ -31,7 +31,9 @@ export const SlaughterManageInventoryAllocationOperations = ({
remainWeight,
}) => {
const [anchorEl, setAnchorEl] = useState(null);
const selectedSubUser = useSelector(
(state) => state?.userSlice?.selectedSubUser
);
const handleClick = (event) => {
setAnchorEl(event.currentTarget);
};
@@ -150,7 +152,11 @@ export const SlaughterManageInventoryAllocationOperations = ({
})
).then(() => {
dispatch(CLOSE_MODAL());
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
fetchApiData(1);
});
}}

View File

@@ -10,7 +10,7 @@ import {
Tooltip,
Typography,
} from "@mui/material";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { AppContext } from "../../../../contexts/AppContext";
import { DRAWER } from "../../../../lib/redux/slices/appSlice";
import { slaughterDeleteOutOfProvinceSell } from "../../services/slaughter-delete-out-province-sell";
@@ -31,7 +31,9 @@ export const SlaughterOutProvinceSalesOperations = ({
const dispatch = useDispatch();
const [openNotif] = useContext(AppContext);
const [anchorEl, setAnchorEl] = useState(null);
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const openPopover = (event) => {
setAnchorEl(event.currentTarget);
};
@@ -70,7 +72,11 @@ export const SlaughterOutProvinceSalesOperations = ({
});
} else {
updateTable();
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
openNotif({
vertical: "top",
horizontal: "center",

View File

@@ -10,6 +10,10 @@ import {
FormControlLabel,
TextField,
Typography,
FormControl,
InputLabel,
Select,
MenuItem,
} from "@mui/material";
import { useFormik } from "formik";
import { Yup } from "../../../../lib/yup/yup";
@@ -19,7 +23,7 @@ import {
slaughterSubmitBuyerDataService,
} from "../../services/slaughter-house-submit-buyer";
import { AppContext } from "../../../../contexts/AppContext";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { DRAWER } from "../../../../lib/redux/slices/appSlice";
import {
slaughterGetCitiesService,
@@ -28,6 +32,10 @@ import {
import { provinceGetNationalDocumentsService } from "../../../province/services/province-get-national-documents";
import { LabelField } from "../../../../components/label-field/LabelField";
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
@@ -40,6 +48,12 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
userType,
}) => {
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 [userData, setUserData] = useState(null);
const [notFound, setNotFound] = useState(false);
@@ -48,16 +62,20 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
const dispatch = useDispatch();
const [provinceData, setProvinceData] = useState([]);
const [cityData, setCityData] = useState([]);
const [killhouses, setKillhouses] = useState([]);
const [stewardsData, setStewardsData] = useState([]);
const formik = useFormik({
initialValues: {
mobile: "",
firstName: "",
lastName: "",
unitName: "",
unit_name: "",
province: "",
city: "",
nationalId: "",
role_key: "",
type: "",
},
validationSchema: Yup.object({
mobile: Yup.string()
@@ -71,7 +89,7 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
lastName: Yup.string()
.required("این فیلد اجباری است!")
.typeError("لطفا فیلد را به درستی وارد کنید!"),
unitName: Yup.string()
unit_name: Yup.string()
.required("این فیلد اجباری است!")
.typeError("لطفا فیلد را به درستی وارد کنید!"),
province: Yup.string()
@@ -86,10 +104,42 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
: Yup.string()
.required("این فیلد اجباری است!")
.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,
});
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({
initialValues: {
personType: defaultPersonType || "real", // real | legal
@@ -153,7 +203,12 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
province: userData.province || "",
city: userData.city || "",
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);
@@ -163,8 +218,10 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
"mobile",
"firstName",
"lastName",
"unitName",
"unit_name",
"city",
"type",
"role_key",
];
const locks = fieldKeys.reduce((acc, key) => {
const value = userData[key];
@@ -189,7 +246,12 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
province: data.province || "",
city: data.city || "",
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);
@@ -261,10 +323,15 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
mobile: "",
firstName: d.name || "",
lastName: d.name || "",
unitName: d.name || "",
unitName: (IS_STEWARD ? d.unitName : d.unitName) || "",
province: d.state || extractedProvince || "",
city: "", // User will select city manually
nationalId: d.nationalCode || nationalCode,
...(IS_ADMINX &&
IS_OUT_PROVINCE && {
type: formik.values?.type,
role_key: formik.values?.role_key,
}),
};
setUserData(aggregatedUserData);
formik2.setFieldValue(
@@ -396,6 +463,11 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
layerTwo.nationalcode ||
selectedGuild?.nationalId ||
nationalCode,
...(IS_ADMINX &&
IS_OUT_PROVINCE && {
type: formik.values?.type,
role_key: formik.values?.role_key,
}),
};
setUserData(aggregatedUserData);
@@ -414,6 +486,8 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
}
};
console.log(formik.errors);
return (
<Grid
container
@@ -442,7 +516,7 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
mobile: "",
firstName: "",
lastName: "",
unitName: "",
unit_name: "",
province: "",
city: "",
nationalId: "",
@@ -535,6 +609,103 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
helperText={formik.touched.nationalId && formik.errors.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
fullWidth
id="mobile"
@@ -574,16 +745,16 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
/>
<TextField
fullWidth
id="unitName"
id="unit_name"
label="نام واحد"
variant="outlined"
value={formik.values.unitName}
value={formik.values.unit_name}
onChange={formik.handleChange}
onBlur={formik.handleBlur}
helperText={formik.touched.unitName && formik.errors.unitName}
disabled={Boolean(lockedFields.unitName)}
InputProps={{ readOnly: Boolean(lockedFields.unitName) }}
error={Boolean(formik.errors.unitName)}
helperText={formik.touched.unit_name && formik.errors.unit_name}
disabled={Boolean(lockedFields.unit_name)}
InputProps={{ readOnly: Boolean(lockedFields.unit_name) }}
error={Boolean(formik.errors.unit_name)}
/>
<Autocomplete
@@ -676,7 +847,9 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
city: formik.values.city,
province: formik.values.province,
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(
@@ -711,17 +884,23 @@ export const SlaughterSellCarcassOutProvinceAddBuyer = ({
last_name: formik.values.lastName,
city: formik.values.city,
province: formik.values.province,
unit_name: formik.values.unit_name,
national_id:
formik2.values.personType === "legal"
? null
: formik.values.nationalId,
type: formik.values.type,
role_key: formik.values.role_key,
...(formik2.values.personType === "legal" && {
isRealPerson: false,
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(
(r) => {
updateTable();

View File

@@ -22,6 +22,7 @@ import { formatJustDate, formatTime } from "../../../../utils/formatTime";
import { SlaughterOutProvinceRegistrationCodeInput } from "../slaughter-out-province-registration-code-input/SlaughterOutProvinceRegistrationCodeInput";
import { SlaughterOutProvinceSalesOperations } from "../slaughter-out-province-sales-operations/SlaughterOutProvinceSalesOperations";
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
import { fetchSlaughterBroadcastAndProducts } from "../../services/handle-fetch-slaughter-products";
export const SlaughterSellCarcassOutProvinceSell = () => {
const [, , selectedDate1, setSelectedDate1, selectedDate2, setSelectedDate2] =
@@ -77,6 +78,13 @@ export const SlaughterSellCarcassOutProvinceSell = () => {
const updateTable = () => {
fetchApiData(page !== 0 ? page : 1);
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: checkPathStartsWith("slaughter")
? selectedSubUser?.key || ""
: "",
})
);
};
useEffect(() => {

View File

@@ -346,7 +346,11 @@ export const SlaughterSellCarcassOutProvinceSellSubmitSell = ({
} else {
updateTable();
}
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
dispatch(
DRAWER({ right: false, bottom: false, content: null })
);

View File

@@ -4,7 +4,7 @@ import { Formik, Form, Field } from "formik";
import * as Yup from "yup";
import { Grid } from "../../../../components/grid/Grid";
import { AppContext } from "../../../../contexts/AppContext";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import {
guildSubmitOutOfProvinceService,
slaughterSubmitOutOfProvinceService,
@@ -36,7 +36,9 @@ export const SlaughterSubmitOutProvinceSell = ({
}) => {
const dispatch = useDispatch();
const [openNotif] = useContext(AppContext);
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const initialValues = {
clearance_code: item?.clearanceCode || "",
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 }));
openNotif({
vertical: "top",

View File

@@ -9,7 +9,7 @@ import {
OPEN_MODAL,
} from "../../../../lib/redux/slices/appSlice";
import { SPACING } from "../../../../data/spacing";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { AppContext } from "../../../../contexts/AppContext";
import { slaughterEditFreeSaleService } from "../../services/slaughter-edit-free-sale";
@@ -17,9 +17,12 @@ import { fetchSlaughterBroadcastAndProducts } from "../../services/handle-fetch-
export const SlaughterSubmitRealInventoryFreeBar = ({ item, updateTable }) => {
const [loss, setLoss] = useState("0");
const [openNotif] = useContext(AppContext);
const dispatch = useDispatch();
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const formik = useFormik({
initialValues: {
realNumber: item.numberOfCarcasses ? item.numberOfCarcasses : "",
@@ -36,7 +39,7 @@ export const SlaughterSubmitRealInventoryFreeBar = ({ item, updateTable }) => {
});
useEffect(() => {
let difference = item?.liveWeight - formik.values.realWeight;
const difference = item?.liveWeight - formik.values.realWeight;
if (difference < item?.liveWeight) {
setLoss(((difference / item?.liveWeight) * 100).toPrecision(4));
} else {
@@ -182,7 +185,11 @@ export const SlaughterSubmitRealInventoryFreeBar = ({ item, updateTable }) => {
dispatch(CLOSE_MODAL());
updateTable(1);
handleAlert();
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
}
});
}}

View File

@@ -88,7 +88,9 @@ export const StewardShowAllocations = forwardRef(
};
const updateTable = () => {
console.log("--------------------------------------");
fetchApiData(1);
handleUpdate();
};
useImperativeHandle(ref, () => ({