feat: add logo field to settings schema and update settings client to handle file uploads
feat: integrate dialog close context in vendor select field and CRUD dialog components feat: enhance vendor general info to format status using utility function feat: implement form dialog context for managing dialog close actions feat: add async select field dialog close context for better form handling fix: update form mutation hook to close dialog on successful submission feat: extend document print types to include expense and credit note feat: add settings update payload type to include logo and other fields feat: create employee attendance and work history pages with resource management feat: implement payment made and received detail pages with actions feat: add quick shortcuts component for easy navigation in the dashboard feat: create actions for payment made and received with print and delete options feat: implement dialog close context for better dialog management feat: add error parsing utility for improved error handling in API responses
This commit is contained in:
@@ -7,6 +7,9 @@ import FormDialog from "@/shared/components/form-dialog"
|
||||
import { CreditNoteForm } from "@/modules/credit-notes/credit-note-form"
|
||||
import { CREDIT_NOTE_ROUTES, CreditNoteStatus } from "@garage/api"
|
||||
import type { CreditNotesClient } from "@garage/api"
|
||||
import { formatEnum } from "@/shared/utils/formatters"
|
||||
import { Printer } from "lucide-react"
|
||||
import { useDocumentPrint } from "@/shared/hooks/use-document-print"
|
||||
|
||||
type CreditNoteItem = {
|
||||
id: number
|
||||
@@ -20,6 +23,7 @@ type CreditNoteItem = {
|
||||
|
||||
export default function CreditNotesPage() {
|
||||
const router = useRouter()
|
||||
const { print, isPrinting } = useDocumentPrint()
|
||||
|
||||
return (
|
||||
<ResourcePage<CreditNotesClient>
|
||||
@@ -66,7 +70,7 @@ export default function CreditNotesPage() {
|
||||
}
|
||||
return (
|
||||
<span className={colorMap[status ?? ""] ?? ""}>
|
||||
{status ? status.charAt(0).toUpperCase() + status.slice(1) : "—"}
|
||||
{formatEnum(status)}
|
||||
</span>
|
||||
)
|
||||
},
|
||||
@@ -75,7 +79,15 @@ export default function CreditNotesPage() {
|
||||
accessorKey: "date",
|
||||
header: ({ column }) => <ColumnHeader column={column} title="Date" />,
|
||||
},
|
||||
actionsColumn(),
|
||||
actionsColumn({
|
||||
extraItems: (row) => [
|
||||
{
|
||||
label: isPrinting ? "Printing..." : "Print",
|
||||
icon: Printer,
|
||||
onClick: (r) => print("credit_note", String(r.id), "print"),
|
||||
},
|
||||
],
|
||||
}),
|
||||
]}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -7,7 +7,8 @@ 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, UserIcon } from 'lucide-react'
|
||||
import { Car, FileTextIcon, Printer, UserIcon } from 'lucide-react'
|
||||
import { useDocumentPrint } from '@/shared/hooks/use-document-print'
|
||||
import Link from 'next/link'
|
||||
import { formatDate } from '@/shared/utils/formatters'
|
||||
import { getVehicleLabel } from '@/modules/vehicles/utils/getVehicleLabel'
|
||||
@@ -16,6 +17,7 @@ import { RelationLink } from '@/shared/components/relation-link'
|
||||
|
||||
export default function EstimatesPage() {
|
||||
const router = useRouter()
|
||||
const { print, isPrinting } = useDocumentPrint()
|
||||
return (
|
||||
<ResourcePage<EstimatesClient>
|
||||
pageTitle="Estimates"
|
||||
@@ -109,7 +111,15 @@ export default function EstimatesPage() {
|
||||
return item.created_at ? new Date(item.created_at).toLocaleDateString() : "—"
|
||||
},
|
||||
},
|
||||
actionsColumn(),
|
||||
actionsColumn({
|
||||
extraItems: (row) => [
|
||||
{
|
||||
label: isPrinting ? "Printing..." : "Print",
|
||||
icon: Printer,
|
||||
onClick: (r) => print("estimate", String(r.id), "print"),
|
||||
},
|
||||
],
|
||||
}),
|
||||
]}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
"use client"
|
||||
|
||||
import { Car, UserIcon } from "lucide-react"
|
||||
import { Car, Printer, UserIcon } from "lucide-react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { useDocumentPrint } from "@/shared/hooks/use-document-print"
|
||||
import { ResourcePage } from "@/shared/data-view/resource-page"
|
||||
import { ColumnHeader } from "@/shared/data-view/table-view"
|
||||
import FormDialog from "@/shared/components/form-dialog"
|
||||
@@ -81,6 +82,7 @@ function getDueMeta(dueDate?: string) {
|
||||
|
||||
export default function InvoicesPage() {
|
||||
const router = useRouter()
|
||||
const { print, isPrinting } = useDocumentPrint()
|
||||
|
||||
return (
|
||||
<ResourcePage<InvoicesClient>
|
||||
@@ -238,7 +240,15 @@ export default function InvoicesPage() {
|
||||
)
|
||||
},
|
||||
},
|
||||
actionsColumn(),
|
||||
actionsColumn({
|
||||
extraItems: (row) => [
|
||||
{
|
||||
label: isPrinting ? "Printing..." : "Print",
|
||||
icon: Printer,
|
||||
onClick: (r) => print("invoice", String(r.id), "print"),
|
||||
},
|
||||
],
|
||||
}),
|
||||
]}
|
||||
/>
|
||||
)
|
||||
|
||||
@@ -14,6 +14,7 @@ import { Badge } from "@/shared/components/ui/badge"
|
||||
import { useJobCard } from "@/modules/job-cards/job-card-context"
|
||||
import { getFullName } from "@/shared/utils/getFullName"
|
||||
import { getVehicleLabel } from "@/modules/vehicles/utils/getVehicleLabel"
|
||||
import { formatEnum } from "@/shared/utils/formatters"
|
||||
|
||||
const STATUS_COLORS: Record<string, string> = {
|
||||
requested: "bg-yellow-100 text-yellow-800",
|
||||
@@ -125,7 +126,7 @@ export default function JobCardAppointmentsPage({
|
||||
const colorClass = STATUS_COLORS[status] ?? "bg-gray-100 text-gray-800"
|
||||
return (
|
||||
<Badge className={colorClass}>
|
||||
{status?.replace("_", " ") ?? "—"}
|
||||
{formatEnum(status)}
|
||||
</Badge>
|
||||
)
|
||||
},
|
||||
|
||||
@@ -12,6 +12,7 @@ import { useJobCard } from "@/modules/job-cards/job-card-context"
|
||||
import { RelationLink } from "@/shared/components/relation-link"
|
||||
import { Building2, FileTextIcon } from "lucide-react"
|
||||
import { getFullName } from "@/shared/utils/getFullName"
|
||||
import { formatEnum } from "@/shared/utils/formatters"
|
||||
|
||||
export default function JobCardBillsPage({
|
||||
params,
|
||||
@@ -102,7 +103,7 @@ export default function JobCardBillsPage({
|
||||
header: ({ column }) => <ColumnHeader column={column} title="Status" />,
|
||||
cell: ({ row }) => {
|
||||
const status = (row.original as any).status
|
||||
return <Badge variant={status === "paid" ? "default" : "secondary"}>{status || "—"}</Badge>
|
||||
return <Badge variant={status === "paid" ? "default" : "secondary"}>{formatEnum(status)}</Badge>
|
||||
},
|
||||
},
|
||||
actionsColumn(),
|
||||
|
||||
@@ -6,7 +6,8 @@ import FormDialog from '@/shared/components/form-dialog'
|
||||
import { JobCardForm } from '@/modules/job-cards/job-card-form'
|
||||
import { JOB_CARD_ROUTES, JobCardStatus } from '@garage/api'
|
||||
import type { JobCardsClient } from '@garage/api'
|
||||
import { ClipboardListIcon } from 'lucide-react'
|
||||
import { ClipboardListIcon, Printer } from 'lucide-react'
|
||||
import { useDocumentPrint } from '@/shared/hooks/use-document-print'
|
||||
import { Badge } from '@/shared/components/ui/badge'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { formatDate, formatEnum, formatNumber } from '@/shared/utils/formatters'
|
||||
@@ -35,6 +36,7 @@ const statusColorMap: Record<string, string> = {
|
||||
export default function JobCardsPage() {
|
||||
const router = useRouter()
|
||||
const filter = useFilterParams(jobCardFilterConfig)
|
||||
const { print, isPrinting } = useDocumentPrint()
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -117,7 +119,15 @@ export default function JobCardsPage() {
|
||||
)
|
||||
},
|
||||
},
|
||||
actionsColumn(),
|
||||
actionsColumn({
|
||||
extraItems: (row) => [
|
||||
{
|
||||
label: isPrinting ? "Printing..." : "Print",
|
||||
icon: Printer,
|
||||
onClick: (r) => print("job_card", String(r.id), "print"),
|
||||
},
|
||||
],
|
||||
}),
|
||||
]}
|
||||
/>
|
||||
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
import { DashboardDetailsPage } from '@/base/components/layout/dashboard'
|
||||
import { getServerApi } from '@garage/api/server'
|
||||
import { PaymentReceivedActions } from '@/modules/payment-received/payment-received-actions'
|
||||
import { BanknoteIcon } from 'lucide-react'
|
||||
import React from 'react'
|
||||
|
||||
export default async function PaymentReceivedDetailLayout(props: {
|
||||
params: Promise<{ id: string }>
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
const { id } = await props.params
|
||||
const api = await getServerApi()
|
||||
const payment = await api.paymentReceived.show(id)
|
||||
const data = (payment as any)?.data ?? payment
|
||||
const title = data?.payment_number || 'Payment Details'
|
||||
|
||||
return (
|
||||
<DashboardDetailsPage
|
||||
title={title}
|
||||
description={data?.payment_number ? `Payment #: ${data.payment_number}` : undefined}
|
||||
icon={<BanknoteIcon className="size-5" />}
|
||||
backHref="/sales/payment-received"
|
||||
actions={<PaymentReceivedActions paymentId={id} />}
|
||||
tabs={[
|
||||
{
|
||||
href: `/sales/payment-received/${id}`,
|
||||
label: 'Details',
|
||||
},
|
||||
]}
|
||||
>
|
||||
{props.children}
|
||||
</DashboardDetailsPage>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
import { getServerApi } from '@garage/api/server'
|
||||
import DashboardPage from '@/base/components/layout/dashboard/dashboard-page'
|
||||
import {
|
||||
BadgeDollarSignIcon,
|
||||
CalendarIcon,
|
||||
ClipboardListIcon,
|
||||
CreditCardIcon,
|
||||
HashIcon,
|
||||
UserIcon,
|
||||
} from 'lucide-react'
|
||||
|
||||
export default async function PaymentReceivedDetailPage(props: { params: Promise<{ id: string }> }) {
|
||||
const { id } = await props.params
|
||||
const api = await getServerApi()
|
||||
const payment = await api.paymentReceived.show(id)
|
||||
const data = (payment as any)?.data ?? payment
|
||||
|
||||
if (!data) {
|
||||
return <div className="text-muted-foreground">Payment not found.</div>
|
||||
}
|
||||
|
||||
const amount = data.amount_received != null
|
||||
? Number(data.amount_received).toLocaleString(undefined, { minimumFractionDigits: 2, maximumFractionDigits: 2 })
|
||||
: '—'
|
||||
|
||||
const paymentDate = data.payment_date
|
||||
? new Date(data.payment_date).toLocaleDateString(undefined, { year: 'numeric', month: 'long', day: 'numeric' })
|
||||
: '—'
|
||||
|
||||
const customerName = data.customer?.first_name
|
||||
? `${data.customer.first_name} ${data.customer.last_name ?? ''}`.trim()
|
||||
: data.customer?.company_name ?? data.customer_name ?? '—'
|
||||
|
||||
const jobCardLabel = data.job_card?.title ?? data.job_card_name ?? '—'
|
||||
const paymentMode = data.payment_mode?.title ?? data.payment_mode?.name ?? data.payment_mode_name ?? '—'
|
||||
|
||||
return (
|
||||
<DashboardPage header={null}>
|
||||
<div className="grid gap-4 sm:grid-cols-2 lg:grid-cols-3">
|
||||
<div className="flex items-center gap-3 rounded-lg border p-4">
|
||||
<HashIcon className="size-5 text-muted-foreground" />
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">Payment Number</p>
|
||||
<p className="font-medium">{data.payment_number || '—'}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 rounded-lg border p-4">
|
||||
<UserIcon className="size-5 text-muted-foreground" />
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">Customer</p>
|
||||
<p className="font-medium">{customerName}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 rounded-lg border p-4">
|
||||
<ClipboardListIcon className="size-5 text-muted-foreground" />
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">Job Card</p>
|
||||
<p className="font-medium">{jobCardLabel}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 rounded-lg border p-4">
|
||||
<BadgeDollarSignIcon className="size-5 text-emerald-600" />
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">Amount Received</p>
|
||||
<p className="font-semibold text-emerald-700 dark:text-emerald-400">{amount}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 rounded-lg border p-4">
|
||||
<CreditCardIcon className="size-5 text-muted-foreground" />
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">Payment Mode</p>
|
||||
<p className="font-medium capitalize">{paymentMode}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-3 rounded-lg border p-4">
|
||||
<CalendarIcon className="size-5 text-muted-foreground" />
|
||||
<div>
|
||||
<p className="text-xs text-muted-foreground">Payment Date</p>
|
||||
<p className="font-medium">{paymentDate}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{data.note && (
|
||||
<div className="sm:col-span-2 lg:col-span-3 rounded-lg border p-4">
|
||||
<p className="text-xs text-muted-foreground mb-1">Note</p>
|
||||
<p className="text-sm">{data.note}</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</DashboardPage>
|
||||
)
|
||||
}
|
||||
@@ -10,9 +10,12 @@ import {
|
||||
CalendarIcon,
|
||||
CreditCardIcon,
|
||||
HashIcon,
|
||||
Printer,
|
||||
UserIcon,
|
||||
ClipboardListIcon,
|
||||
} from "lucide-react"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { useDocumentPrint } from "@/shared/hooks/use-document-print"
|
||||
import { getFullName } from "@/shared/utils/getFullName"
|
||||
import { RelationLink } from "@/shared/components/relation-link"
|
||||
|
||||
@@ -31,6 +34,9 @@ type PaymentReceivedItem = {
|
||||
}
|
||||
|
||||
export default function PaymentReceivedPage() {
|
||||
const router = useRouter()
|
||||
const { print, isPrinting } = useDocumentPrint()
|
||||
|
||||
return (
|
||||
<ResourcePage<{ list(query?: any): Promise<any>; destroy(id: string): Promise<any> }>
|
||||
routeKey={PAYMENT_RECEIVED_ROUTES.INDEX}
|
||||
@@ -40,6 +46,7 @@ export default function PaymentReceivedPage() {
|
||||
list: (query?: any) => api.paymentReceived.list(query),
|
||||
destroy: (id: string) => api.paymentReceived.destroy(id),
|
||||
})}
|
||||
onRowClick={(row) => router.push(`/sales/payment-received/${(row as any).id}`)}
|
||||
headerProps={({ invalidateQuery }) => ({
|
||||
actions: (
|
||||
<FormDialog title="Record Payment">
|
||||
@@ -68,6 +75,7 @@ export default function PaymentReceivedPage() {
|
||||
},
|
||||
{
|
||||
accessorKey: "customer",
|
||||
|
||||
header: ({ column }) => <ColumnHeader column={column} title="Customer" />,
|
||||
cell: ({ row }) => {
|
||||
const item: any = row.original as unknown as PaymentReceivedItem
|
||||
@@ -165,7 +173,15 @@ export default function PaymentReceivedPage() {
|
||||
)
|
||||
},
|
||||
},
|
||||
actionsColumn(),
|
||||
actionsColumn({
|
||||
extraItems: (row) => [
|
||||
{
|
||||
label: isPrinting ? "Printing..." : "Print",
|
||||
icon: Printer,
|
||||
onClick: (r) => print("payment_received", String(r.id), "print"),
|
||||
},
|
||||
],
|
||||
}),
|
||||
]}
|
||||
/>
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user