@appcorp/fusion-storybook 0.5.15 → 0.5.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/base-modules/enrollment/context.d.ts +6 -0
  2. package/base-modules/enrollment/context.js +69 -25
  3. package/base-modules/enrollment/date.d.ts +8 -0
  4. package/base-modules/enrollment/date.js +21 -0
  5. package/base-modules/enrollment/filter.js +1 -1
  6. package/base-modules/enrollment/form.js +55 -24
  7. package/base-modules/enrollment/more-actions.js +47 -10
  8. package/base-modules/enrollment/page.js +11 -14
  9. package/base-modules/enrollment/validate.d.ts +1 -0
  10. package/base-modules/enrollment/validate.js +3 -1
  11. package/base-modules/enrollment/view.js +11 -19
  12. package/base-modules/expense/context/expense-api-provider.js +22 -9
  13. package/base-modules/expense/context/shared.d.ts +35 -0
  14. package/base-modules/expense/context/shared.js +11 -3
  15. package/base-modules/expense/context/use-expense-module.d.ts +7 -1
  16. package/base-modules/expense/context/use-expense-module.js +58 -55
  17. package/base-modules/expense/filter.js +25 -57
  18. package/base-modules/expense/form.js +17 -74
  19. package/base-modules/expense/page.js +60 -29
  20. package/base-modules/expense/validate.d.ts +17 -11
  21. package/base-modules/expense/validate.js +35 -14
  22. package/base-modules/family/context.d.ts +13 -9
  23. package/base-modules/family/context.js +69 -75
  24. package/base-modules/family/page.js +11 -4
  25. package/base-modules/family/view.js +3 -2
  26. package/base-modules/family-member/constants.d.ts +8 -0
  27. package/base-modules/family-member/constants.js +12 -0
  28. package/base-modules/family-member/context.d.ts +12 -2
  29. package/base-modules/family-member/context.js +78 -81
  30. package/base-modules/family-member/date.d.ts +6 -0
  31. package/base-modules/family-member/date.js +13 -0
  32. package/base-modules/family-member/filter.js +1 -1
  33. package/base-modules/family-member/form.js +25 -2
  34. package/base-modules/family-member/page.js +12 -4
  35. package/constants.d.ts +0 -6
  36. package/constants.js +0 -6
  37. package/package.json +1 -1
  38. package/tsconfig.build.tsbuildinfo +1 -1
  39. package/utils/resolve-rbac-permissions.js +5 -3
  40. package/base-modules/expense/more-actions.d.ts +0 -1
  41. package/base-modules/expense/more-actions.js +0 -265
  42. package/base-modules/family/more-actions.d.ts +0 -1
  43. package/base-modules/family/more-actions.js +0 -255
  44. package/base-modules/family-member/more-actions.d.ts +0 -1
  45. package/base-modules/family-member/more-actions.js +0 -261
@@ -1,19 +1,20 @@
1
1
  "use client";
2
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  /**
4
4
  * Expense Form
5
5
  *
6
- * Create / update form for an expense record.
6
+ * Create / update form for an expense record. Enum pickers are static —
7
+ * attaching a remote search would replace their options with expense rows.
7
8
  */
8
9
  import { EnhancedCheckbox } from "@appcorp/shadcn/components/enhanced-checkbox";
9
- import { useEnhancedCombobox } from "@appcorp/shadcn/hooks/use-enhanced-combobox";
10
+ import { EnhancedCombobox } from "@appcorp/shadcn/components/enhanced-combobox";
10
11
  import { EnhancedInput } from "@appcorp/shadcn/components/enhanced-input";
11
12
  import { EnhancedTextarea } from "@appcorp/shadcn/components/enhanced-textarea";
12
13
  import { EnhancedDropzone } from "@appcorp/shadcn/components/enhanced-dropzone";
13
14
  import { useExpenseModule } from "./context";
14
15
  import { EXPENSE_CATEGORY_OPTIONS, EXPENSE_STATUS_OPTIONS, PAYMENT_METHOD_OPTIONS, } from "./constants";
15
- import { EXPENSE_API_ROUTES } from "../../constants";
16
16
  import { getCachedWorkspaceSync } from "../workspace/cache";
17
+ import { getTranslatedError } from "../../utils/get-translated-error";
17
18
  import { useTranslations } from "next-intl";
18
19
  export const ExpenseForm = () => {
19
20
  var _a, _b;
@@ -54,79 +55,21 @@ export const ExpenseForm = () => {
54
55
  ONLINE: t("formOptionOnline"),
55
56
  MOBILE_WALLET: t("formOptionMobileWallet"),
56
57
  };
57
- const { enhancedComboboxElement: categoryCombo } = useEnhancedCombobox({
58
- emptyText: t("formNoCategoryEmpty"),
59
- id: "category",
60
- info: t("formCategoryInfo"),
61
- label: t("formCategoryLabel"),
62
- onValueChange: (value) => handleChange("category", value),
63
- options: EXPENSE_CATEGORY_OPTIONS.map((opt) => ({
64
- value: opt.value,
65
- label: categoryLabelMap[opt.value] || opt.label,
66
- })),
67
- placeholder: t("formCategoryPlaceholder"),
68
- required: true,
69
- searchEndpoint: EXPENSE_API_ROUTES.UNIT,
70
- searchPlaceholder: t("formSearchCategoriesPlaceholder"),
71
- formatSearchResult: (item) => {
72
- var _a, _b;
73
- return ({
74
- label: String((_a = item.label) !== null && _a !== void 0 ? _a : ""),
75
- value: String((_b = item.value) !== null && _b !== void 0 ? _b : ""),
76
- });
77
- },
78
- value: category || "",
79
- });
80
- const { enhancedComboboxElement: statusCombo } = useEnhancedCombobox({
81
- emptyText: t("formNoStatusEmpty"),
82
- id: "status",
83
- info: t("formStatusInfo"),
84
- label: t("formStatusLabel"),
85
- onValueChange: (value) => handleChange("status", value),
86
- options: EXPENSE_STATUS_OPTIONS.map((opt) => ({
87
- value: opt.value,
88
- label: statusLabelMap[opt.value] || opt.label,
89
- })),
90
- placeholder: t("formStatusPlaceholder"),
91
- required: true,
92
- searchEndpoint: EXPENSE_API_ROUTES.UNIT,
93
- searchPlaceholder: t("formSearchStatusPlaceholder"),
94
- formatSearchResult: (item) => {
95
- var _a, _b;
96
- return ({
97
- label: String((_a = item.label) !== null && _a !== void 0 ? _a : ""),
98
- value: String((_b = item.value) !== null && _b !== void 0 ? _b : ""),
99
- });
100
- },
101
- value: status || "",
102
- });
103
- const { enhancedComboboxElement: paymentMethodCombo } = useEnhancedCombobox({
104
- emptyText: t("formNoPaymentMethodEmpty"),
105
- id: "paymentMethod",
106
- info: t("formPaymentMethodInfo"),
107
- label: t("formPaymentMethodLabel"),
108
- onValueChange: (value) => handleChange("paymentMethod", value),
109
- options: PAYMENT_METHOD_OPTIONS.map((opt) => ({
110
- value: opt.value,
111
- label: paymentMethodLabelMap[opt.value] || opt.label,
112
- })),
113
- placeholder: t("formPaymentMethodPlaceholder"),
114
- searchEndpoint: EXPENSE_API_ROUTES.UNIT,
115
- searchPlaceholder: t("formSearchPaymentMethodsPlaceholder"),
116
- formatSearchResult: (item) => {
117
- var _a, _b;
118
- return ({
119
- label: String((_a = item.label) !== null && _a !== void 0 ? _a : ""),
120
- value: String((_b = item.value) !== null && _b !== void 0 ? _b : ""),
121
- });
122
- },
123
- value: paymentMethod || "",
124
- });
125
- return (_jsxs("div", { className: "space-y-4", children: [_jsx(EnhancedInput, { error: errors.title ? t(errors.title) : undefined, id: "title", info: t("formTitleInfo"), label: t("formTitleLabel"), onChange: (e) => handleChange("title", e.target.value), placeholder: t("formTitlePlaceholder"), required: true, type: "text", value: title || "" }), categoryCombo, statusCombo, _jsx(EnhancedInput, { error: errors.amount ? t(errors.amount) : undefined, id: "amount", info: t("formAmountInfo", { currency }), label: t("formAmountLabel"), min: "0", onChange: (e) => handleChange("amount", Number(e.target.value)), placeholder: "0.00", required: true, step: "0.01", type: "number", value: amount }), _jsx(EnhancedInput, { error: errors.expenseDate ? t(errors.expenseDate) : undefined, id: "expenseDate", info: t("formExpenseDateInfo"), label: t("formExpenseDateLabel"), onChange: (e) => handleChange("expenseDate", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, required: true, type: "date", value: expenseDate || "" }), _jsx(EnhancedTextarea, { error: errors.description, id: "description", label: t("formDescriptionLabel"), onChange: (e) => handleChange("description", e.target.value), placeholder: t("formDescriptionPlaceholder"), rows: 3, value: description || "" }), _jsx(EnhancedInput, { error: errors.vendorName ? t(errors.vendorName) : undefined, id: "vendorName", info: t("formVendorNameInfo"), label: t("formVendorNameLabel"), onChange: (e) => handleChange("vendorName", e.target.value), placeholder: t("formVendorNamePlaceholder"), type: "text", value: vendorName || "" }), _jsx(EnhancedInput, { error: errors.vendorContact ? t(errors.vendorContact) : undefined, id: "vendorContact", info: t("formVendorContactInfo"), label: t("formVendorContactLabel"), onChange: (e) => handleChange("vendorContact", e.target.value), placeholder: t("formVendorContactPlaceholder"), type: "text", value: vendorContact || "" }), _jsx(EnhancedInput, { error: errors.invoiceNumber ? t(errors.invoiceNumber) : undefined, id: "invoiceNumber", info: t("formInvoiceNumberInfo"), label: t("formInvoiceNumberLabel"), onChange: (e) => handleChange("invoiceNumber", e.target.value), placeholder: t("formInvoiceNumberPlaceholder"), type: "text", value: invoiceNumber || "" }), paymentMethodCombo, _jsx(EnhancedInput, { error: errors.paymentDate ? t(errors.paymentDate) : undefined, id: "paymentDate", info: t("formPaymentDateInfo"), label: t("formPaymentDateLabel"), onChange: (e) => handleChange("paymentDate", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, type: "date", value: paymentDate || "" }), _jsx(EnhancedInput, { error: errors.receiptNumber ? t(errors.receiptNumber) : undefined, id: "receiptNumber", info: t("formReceiptNumberInfo"), label: t("formReceiptNumberLabel"), onChange: (e) => handleChange("receiptNumber", e.target.value), placeholder: t("formReceiptNumberPlaceholder"), type: "text", value: receiptNumber || "" }), _jsx(EnhancedInput, { error: errors.transactionId ? t(errors.transactionId) : undefined, id: "transactionId", info: t("formTransactionIdInfo"), label: t("formTransactionIdLabel"), onChange: (e) => handleChange("transactionId", e.target.value), placeholder: t("formTransactionIdPlaceholder"), type: "text", value: transactionId || "" }), _jsx(EnhancedTextarea, { error: errors.remarks, id: "remarks", label: t("formRemarksLabel"), onChange: (e) => handleChange("remarks", e.target.value), placeholder: t("formRemarksPlaceholder"), rows: 3, value: remarks || "" }), _jsx(EnhancedDropzone, { accept: ["image/*", "application/pdf"], error: errors.attachments ? t(errors.attachments) : undefined, id: "attachments", info: t("formAttachmentsInfo"), label: t("formAttachmentsLabel"), maxFiles: 10, onChange: (files) => {
58
+ const isPaid = status === "PAID";
59
+ return (_jsxs("div", { className: "space-y-4", children: [_jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "title", t }), id: "title", info: t("formTitleInfo"), label: t("formTitleLabel"), maxLength: 200, onChange: (e) => handleChange("title", e.target.value), placeholder: t("formTitlePlaceholder"), required: true, type: "text", value: title || "" }), _jsx(EnhancedCombobox, { emptyText: t("formNoCategoryEmpty"), error: getTranslatedError({ errors, key: "category", t }), id: "category", info: t("formCategoryInfo"), label: t("formCategoryLabel"), onValueChange: (value) => handleChange("category", value), options: EXPENSE_CATEGORY_OPTIONS.map((opt) => ({
60
+ value: opt.value,
61
+ label: categoryLabelMap[opt.value] || opt.label,
62
+ })), placeholder: t("formCategoryPlaceholder"), required: true, searchPlaceholder: t("formCategoryPlaceholder"), value: category || "" }), _jsx(EnhancedCombobox, { emptyText: t("formNoStatusEmpty"), error: getTranslatedError({ errors, key: "status", t }), id: "status", info: t("formStatusInfo"), label: t("formStatusLabel"), onValueChange: (value) => handleChange("status", value), options: EXPENSE_STATUS_OPTIONS.map((opt) => ({
63
+ value: opt.value,
64
+ label: statusLabelMap[opt.value] || opt.label,
65
+ })), placeholder: t("formStatusPlaceholder"), required: true, searchPlaceholder: t("formStatusPlaceholder"), value: status || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "amount", t }), id: "amount", info: t("formAmountInfo", { currency }), label: t("formAmountLabel"), min: "0", onChange: (e) => handleChange("amount", Number(e.target.value)), placeholder: "0.00", required: true, step: "0.01", type: "number", value: amount }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "expenseDate", t }), id: "expenseDate", info: t("formExpenseDateInfo"), label: t("formExpenseDateLabel"), onChange: (e) => handleChange("expenseDate", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, required: true, type: "date", value: expenseDate || "" }), _jsx(EnhancedTextarea, { error: getTranslatedError({ errors, key: "description", t }), id: "description", label: t("formDescriptionLabel"), maxLength: 1000, onChange: (e) => handleChange("description", e.target.value), placeholder: t("formDescriptionPlaceholder"), rows: 3, value: description || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "vendorName", t }), id: "vendorName", info: t("formVendorNameInfo"), label: t("formVendorNameLabel"), maxLength: 200, onChange: (e) => handleChange("vendorName", e.target.value), placeholder: t("formVendorNamePlaceholder"), type: "text", value: vendorName || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "vendorContact", t }), id: "vendorContact", info: t("formVendorContactInfo"), label: t("formVendorContactLabel"), maxLength: 200, onChange: (e) => handleChange("vendorContact", e.target.value), placeholder: t("formVendorContactPlaceholder"), type: "text", value: vendorContact || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "invoiceNumber", t }), id: "invoiceNumber", info: t("formInvoiceNumberInfo"), label: t("formInvoiceNumberLabel"), maxLength: 100, onChange: (e) => handleChange("invoiceNumber", e.target.value), placeholder: t("formInvoiceNumberPlaceholder"), type: "text", value: invoiceNumber || "" }), isPaid ? (_jsxs(_Fragment, { children: [_jsx(EnhancedCombobox, { emptyText: t("formNoPaymentMethodEmpty"), id: "paymentMethod", info: t("formPaymentMethodInfo"), label: t("formPaymentMethodLabel"), onValueChange: (value) => handleChange("paymentMethod", value), options: PAYMENT_METHOD_OPTIONS.map((opt) => ({
66
+ value: opt.value,
67
+ label: paymentMethodLabelMap[opt.value] || opt.label,
68
+ })), placeholder: t("formPaymentMethodPlaceholder"), searchPlaceholder: t("formPaymentMethodPlaceholder"), value: paymentMethod || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "paymentDate", t }), id: "paymentDate", info: t("formPaymentDateInfo"), label: t("formPaymentDateLabel"), onChange: (e) => handleChange("paymentDate", e.target.value), onClick: (e) => { var _a, _b; return (_b = (_a = e.currentTarget).showPicker) === null || _b === void 0 ? void 0 : _b.call(_a); }, type: "date", value: paymentDate || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "receiptNumber", t }), id: "receiptNumber", info: t("formReceiptNumberInfo"), label: t("formReceiptNumberLabel"), maxLength: 100, onChange: (e) => handleChange("receiptNumber", e.target.value), placeholder: t("formReceiptNumberPlaceholder"), type: "text", value: receiptNumber || "" }), _jsx(EnhancedInput, { error: getTranslatedError({ errors, key: "transactionId", t }), id: "transactionId", info: t("formTransactionIdInfo"), label: t("formTransactionIdLabel"), maxLength: 100, onChange: (e) => handleChange("transactionId", e.target.value), placeholder: t("formTransactionIdPlaceholder"), type: "text", value: transactionId || "" })] })) : null, _jsx(EnhancedTextarea, { error: getTranslatedError({ errors, key: "remarks", t }), id: "remarks", label: t("formRemarksLabel"), maxLength: 1000, onChange: (e) => handleChange("remarks", e.target.value), placeholder: t("formRemarksPlaceholder"), rows: 3, value: remarks || "" }), _jsx(EnhancedDropzone, { accept: ["image/*", "application/pdf"], error: getTranslatedError({ errors, key: "attachments", t }), id: "attachments", info: t("formAttachmentsInfo"), label: t("formAttachmentsLabel"), maxFiles: 10, onChange: (files) => {
126
69
  const urls = files.map((f) => URL.createObjectURL(f));
127
70
  handleChange("attachments", urls);
128
71
  }, onRemoveRemote: (url) => {
129
72
  const newList = (attachments || []).filter((a) => a !== url);
130
73
  handleChange("attachments", newList);
131
- }, value: attachments || [] }), _jsx(EnhancedCheckbox, { checked: enabled, error: errors.enabled ? t(errors.enabled) : undefined, id: "enabled", info: t("formEnabledInfo"), label: t("badgeActive"), onCheckedChange: (checked) => handleChange("enabled", !!checked) })] }));
74
+ }, value: attachments || [] }), _jsx(EnhancedCheckbox, { checked: enabled, error: getTranslatedError({ errors, key: "enabled", t }), id: "enabled", info: t("formEnabledInfo"), label: t("badgeActive"), onCheckedChange: (checked) => handleChange("enabled", !!checked) })] }));
132
75
  };
@@ -15,13 +15,13 @@
15
15
  "use client";
16
16
  import { jsx as _jsx } from "react/jsx-runtime";
17
17
  import { useMemo } from "react";
18
+ import { useTranslations } from "next-intl";
18
19
  import { COMPONENT_TYPE } from "@appcorp/shadcn/components/enhanced-table";
19
20
  import { createGenericModulePage, } from "@react-pakistan/util-functions/factory/generic-component-factory";
20
21
  import { DATE_FORMATS, formatDate, } from "@react-pakistan/util-functions/general/format-date";
21
22
  import { useExpenseModule, ExpenseProvider, ExpenseApiProvider, } from "./context";
22
23
  import { ExpenseFilter } from "./filter";
23
24
  import { ExpenseForm } from "./form";
24
- import { ExpenseMoreActions } from "./more-actions";
25
25
  import { ExpenseView } from "./view";
26
26
  import { resolveRbacPermissions } from "../../utils/resolve-rbac-permissions";
27
27
  import { RbacNoAccess } from "../../components/rbac-no-access";
@@ -29,39 +29,12 @@ import { getCachedWorkspaceSync } from "../workspace/cache";
29
29
  // ============================================================================
30
30
  // TABLE COLUMN CONFIGURATION (static — lazy workspace currency per row)
31
31
  // ============================================================================
32
- const tableBodyCols = [
33
- { componentType: COMPONENT_TYPE.ID, key: "id" },
34
- { componentType: COMPONENT_TYPE.BOLD_TEXT, key: "title" },
35
- { componentType: COMPONENT_TYPE.TEXT, key: "category" },
36
- {
37
- componentType: COMPONENT_TYPE.TEXT,
38
- key: "amount",
39
- textFormatter: (_, row) => {
40
- var _a, _b, _c, _d;
41
- const currency = (_c = (_b = (_a = getCachedWorkspaceSync()) === null || _a === void 0 ? void 0 : _a.school) === null || _b === void 0 ? void 0 : _b.currency) !== null && _c !== void 0 ? _c : "";
42
- return `${currency} ${((_d = row.amount) !== null && _d !== void 0 ? _d : 0).toFixed(2)}`;
43
- },
44
- },
45
- {
46
- componentType: COMPONENT_TYPE.TEXT,
47
- key: "expenseDate",
48
- textFormatter: (_, row) => formatDate(row.expenseDate, DATE_FORMATS.LOCALE_DATE),
49
- },
50
- { componentType: COMPONENT_TYPE.TEXT, key: "status" },
51
- {
52
- componentType: COMPONENT_TYPE.TEXT,
53
- key: "vendorName",
54
- textFormatter: (_, row) => row.vendorName || "N/A",
55
- },
56
- { componentType: COMPONENT_TYPE.ACTIONS },
57
- ];
58
32
  // ============================================================================
59
33
  // COMPONENT FACTORY (creates JSX elements when config is created, not during render)
60
34
  // ============================================================================
61
35
  const createComponentInstances = () => ({
62
36
  filter: _jsx(ExpenseFilter, {}),
63
37
  form: _jsx(ExpenseForm, {}),
64
- moreActions: _jsx(ExpenseMoreActions, {}),
65
38
  view: _jsx(ExpenseView, {}),
66
39
  });
67
40
  const createExpenseConfig = ({ clearFilters, drawerButtonCancel, drawerButtonSave, drawerFilterDescription, drawerFilterTitle, drawerFormDescription, drawerFormTitle, drawerMoreActionsDescription, drawerMoreActionsTitle, drawerViewDescription, drawerViewTitle, tableColumnHeaderActions, tableColumnHeaderAmount, tableColumnHeaderCategory, tableColumnHeaderExpenseDate, tableColumnHeaderId, tableColumnHeaderStatus, tableColumnHeaderTitle, tableColumnHeaderVendorName, tableDescription, tableSearchPlaceholder, tableTitle, }) => {
@@ -89,7 +62,7 @@ const createExpenseConfig = ({ clearFilters, drawerButtonCancel, drawerButtonSav
89
62
  drawerViewTitle,
90
63
  filterContent: components.filter,
91
64
  formContent: components.form,
92
- moreActionsContent: components.moreActions,
65
+ moreActionsContent: null,
93
66
  saveLabel: drawerButtonSave,
94
67
  searchPlaceholder: tableSearchPlaceholder,
95
68
  tableDescription,
@@ -107,6 +80,64 @@ const GenericExpensePage = createGenericModulePage();
107
80
  // ============================================================================
108
81
  const ExpensePageInner = (props) => {
109
82
  const context = useExpenseModule();
83
+ const t = useTranslations("expense");
84
+ const categoryLabels = useMemo(() => ({
85
+ SALARY: t("formOptionSalary"),
86
+ UTILITIES: t("formOptionUtilities"),
87
+ MAINTENANCE: t("formOptionMaintenance"),
88
+ SUPPLIES: t("formOptionSupplies"),
89
+ TRANSPORT: t("formOptionTransport"),
90
+ MARKETING: t("formOptionMarketing"),
91
+ INSURANCE: t("formOptionInsurance"),
92
+ RENT: t("formOptionRent"),
93
+ TECHNOLOGY: t("formOptionTechnology"),
94
+ PROFESSIONAL: t("formOptionProfessional"),
95
+ TRAINING: t("formOptionTraining"),
96
+ EVENTS: t("formOptionEvents"),
97
+ FOOD: t("formOptionFood"),
98
+ MISCELLANEOUS: t("formOptionMiscellaneous"),
99
+ }), [t]);
100
+ const statusLabels = useMemo(() => ({
101
+ PENDING: t("formOptionPending"),
102
+ APPROVED: t("formOptionApproved"),
103
+ PAID: t("formOptionPaid"),
104
+ REJECTED: t("formOptionRejected"),
105
+ CANCELLED: t("formOptionCancelled"),
106
+ }), [t]);
107
+ const tableBodyCols = useMemo(() => [
108
+ { componentType: COMPONENT_TYPE.ID, key: "id" },
109
+ { componentType: COMPONENT_TYPE.BOLD_TEXT, key: "title" },
110
+ {
111
+ componentType: COMPONENT_TYPE.TEXT,
112
+ key: "category",
113
+ textFormatter: (value) => { var _a; return (_a = categoryLabels[String(value !== null && value !== void 0 ? value : "")]) !== null && _a !== void 0 ? _a : "—"; },
114
+ },
115
+ {
116
+ componentType: COMPONENT_TYPE.TEXT,
117
+ key: "amount",
118
+ textFormatter: (_, row) => {
119
+ var _a, _b, _c, _d;
120
+ const currency = (_c = (_b = (_a = getCachedWorkspaceSync()) === null || _a === void 0 ? void 0 : _a.school) === null || _b === void 0 ? void 0 : _b.currency) !== null && _c !== void 0 ? _c : "";
121
+ return `${currency} ${((_d = row.amount) !== null && _d !== void 0 ? _d : 0).toFixed(2)}`.trim();
122
+ },
123
+ },
124
+ {
125
+ componentType: COMPONENT_TYPE.TEXT,
126
+ key: "expenseDate",
127
+ textFormatter: (value) => value ? formatDate(value, DATE_FORMATS.LOCALE_DATE) : "—",
128
+ },
129
+ {
130
+ componentType: COMPONENT_TYPE.TEXT,
131
+ key: "status",
132
+ textFormatter: (value) => { var _a; return (_a = statusLabels[String(value !== null && value !== void 0 ? value : "")]) !== null && _a !== void 0 ? _a : "—"; },
133
+ },
134
+ {
135
+ componentType: COMPONENT_TYPE.TEXT,
136
+ key: "vendorName",
137
+ textFormatter: (value) => value || "—",
138
+ },
139
+ { componentType: COMPONENT_TYPE.ACTIONS },
140
+ ], [categoryLabels, statusLabels]);
110
141
  // Memoize config creation - destructure props to avoid object reference changes
111
142
  const expenseConfig = useMemo(() => createExpenseConfig({
112
143
  clearFilters: context.clearFilters,
@@ -1,31 +1,37 @@
1
1
  /**
2
2
  * Expense Module Validation
3
3
  *
4
- * Zod validation schemas for expense forms.
4
+ * Zod validation schemas for expense forms. Optional text fields accept
5
+ * `null` because the API returns `null` for empty values.
5
6
  */
6
7
  import { z } from "zod";
7
8
  import { EXPENSE_CATEGORY, EXPENSE_STATUS, PAYMENT_METHOD } from "../../type";
8
9
  export declare const VALIDATION_KEYS: {
9
10
  readonly titleRequired: "validationExpenseTitleRequired";
11
+ readonly titleMaxLength: "validationExpenseTitleMaxLength";
10
12
  readonly amountRequired: "validationExpenseAmountRequired";
11
13
  readonly categoryRequired: "validationExpenseCategoryRequired";
12
14
  readonly expenseDateRequired: "validationExpenseExpenseDateRequired";
15
+ readonly invalidDate: "validationExpenseInvalidDate";
13
16
  readonly statusRequired: "validationExpenseStatusRequired";
14
- readonly idForUpdateRequired: "validationExpenseIdForUpdateRequired";
15
17
  };
16
18
  export declare const expenseFormValidation: z.ZodObject<{
17
19
  amount: z.ZodNumber;
18
20
  category: z.ZodEnum<typeof EXPENSE_CATEGORY>;
19
- description: z.ZodOptional<z.ZodString>;
21
+ description: z.ZodOptional<z.ZodNullable<z.ZodString>>;
20
22
  expenseDate: z.ZodString;
21
- invoiceNumber: z.ZodOptional<z.ZodString>;
22
- paymentDate: z.ZodOptional<z.ZodString>;
23
- paymentMethod: z.ZodOptional<z.ZodEnum<typeof PAYMENT_METHOD>>;
24
- receiptNumber: z.ZodOptional<z.ZodString>;
25
- remarks: z.ZodOptional<z.ZodString>;
23
+ invoiceNumber: z.ZodOptional<z.ZodNullable<z.ZodString>>;
24
+ paymentDate: z.ZodOptional<z.ZodNullable<z.ZodString>>;
25
+ paymentMethod: z.ZodOptional<z.ZodNullable<z.ZodEnum<typeof PAYMENT_METHOD>>>;
26
+ receiptNumber: z.ZodOptional<z.ZodNullable<z.ZodString>>;
27
+ remarks: z.ZodOptional<z.ZodNullable<z.ZodString>>;
26
28
  status: z.ZodEnum<typeof EXPENSE_STATUS>;
27
29
  title: z.ZodString;
28
- transactionId: z.ZodOptional<z.ZodString>;
29
- vendorContact: z.ZodOptional<z.ZodString>;
30
- vendorName: z.ZodOptional<z.ZodString>;
30
+ transactionId: z.ZodOptional<z.ZodNullable<z.ZodString>>;
31
+ vendorContact: z.ZodOptional<z.ZodNullable<z.ZodString>>;
32
+ vendorName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
33
+ approvedBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
34
+ paidBy: z.ZodOptional<z.ZodNullable<z.ZodString>>;
35
+ attachments: z.ZodOptional<z.ZodArray<z.ZodString>>;
36
+ enabled: z.ZodOptional<z.ZodBoolean>;
31
37
  }, z.core.$strip>;
@@ -1,35 +1,56 @@
1
1
  /**
2
2
  * Expense Module Validation
3
3
  *
4
- * Zod validation schemas for expense forms.
4
+ * Zod validation schemas for expense forms. Optional text fields accept
5
+ * `null` because the API returns `null` for empty values.
5
6
  */
6
7
  import { z } from "zod";
7
8
  import { EXPENSE_CATEGORY, EXPENSE_STATUS, PAYMENT_METHOD } from "../../type";
8
9
  export const VALIDATION_KEYS = {
9
10
  titleRequired: "validationExpenseTitleRequired",
11
+ titleMaxLength: "validationExpenseTitleMaxLength",
10
12
  amountRequired: "validationExpenseAmountRequired",
11
13
  categoryRequired: "validationExpenseCategoryRequired",
12
14
  expenseDateRequired: "validationExpenseExpenseDateRequired",
15
+ invalidDate: "validationExpenseInvalidDate",
13
16
  statusRequired: "validationExpenseStatusRequired",
14
- idForUpdateRequired: "validationExpenseIdForUpdateRequired",
15
17
  };
18
+ const optionalText = z.string().nullable().optional();
19
+ const validDate = (value) => !Number.isNaN(new Date(value).getTime());
16
20
  export const expenseFormValidation = z.object({
17
- amount: z.number().min(0.01, VALIDATION_KEYS.amountRequired),
21
+ amount: z
22
+ .number({ error: VALIDATION_KEYS.amountRequired })
23
+ .positive(VALIDATION_KEYS.amountRequired),
18
24
  category: z.nativeEnum(EXPENSE_CATEGORY, {
19
25
  error: VALIDATION_KEYS.categoryRequired,
20
26
  }),
21
- description: z.string().optional(),
22
- expenseDate: z.string().nonempty(VALIDATION_KEYS.expenseDateRequired),
23
- invoiceNumber: z.string().optional(),
24
- paymentDate: z.string().optional(),
25
- paymentMethod: z.nativeEnum(PAYMENT_METHOD).optional(),
26
- receiptNumber: z.string().optional(),
27
- remarks: z.string().optional(),
27
+ description: optionalText,
28
+ expenseDate: z
29
+ .string()
30
+ .min(1, VALIDATION_KEYS.expenseDateRequired)
31
+ .refine(validDate, VALIDATION_KEYS.invalidDate),
32
+ invoiceNumber: optionalText,
33
+ paymentDate: z
34
+ .string()
35
+ .nullable()
36
+ .optional()
37
+ .refine((value) => !value || validDate(value), VALIDATION_KEYS.invalidDate),
38
+ paymentMethod: z.nativeEnum(PAYMENT_METHOD).nullable().optional(),
39
+ receiptNumber: optionalText,
40
+ remarks: optionalText,
28
41
  status: z.nativeEnum(EXPENSE_STATUS, {
29
42
  error: VALIDATION_KEYS.statusRequired,
30
43
  }),
31
- title: z.string().min(1, VALIDATION_KEYS.titleRequired),
32
- transactionId: z.string().optional(),
33
- vendorContact: z.string().optional(),
34
- vendorName: z.string().optional(),
44
+ title: z
45
+ .string()
46
+ .trim()
47
+ .min(1, VALIDATION_KEYS.titleRequired)
48
+ .max(200, VALIDATION_KEYS.titleMaxLength),
49
+ transactionId: optionalText,
50
+ vendorContact: optionalText,
51
+ vendorName: optionalText,
52
+ approvedBy: optionalText,
53
+ paidBy: optionalText,
54
+ attachments: z.array(z.string()).optional(),
55
+ enabled: z.boolean().optional(),
35
56
  });
@@ -1,4 +1,4 @@
1
- import { FamilyBE } from "../../type";
1
+ import { FamilyBE, FamilyMemberBE } from "../../type";
2
2
  import { TableRow, type RowAction } from "@appcorp/shadcn/components/enhanced-table";
3
3
  export declare const FAMILY_DRAWER: {
4
4
  readonly FILTER_DRAWER: string;
@@ -33,10 +33,11 @@ export declare const FAMILY_ACTION_TYPES: {
33
33
  errors: Record<string, string>;
34
34
  familyCode: string;
35
35
  filterEnabled: boolean | undefined;
36
+ appliedFilterEnabled: boolean | undefined;
36
37
  id: string;
38
+ members: FamilyMemberBE[];
37
39
  postalCode: string;
38
40
  stateProvince: string;
39
- userId: string;
40
41
  }>, initialFamilyState: {
41
42
  items: FamilyBE[];
42
43
  count: number;
@@ -52,10 +53,11 @@ export declare const FAMILY_ACTION_TYPES: {
52
53
  errors: Record<string, string>;
53
54
  familyCode: string;
54
55
  filterEnabled: boolean | undefined;
56
+ appliedFilterEnabled: boolean | undefined;
55
57
  id: string;
58
+ members: FamilyMemberBE[];
56
59
  postalCode: string;
57
60
  stateProvince: string;
58
- userId: string;
59
61
  }, FamilyProvider: import("react").FC<{
60
62
  children: React.ReactNode;
61
63
  }>, familyReducer: (state: {
@@ -73,10 +75,11 @@ export declare const FAMILY_ACTION_TYPES: {
73
75
  errors: Record<string, string>;
74
76
  familyCode: string;
75
77
  filterEnabled: boolean | undefined;
78
+ appliedFilterEnabled: boolean | undefined;
76
79
  id: string;
80
+ members: FamilyMemberBE[];
77
81
  postalCode: string;
78
82
  stateProvince: string;
79
- userId: string;
80
83
  }, action: any) => {
81
84
  items: FamilyBE[];
82
85
  count: number;
@@ -92,10 +95,11 @@ export declare const FAMILY_ACTION_TYPES: {
92
95
  errors: Record<string, string>;
93
96
  familyCode: string;
94
97
  filterEnabled: boolean | undefined;
98
+ appliedFilterEnabled: boolean | undefined;
95
99
  id: string;
100
+ members: FamilyMemberBE[];
96
101
  postalCode: string;
97
102
  stateProvince: string;
98
- userId: string;
99
103
  }, useFamilyContext: () => import("@react-pakistan/util-functions/factory/generic-module-factory").GenericModuleContextWithHandlers<{
100
104
  items: FamilyBE[];
101
105
  count: number;
@@ -111,10 +115,11 @@ export declare const FAMILY_ACTION_TYPES: {
111
115
  errors: Record<string, string>;
112
116
  familyCode: string;
113
117
  filterEnabled: boolean | undefined;
118
+ appliedFilterEnabled: boolean | undefined;
114
119
  id: string;
120
+ members: FamilyMemberBE[];
115
121
  postalCode: string;
116
122
  stateProvince: string;
117
- userId: string;
118
123
  }>;
119
124
  /**
120
125
  * Backward-compatible alias used by dashboard-providers.tsx
@@ -130,11 +135,9 @@ export declare const useFamilyModule: () => {
130
135
  deleteLoading: boolean;
131
136
  handleChange: (field: string, value: string | number | boolean | undefined | null) => void;
132
137
  handleCloseDrawer: () => void;
133
- handleCreate: () => void;
134
138
  handleDelete: (row?: TableRow) => void;
135
139
  handleEdit: (row?: TableRow) => void;
136
140
  handleFilters: () => void;
137
- handleMoreActions: () => void;
138
141
  handlePageChange: (page: number | unknown) => void;
139
142
  handlePageLimitChange: (_k: string, value: object) => void;
140
143
  handleSearch: (query: string) => void;
@@ -166,10 +169,11 @@ export declare const useFamilyModule: () => {
166
169
  errors: Record<string, string>;
167
170
  familyCode: string;
168
171
  filterEnabled: boolean | undefined;
172
+ appliedFilterEnabled: boolean | undefined;
169
173
  id: string;
174
+ members: FamilyMemberBE[];
170
175
  postalCode: string;
171
176
  stateProvince: string;
172
- userId: string;
173
177
  };
174
178
  dispatch: React.Dispatch<any>;
175
179
  };