Fix new services implementation 5
This commit is contained in:
@@ -31,7 +31,7 @@ export const useForecast = () => {
|
||||
setError(null);
|
||||
|
||||
const newForecasts = await forecastingService.createSingleForecast(tenantId, request);
|
||||
setForecasts(prev => [...newForecasts, ...prev]);
|
||||
setForecasts(prev => [...newForecasts, ...(prev || [])]);
|
||||
|
||||
return newForecasts;
|
||||
} catch (error) {
|
||||
@@ -52,7 +52,7 @@ export const useForecast = () => {
|
||||
setError(null);
|
||||
|
||||
const batchForecast = await forecastingService.createBatchForecast(tenantId, request);
|
||||
setBatchForecasts(prev => [batchForecast, ...prev]);
|
||||
setBatchForecasts(prev => [batchForecast, ...(prev || [])]);
|
||||
|
||||
return batchForecast;
|
||||
} catch (error) {
|
||||
@@ -90,7 +90,7 @@ export const useForecast = () => {
|
||||
const batchForecast = await forecastingService.getBatchForecastStatus(tenantId, batchId);
|
||||
|
||||
// Update batch forecast in state
|
||||
setBatchForecasts(prev => prev.map(bf =>
|
||||
setBatchForecasts(prev => (prev || []).map(bf =>
|
||||
bf.id === batchId ? batchForecast : bf
|
||||
));
|
||||
|
||||
@@ -147,7 +147,7 @@ export const useForecast = () => {
|
||||
setError(null);
|
||||
|
||||
const acknowledgedAlert = await forecastingService.acknowledgeForecastAlert(tenantId, alertId);
|
||||
setAlerts(prev => prev.map(alert =>
|
||||
setAlerts(prev => (prev || []).map(alert =>
|
||||
alert.id === alertId ? acknowledgedAlert : alert
|
||||
));
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user