diff --git a/src/features/slaughter-house/components/slaughter-inventory-free-buy-bars-alives/SlaughterInventoryFreeBuyBarsAlives.js b/src/features/slaughter-house/components/slaughter-inventory-free-buy-bars-alives/SlaughterInventoryFreeBuyBarsAlives.js index a5319d5..74b520a 100644 --- a/src/features/slaughter-house/components/slaughter-inventory-free-buy-bars-alives/SlaughterInventoryFreeBuyBarsAlives.js +++ b/src/features/slaughter-house/components/slaughter-inventory-free-buy-bars-alives/SlaughterInventoryFreeBuyBarsAlives.js @@ -8,7 +8,7 @@ import ResponsiveTable from "../../../../components/responsive-table/ResponsiveT import { LOADING_END, LOADING_START, - OPEN_MODAL, + OPEN_MODAL } from "../../../../lib/redux/slices/appSlice"; import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl"; import { formatJustDate } from "../../../../utils/formatTime"; @@ -26,10 +26,11 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({ title, barState, handleUpdate, + refreshTrigger, withDate, selectedDate1, selectedDate2, - searchValue, + searchValue }) => { const dispatch = useDispatch(); const [openNotif] = useContext(AppContext); @@ -42,7 +43,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({ slaughterGetProfile({ role_key: checkPathStartsWith("slaughter") ? selectedSubUser?.key || "" - : "", + : "" }) ); }, [selectedSubUser?.key]); @@ -92,7 +93,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({ fetchSlaughterBroadcastAndProducts({ role_key: checkPathStartsWith("slaughter") ? selectedSubUser?.key || "" - : "", + : "" }) ); }; @@ -105,9 +106,16 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({ selectedDate1, selectedDate2, searchValue, - selectedSubUser?.key, + selectedSubUser?.key ]); + useEffect(() => { + if (refreshTrigger != null && refreshTrigger > 0) { + setPage(1); + fetchApiData(1); + } + }, [refreshTrigger]); + useEffect(() => { const d = data?.map((item, i) => { return [ @@ -153,7 +161,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({ item={item} updateTable={updateTable} /> - ), + ) }) ); }} @@ -161,7 +169,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({ تایید / رد )} - , + ]; }); @@ -190,7 +198,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({ vertical: "top", horizontal: "center", msg: "فایل اکسل در حال دانلود می باشد، این علمیات ممکن است زمان بر باشد لطفا صبر کنید.", - severity: "success", + severity: "success" }); const link = `${ axios.defaults.baseURL @@ -230,7 +238,7 @@ export const SlaughterInventoryFreeBuyBarsAlives = ({ "وزن لاشه (کیلوگرم)", "درصد افت", "بارنامه", - "عملیات", + "عملیات" ]} handlePageChange={handlePageChange} totalRows={totalRows} diff --git a/src/features/slaughter-house/components/slaughter-inventory-free-buy-bars/SlaughterInventoryFreeBuyBars.js b/src/features/slaughter-house/components/slaughter-inventory-free-buy-bars/SlaughterInventoryFreeBuyBars.js index f296568..880b502 100644 --- a/src/features/slaughter-house/components/slaughter-inventory-free-buy-bars/SlaughterInventoryFreeBuyBars.js +++ b/src/features/slaughter-house/components/slaughter-inventory-free-buy-bars/SlaughterInventoryFreeBuyBars.js @@ -11,7 +11,7 @@ import { DRAWER, LOADING_END, LOADING_START, - OPEN_MODAL, + OPEN_MODAL } from "../../../../lib/redux/slices/appSlice"; import { getRoleFromUrl } from "../../../../utils/getRoleFromUrl"; import { AppContext } from "../../../../contexts/AppContext"; @@ -57,7 +57,7 @@ export const SlaughterInventoryFreeBuyBars = () => { slaughterGetProfile({ role_key: checkPathStartsWith("slaughter") ? selectedSubUser?.key || "" - : "", + : "" }) ); }, [selectedSubUser?.key, dispatch]); @@ -70,6 +70,7 @@ export const SlaughterInventoryFreeBuyBars = () => { const [tableData, setTableData] = useState([]); const [withDate, setWithDate] = useState(false); const [searchValue, setSearchValue] = useState(""); + const [aliveTablesRefreshTrigger, setAliveTablesRefreshTrigger] = useState(0); const fetchApiData = async (page) => { dispatch(LOADING_START()); @@ -103,11 +104,12 @@ export const SlaughterInventoryFreeBuyBars = () => { setPage(1); fetchApiData(1); fetchDashboardData(); + setAliveTablesRefreshTrigger((prev) => prev + 1); dispatch( fetchSlaughterBroadcastAndProducts({ role_key: checkPathStartsWith("slaughter") ? selectedSubUser?.key || "" - : "", + : "" }) ); }; @@ -124,8 +126,8 @@ export const SlaughterInventoryFreeBuyBars = () => { type: activeTab === 0 ? "live" : "carcass", ...(withDate && { date1: selectedDate1, - date2: selectedDate2, - }), + date2: selectedDate2 + }) }) ).then((r) => { setDashboardData(r.payload.data); @@ -142,7 +144,7 @@ export const SlaughterInventoryFreeBuyBars = () => { perPage, activeTab, searchValue, - selectedSubUser?.key, + selectedSubUser?.key ]); useEffect(() => { @@ -185,7 +187,7 @@ export const SlaughterInventoryFreeBuyBars = () => { item={item} updateTable={updateTable} /> - ), + ) }) ); }} @@ -193,7 +195,7 @@ export const SlaughterInventoryFreeBuyBars = () => { تایید / رد )} - , + ]; }); @@ -240,7 +242,7 @@ export const SlaughterInventoryFreeBuyBars = () => { padding: "5px", borderRadius: "15px", borderColor: "gray", - justifyContent: "left", + justifyContent: "left" }} alignItems="center" > @@ -342,7 +344,7 @@ export const SlaughterInventoryFreeBuyBars = () => { selectedDate={selectedDate1} updateTable={updateTable} /> - ), + ) }) ); }} @@ -365,7 +367,7 @@ export const SlaughterInventoryFreeBuyBars = () => { "وزن لاشه بارهای وارد شده به انبار", "تعداد کل بارها وارد نشده به انبار", "حجم کل بارهای زنده وارد نشده به انبار", - "وزن کل بارهای زنده وارد نشده به انبار", + "وزن کل بارهای زنده وارد نشده به انبار" ]} data={[ [ @@ -378,14 +380,14 @@ export const SlaughterInventoryFreeBuyBars = () => { dashboardData?.enteredTotalBarsWeightOfCarcasses?.toLocaleString(), dashboardData?.notEnteredTotalBars?.toLocaleString(), dashboardData?.notEnteredTotalBarsQuantity?.toLocaleString(), - dashboardData?.notEnteredTotalBarsLiveWeight?.toLocaleString(), - ], + dashboardData?.notEnteredTotalBarsLiveWeight?.toLocaleString() + ] ]} customColors={[ { name: "وزن لاشه بارهای وارد شده به انبار", - color: "green", - }, + color: "green" + } ]} title={"خلاصه اطلاعات"} /> @@ -398,8 +400,8 @@ export const SlaughterInventoryFreeBuyBars = () => { [ dashboardData?.totalBars?.toLocaleString(), dashboardData?.totalBarsNumberOfCarcasses?.toLocaleString(), - dashboardData?.totalBarsWeightOfCarcasses?.toLocaleString(), - ], + dashboardData?.totalBarsWeightOfCarcasses?.toLocaleString() + ] ]} title={"خلاصه اطلاعات"} /> @@ -412,6 +414,7 @@ export const SlaughterInventoryFreeBuyBars = () => { title={"بار زنده در انتظار ورود به انبار (خارج استان)"} barState={"notentered"} handleUpdate={updateTable} + refreshTrigger={aliveTablesRefreshTrigger} searchValue={searchValue} withDate={withDate} selectedDate1={selectedDate1} @@ -422,6 +425,7 @@ export const SlaughterInventoryFreeBuyBars = () => { title={"بار زنده وارد شده به انبار (خارج استان)"} barState={"entered"} handleUpdate={updateTable} + refreshTrigger={aliveTablesRefreshTrigger} searchValue={searchValue} withDate={withDate} selectedDate1={selectedDate1} @@ -516,7 +520,7 @@ export const SlaughterInventoryFreeBuyBars = () => { "حجم لاشه", "وزن لاشه (کیلوگرم)", "بارنامه", - "عملیات", + "عملیات" ]} handlePageChange={handlePageChange} totalRows={totalRows}