fix build
This commit is contained in:
@@ -6,13 +6,21 @@ import { useRouter } from 'next/dist/client/components/navigation';
|
||||
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuSeparator, DropdownMenuTrigger } from '@/shared/components/ui/dropdown-menu'
|
||||
import { Button } from '@/shared/components/ui/button'
|
||||
import { toast } from 'sonner'
|
||||
import { Ellipsis, Pencil, Trash2 } from 'lucide-react';
|
||||
import { Ellipsis, Pencil, Printer, Trash2 } from 'lucide-react';
|
||||
import { useDocumentPrint } from '@/shared/hooks/use-document-print';
|
||||
|
||||
export default function JobCardDropdown({ id }: { id: string }) {
|
||||
const router = useRouter();
|
||||
const { print, isPrinting } = useDocumentPrint()
|
||||
|
||||
const handleEdit = () => {
|
||||
router.push(`/sales/job-cards/${id}/edit`)
|
||||
}
|
||||
|
||||
const handlePrint = () => {
|
||||
print("job_card", id, "print")
|
||||
}
|
||||
|
||||
const handleDelete = async () => {
|
||||
const confirmed = await confirm({
|
||||
title: "Delete Job Card",
|
||||
@@ -45,6 +53,10 @@ export default function JobCardDropdown({ id }: { id: string }) {
|
||||
<Pencil className="size-4" />
|
||||
Edit
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem onClick={handlePrint} disabled={isPrinting}>
|
||||
<Printer className="size-4" />
|
||||
{isPrinting ? "Printing..." : "Print"}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuSeparator />
|
||||
<DropdownMenuItem variant="destructive" onClick={handleDelete}>
|
||||
<Trash2 className="size-4" />
|
||||
|
||||
@@ -190,7 +190,7 @@ export function JobCardFilterFields() {
|
||||
name="customer_id"
|
||||
label="Customer"
|
||||
queryKey={[CUSTOMER_ROUTES.INDEX]}
|
||||
listFn={() => api.customers.list({ per_page: 100 })}
|
||||
listFn={() => api.customers.list( )}
|
||||
mapOption={customerMapOption}
|
||||
placeholder="All customers"
|
||||
/>
|
||||
@@ -199,7 +199,7 @@ export function JobCardFilterFields() {
|
||||
name="vehicle_id"
|
||||
label="Vehicle"
|
||||
queryKey={[VEHICLE_ROUTES.INDEX]}
|
||||
listFn={() => api.vehicles.list({ per_page: 100 })}
|
||||
listFn={() => api.vehicles.list( )}
|
||||
mapOption={vehicleMapOption}
|
||||
placeholder="All vehicles"
|
||||
/>
|
||||
@@ -208,7 +208,7 @@ export function JobCardFilterFields() {
|
||||
name="insurer_id"
|
||||
label="Insurance Type"
|
||||
queryKey={[INSURANCE_TYPE_ROUTES.INDEX]}
|
||||
listFn={() => api.insuranceTypes.list({ per_page: 100 })}
|
||||
listFn={() => api.insuranceTypes.list( )}
|
||||
mapOption={(item: any) => ({ value: String(item.id), label: item.title ?? item.name ?? `#${item.id}` })}
|
||||
placeholder="All insurers"
|
||||
/>
|
||||
@@ -217,7 +217,7 @@ export function JobCardFilterFields() {
|
||||
name="department_id"
|
||||
label="Department"
|
||||
queryKey={[DEPARTMENT_ROUTES.INDEX]}
|
||||
listFn={() => api.departments.list({ per_page: 100 })}
|
||||
listFn={() => api.departments.list( )}
|
||||
mapOption={(item: any) => ({ value: String(item.id), label: item.title ?? item.name ?? `#${item.id}` })}
|
||||
placeholder="All departments"
|
||||
/>
|
||||
@@ -229,7 +229,7 @@ export function JobCardFilterFields() {
|
||||
name="sales_person_id"
|
||||
label="Sales Person"
|
||||
queryKey={[EMPLOYEE_ROUTES.INDEX, "sales_person"]}
|
||||
listFn={() => api.employees.list({ per_page: 100 })}
|
||||
listFn={() => api.employees.list( )}
|
||||
mapOption={employeeMapOption}
|
||||
placeholder="All sales persons"
|
||||
/>
|
||||
@@ -238,7 +238,7 @@ export function JobCardFilterFields() {
|
||||
name="primary_technician_id"
|
||||
label="Primary Technician"
|
||||
queryKey={[EMPLOYEE_ROUTES.INDEX, "technician"]}
|
||||
listFn={() => api.employees.list({ per_page: 100 })}
|
||||
listFn={() => api.employees.list( )}
|
||||
mapOption={employeeMapOption}
|
||||
placeholder="All technicians"
|
||||
/>
|
||||
@@ -247,7 +247,7 @@ export function JobCardFilterFields() {
|
||||
name="service_writer_id"
|
||||
label="Service Writer"
|
||||
queryKey={[EMPLOYEE_ROUTES.INDEX, "service_writer"]}
|
||||
listFn={() => api.employees.list({ per_page: 100 })}
|
||||
listFn={() => api.employees.list( )}
|
||||
mapOption={employeeMapOption}
|
||||
placeholder="All service writers"
|
||||
/>
|
||||
|
||||
@@ -33,6 +33,7 @@ import { RhfVehicleSelectField } from "@/modules/vehicles/rhf-vehicle-select-fie
|
||||
import { RhfLabelPickerField } from "@/modules/labels/rhf-label-picker-field"
|
||||
import { RhfCustomerRemarksField } from "@/modules/estimates/rhf-customer-remarks-field"
|
||||
import { InsuranceTypeCrudDialog } from "./insurance-type-crud-dialog"
|
||||
import { RhfEmployeeSelectField } from "../employees/rhf-employee-select-field"
|
||||
|
||||
// ── Props ──
|
||||
|
||||
@@ -282,22 +283,18 @@ export function JobCardForm({ resourceId, initialData, onSuccess }: JobCardFormP
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 gap-4 sm:grid-cols-2">
|
||||
<RhfAsyncSelectField
|
||||
<RhfEmployeeSelectField
|
||||
showCreate
|
||||
name="service_writer"
|
||||
label="Service Writer"
|
||||
placeholder="Select service writer"
|
||||
queryKey={[EMPLOYEE_ROUTES.INDEX]}
|
||||
listFn={() => api.employees.list()}
|
||||
mapOption={mapEmployeeOption}
|
||||
{...STORE_OBJECT}
|
||||
/>
|
||||
<RhfAsyncSelectField
|
||||
/>
|
||||
<RhfEmployeeSelectField
|
||||
showCreate
|
||||
name="primary_technician"
|
||||
label="Primary Technician"
|
||||
placeholder="Select technician"
|
||||
queryKey={[EMPLOYEE_ROUTES.INDEX]}
|
||||
listFn={() => api.employees.list()}
|
||||
mapOption={mapEmployeeOption}
|
||||
{...STORE_OBJECT}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user