mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 14:38:12 +00:00
pERTRUCK EXIT
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
import { Alert, Badge, Button, Group, Loader, Modal, MultiSelect, Stack, Text } from '@mantine/core';
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
||||
import { Truck } from 'lucide-react';
|
||||
import { FileText, Truck } from 'lucide-react';
|
||||
import { useState } from 'react';
|
||||
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
import { warehouseService } from '@/services/warehouse.service';
|
||||
import { extractErrorMessage } from './options';
|
||||
import { openPdfBlob } from './pdf';
|
||||
|
||||
interface TruckDispatchModalProps {
|
||||
opened: boolean;
|
||||
@@ -50,6 +51,15 @@ export function TruckDispatchModal({ opened, onClose, bookingId, bookingReferenc
|
||||
onError: (e) => toast({ variant: 'destructive', title: 'Load failed', description: extractErrorMessage(e) }),
|
||||
});
|
||||
|
||||
const openTruckExitPaper = async (assignmentId: string, plate: string) => {
|
||||
try {
|
||||
const res = await warehouseService.downloadTruckExitPaper(assignmentId);
|
||||
openPdfBlob(res.data, `exit-${plate}.pdf`);
|
||||
} catch (e) {
|
||||
toast({ variant: 'destructive', title: 'Exit paper not ready', description: extractErrorMessage(e) });
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<Modal
|
||||
opened={opened}
|
||||
@@ -102,7 +112,16 @@ export function TruckDispatchModal({ opened, onClose, bookingId, bookingReferenc
|
||||
disabled={departed || !t.arrivedAt}
|
||||
nothingFoundMessage="No loadable containers"
|
||||
/>
|
||||
<Group justify="flex-end">
|
||||
<Group justify="flex-end" gap="xs">
|
||||
<Button
|
||||
size="xs"
|
||||
variant="light"
|
||||
color="orange"
|
||||
leftSection={<FileText size={14} />}
|
||||
onClick={() => openTruckExitPaper(t.id, t.plateNumber)}
|
||||
>
|
||||
Exit Paper
|
||||
</Button>
|
||||
<Button
|
||||
size="xs"
|
||||
color="edr-green"
|
||||
|
||||
Reference in New Issue
Block a user