Add improved production UI

This commit is contained in:
Urtzi Alfaro
2025-09-23 12:49:35 +02:00
parent 8d54202e91
commit 4ae8e14e55
35 changed files with 6848 additions and 415 deletions

View File

@@ -88,7 +88,9 @@ export const useActiveBatches = (
) => {
return useQuery<ProductionBatchListResponse, ApiError>({
queryKey: productionKeys.activeBatches(tenantId),
queryFn: () => productionService.getActiveBatches(tenantId),
queryFn: () => productionService.getBatches(tenantId, {
status: undefined // Get all active statuses
}),
enabled: !!tenantId,
staleTime: 30 * 1000, // 30 seconds
refetchInterval: 60 * 1000, // 1 minute
@@ -103,7 +105,7 @@ export const useBatchDetails = (
) => {
return useQuery<ProductionBatchResponse, ApiError>({
queryKey: productionKeys.batch(tenantId, batchId),
queryFn: () => productionService.getBatchDetails(tenantId, batchId),
queryFn: () => productionService.getBatch(tenantId, batchId),
enabled: !!tenantId && !!batchId,
staleTime: 30 * 1000, // 30 seconds
...options,
@@ -160,9 +162,9 @@ export const useCreateProductionBatch = (
options?: UseMutationOptions<ProductionBatchResponse, ApiError, { tenantId: string; batchData: ProductionBatchCreate }>
) => {
const queryClient = useQueryClient();
return useMutation<ProductionBatchResponse, ApiError, { tenantId: string; batchData: ProductionBatchCreate }>({
mutationFn: ({ tenantId, batchData }) => productionService.createProductionBatch(tenantId, batchData),
mutationFn: ({ tenantId, batchData }) => productionService.createBatch(tenantId, batchData),
onSuccess: (data, { tenantId }) => {
// Invalidate active batches to refresh the list
queryClient.invalidateQueries({ queryKey: productionKeys.activeBatches(tenantId) });
@@ -189,7 +191,7 @@ export const useUpdateBatchStatus = (
ApiError,
{ tenantId: string; batchId: string; statusUpdate: ProductionBatchStatusUpdate }
>({
mutationFn: ({ tenantId, batchId, statusUpdate }) =>
mutationFn: ({ tenantId, batchId, statusUpdate }) =>
productionService.updateBatchStatus(tenantId, batchId, statusUpdate),
onSuccess: (data, { tenantId, batchId }) => {
// Update the specific batch data