Update analytics-service.ts
This commit is contained in:
@@ -424,6 +424,23 @@ export interface PredictionsOverview {
|
|||||||
message?: string;
|
message?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface BatchPredictionsResponse {
|
||||||
|
success: boolean;
|
||||||
|
storeId?: string;
|
||||||
|
historicalPeriod?: number;
|
||||||
|
horizons?: number[];
|
||||||
|
simulationFactors?: number[];
|
||||||
|
predictions?: {
|
||||||
|
[horizon: string]: {
|
||||||
|
[simulationFactor: string]: PredictionsOverview;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
totalEntries?: number;
|
||||||
|
generatedAt?: string;
|
||||||
|
message?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Prediction Service Functions
|
// Prediction Service Functions
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -546,3 +563,28 @@ export const getPredictionsOverviewWithStore = async (
|
|||||||
const storeId = getStoreIdForUser();
|
const storeId = getStoreIdForUser();
|
||||||
return getPredictionsOverview(daysAhead, period, storeId, simulation);
|
return getPredictionsOverview(daysAhead, period, storeId, simulation);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get all cached predictions in one request (for client-side switching)
|
||||||
|
* @param period Historical period in days (default: 90)
|
||||||
|
* @param storeId Optional storeId for staff users
|
||||||
|
*/
|
||||||
|
export const getBatchPredictions = async (
|
||||||
|
period: number = 90,
|
||||||
|
storeId?: string,
|
||||||
|
): Promise<BatchPredictionsResponse> => {
|
||||||
|
const params = new URLSearchParams({
|
||||||
|
period: period.toString(),
|
||||||
|
});
|
||||||
|
if (storeId) params.append("storeId", storeId);
|
||||||
|
|
||||||
|
const url = `/analytics/predictions/batch?${params.toString()}`;
|
||||||
|
return clientFetch<BatchPredictionsResponse>(url);
|
||||||
|
};
|
||||||
|
|
||||||
|
export const getBatchPredictionsWithStore = async (
|
||||||
|
period: number = 90,
|
||||||
|
): Promise<BatchPredictionsResponse> => {
|
||||||
|
const storeId = getStoreIdForUser();
|
||||||
|
return getBatchPredictions(period, storeId);
|
||||||
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user