Fix: some issues like dispatch and wrong keys
This commit is contained in:
@@ -24,7 +24,7 @@ import { getRoleFromUrl } from "../../../utils/getRoleFromUrl";
|
||||
import { senfGetInventoryStockService } from "../services/senf-get-inventory-stock";
|
||||
import { senfGetInventoryAllocatedService } from "../services/senf-get-inventory-allocated";
|
||||
|
||||
export const GuildReceiveBarOperation = ({ item }) => {
|
||||
export const GuildReceiveBarOperation = ({ item, onSuccess }) => {
|
||||
const dispatch = useDispatch();
|
||||
const [, , selectedDate1] = useContext(AppContext);
|
||||
const [openNotif] = useContext(AppContext);
|
||||
@@ -251,6 +251,7 @@ export const GuildReceiveBarOperation = ({ item }) => {
|
||||
})
|
||||
);
|
||||
}
|
||||
onSuccess?.();
|
||||
openNotif({
|
||||
vertical: "top",
|
||||
horizontal: "center",
|
||||
@@ -283,16 +284,30 @@ export const GuildReceiveBarOperation = ({ item }) => {
|
||||
severity: "error",
|
||||
});
|
||||
} else {
|
||||
dispatch(
|
||||
guildGetInventoryStockService({
|
||||
date: selectedDate1,
|
||||
})
|
||||
);
|
||||
dispatch(
|
||||
guildGetInventoryAllocatedService({
|
||||
date: selectedDate1,
|
||||
})
|
||||
);
|
||||
if (getRoleFromUrl() === "senf") {
|
||||
dispatch(
|
||||
senfGetInventoryStockService({
|
||||
date: selectedDate1,
|
||||
})
|
||||
);
|
||||
dispatch(
|
||||
senfGetInventoryAllocatedService({
|
||||
date: selectedDate1,
|
||||
})
|
||||
);
|
||||
} else {
|
||||
dispatch(
|
||||
guildGetInventoryStockService({
|
||||
date: selectedDate1,
|
||||
})
|
||||
);
|
||||
dispatch(
|
||||
guildGetInventoryAllocatedService({
|
||||
date: selectedDate1,
|
||||
})
|
||||
);
|
||||
}
|
||||
onSuccess?.();
|
||||
openNotif({
|
||||
vertical: "top",
|
||||
horizontal: "center",
|
||||
|
||||
@@ -155,6 +155,7 @@ export const StewardSegmentSubmitOperation = ({
|
||||
Object.entries(req).filter(([, val]) => val !== null)
|
||||
);
|
||||
}
|
||||
req.role_key = selectedSubUser?.key;
|
||||
|
||||
dispatch(stewardSegmentSubmitService(req)).then((r) => {
|
||||
if (r.payload.error) {
|
||||
|
||||
@@ -5,11 +5,13 @@ import { useLocation } from "react-router-dom";
|
||||
import {
|
||||
ROUTE_ADMINX_COMPANY_ROUTE_ACTIVE_SESSION,
|
||||
ROUTE_ADMINX_COMPANY_ROUTE_DEVICES,
|
||||
ROUTE_ADMINX_ROUTE_DEVICES_V2,
|
||||
ROUTE_PSP_COMPANY_ROUTE_ACTIVE_SESSION,
|
||||
ROUTE_PSP_COMPANY_ROUTE_DEVICES,
|
||||
ROUTE_PSP_COMPANY_ROUTE_DEVICES_V2,
|
||||
ROUTE_SUPER_ADMIN_COMPANY_ROUTE_ACTIVE_SESSION,
|
||||
ROUTE_SUPER_ADMIN_COMPANY_ROUTE_DEVICES,
|
||||
ROUTE_SUPER_ADMIN_ROUTE_DEVICES_V2,
|
||||
// ROUTE_PSP_COMPANY_ROUTE_GUILDS,
|
||||
} from "../../../../routes/routes";
|
||||
import LinkItem from "../../../../components/link-item/LinkItem";
|
||||
@@ -28,14 +30,22 @@ export const PspOperations = () => {
|
||||
justifyContent="center"
|
||||
>
|
||||
<NavLink
|
||||
to={ROUTE_PSP_COMPANY_ROUTE_DEVICES_V2}
|
||||
to={
|
||||
getRoleFromUrl() === "PosCompany"
|
||||
? ROUTE_PSP_COMPANY_ROUTE_DEVICES_V2
|
||||
: getRoleFromUrl() === "SuperAdmin"
|
||||
? ROUTE_SUPER_ADMIN_ROUTE_DEVICES_V2
|
||||
: getRoleFromUrl() === "AdminX"
|
||||
? ROUTE_ADMINX_ROUTE_DEVICES_V2
|
||||
: null
|
||||
}
|
||||
active={
|
||||
getRoleFromUrl() === "PosCompany"
|
||||
? pathname === ROUTE_PSP_COMPANY_ROUTE_DEVICES
|
||||
? pathname === ROUTE_PSP_COMPANY_ROUTE_DEVICES_V2
|
||||
: getRoleFromUrl() === "SuperAdmin"
|
||||
? pathname === ROUTE_SUPER_ADMIN_COMPANY_ROUTE_DEVICES
|
||||
? pathname === ROUTE_SUPER_ADMIN_ROUTE_DEVICES_V2
|
||||
: getRoleFromUrl() === "AdminX"
|
||||
? pathname === ROUTE_ADMINX_COMPANY_ROUTE_DEVICES
|
||||
? pathname === ROUTE_ADMINX_ROUTE_DEVICES_V2
|
||||
: null
|
||||
}
|
||||
>
|
||||
|
||||
@@ -36,12 +36,13 @@ export const SenfStock = () => {
|
||||
const selectedSubUser = useSelector(
|
||||
(state) => state.userSlice.selectedSubUser
|
||||
);
|
||||
useEffect(() => {
|
||||
|
||||
const handleRefreshServices = () => {
|
||||
dispatch(
|
||||
senfGetAllocationDashboardService({
|
||||
date1: selectedDate1,
|
||||
date2: selectedDate2,
|
||||
role_key: checkPathStartsWith("senf") ? selectedSubUser?.key : "",
|
||||
role_key: selectedSubUser?.key || "",
|
||||
search: text,
|
||||
})
|
||||
);
|
||||
@@ -49,17 +50,21 @@ export const SenfStock = () => {
|
||||
senfGetInventoryAllocatedService({
|
||||
date1: selectedDate1,
|
||||
date2: selectedDate2,
|
||||
role_key: checkPathStartsWith("senf") ? selectedSubUser?.key : "",
|
||||
role_key: selectedSubUser?.key || "",
|
||||
type: statusTab,
|
||||
search: text,
|
||||
})
|
||||
);
|
||||
dispatch(
|
||||
guildSalesInfoDashboardService({
|
||||
role_key: checkPathStartsWith("senf") ? selectedSubUser?.key : "",
|
||||
role_key: selectedSubUser?.key,
|
||||
})
|
||||
);
|
||||
}, [selectedDate1, selectedDate2, selectedSubUser?.key, statusTab, dispatch]);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
handleRefreshServices();
|
||||
}, [selectedDate1, selectedDate2, selectedSubUser?.key, statusTab]);
|
||||
|
||||
useEffect(() => {
|
||||
const items = senfGetInventoryAllocated?.results || [];
|
||||
@@ -93,19 +98,16 @@ export const SenfStock = () => {
|
||||
`${sellerRoleFa} ${sellerName} (${sellerMobile})`,
|
||||
formatJustDate(item.date),
|
||||
(item?.weightOfCarcasses || 0).toLocaleString() + " کیلوگرم",
|
||||
item?.quota === "free" ? "آزاد" : "دولتی",
|
||||
<Grid container direction="column" key={item.key}>
|
||||
{item?.receiverRealNumberOfCarcasses && (
|
||||
<>
|
||||
<Typography variant="caption">
|
||||
{item?.receiverRealNumberOfCarcasses?.toLocaleString() +
|
||||
" قطعه"}
|
||||
</Typography>
|
||||
<Typography variant="caption">
|
||||
{item?.receiverRealWeightOfCarcasses?.toLocaleString() +
|
||||
" کیلوگرم"}
|
||||
</Typography>
|
||||
</>
|
||||
)}
|
||||
{/* <Typography variant="caption">
|
||||
{item?.receiverRealNumberOfCarcasses?.toLocaleString() + " قطعه"}
|
||||
</Typography> */}
|
||||
<Typography variant="caption">
|
||||
{item?.receiverRealWeightOfCarcasses?.toLocaleString() +
|
||||
" کیلوگرم"}
|
||||
</Typography>
|
||||
|
||||
{/* {item?.receiverState === "pending" && (
|
||||
<Grid>
|
||||
<Button
|
||||
@@ -132,7 +134,12 @@ export const SenfStock = () => {
|
||||
dispatch(
|
||||
OPEN_MODAL({
|
||||
title: "ثبت تحویل بار",
|
||||
content: <GuildReceiveBarOperation item={item} />,
|
||||
content: (
|
||||
<GuildReceiveBarOperation
|
||||
item={item}
|
||||
onSuccess={handleRefreshServices}
|
||||
/>
|
||||
),
|
||||
})
|
||||
);
|
||||
}}
|
||||
@@ -208,7 +215,7 @@ export const SenfStock = () => {
|
||||
(
|
||||
guildSalesInfoDashboard?.totalFreeOutputWeight || 0
|
||||
).toLocaleString(),
|
||||
"0",
|
||||
guildSalesInfoDashboard?.segmentationsWeight || "0",
|
||||
"0",
|
||||
(
|
||||
guildSalesInfoDashboard?.totalGovernmentalRemainWeight || 0
|
||||
@@ -317,14 +324,16 @@ export const SenfStock = () => {
|
||||
"فروشنده",
|
||||
"تاریخ تخصیص",
|
||||
"وزن تخصیص",
|
||||
"تعداد/وزن واقعی تحویلی",
|
||||
"نوع فروش",
|
||||
"وزن واقعی تحویلی",
|
||||
]
|
||||
: [
|
||||
"ردیف",
|
||||
"فروشنده",
|
||||
"تاریخ تخصیص",
|
||||
"وزن تخصیص",
|
||||
"تعداد/وزن واقعی تحویلی",
|
||||
"نوع فروش",
|
||||
"وزن واقعی تحویلی",
|
||||
"عملیات",
|
||||
]
|
||||
}
|
||||
|
||||
@@ -504,6 +504,7 @@ export const SlaughterManageDispensersForm = ({
|
||||
city: values.city || currentUserInfo?.city || "",
|
||||
mobile: values.mobile,
|
||||
role: getRoleFromUrl(),
|
||||
role_key: selectedSubUser?.key || "",
|
||||
};
|
||||
|
||||
if (dispenser?.key) {
|
||||
|
||||
@@ -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 || []);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -24,7 +24,6 @@ import { StewardStock } from "../features/steward/components/steward-stock/Stewa
|
||||
import { StewardPurchaseOutProvince } from "../features/steward/components/steward-purchase-out-province/StewardPurchaseOutProvince";
|
||||
import { StewardSellOutOfProvince } from "../features/steward/components/steward-sell-out-of-province/StewardSellOutOfProvince";
|
||||
import { StewardSellInProvince } from "../features/steward/components/steward-sell-in-province/StewardSellInProvince";
|
||||
import { checkPathStartsWith } from "../utils/checkPathStartsWith";
|
||||
|
||||
const StewardInventoryPage = () => {
|
||||
const { pathname } = useLocation();
|
||||
@@ -44,11 +43,11 @@ const StewardInventoryPage = () => {
|
||||
) {
|
||||
dispatch(
|
||||
fetchStewardBroadcastAndProducts({
|
||||
role_key: checkPathStartsWith("steward") ? selectedSubUser?.key : "",
|
||||
role_key: selectedSubUser?.key || "",
|
||||
})
|
||||
);
|
||||
}
|
||||
}, [dispatch, pathname, selectedSubUser?.key]);
|
||||
}, [pathname, selectedSubUser?.key]);
|
||||
|
||||
return (
|
||||
<>
|
||||
|
||||
@@ -188,6 +188,12 @@ const ManageStewards = lazy(() =>
|
||||
lazyRetry(() => import("../pages/ProvinceManageStewards"))
|
||||
);
|
||||
|
||||
const PspDevicesV2 = lazy(() =>
|
||||
lazyRetry(() =>
|
||||
import("../features/psp-company/components/psp-devices-v2/PspDevicesV2")
|
||||
)
|
||||
);
|
||||
|
||||
const consolidatedRouting = [
|
||||
{
|
||||
path: [ROUTES.ROUTE_ADMINX_BASE_NEW_HOME],
|
||||
@@ -981,6 +987,15 @@ const consolidatedRouting = [
|
||||
exact: false,
|
||||
props: {},
|
||||
},
|
||||
{
|
||||
path: [
|
||||
ROUTES.ROUTE_SUPER_ADMIN_ROUTE_DEVICES_V2,
|
||||
ROUTES.ROUTE_ADMINX_ROUTE_DEVICES_V2,
|
||||
],
|
||||
Page: PspDevicesV2,
|
||||
exact: false,
|
||||
props: {},
|
||||
},
|
||||
{
|
||||
path: [
|
||||
ROUTES.ROUTE_ADMINX_POULTRIES_DETAILS,
|
||||
|
||||
@@ -1365,7 +1365,8 @@ export const ROUTE_SUPER_ADMIN_COMPANY_ROUTE_ACTIVE_SESSION =
|
||||
ROUTE_SUPER_ADMIN_BASE + "/active-session/session";
|
||||
export const ROUTE_SUPER_ADMIN_COMPANY_ROUTE_DEVICES =
|
||||
ROUTE_SUPER_ADMIN_BASE + "/devices";
|
||||
|
||||
export const ROUTE_SUPER_ADMIN_ROUTE_DEVICES_V2 =
|
||||
ROUTE_SUPER_ADMIN_BASE + "/devices-v2";
|
||||
export const ROUTE_SUPER_ADMIN_ROUTE_INSPECTION =
|
||||
ROUTE_SUPER_ADMIN_BASE + "/inspection";
|
||||
|
||||
@@ -1687,7 +1688,7 @@ export const ROUTE_ADMINX_COMPANY_ROUTE_ACTIVE_SESSION =
|
||||
ROUTE_ADMINX_BASE + "/active-session/session";
|
||||
export const ROUTE_ADMINX_COMPANY_ROUTE_DEVICES =
|
||||
ROUTE_ADMINX_BASE + "/devices";
|
||||
|
||||
export const ROUTE_ADMINX_ROUTE_DEVICES_V2 = ROUTE_ADMINX_BASE + "/devices-v2";
|
||||
export const ROUTE_ADMINX_ROUTE_INSPECTION = ROUTE_ADMINX_BASE + "/inspection";
|
||||
|
||||
// Supporter
|
||||
|
||||
Reference in New Issue
Block a user