Add improved production UI
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user