Fix: some issues like dispatch and wrong keys

This commit is contained in:
2026-02-07 10:29:48 +03:30
parent a2a33b0efb
commit 7f1f55e478
11 changed files with 113 additions and 55 deletions

View File

@@ -14,14 +14,14 @@ import {
ROUTE_ADMINX_ROUTE_OUT_PROVINCE_TRUE_GUILDS,
ROUTE_SLAUGHTER_INVENTORY_SELL_CARCASS_OUT_PROVINCE,
ROUTE_SLAUGHTER_MANAGE_GUILDS_OUT_PROVINCE_TRUE,
ROUTE_STEWARD_SALE_OUT_PROVINCE
ROUTE_STEWARD_SALE_OUT_PROVINCE,
} from "../../../../routes/routes";
import {
handleSetFormDataFromTableDataForStewardAddBuyer,
handleSubmitForStewardAddBuyer,
InquiryForStewardAddBuyer,
StewardAddBuyerForm,
validationSchemaForStewardAddBuyer
validationSchemaForStewardAddBuyer,
} from "./InquiryForStewardAddBuyer";
import { useAddBuyer } from "./hooks/useAddBuyer";
import { slaughterGetCitiesService } from "../../../slaughter-house/services/slaughter-get-provinces";
@@ -30,7 +30,7 @@ import {
handleSubmitForSlaughterAddBuyer,
InquiryForSlaughterAddBuyer,
SlaughterAddBuyerForm,
validationSchemaForSlaughterAddBuyer
validationSchemaForSlaughterAddBuyer,
} from "./InquiryForSlaughterAddBuyer";
import { useFormik } from "formik";
import {
@@ -38,7 +38,7 @@ import {
handleSetFormDataFromTableDataForAdminAddBuyer,
handleSubmitForAdminAddBuyer,
InquiryForAdminAddBuyer,
validationSchemaForAdminAddBuyer
validationSchemaForAdminAddBuyer,
} from "./InquiryForAdminAddBuyer";
import { inspectorGetKillHousesService } from "../../../inspector/services/inspector-get-kill-houses";
import { slaughterGetStewardsForAllocateService } from "../../../slaughter-house/services/slaughter-get-guilds-for-allocate";
@@ -64,7 +64,7 @@ const getCurrentPage = (role, pathname) => {
ROUTE_ADMINX_ROUTE_OUT_PROVINCE_TRUE_GUILDS,
ROUTE_ADMINX_ROUTE_OUT_PROVINCE_LEGAL_GUILDS,
ROUTE_ADMINX_ROUTE_MANAGE_STEWARDS_OUT_PROVINCE_LEGAL,
ROUTE_ADMINX_ROUTE_MANAGE_STEWARDS_OUT_PROVINCE_TRUE
ROUTE_ADMINX_ROUTE_MANAGE_STEWARDS_OUT_PROVINCE_TRUE,
];
if (routes.some((r) => r === pathname)) {
return "admin_add_buyer";
@@ -79,20 +79,20 @@ const getInitialValues = (page) => {
lastName: "",
unit_name: "",
province: "",
city: ""
city: "",
};
if (page === "steward_add_buyer" || page === "slaughter_manage_add_buyer") {
return initialValues;
} else if (page === "slaughter_add_buyer") {
return {
...initialValues,
nationalId: ""
nationalId: "",
};
} else if (page === "admin_add_buyer") {
return {
...initialValues,
role_key: "",
type: ""
type: "",
};
}
return initialValues;
@@ -103,7 +103,7 @@ export const StewardAddBuyer = ({
isEdit = false,
data,
isRealPerson,
buyerType = ""
buyerType = "",
// buyerYype => "Guilds" | "Steward"
}) => {
const role = getRoleFromUrl();
@@ -124,7 +124,7 @@ export const StewardAddBuyer = ({
cityData,
setCityData,
userData,
setUserData
setUserData,
} = useAddBuyer(page);
const { selectedSubUser } = useSelector((state) => state.userSlice);
@@ -141,7 +141,7 @@ export const StewardAddBuyer = ({
? validationSchemaForSlaughterAddBuyer(isRealPerson, isEdit)
: IS_ADMIN_ADD_BUYER
? validationSchemaForAdminAddBuyer(isRealPerson, isEdit)
: Yup.object({})
: Yup.object({}),
});
useEffect(() => {
@@ -157,7 +157,7 @@ export const StewardAddBuyer = ({
} else {
dispatch(
slaughterGetStewardsForAllocateService({
free: true
free: true,
})
).then((r) => {
setStewards(r.payload.data || []);

View File

@@ -314,6 +314,7 @@ export const StewardSellOutOfProvinceSubmitSell = ({
dispatch(
stewardSellOuutSubmitSell({
buyer_key: buyerSelected,
role_key: selectedSubUser?.key,
number_of_carcasses:
Math.round(
values?.weight_of_carcasses / productKey?.weightAverage

View File

@@ -9,11 +9,11 @@ import {
} from "@mui/material";
import ExpandMoreIcon from "@mui/icons-material/ExpandMore";
import { stewardGetBarsInfo } from "../../services/steward-get-bars-info";
import { fetchStewardBroadcastAndProducts } from "../../services/handle-fetch-steward-products";
import { Grid } from "../../../../components/grid/Grid";
import { StewardShowProducts } from "../steward-show-products/StewardShowProducts";
import ResponsiveTable from "../../../../components/responsive-table/ResponsiveTable";
import { StewardShowAllocations } from "../steward-show-allocations/StewardShowAllocations";
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
export const StewardStock = () => {
const dispatch = useDispatch();
@@ -27,12 +27,18 @@ export const StewardStock = () => {
const handleUpdate = () => {
dispatch(
stewardGetBarsInfo({
role_key: checkPathStartsWith("steward") ? selectedSubUser?.key : "",
role_key: selectedSubUser?.key || "",
})
).then((r) => {
setBarsInfo(r.payload.data);
});
dispatch(
fetchStewardBroadcastAndProducts({
role_key: selectedSubUser?.key || "",
})
);
if (notEnteredRef.current) {
notEnteredRef.current.updateTable();
}