some changes

This commit is contained in:
2026-01-19 15:18:50 +03:30
parent 4fe6e70525
commit 5b251732a9
12 changed files with 275 additions and 46 deletions

View File

@@ -181,6 +181,7 @@ export const SlaughterFreeBuy = () => {
item?.createDate ? formatTime(item?.createDate) : "-",
item?.reciveDate ? formatJustDate(item?.reciveDate) : "-",
`${item.killHouse.name} (${item.killHouse.killHouseOperator.user.mobile})`,
item?.freezing ? "انجماد" : "عادی",
item?.freeDirectBuying ? "آزاد" : "دولتی",
item?.slaughterHouse
? item?.slaughterHouse?.name
@@ -192,7 +193,6 @@ export const SlaughterFreeBuy = () => {
item.IndexWeight,
(item.IndexWeight * item.killCapacity)?.toLocaleString(),
item?.amount?.toLocaleString(),
<Grid key={i}>
{item?.directBuyingState === "pending" &&
item?.finalAccept === true &&
@@ -380,6 +380,7 @@ export const SlaughterFreeBuy = () => {
"تاریخ ثبت درخواست",
"تاریخ کشتار",
"خریدار",
"کشتار",
"نوع خرید",
"محل کشتار",
"مرغدار (تلفن)",

View File

@@ -20,6 +20,7 @@ import { CheckCleanceCode } from "../../../../components/check-clearance-code/Ch
import { SlaughterFreeBarsAlivesOperations } from "../slaughter-free-bars-alives-operations/SlaughterFreeBarsAlivesOperations";
import { AppContext } from "../../../../contexts/AppContext";
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
import { fetchSlaughterBroadcastAndProducts } from "../../services/handle-fetch-slaughter-products";
export const SlaughterInventoryFreeBuyBarsAlives = ({
title,
@@ -87,6 +88,13 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({
const updateTable = () => {
fetchApiData(page !== 0 ? page : 1);
fetchDashboardData();
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: checkPathStartsWith("slaughter")
? selectedSubUser?.key || ""
: "",
})
);
};
useEffect(() => {

View File

@@ -27,6 +27,7 @@ import ToggleOffOutlinedIcon from "@mui/icons-material/ToggleOffOutlined";
import ToggleOnIcon from "@mui/icons-material/ToggleOn";
import { SlaughterInventoryFreeBuyBarsAlives } from "../slaughter-inventory-free-buy-bars-alives/SlaughterInventoryFreeBuyBarsAlives";
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
import { fetchSlaughterBroadcastAndProducts } from "../../services/handle-fetch-slaughter-products";
export const SlaughterInventoryFreeBuyBars = () => {
const dispatch = useDispatch();
@@ -102,6 +103,13 @@ export const SlaughterInventoryFreeBuyBars = () => {
setPage(1);
fetchApiData(1);
fetchDashboardData();
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: checkPathStartsWith("slaughter")
? selectedSubUser?.key || ""
: "",
})
);
};
const fetchDashboardData = () => {

View File

@@ -450,6 +450,13 @@ export const SlaughterSubmitFreeBar = ({ item, updateTable }) => {
} else {
if (updateTable) {
updateTable();
// dispatch(
// fetchSlaughterBroadcastAndProducts({
// role_key: checkPathStartsWith("slaughter")
// ? selectedSubUser?.key
// : "",
// })
// );
}
dispatch(DRAWER({ right: false, bottom: false, content: null }));
openNotif({

View File

@@ -39,6 +39,7 @@ import FilterAltIcon from "@mui/icons-material/FilterAlt";
import { provincePolicyGetWeightRange } from "../../../province/services/province-policy-get-weight-range";
import { isValidIndexWeight } from "../../../../utils/isValidIndexWeight";
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
import { provinceGetSellForFreezingStatus } from "../../../province/services/province-get-sell-for-freezing-status";
export const SlaughterSubmitFreeBuy = ({ edit, updateTable }) => {
const dispatch = useDispatch();
@@ -48,6 +49,7 @@ export const SlaughterSubmitFreeBuy = ({ edit, updateTable }) => {
const [selectedAge2, setSelectedAge2] = useState(1);
const [showSearchFields, setShowSearchFields] = useState(false);
const [editPoultry, setEditPoultry] = useState(false);
const [sellForFreezing, setSellForFreezing] = useState(false);
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
@@ -110,6 +112,9 @@ export const SlaughterSubmitFreeBuy = ({ edit, updateTable }) => {
: "",
})
);
dispatch(provinceGetSellForFreezingStatus()).then((r) => {
setSellForFreezing(r.payload.data.permission);
});
fetchData();
}, [selectedSubUser?.key]);
@@ -130,6 +135,7 @@ export const SlaughterSubmitFreeBuy = ({ edit, updateTable }) => {
poultryPrice: edit ? edit.amount : 0,
hatching_key: edit?.poultryHatching?.key || null,
paymentDeadlineDays: edit?.paymentDeadlineDays?.key,
freezing: false,
};
const onSubmit = (values) => {
if (!paymentDeadlineDays && values.paymentDeadlineDays === 0) {
@@ -165,6 +171,7 @@ export const SlaughterSubmitFreeBuy = ({ edit, updateTable }) => {
chicken_breed: selectedPolutry?.chickenBreed,
cash: true,
credit: false,
freezing: values.freezing,
sms_payment: false,
kill_house_key: values.killhouse,
killer_kill_house_key: values.killerPlace ? values.killerPlace : null,
@@ -1049,6 +1056,15 @@ export const SlaughterSubmitFreeBuy = ({ edit, updateTable }) => {
/>
</Grid>
)}
{sellForFreezing && (
<Typography variant="body2">
<Checkbox
id="freezing"
onChange={formik.handleChange}
/>
انجماد
</Typography>
)}
{!edit && (
<Button

View File

@@ -13,17 +13,20 @@ import {
} from "@mui/material";
import { CLOSE_MODAL, OPEN_MODAL } from "../../../../lib/redux/slices/appSlice";
import { SPACING } from "../../../../data/spacing";
import { useDispatch } from "react-redux";
import { useDispatch, useSelector } from "react-redux";
import { killhouseSubmitRealInventoryService } from "../../services/killhouse-submit-real-inventory";
import { AppContext } from "../../../../contexts/AppContext";
import { provincePolicyGetDropLimitService } from "../../../province/services/province-policy-drop-limit";
import { fetchSlaughterBroadcastAndProducts } from "../../services/handle-fetch-slaughter-products";
import { checkPathStartsWith } from "../../../../utils/checkPathStartsWith";
export const SlaughterSubmitRealInventory = ({ item, updateTable }) => {
const [value, setValue] = useState("weight");
const [loss, setLoss] = useState("0");
const [dropLimits, setDropLimits] = useState({ min: 0, max: 100 });
const selectedSubUser = useSelector(
(state) => state.userSlice.selectedSubUser
);
const handleChange = (event) => {
setValue(event.target.value);
};
@@ -159,7 +162,13 @@ export const SlaughterSubmitRealInventory = ({ item, updateTable }) => {
} else {
dispatch(CLOSE_MODAL());
updateTable();
dispatch(fetchSlaughterBroadcastAndProducts());
dispatch(
fetchSlaughterBroadcastAndProducts({
role_key: checkPathStartsWith("slaughter")
? selectedSubUser?.key
: "",
})
);
handleAlert();
}
});

View File

@@ -6,37 +6,36 @@ import axios from "axios";
export const fetchSlaughterBroadcastAndProducts = createAsyncThunk(
"SLAUGHTER_FETCH_BROADCAST_AND_PRODUCTS",
async (d, { dispatch }) => {
dispatch(LOADING_START());
try {
dispatch(LOADING_START());
const endpointPart =
getRoleFromUrl() === "KillHouse" ? "kill-house" : "steward";
const role = getRoleFromUrl();
const [broadcastResponse, productsResponse] = await Promise.all([
axios.get(
`${
getRoleFromUrl() === "KillHouse" ? "kill-house" : "steward"
}-sales-info-dashboard/`,
{
params: {
role: getRoleFromUrl(),
...d,
},
}
),
axios.get(`${endpointPart}-sales-info-dashboard/`, {
params: {
role: role,
...d,
},
}),
axios.get("roles-products", {
params: {
role: getRoleFromUrl(),
role: role,
role_key: d.role_key || "",
},
}),
]);
dispatch(LOADING_END());
return {
broadcastData: broadcastResponse.data,
productsData: productsResponse.data,
};
} catch (error) {
dispatch(LOADING_END());
console.error("Data fetching failed:", error);
throw error;
} finally {
dispatch(LOADING_END());
}
}
);