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:
@@ -0,0 +1,48 @@
|
||||
"use client"
|
||||
|
||||
import { useAuthApi } from "@/shared/useApi"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { Button } from "@/shared/components/ui/button"
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from "@/shared/components/ui/dropdown-menu"
|
||||
import { Ellipsis, Printer, Trash2 } from "lucide-react"
|
||||
import { useDocumentPrint } from "@/shared/hooks/use-document-print"
|
||||
|
||||
type PaymentReceivedActionsProps = {
|
||||
paymentId: string
|
||||
}
|
||||
|
||||
export function PaymentReceivedActions({ paymentId }: PaymentReceivedActionsProps) {
|
||||
const api = useAuthApi()
|
||||
const router = useRouter()
|
||||
const { print, isPrinting } = useDocumentPrint()
|
||||
|
||||
const handleDelete = async () => {
|
||||
await api.paymentReceived.destroy(paymentId)
|
||||
router.push("/sales/payment-received")
|
||||
}
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<Button variant="ghost" size="icon">
|
||||
<Ellipsis className="size-4" />
|
||||
</Button>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent align="end">
|
||||
<DropdownMenuItem onClick={() => print("payment_received", paymentId, "print")} disabled={isPrinting}>
|
||||
<Printer className="size-4" />
|
||||
{isPrinting ? "Printing..." : "Print"}
|
||||
</DropdownMenuItem>
|
||||
<DropdownMenuItem variant="destructive" onClick={handleDelete}>
|
||||
<Trash2 className="size-4" />
|
||||
Delete
|
||||
</DropdownMenuItem>
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
)
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import {
|
||||
paymentReceivedFormSchema,
|
||||
type PaymentReceivedFormValues,
|
||||
} from "./payment-received.schema"
|
||||
import { PAYMENT_MODE_ROUTES, CUSTOMER_ROUTES, JOB_CARD_ROUTES } from "@garage/api"
|
||||
import { PAYMENT_MODE_ROUTES, CUSTOMER_ROUTES, JOB_CARD_ROUTES, PAYMENT_RECEIVED_ROUTES } from "@garage/api"
|
||||
|
||||
// ── Props ──
|
||||
|
||||
@@ -58,13 +58,29 @@ const DEFAULT_VALUES: PaymentReceivedFormValues = {
|
||||
function mapToFormValues(data: unknown): PaymentReceivedFormValues {
|
||||
const d = (data as any)?.data ?? data ?? {}
|
||||
|
||||
const jobCardId = d.job_card_id ?? d.job_card?.id
|
||||
const jobCardLabel = d.job_card?.title ?? d.job_card_name
|
||||
|
||||
const paymentModeId = d.payment_mode_id ?? d.payment_mode?.id
|
||||
const paymentModeLabel = d.payment_mode?.title ?? d.payment_mode?.name ?? d.payment_mode_name
|
||||
|
||||
const customerId = d.customer_id ?? d.customer?.id
|
||||
const customerLabel = d.customer?.first_name
|
||||
? `${d.customer.first_name} ${d.customer.last_name ?? ""}`.trim()
|
||||
: d.customer?.company_name ?? d.customer?.name ?? d.customer_name
|
||||
|
||||
const rawDate = d.payment_date
|
||||
const payment_date = typeof rawDate === "string" && rawDate
|
||||
? rawDate.slice(0, 10)
|
||||
: new Date().toISOString().split("T")[0]
|
||||
|
||||
return {
|
||||
job_card: toRelation(d.job_card_id, d.job_card_name),
|
||||
payment_mode: toRelation(d.payment_mode_id, d.payment_mode_name),
|
||||
customer: toRelation(d.customer_id, d.customer_name),
|
||||
job_card: toRelation(jobCardId, jobCardLabel),
|
||||
payment_mode: toRelation(paymentModeId, paymentModeLabel),
|
||||
customer: toRelation(customerId, customerLabel),
|
||||
amount_received: d.amount_received != null ? Number(d.amount_received) : 0,
|
||||
payment_number: d.payment_number || "",
|
||||
payment_date: d.payment_date || new Date().toISOString().split("T")[0],
|
||||
payment_date,
|
||||
note: d.note || "",
|
||||
}
|
||||
}
|
||||
@@ -126,6 +142,8 @@ export function PaymentReceivedForm({ resourceId, initialData, onSuccess, defaul
|
||||
defaultValues: DEFAULT_VALUES,
|
||||
resourceId,
|
||||
initialData: resolvedInitialData,
|
||||
initialize: (id) => api.paymentReceived.show(id),
|
||||
queryKey: [PAYMENT_RECEIVED_ROUTES.BY_ID, resourceId],
|
||||
mapToFormValues,
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user