Add a new analitycs page for production
This commit is contained in:
@@ -56,11 +56,11 @@ export const useProductionDashboard = (
|
||||
export const useDailyProductionRequirements = (
|
||||
tenantId: string,
|
||||
date?: string,
|
||||
options?: Omit<UseQueryOptions<DailyProductionRequirements, ApiError>, 'queryKey' | 'queryFn'>
|
||||
options?: Omit<UseQueryOptions<any, ApiError>, 'queryKey' | 'queryFn'>
|
||||
) => {
|
||||
return useQuery<DailyProductionRequirements, ApiError>({
|
||||
return useQuery<any, ApiError>({
|
||||
queryKey: productionKeys.dailyRequirements(tenantId, date),
|
||||
queryFn: () => productionService.getDailyRequirements(tenantId, date),
|
||||
queryFn: () => productionService.getDailyProductionPlan(tenantId, date),
|
||||
enabled: !!tenantId,
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||
...options,
|
||||
@@ -70,11 +70,13 @@ export const useDailyProductionRequirements = (
|
||||
export const useProductionRequirements = (
|
||||
tenantId: string,
|
||||
date?: string,
|
||||
options?: Omit<UseQueryOptions<ProductionRequirements, ApiError>, 'queryKey' | 'queryFn'>
|
||||
options?: Omit<UseQueryOptions<any, ApiError>, 'queryKey' | 'queryFn'>
|
||||
) => {
|
||||
return useQuery<ProductionRequirements, ApiError>({
|
||||
const queryDate = date || new Date().toISOString().split('T')[0];
|
||||
|
||||
return useQuery<any, ApiError>({
|
||||
queryKey: productionKeys.requirements(tenantId, date),
|
||||
queryFn: () => productionService.getProductionRequirements(tenantId, date),
|
||||
queryFn: () => productionService.getProductionRequirements(tenantId, queryDate),
|
||||
enabled: !!tenantId,
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||
...options,
|
||||
@@ -117,11 +119,11 @@ export const useProductionSchedule = (
|
||||
tenantId: string,
|
||||
startDate?: string,
|
||||
endDate?: string,
|
||||
options?: Omit<UseQueryOptions<ProductionScheduleData, ApiError>, 'queryKey' | 'queryFn'>
|
||||
options?: Omit<UseQueryOptions<any, ApiError>, 'queryKey' | 'queryFn'>
|
||||
) => {
|
||||
return useQuery<ProductionScheduleData, ApiError>({
|
||||
return useQuery<any, ApiError>({
|
||||
queryKey: productionKeys.schedule(tenantId, startDate, endDate),
|
||||
queryFn: () => productionService.getProductionSchedule(tenantId, startDate, endDate),
|
||||
queryFn: () => productionService.getSchedules(tenantId, { start_date: startDate, end_date: endDate }),
|
||||
enabled: !!tenantId,
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||
...options,
|
||||
@@ -131,11 +133,11 @@ export const useProductionSchedule = (
|
||||
export const useCapacityStatus = (
|
||||
tenantId: string,
|
||||
date?: string,
|
||||
options?: Omit<UseQueryOptions<ProductionCapacityStatus, ApiError>, 'queryKey' | 'queryFn'>
|
||||
options?: Omit<UseQueryOptions<any, ApiError>, 'queryKey' | 'queryFn'>
|
||||
) => {
|
||||
return useQuery<ProductionCapacityStatus, ApiError>({
|
||||
return useQuery<any, ApiError>({
|
||||
queryKey: productionKeys.capacity(tenantId, date),
|
||||
queryFn: () => productionService.getCapacityStatus(tenantId, date),
|
||||
queryFn: () => date ? productionService.getCapacityByDate(tenantId, date) : productionService.getCapacity(tenantId),
|
||||
enabled: !!tenantId,
|
||||
staleTime: 5 * 60 * 1000, // 5 minutes
|
||||
...options,
|
||||
@@ -146,11 +148,11 @@ export const useYieldMetrics = (
|
||||
tenantId: string,
|
||||
startDate: string,
|
||||
endDate: string,
|
||||
options?: Omit<UseQueryOptions<ProductionYieldMetrics, ApiError>, 'queryKey' | 'queryFn'>
|
||||
options?: Omit<UseQueryOptions<any, ApiError>, 'queryKey' | 'queryFn'>
|
||||
) => {
|
||||
return useQuery<ProductionYieldMetrics, ApiError>({
|
||||
return useQuery<any, ApiError>({
|
||||
queryKey: productionKeys.yieldMetrics(tenantId, startDate, endDate),
|
||||
queryFn: () => productionService.getYieldMetrics(tenantId, startDate, endDate),
|
||||
queryFn: () => productionService.getYieldTrends(tenantId, startDate, endDate),
|
||||
enabled: !!tenantId && !!startDate && !!endDate,
|
||||
staleTime: 15 * 60 * 1000, // 15 minutes (metrics are less frequently changing)
|
||||
...options,
|
||||
|
||||
Reference in New Issue
Block a user