fix: dispatch for trade panel

This commit is contained in:
2026-02-01 16:55:52 +03:30
parent 19dbdd14a0
commit f041beb869
2 changed files with 20 additions and 3 deletions

View File

@@ -28,6 +28,7 @@ export const ProvinceTradePanel = () => {
userKey,
fetchApiData,
initializeData,
refreshAllData,
} = useTradePanelData();
const {
@@ -91,9 +92,8 @@ export const ProvinceTradePanel = () => {
};
const updateAllTables = () => {
// Update "لیست اعلام کشتار های مرغداران" (tab 0)
updateTable();
// Update "خریدهای ثبت شده" (tab 1) - call all services for ProvinceTradePanelMarketRequest
setPage(1);
refreshAllData(textValue, filters, perPage);
if (
marketRequestUpdateRef.current &&
typeof marketRequestUpdateRef.current === "function"

View File

@@ -154,6 +154,22 @@ export const useTradePanelData = () => {
lastRequestPayload.current = null;
}, []);
const refreshAllData = useCallback(
async (textValue, filters, perPage) => {
lastRequestPayload.current = null;
try {
await Promise.all([
fetchTradeTimeRange(),
fetchChartData(),
fetchApiData(1, textValue, filters, perPage, true),
]);
} catch (error) {
console.error("Error refreshing trade panel data:", error);
}
},
[fetchTradeTimeRange, fetchChartData, fetchApiData]
);
return {
range,
chartsData,
@@ -165,5 +181,6 @@ export const useTradePanelData = () => {
fetchApiData,
initializeData,
resetPayload,
refreshAllData,
};
};