diff --git a/src/features/province/components/province-trade-panel/ProvinceTradePanel.js b/src/features/province/components/province-trade-panel/ProvinceTradePanel.js index cde2996..dd12c7d 100644 --- a/src/features/province/components/province-trade-panel/ProvinceTradePanel.js +++ b/src/features/province/components/province-trade-panel/ProvinceTradePanel.js @@ -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" diff --git a/src/features/province/components/province-trade-panel/useTradePanelData.js b/src/features/province/components/province-trade-panel/useTradePanelData.js index 441d7a8..3a545d8 100644 --- a/src/features/province/components/province-trade-panel/useTradePanelData.js +++ b/src/features/province/components/province-trade-panel/useTradePanelData.js @@ -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, }; };