fix many bugs

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-04-30 19:03:31 +03:00
co-authored by Copilot
parent 0c43c8edd2
commit e1ef6fa2ea
24 changed files with 333 additions and 82 deletions
@@ -6,10 +6,12 @@ import FormDialog from '@/shared/components/form-dialog'
import { EstimateForm } from '@/modules/estimates/estimate-form'
import { ESTIMATE_ROUTES } from '@garage/api'
import type { EstimatesClient } from '@garage/api'
import { Car, FileTextIcon } from 'lucide-react'
import { Car, FileTextIcon, UserIcon } from 'lucide-react'
import { Button } from '@/shared/components/ui/button'
import Link from 'next/link'
import { formatDate } from '@/shared/utils/formatters'
import { getVehicleLabel } from '@/modules/vehicles/utils/getVehicleLabel'
import { getFullName } from '@/shared/utils/getFullName'
export default function EstimatesPage() {
return (
@@ -52,15 +54,24 @@ export default function EstimatesPage() {
{
accessorKey: "customer_name",
header: ({ column }) => <ColumnHeader column={column} title="Customer" />,
cell: ({ row }) => {
const item:any = row.original
return (
<div className="flex items-center gap-2">
<UserIcon className="h-4 w-4 text-muted-foreground" />
<span>{getFullName(item.customer) || "—"}</span>
</div>
)
}
},
{
accessorKey: "vehicle_id",
accessorKey: "vehicle",
header: ({ column }) => <ColumnHeader column={column} title="Vehicle" />,
cell: ({ row }) => {
const item = row.original
const item :any= row.original
return <Button variant="outline" asChild size="sm">
<Link href={`/sales/vehicles/${item.vehicle_id}`}>
<Car/> Go to vehicle
<Link href={`/sales/vehicles/${item.vehicle?.id}`}>
<Car/> {getVehicleLabel(item.vehicle as any) || "—"}
</Link>
</Button>
}
@@ -13,6 +13,7 @@ import {
UserIcon,
ClipboardListIcon,
} from "lucide-react"
import { getFullName } from "@/shared/utils/getFullName"
type PaymentReceivedItem = {
id: number
@@ -63,24 +64,24 @@ export default function PaymentReceivedPage() {
},
},
{
accessorKey: "customer_name",
accessorKey: "customer",
header: ({ column }) => <ColumnHeader column={column} title="Customer" />,
cell: ({ row }) => {
const item = row.original as unknown as PaymentReceivedItem
const item:any = row.original as unknown as PaymentReceivedItem
return (
<div className="flex items-center gap-2">
<UserIcon className="h-4 w-4 text-muted-foreground" />
<span>{item.customer_name || "—"}</span>
<span>{getFullName(item.customer) || "—"}</span>
</div>
)
},
},
{
accessorKey: "job_card_name",
accessorKey: "job_card",
header: ({ column }) => <ColumnHeader column={column} title="Job Card" />,
cell: ({ row }) => {
const item = row.original as unknown as PaymentReceivedItem
const label = item.job_card_number || item.job_card_name
const item:any = row.original as unknown as PaymentReceivedItem
const label = item.job_card?.title
return (
<div className="flex items-center gap-2">
<ClipboardListIcon className="h-4 w-4 text-muted-foreground" />
@@ -111,14 +112,14 @@ export default function PaymentReceivedPage() {
},
},
{
accessorKey: "payment_mode_name",
accessorKey: "payment_mode",
header: ({ column }) => <ColumnHeader column={column} title="Payment Mode" />,
cell: ({ row }) => {
const item = row.original as unknown as PaymentReceivedItem
const item:any = row.original as unknown as PaymentReceivedItem
return (
<div className="flex items-center gap-2">
<CreditCardIcon className="h-4 w-4 text-muted-foreground" />
<span className="capitalize">{item.payment_mode_name || "—"}</span>
<span className="capitalize">{item.payment_mode?.title || "—"}</span>
</div>
)
},