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
91 lines
4.0 KiB
TypeScript
91 lines
4.0 KiB
TypeScript
"use client"
|
|
|
|
import FormDialog from "@/shared/components/form-dialog"
|
|
import { Badge } from "@/shared/components/ui/badge"
|
|
import { ResourcePage } from "@/shared/data-view/resource-page"
|
|
import { ColumnHeader } from "@/shared/data-view/table-view"
|
|
import { VendorCreditForm } from "@/modules/vendor-credits/vendor-credit-form"
|
|
import { VENDOR_CREDIT_ROUTES, VendorCreditStatus } from "@garage/api"
|
|
import type { VendorCreditsClient } from "@garage/api"
|
|
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 VendorCreditsPage() {
|
|
return (
|
|
<ResourcePage<VendorCreditsClient>
|
|
pageTitle="Vendor Credits"
|
|
routeKey={VENDOR_CREDIT_ROUTES.INDEX}
|
|
searchable
|
|
searchPlaceholder="Search vendor credits..."
|
|
statusFilter={{ statuses: VendorCreditStatus }}
|
|
getClient={(api) => api.vendorCredits}
|
|
headerProps={({ selectedItem, invalidateQuery }) => ({
|
|
actions: (
|
|
<FormDialog title="Vendor Credit">
|
|
{(resourceId) => (
|
|
<VendorCreditForm
|
|
resourceId={resourceId}
|
|
initialData={selectedItem}
|
|
onSuccess={invalidateQuery}
|
|
/>
|
|
)}
|
|
</FormDialog>
|
|
),
|
|
})}
|
|
columns={({ actionsColumn }) => [
|
|
{
|
|
accessorKey: "subject",
|
|
header: ({ column }) => <ColumnHeader column={column} title="Subject" />,
|
|
},
|
|
{
|
|
accessorKey: "vendor_name",
|
|
header: ({ column }) => <ColumnHeader column={column} title="Vendor" />,
|
|
cell: ({ row }) => {
|
|
const item = row.original as any
|
|
return (
|
|
<RelationLink
|
|
href={item.vendor?.id ? `/purchase/vendor/${item.vendor.id}` : null}
|
|
icon={Building2}
|
|
label={item.vendor?.company_name || getFullName(item.vendor) || item.vendor_name}
|
|
/>
|
|
)
|
|
},
|
|
},
|
|
{
|
|
accessorKey: "bill_number",
|
|
header: ({ column }) => <ColumnHeader column={column} title="Bill #" />,
|
|
cell: ({ row }) => {
|
|
const item = row.original as any
|
|
return (
|
|
<RelationLink
|
|
href={item.bill?.id ? `/purchase/bill/${item.bill.id}` : null}
|
|
icon={FileTextIcon}
|
|
label={item.bill?.bill_number || item.bill_number}
|
|
/>
|
|
)
|
|
},
|
|
},
|
|
{
|
|
accessorKey: "vendor_credit_date",
|
|
header: ({ column }) => <ColumnHeader column={column} title="Date" />,
|
|
cell: ({ row }) => {
|
|
const value = (row.original as any).vendor_credit_date
|
|
return value ? new Date(value).toLocaleDateString() : "—"
|
|
},
|
|
},
|
|
{
|
|
accessorKey: "status",
|
|
header: ({ column }) => <ColumnHeader column={column} title="Status" />,
|
|
cell: ({ row }) => {
|
|
const status = (row.original as any).status
|
|
return <Badge variant={status === "closed" ? "secondary" : "default"}>{formatEnum(status)}</Badge>
|
|
},
|
|
},
|
|
actionsColumn(),
|
|
]}
|
|
/>
|
|
)
|
|
}
|