feat: add template checkpoint edit dialog and vendor management components

- Implemented TemplateCheckpointEditDialog for creating and editing inspection checkpoints.
- Added VendorActions component for managing vendor actions including edit, activate/deactivate, and delete.
- Created VendorContext for managing vendor state across components.
- Developed VendorGeneralInfo component to display detailed vendor information.
- Introduced AedSymbol and Money components for consistent currency representation.
- Added PromptDialog for user input prompts throughout the application.
- Implemented RelationLink component for unified related-data display in CRUD tables.
- Created InspectionTemplatesClient for API interactions related to inspection templates.
This commit is contained in:
2026-05-18 12:08:42 +04:00
parent 54d11f01b4
commit 4bfd8c84a9
111 changed files with 5002 additions and 1047 deletions
@@ -73,23 +73,30 @@ const DEFAULT_VALUES: PaymentMadeFormValues & { details: Array<{ bill_id?: strin
function mapToFormValues(data: unknown): typeof DEFAULT_VALUES {
const d = (data as any)?.data ?? data ?? {}
// PaymentMade lists carry the linked bill/expense inside details[]; top-level
// bill_id/expense_id only exist on inputs sent from a bill/expense subpage.
const firstDetail = Array.isArray(d.details) ? d.details[0] ?? {} : {}
const billId = d.bill_id ?? firstDetail.bill_id ?? firstDetail.bill?.id
const billNumber = d.bill?.bill_number ?? d.bill_number ?? firstDetail.bill?.bill_number
const expenseId = d.expense_id ?? firstDetail.expense_id ?? firstDetail.expense?.id
// Resolve payment_mode label from nested object (title) or fallback to id
const paymentModeId = d.payment_mode_id ?? d.payment_mode?.id
const paymentModeLabel = d.payment_mode?.title ?? d.payment_mode?.name ?? d.payment_mode_name
return {
bill: toRelation(d.bill_id, d.bill?.bill_number ?? d.bill_number),
vendor: toRelation(d.vendor_id, d.vendor?.company_name ?? d.vendor?.name ?? d.vendor_name),
employee: toRelation(d.employee_id, d.employee?.first_name ? `${d.employee.first_name} ${d.employee.last_name ?? ""}`.trim() : d.employee_name),
bill: toRelation(billId, billNumber),
vendor: toRelation(d.vendor_id ?? d.vendor?.id, d.vendor?.company_name ?? d.vendor?.name ?? d.vendor_name),
employee: toRelation(d.employee_id ?? d.employee?.id, d.employee?.first_name ? `${d.employee.first_name} ${d.employee.last_name ?? ""}`.trim() : d.employee_name),
payment_mode: toRelation(paymentModeId, paymentModeLabel),
payment_for: d.payment_for || "bill",
amount: d.payment_made != null ? Number(d.payment_made) : 0,
payment_for: d.payment_for || (expenseId ? "expense" : "bill"),
amount: d.payment_made != null ? Number(d.payment_made) : firstDetail.amount_paid != null ? Number(firstDetail.amount_paid) : 0,
payment_number: d.payment_number || "",
payment_reference: d.payment_reference || "",
payment_date: d.payment_date || "",
paid_through: d.paid_through || "-",
notes: d.notes || "-",
details: [{ bill_id: d.bill_id, expense_id: d.expense_id, amount_paid: d.amount_paid ?? 0 }],
paid_through: d.paid_through || "",
notes: d.notes || "",
details: [{ bill_id: billId, expense_id: expenseId, amount_paid: firstDetail.amount_paid ?? 0 }],
}
}