@wealthx/shadcn 1.2.2 → 1.3.1

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 (230) hide show
  1. package/.turbo/turbo-build.log +193 -149
  2. package/CHANGELOG.md +28 -0
  3. package/dist/{chunk-4Y6R4WEC.mjs → chunk-2A5RRQGG.mjs} +9 -22
  4. package/dist/{chunk-TS2ZX2VS.mjs → chunk-2UM72RJ7.mjs} +11 -15
  5. package/dist/{chunk-A56YQQHG.mjs → chunk-3NCUZIFP.mjs} +2 -2
  6. package/dist/chunk-3OYFOX3X.mjs +79 -0
  7. package/dist/{chunk-RP3SQYA3.mjs → chunk-3TTACBDP.mjs} +9 -4
  8. package/dist/chunk-4GAWMKMI.mjs +710 -0
  9. package/dist/{chunk-VGSESELX.mjs → chunk-5FQIKDKP.mjs} +5 -5
  10. package/dist/{chunk-K3JYD4IU.mjs → chunk-5IS7G74I.mjs} +11 -4
  11. package/dist/chunk-6AW4KJHE.mjs +235 -0
  12. package/dist/chunk-6CR5N2JW.mjs +302 -0
  13. package/dist/{chunk-XIRTEFKH.mjs → chunk-6DZEXFNB.mjs} +36 -8
  14. package/dist/chunk-6O6KD7CE.mjs +271 -0
  15. package/dist/chunk-7PV3IWCN.mjs +33 -0
  16. package/dist/{chunk-SPJ5KXW7.mjs → chunk-7S5AESZO.mjs} +5 -5
  17. package/dist/{chunk-RYCLWMZ7.mjs → chunk-ABFDMHOR.mjs} +9 -7
  18. package/dist/{chunk-SWGT756Z.mjs → chunk-AMQZRHEZ.mjs} +10 -4
  19. package/dist/{chunk-WAZD7NFU.mjs → chunk-BKNFWEH2.mjs} +6 -6
  20. package/dist/{chunk-CLIN5525.mjs → chunk-C7CQJNMR.mjs} +1 -1
  21. package/dist/{chunk-D4ILTPOG.mjs → chunk-CFMQP5QS.mjs} +5 -4
  22. package/dist/{chunk-VPBN3WOO.mjs → chunk-DGHAXJBN.mjs} +9 -7
  23. package/dist/chunk-DOEO3CDL.mjs +27 -0
  24. package/dist/{chunk-5MEWU56Z.mjs → chunk-DUJTAXMH.mjs} +11 -6
  25. package/dist/{chunk-GGM2UYGG.mjs → chunk-EBXQWIYG.mjs} +10 -4
  26. package/dist/chunk-EWRB4PAD.mjs +468 -0
  27. package/dist/{chunk-ZSHYDDRB.mjs → chunk-FAKPBKLT.mjs} +6 -2
  28. package/dist/{chunk-A6AAWBPF.mjs → chunk-GHC7LLUX.mjs} +13 -4
  29. package/dist/chunk-HBZLGDIN.mjs +507 -0
  30. package/dist/{chunk-SIZMLSRU.mjs → chunk-HISNT2MG.mjs} +8 -6
  31. package/dist/{chunk-CGH4DRNG.mjs → chunk-HVY6KCCF.mjs} +10 -7
  32. package/dist/chunk-I3RZS7V2.mjs +136 -0
  33. package/dist/chunk-IAE3F7DR.mjs +1962 -0
  34. package/dist/{chunk-UT4KJR7V.mjs → chunk-IHMFS7NZ.mjs} +35 -74
  35. package/dist/{chunk-PCPLO5HT.mjs → chunk-IOJRDS6V.mjs} +96 -14
  36. package/dist/{chunk-LHYCMLVA.mjs → chunk-JKGDCQTZ.mjs} +11 -4
  37. package/dist/{chunk-H45TKD34.mjs → chunk-JMHR3YGZ.mjs} +1 -1
  38. package/dist/{chunk-4MN6UQHG.mjs → chunk-K5A5L6T2.mjs} +17 -39
  39. package/dist/chunk-LV35NGVG.mjs +272 -0
  40. package/dist/{chunk-FZIXGLMV.mjs → chunk-M3FV7LOK.mjs} +5 -12
  41. package/dist/{chunk-FMAXJ2SI.mjs → chunk-MBON7YRJ.mjs} +1 -1
  42. package/dist/chunk-MIZQHHUO.mjs +441 -0
  43. package/dist/chunk-MLNEWRWV.mjs +449 -0
  44. package/dist/chunk-MN5NYQCL.mjs +29 -0
  45. package/dist/chunk-NL3ZO62D.mjs +31 -0
  46. package/dist/{chunk-Q76O3RIQ.mjs → chunk-NMOI6CQD.mjs} +1 -1
  47. package/dist/{chunk-P6AM5V7O.mjs → chunk-OODBHKG7.mjs} +1 -1
  48. package/dist/chunk-PBL4OQV2.mjs +283 -0
  49. package/dist/{chunk-Y4QFWRNR.mjs → chunk-PU4YZQXV.mjs} +17 -18
  50. package/dist/chunk-Q2BGOAMG.mjs +202 -0
  51. package/dist/chunk-QMY3AZJH.mjs +80 -0
  52. package/dist/{chunk-BL3DXM2X.mjs → chunk-QZ4RE6NA.mjs} +11 -4
  53. package/dist/{chunk-VACKZOMY.mjs → chunk-R3VSPKNP.mjs} +3 -3
  54. package/dist/{chunk-OPNQAVVH.mjs → chunk-RJI6GKVF.mjs} +8 -6
  55. package/dist/{chunk-WG6JGJXB.mjs → chunk-T4BJLT57.mjs} +1 -1
  56. package/dist/chunk-UMTOX62O.mjs +415 -0
  57. package/dist/{chunk-7MMXNK3C.mjs → chunk-VLARHE5V.mjs} +8 -6
  58. package/dist/{chunk-2I5S2AMY.mjs → chunk-XREGSKX3.mjs} +2 -2
  59. package/dist/{chunk-JNQORUPP.mjs → chunk-YJG55G2H.mjs} +14 -11
  60. package/dist/components/ui/add-column-modal.js +42 -14
  61. package/dist/components/ui/add-column-modal.mjs +5 -5
  62. package/dist/components/ui/add-lead-modal.js +42 -11
  63. package/dist/components/ui/add-lead-modal.mjs +3 -3
  64. package/dist/components/ui/advisor-card.js +530 -0
  65. package/dist/components/ui/advisor-card.mjs +15 -0
  66. package/dist/components/ui/ai-assistant-drawer.js +11 -10
  67. package/dist/components/ui/ai-assistant-drawer.mjs +3 -3
  68. package/dist/components/ui/alert-dialog.js +2 -2
  69. package/dist/components/ui/alert-dialog.mjs +2 -2
  70. package/dist/components/ui/appointment-action-dialogs.js +1160 -0
  71. package/dist/components/ui/appointment-action-dialogs.mjs +23 -0
  72. package/dist/components/ui/appointment-availability-settings.js +1590 -0
  73. package/dist/components/ui/appointment-availability-settings.mjs +23 -0
  74. package/dist/components/ui/appointment-book-dialog.js +1744 -0
  75. package/dist/components/ui/appointment-book-dialog.mjs +27 -0
  76. package/dist/components/ui/appointment-calendar-view.js +833 -0
  77. package/dist/components/ui/appointment-calendar-view.mjs +14 -0
  78. package/dist/components/ui/appointment-detail-sheet.js +1517 -0
  79. package/dist/components/ui/appointment-detail-sheet.mjs +24 -0
  80. package/dist/components/ui/appointment-gmail-connect.js +467 -0
  81. package/dist/components/ui/appointment-gmail-connect.mjs +14 -0
  82. package/dist/components/ui/appointment-mini-card.js +345 -0
  83. package/dist/components/ui/appointment-mini-card.mjs +11 -0
  84. package/dist/components/ui/appointment-time-slot-picker.js +311 -0
  85. package/dist/components/ui/appointment-time-slot-picker.mjs +13 -0
  86. package/dist/components/ui/appointment-upcoming-card.js +1268 -0
  87. package/dist/components/ui/appointment-upcoming-card.mjs +21 -0
  88. package/dist/components/ui/backoffice-alert-history-chart.js +11 -5
  89. package/dist/components/ui/backoffice-alert-history-chart.mjs +5 -4
  90. package/dist/components/ui/backoffice-alerts-chart.js +786 -0
  91. package/dist/components/ui/backoffice-alerts-chart.mjs +19 -0
  92. package/dist/components/ui/backoffice-connections-chart.js +817 -0
  93. package/dist/components/ui/backoffice-connections-chart.mjs +19 -0
  94. package/dist/components/ui/backoffice-contact-history-chart.js +11 -5
  95. package/dist/components/ui/backoffice-contact-history-chart.mjs +5 -4
  96. package/dist/components/ui/badge.js +6 -6
  97. package/dist/components/ui/badge.mjs +1 -1
  98. package/dist/components/ui/borrowing-capacity-line-chart.js +30 -21
  99. package/dist/components/ui/borrowing-capacity-line-chart.mjs +5 -4
  100. package/dist/components/ui/button.js +2 -2
  101. package/dist/components/ui/button.mjs +1 -1
  102. package/dist/components/ui/calendar.js +2 -2
  103. package/dist/components/ui/calendar.mjs +2 -2
  104. package/dist/components/ui/card.js +1 -1
  105. package/dist/components/ui/card.mjs +1 -1
  106. package/dist/components/ui/cash-balance-line-chart.js +31 -23
  107. package/dist/components/ui/cash-balance-line-chart.mjs +5 -4
  108. package/dist/components/ui/cashflow-bar-chart.js +12 -5
  109. package/dist/components/ui/cashflow-bar-chart.mjs +5 -4
  110. package/dist/components/ui/chip.js +97 -18
  111. package/dist/components/ui/chip.mjs +3 -2
  112. package/dist/components/ui/color-picker.js +158 -28
  113. package/dist/components/ui/color-picker.mjs +3 -1
  114. package/dist/components/ui/data-table.js +140 -119
  115. package/dist/components/ui/data-table.mjs +3 -2
  116. package/dist/components/ui/date-picker.js +48 -27
  117. package/dist/components/ui/date-picker.mjs +4 -3
  118. package/dist/components/ui/dialog.js +37 -9
  119. package/dist/components/ui/dialog.mjs +2 -2
  120. package/dist/components/ui/expense-bar-chart.js +12 -5
  121. package/dist/components/ui/expense-bar-chart.mjs +5 -4
  122. package/dist/components/ui/field.mjs +2 -2
  123. package/dist/components/ui/financial-cards.js +322 -155
  124. package/dist/components/ui/financial-cards.mjs +5 -3
  125. package/dist/components/ui/financial-drawers.js +2 -2
  126. package/dist/components/ui/financial-drawers.mjs +3 -3
  127. package/dist/components/ui/financial-sections.js +14 -10
  128. package/dist/components/ui/financial-sections.mjs +6 -5
  129. package/dist/components/ui/income-bar-chart.js +12 -5
  130. package/dist/components/ui/income-bar-chart.mjs +5 -4
  131. package/dist/components/ui/input-group.js +2 -2
  132. package/dist/components/ui/input-group.mjs +2 -2
  133. package/dist/components/ui/kanban-column.js +52 -44
  134. package/dist/components/ui/kanban-column.mjs +7 -5
  135. package/dist/components/ui/opportunity-card.js +52 -44
  136. package/dist/components/ui/opportunity-card.mjs +6 -4
  137. package/dist/components/ui/opportunity-edit-modals.js +1367 -1263
  138. package/dist/components/ui/opportunity-edit-modals.mjs +8 -8
  139. package/dist/components/ui/opportunity-summary-tab.js +2744 -2157
  140. package/dist/components/ui/opportunity-summary-tab.mjs +14 -14
  141. package/dist/components/ui/page-header.js +92 -0
  142. package/dist/components/ui/page-header.mjs +8 -0
  143. package/dist/components/ui/page-top-bar.js +88 -0
  144. package/dist/components/ui/page-top-bar.mjs +8 -0
  145. package/dist/components/ui/pagination.js +303 -19
  146. package/dist/components/ui/pagination.mjs +11 -4
  147. package/dist/components/ui/pipeline-board.js +205 -191
  148. package/dist/components/ui/pipeline-board.mjs +9 -7
  149. package/dist/components/ui/pipeline-dialogs.js +114 -65
  150. package/dist/components/ui/pipeline-dialogs.mjs +7 -6
  151. package/dist/components/ui/pipeline-primitives.js +6 -6
  152. package/dist/components/ui/pipeline-primitives.mjs +2 -2
  153. package/dist/components/ui/property-cashflow-doughnut-chart.js +14 -12
  154. package/dist/components/ui/property-cashflow-doughnut-chart.mjs +5 -4
  155. package/dist/components/ui/property-debt-equity-doughnut-chart.js +14 -12
  156. package/dist/components/ui/property-debt-equity-doughnut-chart.mjs +5 -4
  157. package/dist/components/ui/property-mobile-estimate-line-chart.js +16 -14
  158. package/dist/components/ui/property-mobile-estimate-line-chart.mjs +5 -4
  159. package/dist/components/ui/sidebar-nav.js +426 -191
  160. package/dist/components/ui/sidebar-nav.mjs +5 -1
  161. package/dist/components/ui/stage-timeline.js +6 -6
  162. package/dist/components/ui/stage-timeline.mjs +3 -3
  163. package/dist/components/ui/transactions-expense-categories-doughnut-chart.js +18 -16
  164. package/dist/components/ui/transactions-expense-categories-doughnut-chart.mjs +5 -4
  165. package/dist/components/ui/transactions-income-expense-bar-chart.js +28 -12
  166. package/dist/components/ui/transactions-income-expense-bar-chart.mjs +5 -4
  167. package/dist/components/ui/transactions-liabilities-breakdown-doughnut-chart.js +18 -16
  168. package/dist/components/ui/transactions-liabilities-breakdown-doughnut-chart.mjs +5 -4
  169. package/dist/index.js +12258 -8611
  170. package/dist/index.mjs +258 -190
  171. package/dist/styles.css +1 -1
  172. package/package.json +71 -1
  173. package/src/components/index.tsx +115 -9
  174. package/src/components/ui/add-column-modal.tsx +7 -7
  175. package/src/components/ui/add-lead-modal.tsx +6 -3
  176. package/src/components/ui/advisor-card.tsx +284 -0
  177. package/src/components/ui/ai-assistant-drawer.tsx +4 -3
  178. package/src/components/ui/appointment-action-dialogs.tsx +297 -0
  179. package/src/components/ui/appointment-availability-settings.tsx +645 -0
  180. package/src/components/ui/appointment-book-dialog.tsx +618 -0
  181. package/src/components/ui/appointment-calendar-view.tsx +510 -0
  182. package/src/components/ui/appointment-detail-sheet.tsx +415 -0
  183. package/src/components/ui/appointment-gmail-connect.tsx +188 -0
  184. package/src/components/ui/appointment-mini-card.tsx +104 -0
  185. package/src/components/ui/appointment-time-slot-picker.tsx +123 -0
  186. package/src/components/ui/appointment-upcoming-card.tsx +635 -0
  187. package/src/components/ui/backoffice-alert-history-chart.tsx +10 -2
  188. package/src/components/ui/backoffice-alerts-chart.tsx +312 -0
  189. package/src/components/ui/backoffice-connections-chart.tsx +339 -0
  190. package/src/components/ui/backoffice-contact-history-chart.tsx +10 -2
  191. package/src/components/ui/badge.tsx +12 -6
  192. package/src/components/ui/borrowing-capacity-line-chart.tsx +4 -11
  193. package/src/components/ui/button.tsx +2 -2
  194. package/src/components/ui/card.tsx +1 -1
  195. package/src/components/ui/cash-balance-line-chart.tsx +4 -23
  196. package/src/components/ui/cashflow-bar-chart.tsx +9 -2
  197. package/src/components/ui/chart-shared.tsx +4 -11
  198. package/src/components/ui/chip.tsx +23 -19
  199. package/src/components/ui/color-picker.tsx +4 -2
  200. package/src/components/ui/data-table.tsx +28 -74
  201. package/src/components/ui/date-picker.tsx +42 -37
  202. package/src/components/ui/dialog.tsx +72 -6
  203. package/src/components/ui/expense-bar-chart.tsx +11 -2
  204. package/src/components/ui/financial-cards.tsx +99 -10
  205. package/src/components/ui/income-bar-chart.tsx +11 -2
  206. package/src/components/ui/opportunity-card.tsx +10 -39
  207. package/src/components/ui/opportunity-edit-modals.tsx +98 -36
  208. package/src/components/ui/opportunity-summary-tab.tsx +548 -232
  209. package/src/components/ui/page-header.tsx +57 -0
  210. package/src/components/ui/page-top-bar.tsx +48 -0
  211. package/src/components/ui/pagination.tsx +171 -22
  212. package/src/components/ui/pipeline-board.tsx +12 -5
  213. package/src/components/ui/property-cashflow-doughnut-chart.tsx +3 -1
  214. package/src/components/ui/property-debt-equity-doughnut-chart.tsx +3 -1
  215. package/src/components/ui/property-mobile-estimate-line-chart.tsx +3 -1
  216. package/src/components/ui/sidebar-nav.tsx +213 -157
  217. package/src/components/ui/transactions-expense-categories-doughnut-chart.tsx +3 -1
  218. package/src/components/ui/transactions-income-expense-bar-chart.tsx +12 -9
  219. package/src/components/ui/transactions-liabilities-breakdown-doughnut-chart.tsx +3 -1
  220. package/src/lib/format-currency.ts +44 -0
  221. package/src/lib/format-date.ts +50 -0
  222. package/src/lib/opportunity-constants.ts +12 -0
  223. package/src/styles/globals.css +17 -15
  224. package/src/styles/styles-css.ts +1 -1
  225. package/tsup.config.ts +14 -0
  226. package/dist/chunk-S4QRUQNW.mjs +0 -475
  227. package/dist/chunk-URGMJAE3.mjs +0 -1885
  228. package/dist/chunk-WNGWBVLV.mjs +0 -148
  229. package/dist/chunk-ZRSDX6OW.mjs +0 -385
  230. package/dist/{chunk-LLVQKSU3.mjs → chunk-GD4BJDJR.mjs} +3 -3
@@ -109,6 +109,15 @@ function cn(...inputs) {
109
109
  return twMerge((0, import_clsx.clsx)(inputs));
110
110
  }
111
111
 
112
+ // src/lib/opportunity-constants.ts
113
+ var PROPERTY_ASSET_TYPES = /* @__PURE__ */ new Set([
114
+ "Primary Residence",
115
+ "Investment Property",
116
+ "Holiday Home",
117
+ "Commercial Property",
118
+ "Rural Property"
119
+ ]);
120
+
112
121
  // src/components/ui/dialog.tsx
113
122
  var import_lucide_react2 = require("lucide-react");
114
123
  var import_dialog = require("@base-ui/react/dialog");
@@ -183,10 +192,10 @@ var buttonVariants = (0, import_class_variance_authority.cva)(
183
192
  default: "bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",
184
193
  secondary: "bg-brand-secondary text-brand-secondary-foreground shadow-xs hover:bg-brand-secondary/80 focus-visible:ring-brand-secondary/30",
185
194
  destructive: "bg-destructive text-destructive-foreground shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:bg-destructive/60 dark:focus-visible:ring-destructive/40",
186
- outline: "border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
195
+ outline: "border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground focus-visible:ring-border/50 dark:bg-input/30 dark:border-input dark:hover:bg-input/50",
187
196
  "outline-primary": "border border-primary text-foreground bg-transparent shadow-xs hover:bg-primary/5 focus-visible:ring-primary/50",
188
197
  "outline-secondary": "border border-brand-secondary text-brand-secondary bg-transparent shadow-xs hover:bg-brand-secondary/10 focus-visible:ring-brand-secondary/30",
189
- ghost: "hover:bg-accent hover:text-accent-foreground hover:shadow-xs dark:hover:bg-accent/50",
198
+ ghost: "hover:bg-accent hover:text-accent-foreground hover:shadow-xs focus-visible:ring-border/50 dark:hover:bg-accent/50",
190
199
  link: "text-primary underline-offset-4 hover:underline"
191
200
  },
192
201
  size: {
@@ -275,38 +284,65 @@ function DialogOverlay(_a) {
275
284
  }, props)
276
285
  );
277
286
  }
287
+ var DIALOG_MAX_WIDTHS = {
288
+ sm: "24rem",
289
+ md: "28rem",
290
+ lg: "32rem",
291
+ xl: "36rem",
292
+ "2xl": "42rem",
293
+ "3xl": "48rem",
294
+ "4xl": "56rem",
295
+ full: "100%"
296
+ };
297
+ var DIALOG_AUTO_MIN_WIDTH = "20rem";
278
298
  function DialogContent(_a) {
279
299
  var _b = _a, {
280
300
  className,
281
301
  children,
282
302
  showCloseButton = true,
283
- style
303
+ style,
304
+ container,
305
+ align = "center",
306
+ size = "lg",
307
+ minWidth
284
308
  } = _b, props = __objRest(_b, [
285
309
  "className",
286
310
  "children",
287
311
  "showCloseButton",
288
- "style"
312
+ "style",
313
+ "container",
314
+ "align",
315
+ "size",
316
+ "minWidth"
289
317
  ]);
290
318
  const themeVars = useThemeVars();
291
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(DialogPortal, { children: [
319
+ const isAuto = size === "auto";
320
+ const sizeStyle = isAuto ? { minWidth: minWidth != null ? minWidth : DIALOG_AUTO_MIN_WIDTH } : { maxWidth: DIALOG_MAX_WIDTHS[size] };
321
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(DialogPortal, { container: container != null ? container : void 0, children: [
292
322
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(DialogOverlay, { style: themeVars }),
293
323
  /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
294
324
  import_dialog.Dialog.Popup,
295
325
  __spreadProps(__spreadValues({
296
326
  className: cn(
297
- // WealthX: removed rounded-lg (sharp corners), shadow-lg (flat panels), foreground/50 scrim via DialogOverlay
298
- "fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 duration-200 outline-none data-ending-style:animate-out data-ending-style:fade-out-0 data-ending-style:zoom-out-95 data-ending-style:fill-mode-forwards data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 sm:max-w-lg",
327
+ // WealthX: removed rounded-lg (sharp corners), shadow-lg (flat panels)
328
+ // max-w-[calc(100%-2rem)] acts as a viewport-edge guard on all sizes.
329
+ // Fixed max-width is applied via inline style (sizeStyle) to avoid
330
+ // Tailwind v4 class-scanning gaps with dynamic class lookups.
331
+ "fixed left-[50%] z-50 grid max-w-[calc(100%-2rem)] translate-x-[-50%] gap-4 border bg-background p-6 duration-200 outline-none data-ending-style:animate-out data-ending-style:fade-out-0 data-ending-style:zoom-out-95 data-ending-style:fill-mode-forwards data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95",
332
+ // "auto" → hug content (with min-width floor); fixed sizes → fill to max-width
333
+ isAuto ? "w-auto" : "w-full",
334
+ align === "center" ? "top-[50%] translate-y-[-50%]" : "top-4 translate-y-0",
299
335
  className
300
336
  ),
301
337
  "data-slot": "dialog-content",
302
- style: __spreadValues(__spreadValues({}, themeVars), style)
338
+ style: __spreadValues(__spreadValues(__spreadValues({}, themeVars), sizeStyle), style)
303
339
  }, props), {
304
340
  children: [
305
341
  children,
306
342
  showCloseButton ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
307
343
  import_dialog.Dialog.Close,
308
344
  {
309
- className: "absolute top-4 right-4 transition-colors hover:bg-foreground/5 focus:outline-hidden focus:ring-2 focus:ring-border focus:ring-offset-0 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
345
+ className: "absolute top-4 right-4 inline-flex size-7 items-center justify-center transition-colors hover:bg-foreground/5 focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-border focus-visible:ring-offset-0 disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
310
346
  "data-slot": "dialog-close",
311
347
  children: [
312
348
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_lucide_react2.XIcon, {}),
@@ -359,6 +395,7 @@ function DialogFooter(_a) {
359
395
  import_dialog.Dialog.Close,
360
396
  {
361
397
  className: cn(buttonVariants({ variant: "outline" })),
398
+ type: "button",
362
399
  children: "Close"
363
400
  }
364
401
  ) : null
@@ -955,6 +992,8 @@ function DatePicker({
955
992
  {
956
993
  className: cn(
957
994
  "w-full justify-start rounded-none font-normal data-[empty=true]:text-muted-foreground",
995
+ // Show open/focus state when the popover is expanded
996
+ "aria-expanded:border-ring aria-expanded:ring-2 aria-expanded:ring-ring/20",
958
997
  className
959
998
  ),
960
999
  "data-empty": !value,
@@ -992,9 +1031,9 @@ function DatePicker({
992
1031
  showTimePicker ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "border-t border-border px-3 pb-3 pt-2", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("label", { className: "mb-1.5 block text-xs font-medium text-muted-foreground", children: [
993
1032
  "Time",
994
1033
  /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
995
- "input",
1034
+ Input,
996
1035
  {
997
- className: "mt-1.5 h-8 w-full rounded-none border border-input bg-transparent px-2 text-sm font-sans outline-none focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50",
1036
+ className: "mt-1.5 h-8",
998
1037
  onChange: handleTimeChange,
999
1038
  type: "time",
1000
1039
  value: timeValue
@@ -1568,13 +1607,6 @@ var ASSET_TYPES = [
1568
1607
  "Bonds / Fixed Income",
1569
1608
  "Other"
1570
1609
  ];
1571
- var PROPERTY_ASSET_TYPES = /* @__PURE__ */ new Set([
1572
- "Primary Residence",
1573
- "Investment Property",
1574
- "Holiday Home",
1575
- "Commercial Property",
1576
- "Rural Property"
1577
- ]);
1578
1610
  var PROPERTY_SUBTYPES = [
1579
1611
  "House",
1580
1612
  "Unit / Apartment",
@@ -1783,13 +1815,15 @@ function AccordionItemHeader({
1783
1815
  }
1784
1816
  ),
1785
1817
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1786
- "button",
1818
+ Button,
1787
1819
  {
1788
1820
  type: "button",
1821
+ variant: "ghost",
1822
+ size: "icon",
1789
1823
  onClick: onRemove,
1790
- className: "p-2 hover:bg-foreground/5 transition-colors",
1824
+ className: "size-8 shrink-0",
1791
1825
  "aria-label": removeLabel,
1792
- children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react10.Trash2, { className: "h-3.5 w-3.5 text-destructive" })
1826
+ children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react10.Trash2, { className: "size-3.5 text-destructive" })
1793
1827
  }
1794
1828
  )
1795
1829
  ] });
@@ -1889,14 +1923,19 @@ function EditLoanScenarioModal({
1889
1923
  onOpenChange,
1890
1924
  initialData,
1891
1925
  onSave,
1926
+ container,
1892
1927
  className
1893
1928
  }) {
1894
1929
  const [form, setForm] = React8.useState(__spreadValues(__spreadValues({}, LOAN_SCENARIO_DEFAULTS), initialData));
1930
+ const initialSnapshot = React8.useRef("");
1895
1931
  React8.useEffect(() => {
1896
1932
  if (open) {
1897
- setForm(__spreadValues(__spreadValues({}, LOAN_SCENARIO_DEFAULTS), initialData));
1933
+ const data = __spreadValues(__spreadValues({}, LOAN_SCENARIO_DEFAULTS), initialData);
1934
+ setForm(data);
1935
+ initialSnapshot.current = JSON.stringify(data);
1898
1936
  }
1899
1937
  }, [open]);
1938
+ const isDirty = JSON.stringify(form) !== initialSnapshot.current;
1900
1939
  const set = (key, val) => setForm((prev) => __spreadProps(__spreadValues({}, prev), { [key]: val }));
1901
1940
  const togglePriority = (priority) => {
1902
1941
  setForm((prev) => {
@@ -1937,801 +1976,831 @@ function EditLoanScenarioModal({
1937
1976
  label: "Anticipated changes impacting repayment?"
1938
1977
  }
1939
1978
  ];
1940
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogContent, { className: cn("max-w-lg", className), children: [
1941
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogTitle, { children: "Edit Loan Scenario" }) }),
1942
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
1943
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "What would you like to do?", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1944
- Select,
1945
- {
1946
- value: form.loanPurpose,
1947
- onValueChange: (val) => set("loanPurpose", val),
1948
- children: [
1949
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select purpose" }) }),
1950
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: LOAN_PURPOSES.map((p) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: p, children: p }, p)) })
1951
- ]
1952
- }
1953
- ) }),
1954
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
1955
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Property Estimate", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1956
- CurrencyInputWithSlider,
1957
- {
1958
- value: form.propertyEstimate,
1959
- min: 0,
1960
- max: 1e7,
1961
- step: 5e4,
1962
- onValueChange: (val) => set("propertyEstimate", val)
1963
- }
1964
- ) }),
1965
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Cash/equity towards property", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1966
- CurrencyInputWithSlider,
1967
- {
1968
- value: form.cashEquity,
1969
- min: 0,
1970
- max: 2e6,
1971
- step: 5e3,
1972
- onValueChange: (val) => set("cashEquity", val)
1973
- }
1974
- ) })
1975
- ] }),
1976
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
1977
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Loan Amount", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1978
- CurrencyInputWithSlider,
1979
- {
1980
- value: form.loanAmount,
1981
- min: 0,
1982
- max: 5e6,
1983
- step: 1e4,
1984
- onValueChange: (val) => set("loanAmount", val)
1985
- }
1986
- ) }),
1987
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Loan Duration", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2", children: [
1988
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
1989
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1990
- Input,
1979
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1980
+ DialogContent,
1981
+ {
1982
+ className: cn("max-w-lg", className),
1983
+ container,
1984
+ children: [
1985
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogTitle, { children: "Edit Loan Scenario" }) }),
1986
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
1987
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "What would you like to do?", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
1988
+ Select,
1989
+ {
1990
+ value: form.loanPurpose,
1991
+ onValueChange: (val) => set("loanPurpose", val),
1992
+ children: [
1993
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select purpose" }) }),
1994
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: LOAN_PURPOSES.map((p) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: p, children: p }, p)) })
1995
+ ]
1996
+ }
1997
+ ) }),
1998
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
1999
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Property Estimate", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2000
+ CurrencyInputWithSlider,
1991
2001
  {
1992
- type: "number",
1993
- min: 1,
1994
- max: 40,
1995
- value: form.loanDuration,
1996
- onChange: (e) => {
1997
- const parsed = parseInt(e.target.value, 10);
1998
- if (!isNaN(parsed)) {
1999
- set("loanDuration", Math.min(40, Math.max(1, parsed)));
2002
+ value: form.propertyEstimate,
2003
+ min: 0,
2004
+ max: 1e7,
2005
+ step: 5e4,
2006
+ onValueChange: (val) => set("propertyEstimate", val)
2007
+ }
2008
+ ) }),
2009
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Cash/equity towards property", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2010
+ CurrencyInputWithSlider,
2011
+ {
2012
+ value: form.cashEquity,
2013
+ min: 0,
2014
+ max: 2e6,
2015
+ step: 5e3,
2016
+ onValueChange: (val) => set("cashEquity", val)
2017
+ }
2018
+ ) })
2019
+ ] }),
2020
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2021
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Loan Amount", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2022
+ CurrencyInputWithSlider,
2023
+ {
2024
+ value: form.loanAmount,
2025
+ min: 0,
2026
+ max: 5e6,
2027
+ step: 1e4,
2028
+ onValueChange: (val) => set("loanAmount", val)
2029
+ }
2030
+ ) }),
2031
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Loan Duration", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2", children: [
2032
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
2033
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2034
+ Input,
2035
+ {
2036
+ type: "number",
2037
+ min: 1,
2038
+ max: 40,
2039
+ value: form.loanDuration,
2040
+ onChange: (e) => {
2041
+ const parsed = parseInt(e.target.value, 10);
2042
+ if (!isNaN(parsed)) {
2043
+ set("loanDuration", Math.min(40, Math.max(1, parsed)));
2044
+ }
2045
+ },
2046
+ className: "flex-1"
2047
+ }
2048
+ ),
2049
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-sm text-muted-foreground", children: "years" })
2050
+ ] }),
2051
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2052
+ Slider,
2053
+ {
2054
+ min: 1,
2055
+ max: 40,
2056
+ step: 1,
2057
+ value: form.loanDuration,
2058
+ onValueChange: (val) => set("loanDuration", val)
2059
+ }
2060
+ )
2061
+ ] }) })
2062
+ ] }),
2063
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Do you know what loan features you want?", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2064
+ Select,
2065
+ {
2066
+ value: form.knowsFeatures,
2067
+ onValueChange: (val) => set("knowsFeatures", val),
2068
+ children: [
2069
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2070
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(SelectContent, { children: [
2071
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: "Yes", children: "Yes" }),
2072
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: "No", children: "No" })
2073
+ ] })
2074
+ ]
2075
+ }
2076
+ ) }),
2077
+ form.knowsFeatures === "Yes" && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2", children: [
2078
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { className: "text-sm font-medium text-muted-foreground", children: "What features are important to you?" }),
2079
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "grid grid-cols-2 gap-2", children: LOAN_FEATURES.map(({ key, label }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
2080
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2081
+ Checkbox,
2082
+ {
2083
+ id: `feature-${key}`,
2084
+ checked: form[key],
2085
+ onCheckedChange: (checked) => set(key, checked === true)
2086
+ }
2087
+ ),
2088
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2089
+ "label",
2090
+ {
2091
+ htmlFor: `feature-${key}`,
2092
+ className: "text-sm cursor-pointer select-none",
2093
+ children: label
2094
+ }
2095
+ )
2096
+ ] }, key)) })
2097
+ ] }),
2098
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2", children: [
2099
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { className: "text-sm font-medium text-muted-foreground", children: "Top 3 Priorities (Select up to 3)" }),
2100
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "grid grid-cols-2 gap-2", children: PRIORITIES.map((priority) => {
2101
+ const checked = form.priorities.includes(priority);
2102
+ const disabled = prioritiesAtMax && !checked;
2103
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
2104
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2105
+ Checkbox,
2106
+ {
2107
+ id: `priority-${priority}`,
2108
+ checked,
2109
+ disabled,
2110
+ onCheckedChange: () => togglePriority(priority)
2111
+ }
2112
+ ),
2113
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2114
+ "label",
2115
+ {
2116
+ htmlFor: `priority-${priority}`,
2117
+ className: cn(
2118
+ "text-sm cursor-pointer select-none",
2119
+ disabled && "opacity-40 cursor-not-allowed"
2120
+ ),
2121
+ children: priority
2000
2122
  }
2123
+ )
2124
+ ] }, priority);
2125
+ }) })
2126
+ ] }),
2127
+ YES_NO_FIELDS.map(({ key, label }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2", children: [
2128
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { className: "text-sm font-medium text-muted-foreground", children: label }),
2129
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2130
+ RadioGroup,
2131
+ {
2132
+ value: form[key],
2133
+ onValueChange: (val) => {
2134
+ if (val === "Yes" || val === "No") set(key, val);
2001
2135
  },
2002
- className: "flex-1"
2136
+ className: "flex gap-4",
2137
+ children: ["Yes", "No"].map((opt) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2138
+ "label",
2139
+ {
2140
+ className: "flex items-center gap-2 cursor-pointer select-none",
2141
+ children: [
2142
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RadioGroupItem, { value: opt }),
2143
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-sm", children: opt })
2144
+ ]
2145
+ },
2146
+ opt
2147
+ ))
2003
2148
  }
2004
- ),
2005
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-sm text-muted-foreground", children: "years" })
2006
- ] }),
2149
+ )
2150
+ ] }, key)),
2151
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "What age are you planning to retire?", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2152
+ Input,
2153
+ {
2154
+ type: "number",
2155
+ min: 0,
2156
+ max: 100,
2157
+ value: form.retirementAge,
2158
+ onChange: (e) => set("retirementAge", e.target.value),
2159
+ placeholder: "e.g. 65"
2160
+ }
2161
+ ) })
2162
+ ] }),
2163
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
2164
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
2007
2165
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2008
- Slider,
2166
+ Button,
2009
2167
  {
2010
- min: 1,
2011
- max: 40,
2012
- step: 1,
2013
- value: form.loanDuration,
2014
- onValueChange: (val) => set("loanDuration", val)
2168
+ disabled: !isDirty,
2169
+ onClick: () => {
2170
+ onSave(form);
2171
+ onOpenChange(false);
2172
+ },
2173
+ children: "Save"
2015
2174
  }
2016
2175
  )
2017
- ] }) })
2018
- ] }),
2019
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Do you know what loan features you want?", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2020
- Select,
2021
- {
2022
- value: form.knowsFeatures,
2023
- onValueChange: (val) => set("knowsFeatures", val),
2024
- children: [
2025
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2026
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(SelectContent, { children: [
2027
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: "Yes", children: "Yes" }),
2028
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: "No", children: "No" })
2029
- ] })
2030
- ]
2031
- }
2032
- ) }),
2033
- form.knowsFeatures === "Yes" && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2", children: [
2034
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { className: "text-sm font-medium text-muted-foreground", children: "What features are important to you?" }),
2035
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "grid grid-cols-2 gap-2", children: LOAN_FEATURES.map(({ key, label }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
2176
+ ] })
2177
+ ]
2178
+ }
2179
+ ) });
2180
+ }
2181
+ function EditAssetsModal({
2182
+ open,
2183
+ onOpenChange,
2184
+ initialItems = [],
2185
+ onSave,
2186
+ mainApplicantName = "Main Applicant",
2187
+ coApplicantName = "Co-Applicant",
2188
+ container,
2189
+ className
2190
+ }) {
2191
+ const [items, setItems] = React8.useState(
2192
+ initialItems.length > 0 ? initialItems : [makeDefaultAssetItem()]
2193
+ );
2194
+ const initialSnapshot = React8.useRef("");
2195
+ React8.useEffect(() => {
2196
+ if (open) {
2197
+ const data = initialItems.length > 0 ? initialItems : [makeDefaultAssetItem()];
2198
+ setItems(data);
2199
+ initialSnapshot.current = JSON.stringify(data);
2200
+ }
2201
+ }, [open]);
2202
+ const isDirty = JSON.stringify(items) !== initialSnapshot.current;
2203
+ const updateItem = (id, key, val) => setItems(
2204
+ (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
2205
+ );
2206
+ const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
2207
+ const addItem = () => setItems((prev) => [...prev, makeDefaultAssetItem()]);
2208
+ const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
2209
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2210
+ DialogContent,
2211
+ {
2212
+ className: cn("max-w-lg", className),
2213
+ container,
2214
+ children: [
2215
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogTitle, { children: "Edit Assets" }) }),
2216
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
2036
2217
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2037
- Checkbox,
2218
+ Accordion,
2038
2219
  {
2039
- id: `feature-${key}`,
2040
- checked: form[key],
2041
- onCheckedChange: (checked) => set(key, checked === true)
2220
+ multiple: true,
2221
+ defaultValue: defaultOpenItems,
2222
+ className: "w-full",
2223
+ children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(AccordionItem, { value: item.id, children: [
2224
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2225
+ AccordionItemHeader,
2226
+ {
2227
+ label: `Asset ${index + 1} \u2014 ${item.assetType || "New Asset"}`,
2228
+ onRemove: () => removeItem(item.id),
2229
+ removeLabel: "Remove asset"
2230
+ }
2231
+ ),
2232
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AccordionContent, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-4 pt-1", children: [
2233
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Asset Type", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2234
+ Select,
2235
+ {
2236
+ value: item.assetType,
2237
+ onValueChange: (val) => updateItem(item.id, "assetType", val),
2238
+ children: [
2239
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select type" }) }),
2240
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: ASSET_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
2241
+ ]
2242
+ }
2243
+ ) }),
2244
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Value", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2245
+ CurrencyInputWithSlider,
2246
+ {
2247
+ value: item.value,
2248
+ min: 0,
2249
+ max: 1e7,
2250
+ step: 1e4,
2251
+ onValueChange: (val) => updateItem(item.id, "value", val)
2252
+ }
2253
+ ) }),
2254
+ (() => {
2255
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2256
+ const f = assetFields(item.assetType);
2257
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
2258
+ f.isProperty && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
2259
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Property Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2260
+ AddressAutocomplete,
2261
+ {
2262
+ value: (_a = item.address) != null ? _a : "",
2263
+ onValueChange: (val) => updateItem(item.id, "address", val),
2264
+ onSelect: (opt) => updateItem(item.id, "address", opt.label)
2265
+ }
2266
+ ) }),
2267
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2268
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Property Type", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2269
+ Select,
2270
+ {
2271
+ value: (_b = item.propertySubtype) != null ? _b : "",
2272
+ onValueChange: (val) => updateItem(
2273
+ item.id,
2274
+ "propertySubtype",
2275
+ val
2276
+ ),
2277
+ children: [
2278
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2279
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: PROPERTY_SUBTYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
2280
+ ]
2281
+ }
2282
+ ) }),
2283
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Used As", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2284
+ Select,
2285
+ {
2286
+ value: (_c = item.usedAs) != null ? _c : "",
2287
+ onValueChange: (val) => updateItem(item.id, "usedAs", val),
2288
+ children: [
2289
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2290
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: PROPERTY_USED_AS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
2291
+ ]
2292
+ }
2293
+ ) })
2294
+ ] })
2295
+ ] }),
2296
+ f.isVehicle && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-3 gap-4", children: [
2297
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Make", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2298
+ Input,
2299
+ {
2300
+ value: (_d = item.make) != null ? _d : "",
2301
+ onChange: (e) => updateItem(item.id, "make", e.target.value),
2302
+ placeholder: "e.g. Toyota"
2303
+ }
2304
+ ) }),
2305
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Model", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2306
+ Input,
2307
+ {
2308
+ value: (_e = item.model) != null ? _e : "",
2309
+ onChange: (e) => updateItem(item.id, "model", e.target.value),
2310
+ placeholder: "e.g. Camry"
2311
+ }
2312
+ ) }),
2313
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Year", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2314
+ Input,
2315
+ {
2316
+ type: "number",
2317
+ min: 1900,
2318
+ max: (/* @__PURE__ */ new Date()).getFullYear() + 1,
2319
+ value: (_f = item.year) != null ? _f : "",
2320
+ onChange: (e) => updateItem(item.id, "year", e.target.value),
2321
+ placeholder: "e.g. 2022"
2322
+ }
2323
+ ) })
2324
+ ] }),
2325
+ (f.isFinancialAccount || f.isInvestment) && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Institution / Platform", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2326
+ Input,
2327
+ {
2328
+ value: (_g = item.institution) != null ? _g : "",
2329
+ onChange: (e) => updateItem(
2330
+ item.id,
2331
+ "institution",
2332
+ e.target.value
2333
+ ),
2334
+ placeholder: "e.g. CommBank, Vanguard"
2335
+ }
2336
+ ) }),
2337
+ f.isSuper && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2338
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Fund Name", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2339
+ Input,
2340
+ {
2341
+ value: (_h = item.fundName) != null ? _h : "",
2342
+ onChange: (e) => updateItem(
2343
+ item.id,
2344
+ "fundName",
2345
+ e.target.value
2346
+ ),
2347
+ placeholder: "e.g. Australian Super"
2348
+ }
2349
+ ) }),
2350
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Member Number", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2351
+ Input,
2352
+ {
2353
+ value: (_i = item.memberNumber) != null ? _i : "",
2354
+ onChange: (e) => updateItem(
2355
+ item.id,
2356
+ "memberNumber",
2357
+ e.target.value
2358
+ ),
2359
+ placeholder: "e.g. 1234567"
2360
+ }
2361
+ ) })
2362
+ ] }),
2363
+ f.isBusiness && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2364
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Business Name", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2365
+ Input,
2366
+ {
2367
+ value: (_j = item.businessName) != null ? _j : "",
2368
+ onChange: (e) => updateItem(
2369
+ item.id,
2370
+ "businessName",
2371
+ e.target.value
2372
+ ),
2373
+ placeholder: "e.g. Acme Pty Ltd"
2374
+ }
2375
+ ) }),
2376
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "ABN", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2377
+ Input,
2378
+ {
2379
+ value: (_k = item.abn) != null ? _k : "",
2380
+ onChange: (e) => updateItem(item.id, "abn", e.target.value),
2381
+ placeholder: "e.g. 12 345 678 901"
2382
+ }
2383
+ ) })
2384
+ ] }),
2385
+ f.isInsurance && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2386
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Insurer", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2387
+ Input,
2388
+ {
2389
+ value: (_l = item.insurer) != null ? _l : "",
2390
+ onChange: (e) => updateItem(
2391
+ item.id,
2392
+ "insurer",
2393
+ e.target.value
2394
+ ),
2395
+ placeholder: "e.g. TAL, AIA"
2396
+ }
2397
+ ) }),
2398
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Policy Number", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2399
+ Input,
2400
+ {
2401
+ value: (_m = item.policyNumber) != null ? _m : "",
2402
+ onChange: (e) => updateItem(
2403
+ item.id,
2404
+ "policyNumber",
2405
+ e.target.value
2406
+ ),
2407
+ placeholder: "e.g. POL-123456"
2408
+ }
2409
+ ) })
2410
+ ] })
2411
+ ] });
2412
+ })(),
2413
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2414
+ OwnershipSplit,
2415
+ {
2416
+ owners: [
2417
+ {
2418
+ id: "main",
2419
+ name: mainApplicantName != null ? mainApplicantName : "Main Applicant",
2420
+ share: item.mainShare
2421
+ },
2422
+ {
2423
+ id: "co",
2424
+ name: coApplicantName != null ? coApplicantName : "Co-Applicant",
2425
+ share: item.coShare
2426
+ }
2427
+ ],
2428
+ onOwnersChange: (owners) => {
2429
+ var _a, _b, _c, _d;
2430
+ updateItem(
2431
+ item.id,
2432
+ "mainShare",
2433
+ (_b = (_a = owners.find((o) => o.id === "main")) == null ? void 0 : _a.share) != null ? _b : 50
2434
+ );
2435
+ updateItem(
2436
+ item.id,
2437
+ "coShare",
2438
+ (_d = (_c = owners.find((o) => o.id === "co")) == null ? void 0 : _c.share) != null ? _d : 50
2439
+ );
2440
+ }
2441
+ }
2442
+ ) })
2443
+ ] }) })
2444
+ ] }, item.id))
2042
2445
  }
2043
2446
  ),
2044
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2045
- "label",
2447
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2448
+ Button,
2046
2449
  {
2047
- htmlFor: `feature-${key}`,
2048
- className: "text-sm cursor-pointer select-none",
2049
- children: label
2450
+ variant: "outline",
2451
+ onClick: addItem,
2452
+ className: "w-full gap-1.5",
2453
+ children: [
2454
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react10.Plus, { className: "h-4 w-4" }),
2455
+ "Add More"
2456
+ ]
2050
2457
  }
2051
2458
  )
2052
- ] }, key)) })
2053
- ] }),
2054
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2", children: [
2055
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { className: "text-sm font-medium text-muted-foreground", children: "Top 3 Priorities (Select up to 3)" }),
2056
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "grid grid-cols-2 gap-2", children: PRIORITIES.map((priority) => {
2057
- const checked = form.priorities.includes(priority);
2058
- const disabled = prioritiesAtMax && !checked;
2059
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
2060
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2061
- Checkbox,
2062
- {
2063
- id: `priority-${priority}`,
2064
- checked,
2065
- disabled,
2066
- onCheckedChange: () => togglePriority(priority)
2067
- }
2068
- ),
2069
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2070
- "label",
2071
- {
2072
- htmlFor: `priority-${priority}`,
2073
- className: cn(
2074
- "text-sm cursor-pointer select-none",
2075
- disabled && "opacity-40 cursor-not-allowed"
2076
- ),
2077
- children: priority
2078
- }
2079
- )
2080
- ] }, priority);
2081
- }) })
2082
- ] }),
2083
- YES_NO_FIELDS.map(({ key, label }) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-2", children: [
2084
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { className: "text-sm font-medium text-muted-foreground", children: label }),
2085
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2086
- RadioGroup,
2087
- {
2088
- value: form[key],
2089
- onValueChange: (val) => {
2090
- if (val === "Yes" || val === "No") set(key, val);
2091
- },
2092
- className: "flex gap-4",
2093
- children: ["Yes", "No"].map((opt) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2094
- "label",
2095
- {
2096
- className: "flex items-center gap-2 cursor-pointer select-none",
2097
- children: [
2098
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RadioGroupItem, { value: opt }),
2099
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-sm", children: opt })
2100
- ]
2459
+ ] }),
2460
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
2461
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
2462
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2463
+ Button,
2464
+ {
2465
+ disabled: !isDirty,
2466
+ onClick: () => {
2467
+ onSave(items);
2468
+ onOpenChange(false);
2101
2469
  },
2102
- opt
2103
- ))
2104
- }
2105
- )
2106
- ] }, key)),
2107
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "What age are you planning to retire?", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2108
- Input,
2109
- {
2110
- type: "number",
2111
- min: 0,
2112
- max: 100,
2113
- value: form.retirementAge,
2114
- onChange: (e) => set("retirementAge", e.target.value),
2115
- placeholder: "e.g. 65"
2116
- }
2117
- ) })
2118
- ] }),
2119
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
2120
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
2121
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2122
- Button,
2123
- {
2124
- onClick: () => {
2125
- onSave(form);
2126
- onOpenChange(false);
2127
- },
2128
- children: "Save"
2129
- }
2130
- )
2131
- ] })
2132
- ] }) });
2470
+ children: "Save"
2471
+ }
2472
+ )
2473
+ ] })
2474
+ ]
2475
+ }
2476
+ ) });
2133
2477
  }
2134
- function EditAssetsModal({
2478
+ function EditDebtsModal({
2135
2479
  open,
2136
2480
  onOpenChange,
2137
2481
  initialItems = [],
2138
2482
  onSave,
2139
2483
  mainApplicantName = "Main Applicant",
2140
2484
  coApplicantName = "Co-Applicant",
2485
+ container,
2141
2486
  className
2142
2487
  }) {
2143
2488
  const [items, setItems] = React8.useState(
2144
- initialItems.length > 0 ? initialItems : [makeDefaultAssetItem()]
2489
+ initialItems.length > 0 ? initialItems : [makeDefaultDebtItem()]
2145
2490
  );
2491
+ const initialSnapshot = React8.useRef("");
2146
2492
  React8.useEffect(() => {
2147
2493
  if (open) {
2148
- setItems(
2149
- initialItems.length > 0 ? initialItems : [makeDefaultAssetItem()]
2150
- );
2494
+ const data = initialItems.length > 0 ? initialItems : [makeDefaultDebtItem()];
2495
+ setItems(data);
2496
+ initialSnapshot.current = JSON.stringify(data);
2151
2497
  }
2152
2498
  }, [open]);
2499
+ const isDirty = JSON.stringify(items) !== initialSnapshot.current;
2153
2500
  const updateItem = (id, key, val) => setItems(
2154
2501
  (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
2155
2502
  );
2156
2503
  const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
2157
- const addItem = () => setItems((prev) => [...prev, makeDefaultAssetItem()]);
2504
+ const addItem = () => setItems((prev) => [...prev, makeDefaultDebtItem()]);
2158
2505
  const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
2159
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogContent, { className: cn("max-w-lg", className), children: [
2160
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogTitle, { children: "Edit Assets" }) }),
2161
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
2162
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2163
- Accordion,
2164
- {
2165
- multiple: true,
2166
- defaultValue: defaultOpenItems,
2167
- className: "w-full",
2168
- children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(AccordionItem, { value: item.id, children: [
2169
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2170
- AccordionItemHeader,
2171
- {
2172
- label: `Asset ${index + 1} \u2014 ${item.assetType || "New Asset"}`,
2173
- onRemove: () => removeItem(item.id),
2174
- removeLabel: "Remove asset"
2175
- }
2176
- ),
2177
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AccordionContent, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-4 pt-1", children: [
2178
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Asset Type", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2179
- Select,
2180
- {
2181
- value: item.assetType,
2182
- onValueChange: (val) => updateItem(item.id, "assetType", val),
2183
- children: [
2184
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select type" }) }),
2185
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: ASSET_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
2186
- ]
2187
- }
2188
- ) }),
2189
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Value", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2190
- CurrencyInputWithSlider,
2191
- {
2192
- value: item.value,
2193
- min: 0,
2194
- max: 1e7,
2195
- step: 1e4,
2196
- onValueChange: (val) => updateItem(item.id, "value", val)
2197
- }
2198
- ) }),
2199
- (() => {
2200
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
2201
- const f = assetFields(item.assetType);
2202
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
2203
- f.isProperty && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(import_jsx_runtime18.Fragment, { children: [
2204
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Property Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2506
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2507
+ DialogContent,
2508
+ {
2509
+ className: cn("max-w-xl", className),
2510
+ container,
2511
+ children: [
2512
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogTitle, { children: "Edit Debts" }) }),
2513
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
2514
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2515
+ Accordion,
2516
+ {
2517
+ multiple: true,
2518
+ defaultValue: defaultOpenItems,
2519
+ className: "w-full",
2520
+ children: items.map((item) => {
2521
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2522
+ const df = debtFields(item.debtType);
2523
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(AccordionItem, { value: item.id, children: [
2524
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2525
+ AccordionItemHeader,
2526
+ {
2527
+ label: item.debtType || "New Debt",
2528
+ onRemove: () => removeItem(item.id),
2529
+ removeLabel: "Remove debt"
2530
+ }
2531
+ ),
2532
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AccordionContent, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-4 pt-1", children: [
2533
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Debt Type", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2534
+ Select,
2535
+ {
2536
+ value: item.debtType,
2537
+ onValueChange: (val) => updateItem(item.id, "debtType", val),
2538
+ children: [
2539
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select type" }) }),
2540
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: DEBT_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
2541
+ ]
2542
+ }
2543
+ ) }),
2544
+ (df.isPropertyLoan || df.isGeneralLoan || df.isVehicle) && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2545
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Lender", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2546
+ Input,
2547
+ {
2548
+ value: (_a = item.lender) != null ? _a : "",
2549
+ onChange: (e) => updateItem(item.id, "lender", e.target.value),
2550
+ placeholder: "e.g. CommBank"
2551
+ }
2552
+ ) }),
2553
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Account Number", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2554
+ Input,
2555
+ {
2556
+ value: (_b = item.accountNumber) != null ? _b : "",
2557
+ onChange: (e) => updateItem(
2558
+ item.id,
2559
+ "accountNumber",
2560
+ e.target.value
2561
+ ),
2562
+ placeholder: "e.g. 123-456"
2563
+ }
2564
+ ) })
2565
+ ] }),
2566
+ df.isPropertyLoan && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Property Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2205
2567
  AddressAutocomplete,
2206
2568
  {
2207
- value: (_a = item.address) != null ? _a : "",
2208
- onValueChange: (val) => updateItem(item.id, "address", val),
2209
- onSelect: (opt) => updateItem(item.id, "address", opt.label)
2569
+ value: (_c = item.propertyAddress) != null ? _c : "",
2570
+ onValueChange: (val) => updateItem(item.id, "propertyAddress", val),
2571
+ onSelect: (opt) => updateItem(item.id, "propertyAddress", opt.label)
2210
2572
  }
2211
2573
  ) }),
2212
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2213
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Property Type", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2214
- Select,
2574
+ df.isVehicle && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-3 gap-4", children: [
2575
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Make", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2576
+ Input,
2215
2577
  {
2216
- value: (_b = item.propertySubtype) != null ? _b : "",
2217
- onValueChange: (val) => updateItem(
2578
+ value: (_d = item.vehicleMake) != null ? _d : "",
2579
+ onChange: (e) => updateItem(
2218
2580
  item.id,
2219
- "propertySubtype",
2220
- val
2581
+ "vehicleMake",
2582
+ e.target.value
2221
2583
  ),
2222
- children: [
2223
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2224
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: PROPERTY_SUBTYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
2225
- ]
2584
+ placeholder: "e.g. Toyota"
2226
2585
  }
2227
2586
  ) }),
2228
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Used As", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2229
- Select,
2587
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Model", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2588
+ Input,
2230
2589
  {
2231
- value: (_c = item.usedAs) != null ? _c : "",
2232
- onValueChange: (val) => updateItem(item.id, "usedAs", val),
2233
- children: [
2234
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2235
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: PROPERTY_USED_AS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
2236
- ]
2590
+ value: (_e = item.vehicleModel) != null ? _e : "",
2591
+ onChange: (e) => updateItem(
2592
+ item.id,
2593
+ "vehicleModel",
2594
+ e.target.value
2595
+ ),
2596
+ placeholder: "e.g. Camry"
2597
+ }
2598
+ ) }),
2599
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Year", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2600
+ Input,
2601
+ {
2602
+ type: "number",
2603
+ min: 1900,
2604
+ max: (/* @__PURE__ */ new Date()).getFullYear() + 1,
2605
+ value: (_f = item.vehicleYear) != null ? _f : "",
2606
+ onChange: (e) => updateItem(
2607
+ item.id,
2608
+ "vehicleYear",
2609
+ e.target.value
2610
+ ),
2611
+ placeholder: "e.g. 2022"
2237
2612
  }
2238
2613
  ) })
2239
- ] })
2240
- ] }),
2241
- f.isVehicle && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-3 gap-4", children: [
2242
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Make", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2614
+ ] }),
2615
+ df.isCard && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2616
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Provider", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2617
+ Input,
2618
+ {
2619
+ value: (_g = item.lender) != null ? _g : "",
2620
+ onChange: (e) => updateItem(item.id, "lender", e.target.value),
2621
+ placeholder: "e.g. ANZ, Afterpay"
2622
+ }
2623
+ ) }),
2624
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Credit Limit", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2625
+ CurrencyInputWithSlider,
2626
+ {
2627
+ value: (_h = item.creditLimit) != null ? _h : 0,
2628
+ min: 0,
2629
+ max: 1e5,
2630
+ step: 500,
2631
+ onValueChange: (val) => updateItem(item.id, "creditLimit", val)
2632
+ }
2633
+ ) })
2634
+ ] }),
2635
+ df.isHecs && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Institution", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2243
2636
  Input,
2244
2637
  {
2245
- value: (_d = item.make) != null ? _d : "",
2246
- onChange: (e) => updateItem(item.id, "make", e.target.value),
2247
- placeholder: "e.g. Toyota"
2638
+ value: (_i = item.institution) != null ? _i : "",
2639
+ onChange: (e) => updateItem(item.id, "institution", e.target.value),
2640
+ placeholder: "e.g. University of Sydney"
2248
2641
  }
2249
2642
  ) }),
2250
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Model", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2251
- Input,
2252
- {
2253
- value: (_e = item.model) != null ? _e : "",
2254
- onChange: (e) => updateItem(item.id, "model", e.target.value),
2255
- placeholder: "e.g. Camry"
2256
- }
2257
- ) }),
2258
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Year", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2259
- Input,
2260
- {
2261
- type: "number",
2262
- min: 1900,
2263
- max: (/* @__PURE__ */ new Date()).getFullYear() + 1,
2264
- value: (_f = item.year) != null ? _f : "",
2265
- onChange: (e) => updateItem(item.id, "year", e.target.value),
2266
- placeholder: "e.g. 2022"
2267
- }
2268
- ) })
2269
- ] }),
2270
- (f.isFinancialAccount || f.isInvestment) && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Institution / Platform", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2271
- Input,
2272
- {
2273
- value: (_g = item.institution) != null ? _g : "",
2274
- onChange: (e) => updateItem(
2275
- item.id,
2276
- "institution",
2277
- e.target.value
2278
- ),
2279
- placeholder: "e.g. CommBank, Vanguard"
2280
- }
2281
- ) }),
2282
- f.isSuper && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2283
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Fund Name", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2284
- Input,
2285
- {
2286
- value: (_h = item.fundName) != null ? _h : "",
2287
- onChange: (e) => updateItem(
2288
- item.id,
2289
- "fundName",
2290
- e.target.value
2291
- ),
2292
- placeholder: "e.g. Australian Super"
2293
- }
2294
- ) }),
2295
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Member Number", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2296
- Input,
2297
- {
2298
- value: (_i = item.memberNumber) != null ? _i : "",
2299
- onChange: (e) => updateItem(
2300
- item.id,
2301
- "memberNumber",
2302
- e.target.value
2303
- ),
2304
- placeholder: "e.g. 1234567"
2305
- }
2306
- ) })
2307
- ] }),
2308
- f.isBusiness && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2309
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Business Name", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2643
+ df.isTax && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2644
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Tax Year", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2645
+ Input,
2646
+ {
2647
+ value: (_j = item.taxYear) != null ? _j : "",
2648
+ onChange: (e) => updateItem(item.id, "taxYear", e.target.value),
2649
+ placeholder: "e.g. 2023\u201324"
2650
+ }
2651
+ ) }),
2652
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "ATO Reference", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2653
+ Input,
2654
+ {
2655
+ value: (_k = item.referenceNumber) != null ? _k : "",
2656
+ onChange: (e) => updateItem(
2657
+ item.id,
2658
+ "referenceNumber",
2659
+ e.target.value
2660
+ ),
2661
+ placeholder: "e.g. 1234567890"
2662
+ }
2663
+ ) })
2664
+ ] }),
2665
+ df.isGuarantor && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Beneficiary (borrower's name)", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2310
2666
  Input,
2311
2667
  {
2312
- value: (_j = item.businessName) != null ? _j : "",
2313
- onChange: (e) => updateItem(
2314
- item.id,
2315
- "businessName",
2316
- e.target.value
2317
- ),
2318
- placeholder: "e.g. Acme Pty Ltd"
2668
+ value: (_l = item.beneficiary) != null ? _l : "",
2669
+ onChange: (e) => updateItem(item.id, "beneficiary", e.target.value),
2670
+ placeholder: "e.g. Jane Smith"
2319
2671
  }
2320
2672
  ) }),
2321
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "ABN", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2322
- Input,
2323
- {
2324
- value: (_k = item.abn) != null ? _k : "",
2325
- onChange: (e) => updateItem(item.id, "abn", e.target.value),
2326
- placeholder: "e.g. 12 345 678 901"
2327
- }
2328
- ) })
2329
- ] }),
2330
- f.isInsurance && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2331
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Insurer", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2332
- Input,
2673
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2674
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Amount Owing", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2675
+ CurrencyInputWithSlider,
2676
+ {
2677
+ value: item.amountOwing,
2678
+ min: 0,
2679
+ max: 1e6,
2680
+ step: 1e3,
2681
+ onValueChange: (val) => updateItem(item.id, "amountOwing", val)
2682
+ }
2683
+ ) }),
2684
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Original Loan Amount", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2685
+ CurrencyInputWithSlider,
2686
+ {
2687
+ value: item.originalLoanAmount,
2688
+ min: 0,
2689
+ max: 1e6,
2690
+ step: 1e3,
2691
+ onValueChange: (val) => updateItem(item.id, "originalLoanAmount", val)
2692
+ }
2693
+ ) })
2694
+ ] }),
2695
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-start gap-3", children: [
2696
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Repayments", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2697
+ CurrencyInputWithSlider,
2698
+ {
2699
+ value: item.repaymentAmount,
2700
+ min: 0,
2701
+ max: 1e6,
2702
+ step: 100,
2703
+ onValueChange: (val) => updateItem(item.id, "repaymentAmount", val)
2704
+ }
2705
+ ) }) }),
2706
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2707
+ FrequencyToggle,
2708
+ {
2709
+ value: item.repaymentFrequency,
2710
+ onValueChange: (val) => updateItem(item.id, "repaymentFrequency", val)
2711
+ }
2712
+ ) })
2713
+ ] }),
2714
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Interest Rate", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
2715
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2716
+ Input,
2717
+ {
2718
+ value: item.interestRate,
2719
+ onChange: (e) => updateItem(
2720
+ item.id,
2721
+ "interestRate",
2722
+ e.target.value
2723
+ ),
2724
+ placeholder: "e.g. 6.5",
2725
+ className: "flex-1"
2726
+ }
2727
+ ),
2728
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-sm text-muted-foreground shrink-0", children: "%" })
2729
+ ] }) }),
2730
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Notes", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2731
+ Textarea,
2333
2732
  {
2334
- value: (_l = item.insurer) != null ? _l : "",
2335
- onChange: (e) => updateItem(
2336
- item.id,
2337
- "insurer",
2338
- e.target.value
2339
- ),
2340
- placeholder: "e.g. TAL, AIA"
2733
+ value: item.details,
2734
+ onChange: (e) => updateItem(item.id, "details", e.target.value),
2735
+ placeholder: "Short comment",
2736
+ rows: 2
2341
2737
  }
2342
2738
  ) }),
2343
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Policy Number", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2344
- Input,
2739
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2740
+ OwnershipSplit,
2345
2741
  {
2346
- value: (_m = item.policyNumber) != null ? _m : "",
2347
- onChange: (e) => updateItem(
2348
- item.id,
2349
- "policyNumber",
2350
- e.target.value
2351
- ),
2352
- placeholder: "e.g. POL-123456"
2742
+ owners: [
2743
+ {
2744
+ id: "main",
2745
+ name: mainApplicantName != null ? mainApplicantName : "Main Applicant",
2746
+ share: item.mainShare
2747
+ },
2748
+ {
2749
+ id: "co",
2750
+ name: coApplicantName != null ? coApplicantName : "Co-Applicant",
2751
+ share: item.coShare
2752
+ }
2753
+ ],
2754
+ onOwnersChange: (owners) => {
2755
+ var _a2, _b2, _c2, _d2;
2756
+ updateItem(
2757
+ item.id,
2758
+ "mainShare",
2759
+ (_b2 = (_a2 = owners.find((o) => o.id === "main")) == null ? void 0 : _a2.share) != null ? _b2 : 50
2760
+ );
2761
+ updateItem(
2762
+ item.id,
2763
+ "coShare",
2764
+ (_d2 = (_c2 = owners.find((o) => o.id === "co")) == null ? void 0 : _c2.share) != null ? _d2 : 50
2765
+ );
2766
+ }
2353
2767
  }
2354
2768
  ) })
2355
- ] })
2356
- ] });
2357
- })(),
2358
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2359
- OwnershipSplit,
2360
- {
2361
- owners: [
2362
- {
2363
- id: "main",
2364
- name: mainApplicantName != null ? mainApplicantName : "Main Applicant",
2365
- share: item.mainShare
2366
- },
2367
- {
2368
- id: "co",
2369
- name: coApplicantName != null ? coApplicantName : "Co-Applicant",
2370
- share: item.coShare
2371
- }
2372
- ],
2373
- onOwnersChange: (owners) => {
2374
- var _a, _b, _c, _d;
2375
- updateItem(
2376
- item.id,
2377
- "mainShare",
2378
- (_b = (_a = owners.find((o) => o.id === "main")) == null ? void 0 : _a.share) != null ? _b : 50
2379
- );
2380
- updateItem(
2381
- item.id,
2382
- "coShare",
2383
- (_d = (_c = owners.find((o) => o.id === "co")) == null ? void 0 : _c.share) != null ? _d : 50
2384
- );
2385
- }
2386
- }
2387
- ) })
2388
- ] }) })
2389
- ] }, item.id))
2390
- }
2391
- ),
2392
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2393
- Button,
2394
- {
2395
- variant: "outline",
2396
- onClick: addItem,
2397
- className: "w-full gap-1.5",
2398
- children: [
2399
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react10.Plus, { className: "h-4 w-4" }),
2400
- "Add More"
2401
- ]
2402
- }
2403
- )
2404
- ] }),
2405
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
2406
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
2407
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2408
- Button,
2409
- {
2410
- onClick: () => {
2411
- onSave(items);
2412
- onOpenChange(false);
2413
- },
2414
- children: "Save"
2415
- }
2416
- )
2417
- ] })
2418
- ] }) });
2419
- }
2420
- function EditDebtsModal({
2421
- open,
2422
- onOpenChange,
2423
- initialItems = [],
2424
- onSave,
2425
- mainApplicantName = "Main Applicant",
2426
- coApplicantName = "Co-Applicant",
2427
- className
2428
- }) {
2429
- const [items, setItems] = React8.useState(
2430
- initialItems.length > 0 ? initialItems : [makeDefaultDebtItem()]
2431
- );
2432
- React8.useEffect(() => {
2433
- if (open) {
2434
- setItems(
2435
- initialItems.length > 0 ? initialItems : [makeDefaultDebtItem()]
2436
- );
2769
+ ] }) })
2770
+ ] }, item.id);
2771
+ })
2772
+ }
2773
+ ),
2774
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2775
+ Button,
2776
+ {
2777
+ variant: "outline",
2778
+ onClick: addItem,
2779
+ className: "w-full gap-1.5",
2780
+ children: [
2781
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react10.Plus, { className: "h-4 w-4" }),
2782
+ "Add More"
2783
+ ]
2784
+ }
2785
+ )
2786
+ ] }),
2787
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
2788
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
2789
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2790
+ Button,
2791
+ {
2792
+ disabled: !isDirty,
2793
+ onClick: () => {
2794
+ onSave(items);
2795
+ onOpenChange(false);
2796
+ },
2797
+ children: "Save"
2798
+ }
2799
+ )
2800
+ ] })
2801
+ ]
2437
2802
  }
2438
- }, [open]);
2439
- const updateItem = (id, key, val) => setItems(
2440
- (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
2441
- );
2442
- const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
2443
- const addItem = () => setItems((prev) => [...prev, makeDefaultDebtItem()]);
2444
- const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
2445
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogContent, { className: cn("max-w-xl", className), children: [
2446
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogTitle, { children: "Edit Debts" }) }),
2447
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
2448
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2449
- Accordion,
2450
- {
2451
- multiple: true,
2452
- defaultValue: defaultOpenItems,
2453
- className: "w-full",
2454
- children: items.map((item) => {
2455
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
2456
- const df = debtFields(item.debtType);
2457
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(AccordionItem, { value: item.id, children: [
2458
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2459
- AccordionItemHeader,
2460
- {
2461
- label: item.debtType || "New Debt",
2462
- onRemove: () => removeItem(item.id),
2463
- removeLabel: "Remove debt"
2464
- }
2465
- ),
2466
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AccordionContent, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-4 pt-1", children: [
2467
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Debt Type", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2468
- Select,
2469
- {
2470
- value: item.debtType,
2471
- onValueChange: (val) => updateItem(item.id, "debtType", val),
2472
- children: [
2473
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select type" }) }),
2474
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: DEBT_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
2475
- ]
2476
- }
2477
- ) }),
2478
- (df.isPropertyLoan || df.isGeneralLoan || df.isVehicle) && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2479
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Lender", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2480
- Input,
2481
- {
2482
- value: (_a = item.lender) != null ? _a : "",
2483
- onChange: (e) => updateItem(item.id, "lender", e.target.value),
2484
- placeholder: "e.g. CommBank"
2485
- }
2486
- ) }),
2487
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Account Number", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2488
- Input,
2489
- {
2490
- value: (_b = item.accountNumber) != null ? _b : "",
2491
- onChange: (e) => updateItem(
2492
- item.id,
2493
- "accountNumber",
2494
- e.target.value
2495
- ),
2496
- placeholder: "e.g. 123-456"
2497
- }
2498
- ) })
2499
- ] }),
2500
- df.isPropertyLoan && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Property Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2501
- AddressAutocomplete,
2502
- {
2503
- value: (_c = item.propertyAddress) != null ? _c : "",
2504
- onValueChange: (val) => updateItem(item.id, "propertyAddress", val),
2505
- onSelect: (opt) => updateItem(item.id, "propertyAddress", opt.label)
2506
- }
2507
- ) }),
2508
- df.isVehicle && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-3 gap-4", children: [
2509
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Make", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2510
- Input,
2511
- {
2512
- value: (_d = item.vehicleMake) != null ? _d : "",
2513
- onChange: (e) => updateItem(
2514
- item.id,
2515
- "vehicleMake",
2516
- e.target.value
2517
- ),
2518
- placeholder: "e.g. Toyota"
2519
- }
2520
- ) }),
2521
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Model", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2522
- Input,
2523
- {
2524
- value: (_e = item.vehicleModel) != null ? _e : "",
2525
- onChange: (e) => updateItem(
2526
- item.id,
2527
- "vehicleModel",
2528
- e.target.value
2529
- ),
2530
- placeholder: "e.g. Camry"
2531
- }
2532
- ) }),
2533
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Year", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2534
- Input,
2535
- {
2536
- type: "number",
2537
- min: 1900,
2538
- max: (/* @__PURE__ */ new Date()).getFullYear() + 1,
2539
- value: (_f = item.vehicleYear) != null ? _f : "",
2540
- onChange: (e) => updateItem(
2541
- item.id,
2542
- "vehicleYear",
2543
- e.target.value
2544
- ),
2545
- placeholder: "e.g. 2022"
2546
- }
2547
- ) })
2548
- ] }),
2549
- df.isCard && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2550
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Provider", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2551
- Input,
2552
- {
2553
- value: (_g = item.lender) != null ? _g : "",
2554
- onChange: (e) => updateItem(item.id, "lender", e.target.value),
2555
- placeholder: "e.g. ANZ, Afterpay"
2556
- }
2557
- ) }),
2558
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Credit Limit", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2559
- CurrencyInputWithSlider,
2560
- {
2561
- value: (_h = item.creditLimit) != null ? _h : 0,
2562
- min: 0,
2563
- max: 1e5,
2564
- step: 500,
2565
- onValueChange: (val) => updateItem(item.id, "creditLimit", val)
2566
- }
2567
- ) })
2568
- ] }),
2569
- df.isHecs && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Institution", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2570
- Input,
2571
- {
2572
- value: (_i = item.institution) != null ? _i : "",
2573
- onChange: (e) => updateItem(item.id, "institution", e.target.value),
2574
- placeholder: "e.g. University of Sydney"
2575
- }
2576
- ) }),
2577
- df.isTax && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2578
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Tax Year", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2579
- Input,
2580
- {
2581
- value: (_j = item.taxYear) != null ? _j : "",
2582
- onChange: (e) => updateItem(item.id, "taxYear", e.target.value),
2583
- placeholder: "e.g. 2023\u201324"
2584
- }
2585
- ) }),
2586
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "ATO Reference", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2587
- Input,
2588
- {
2589
- value: (_k = item.referenceNumber) != null ? _k : "",
2590
- onChange: (e) => updateItem(
2591
- item.id,
2592
- "referenceNumber",
2593
- e.target.value
2594
- ),
2595
- placeholder: "e.g. 1234567890"
2596
- }
2597
- ) })
2598
- ] }),
2599
- df.isGuarantor && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Beneficiary (borrower's name)", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2600
- Input,
2601
- {
2602
- value: (_l = item.beneficiary) != null ? _l : "",
2603
- onChange: (e) => updateItem(item.id, "beneficiary", e.target.value),
2604
- placeholder: "e.g. Jane Smith"
2605
- }
2606
- ) }),
2607
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2608
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Amount Owing", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2609
- CurrencyInputWithSlider,
2610
- {
2611
- value: item.amountOwing,
2612
- min: 0,
2613
- max: 1e6,
2614
- step: 1e3,
2615
- onValueChange: (val) => updateItem(item.id, "amountOwing", val)
2616
- }
2617
- ) }),
2618
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Original Loan Amount", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2619
- CurrencyInputWithSlider,
2620
- {
2621
- value: item.originalLoanAmount,
2622
- min: 0,
2623
- max: 1e6,
2624
- step: 1e3,
2625
- onValueChange: (val) => updateItem(item.id, "originalLoanAmount", val)
2626
- }
2627
- ) })
2628
- ] }),
2629
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-start gap-3", children: [
2630
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Repayments", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2631
- CurrencyInputWithSlider,
2632
- {
2633
- value: item.repaymentAmount,
2634
- min: 0,
2635
- max: 1e6,
2636
- step: 100,
2637
- onValueChange: (val) => updateItem(item.id, "repaymentAmount", val)
2638
- }
2639
- ) }) }),
2640
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2641
- FrequencyToggle,
2642
- {
2643
- value: item.repaymentFrequency,
2644
- onValueChange: (val) => updateItem(item.id, "repaymentFrequency", val)
2645
- }
2646
- ) })
2647
- ] }),
2648
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Interest Rate", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
2649
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2650
- Input,
2651
- {
2652
- value: item.interestRate,
2653
- onChange: (e) => updateItem(
2654
- item.id,
2655
- "interestRate",
2656
- e.target.value
2657
- ),
2658
- placeholder: "e.g. 6.5",
2659
- className: "flex-1"
2660
- }
2661
- ),
2662
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-sm text-muted-foreground shrink-0", children: "%" })
2663
- ] }) }),
2664
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Notes", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2665
- Textarea,
2666
- {
2667
- value: item.details,
2668
- onChange: (e) => updateItem(item.id, "details", e.target.value),
2669
- placeholder: "Short comment",
2670
- rows: 2
2671
- }
2672
- ) }),
2673
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2674
- OwnershipSplit,
2675
- {
2676
- owners: [
2677
- {
2678
- id: "main",
2679
- name: mainApplicantName != null ? mainApplicantName : "Main Applicant",
2680
- share: item.mainShare
2681
- },
2682
- {
2683
- id: "co",
2684
- name: coApplicantName != null ? coApplicantName : "Co-Applicant",
2685
- share: item.coShare
2686
- }
2687
- ],
2688
- onOwnersChange: (owners) => {
2689
- var _a2, _b2, _c2, _d2;
2690
- updateItem(
2691
- item.id,
2692
- "mainShare",
2693
- (_b2 = (_a2 = owners.find((o) => o.id === "main")) == null ? void 0 : _a2.share) != null ? _b2 : 50
2694
- );
2695
- updateItem(
2696
- item.id,
2697
- "coShare",
2698
- (_d2 = (_c2 = owners.find((o) => o.id === "co")) == null ? void 0 : _c2.share) != null ? _d2 : 50
2699
- );
2700
- }
2701
- }
2702
- ) })
2703
- ] }) })
2704
- ] }, item.id);
2705
- })
2706
- }
2707
- ),
2708
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2709
- Button,
2710
- {
2711
- variant: "outline",
2712
- onClick: addItem,
2713
- className: "w-full gap-1.5",
2714
- children: [
2715
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react10.Plus, { className: "h-4 w-4" }),
2716
- "Add More"
2717
- ]
2718
- }
2719
- )
2720
- ] }),
2721
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
2722
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
2723
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2724
- Button,
2725
- {
2726
- onClick: () => {
2727
- onSave(items);
2728
- onOpenChange(false);
2729
- },
2730
- children: "Save"
2731
- }
2732
- )
2733
- ] })
2734
- ] }) });
2803
+ ) });
2735
2804
  }
2736
2805
  function EditAboutApplicantModal({
2737
2806
  open,
@@ -2739,14 +2808,19 @@ function EditAboutApplicantModal({
2739
2808
  applicantLabel = "Applicant",
2740
2809
  initialData,
2741
2810
  onSave,
2811
+ container,
2742
2812
  className
2743
2813
  }) {
2744
2814
  const [form, setForm] = React8.useState(__spreadValues(__spreadValues({}, ABOUT_APPLICANT_DEFAULTS), initialData));
2815
+ const initialSnapshot = React8.useRef("");
2745
2816
  React8.useEffect(() => {
2746
2817
  if (open) {
2747
- setForm(__spreadValues(__spreadValues({}, ABOUT_APPLICANT_DEFAULTS), initialData));
2818
+ const data = __spreadValues(__spreadValues({}, ABOUT_APPLICANT_DEFAULTS), initialData);
2819
+ setForm(data);
2820
+ initialSnapshot.current = JSON.stringify(data);
2748
2821
  }
2749
2822
  }, [open]);
2823
+ const isDirty = JSON.stringify(form) !== initialSnapshot.current;
2750
2824
  const setStr = (key) => (val) => setForm((prev) => __spreadProps(__spreadValues({}, prev), { [key]: val }));
2751
2825
  const handleNumDependantsChange = (val) => {
2752
2826
  const n = Math.max(0, Math.min(20, parseInt(val, 10) || 0));
@@ -2761,238 +2835,246 @@ function EditAboutApplicantModal({
2761
2835
  const next = prev.dependants.map((d, i) => i === index ? { dob } : d);
2762
2836
  return __spreadProps(__spreadValues({}, prev), { dependants: next });
2763
2837
  });
2764
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogContent, { className: cn("max-w-md", className), children: [
2765
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogTitle, { children: [
2766
- "Edit About ",
2767
- applicantLabel
2768
- ] }) }),
2769
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
2770
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex gap-3 items-start", children: [
2771
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "w-24 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Title", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Select, { value: form.title, onValueChange: setStr("title"), children: [
2772
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Title" }) }),
2773
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: TITLE_OPTIONS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
2774
- ] }) }) }),
2775
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "First Name", className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2776
- Input,
2777
- {
2778
- value: form.firstName,
2779
- onChange: (e) => setStr("firstName")(e.target.value),
2780
- placeholder: "First name"
2781
- }
2782
- ) }),
2783
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Last Name", className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2784
- Input,
2785
- {
2786
- value: form.lastName,
2787
- onChange: (e) => setStr("lastName")(e.target.value),
2788
- placeholder: "Last name"
2789
- }
2790
- ) })
2791
- ] }),
2792
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2793
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Phone Number", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2794
- Input,
2795
- {
2796
- value: form.phone,
2797
- onChange: (e) => setStr("phone")(e.target.value),
2798
- placeholder: "+61 4xx xxx xxx",
2799
- type: "tel"
2800
- }
2801
- ) }),
2802
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Email", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2803
- Input,
2804
- {
2805
- value: form.email,
2806
- onChange: (e) => setStr("email")(e.target.value),
2807
- placeholder: "email@example.com",
2808
- type: "email"
2809
- }
2810
- ) })
2811
- ] }),
2812
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2813
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Date of Birth", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2814
- DatePicker,
2815
- {
2816
- value: form.dob ? new Date(form.dob) : void 0,
2817
- onChange: (d) => setStr("dob")(d ? d.toISOString().slice(0, 10) : ""),
2818
- calendarProps: {
2819
- fromYear: 1900,
2820
- toYear: (/* @__PURE__ */ new Date()).getFullYear() - 16
2821
- }
2822
- }
2823
- ) }),
2824
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Gender", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Select, { value: form.gender, onValueChange: setStr("gender"), children: [
2825
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2826
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: GENDER_OPTIONS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: g, children: g }, g)) })
2827
- ] }) })
2828
- ] }),
2829
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2830
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Marital Status", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2831
- Select,
2832
- {
2833
- value: form.maritalStatus,
2834
- onValueChange: setStr("maritalStatus"),
2835
- children: [
2838
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2839
+ DialogContent,
2840
+ {
2841
+ className: cn("max-w-md", className),
2842
+ container,
2843
+ children: [
2844
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogTitle, { children: [
2845
+ "Edit About ",
2846
+ applicantLabel
2847
+ ] }) }),
2848
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
2849
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex gap-3 items-start", children: [
2850
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "w-24 shrink-0", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Title", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Select, { value: form.title, onValueChange: setStr("title"), children: [
2851
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Title" }) }),
2852
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: TITLE_OPTIONS.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
2853
+ ] }) }) }),
2854
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "First Name", className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2855
+ Input,
2856
+ {
2857
+ value: form.firstName,
2858
+ onChange: (e) => setStr("firstName")(e.target.value),
2859
+ placeholder: "First name"
2860
+ }
2861
+ ) }),
2862
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Last Name", className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2863
+ Input,
2864
+ {
2865
+ value: form.lastName,
2866
+ onChange: (e) => setStr("lastName")(e.target.value),
2867
+ placeholder: "Last name"
2868
+ }
2869
+ ) })
2870
+ ] }),
2871
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2872
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Phone Number", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2873
+ Input,
2874
+ {
2875
+ value: form.phone,
2876
+ onChange: (e) => setStr("phone")(e.target.value),
2877
+ placeholder: "+61 4xx xxx xxx",
2878
+ type: "tel"
2879
+ }
2880
+ ) }),
2881
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Email", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2882
+ Input,
2883
+ {
2884
+ value: form.email,
2885
+ onChange: (e) => setStr("email")(e.target.value),
2886
+ placeholder: "email@example.com",
2887
+ type: "email"
2888
+ }
2889
+ ) })
2890
+ ] }),
2891
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2892
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Date of Birth", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2893
+ DatePicker,
2894
+ {
2895
+ value: form.dob ? new Date(form.dob) : void 0,
2896
+ onChange: (d) => setStr("dob")(d ? d.toISOString().slice(0, 10) : ""),
2897
+ calendarProps: {
2898
+ fromYear: 1900,
2899
+ toYear: (/* @__PURE__ */ new Date()).getFullYear() - 16
2900
+ }
2901
+ }
2902
+ ) }),
2903
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Gender", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(Select, { value: form.gender, onValueChange: setStr("gender"), children: [
2836
2904
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2837
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: MARITAL_OPTIONS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: m, children: m }, m)) })
2838
- ]
2839
- }
2840
- ) }),
2841
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "No. of Dependants", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2842
- Input,
2843
- {
2844
- type: "number",
2845
- min: 0,
2846
- max: 20,
2847
- value: form.numDependants,
2848
- onChange: (e) => handleNumDependantsChange(e.target.value),
2849
- placeholder: "0"
2850
- }
2851
- ) })
2852
- ] }),
2853
- form.dependants.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-3", children: [
2854
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { className: "text-sm font-medium", children: "Dependant Date of Birth" }),
2855
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "grid grid-cols-2 gap-3", children: form.dependants.map((dep, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: `Dependant ${i + 1}`, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2856
- DatePicker,
2857
- {
2858
- value: dep.dob ? new Date(dep.dob) : void 0,
2859
- onChange: (d) => setDependantDob(
2860
- i,
2861
- d ? d.toISOString().slice(0, 10) : ""
2862
- ),
2863
- calendarProps: {
2864
- fromYear: 1900,
2865
- toYear: (/* @__PURE__ */ new Date()).getFullYear()
2905
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: GENDER_OPTIONS.map((g) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: g, children: g }, g)) })
2906
+ ] }) })
2907
+ ] }),
2908
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2909
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Marital Status", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2910
+ Select,
2911
+ {
2912
+ value: form.maritalStatus,
2913
+ onValueChange: setStr("maritalStatus"),
2914
+ children: [
2915
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2916
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: MARITAL_OPTIONS.map((m) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: m, children: m }, m)) })
2917
+ ]
2918
+ }
2919
+ ) }),
2920
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "No. of Dependants", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2921
+ Input,
2922
+ {
2923
+ type: "number",
2924
+ min: 0,
2925
+ max: 20,
2926
+ value: form.numDependants,
2927
+ onChange: (e) => handleNumDependantsChange(e.target.value),
2928
+ placeholder: "0"
2929
+ }
2930
+ ) })
2931
+ ] }),
2932
+ form.dependants.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-3", children: [
2933
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Label, { className: "text-sm font-medium", children: "Dependant Date of Birth" }),
2934
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "grid grid-cols-2 gap-3", children: form.dependants.map((dep, i) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: `Dependant ${i + 1}`, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2935
+ DatePicker,
2936
+ {
2937
+ value: dep.dob ? new Date(dep.dob) : void 0,
2938
+ onChange: (d) => setDependantDob(
2939
+ i,
2940
+ d ? d.toISOString().slice(0, 10) : ""
2941
+ ),
2942
+ calendarProps: {
2943
+ fromYear: 1900,
2944
+ toYear: (/* @__PURE__ */ new Date()).getFullYear()
2945
+ }
2946
+ }
2947
+ ) }, i)) })
2948
+ ] }),
2949
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Citizen Status", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2950
+ Select,
2951
+ {
2952
+ value: form.citizenStatus,
2953
+ onValueChange: setStr("citizenStatus"),
2954
+ children: [
2955
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select status" }) }),
2956
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: CITIZEN_OPTIONS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: c, children: c }, c)) })
2957
+ ]
2958
+ }
2959
+ ) }),
2960
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Current Residential Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2961
+ AddressAutocomplete,
2962
+ {
2963
+ value: form.residentialAddress,
2964
+ onValueChange: setStr("residentialAddress"),
2965
+ onSelect: (opt) => setStr("residentialAddress")(opt.label)
2966
+ }
2967
+ ) }),
2968
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2969
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Residential Status", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2970
+ Select,
2971
+ {
2972
+ value: form.residentialStatus,
2973
+ onValueChange: setStr("residentialStatus"),
2974
+ children: [
2975
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2976
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: RESIDENTIAL_STATUS_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: o, children: o }, o)) })
2977
+ ]
2978
+ }
2979
+ ) }),
2980
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Time at Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex gap-2", children: [
2981
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1 flex-1", children: [
2982
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2983
+ Input,
2984
+ {
2985
+ type: "number",
2986
+ min: 0,
2987
+ value: form.timeAtAddressYears,
2988
+ onChange: (e) => setStr("timeAtAddressYears")(e.target.value),
2989
+ placeholder: "0"
2990
+ }
2991
+ ),
2992
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-sm text-muted-foreground shrink-0", children: "yr" })
2993
+ ] }),
2994
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1 flex-1", children: [
2995
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2996
+ Input,
2997
+ {
2998
+ type: "number",
2999
+ min: 0,
3000
+ max: 11,
3001
+ value: form.timeAtAddressMonths,
3002
+ onChange: (e) => setStr("timeAtAddressMonths")(e.target.value),
3003
+ placeholder: "0"
3004
+ }
3005
+ ),
3006
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-sm text-muted-foreground shrink-0", children: "mo" })
3007
+ ] })
3008
+ ] }) })
3009
+ ] }),
3010
+ parseInt(form.timeAtAddressYears || "99") < 2 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Previous Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3011
+ AddressAutocomplete,
3012
+ {
3013
+ value: form.previousAddress,
3014
+ onValueChange: setStr("previousAddress"),
3015
+ onSelect: (opt) => setStr("previousAddress")(opt.label)
2866
3016
  }
2867
- }
2868
- ) }, i)) })
2869
- ] }),
2870
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Citizen Status", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2871
- Select,
2872
- {
2873
- value: form.citizenStatus,
2874
- onValueChange: setStr("citizenStatus"),
2875
- children: [
2876
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select status" }) }),
2877
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: CITIZEN_OPTIONS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: c, children: c }, c)) })
2878
- ]
2879
- }
2880
- ) }),
2881
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Current Residential Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2882
- AddressAutocomplete,
2883
- {
2884
- value: form.residentialAddress,
2885
- onValueChange: setStr("residentialAddress"),
2886
- onSelect: (opt) => setStr("residentialAddress")(opt.label)
2887
- }
2888
- ) }),
2889
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2890
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Residential Status", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2891
- Select,
2892
- {
2893
- value: form.residentialStatus,
2894
- onValueChange: setStr("residentialStatus"),
2895
- children: [
2896
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2897
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: RESIDENTIAL_STATUS_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: o, children: o }, o)) })
2898
- ]
2899
- }
2900
- ) }),
2901
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Time at Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex gap-2", children: [
2902
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1 flex-1", children: [
2903
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3017
+ ) }),
3018
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
3019
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Driver's Licence", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2904
3020
  Input,
2905
3021
  {
2906
- type: "number",
2907
- min: 0,
2908
- value: form.timeAtAddressYears,
2909
- onChange: (e) => setStr("timeAtAddressYears")(e.target.value),
2910
- placeholder: "0"
3022
+ value: form.driversLicence,
3023
+ onChange: (e) => setStr("driversLicence")(e.target.value),
3024
+ placeholder: "e.g. 12345678"
2911
3025
  }
2912
- ),
2913
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-sm text-muted-foreground shrink-0", children: "yr" })
2914
- ] }),
2915
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-1 flex-1", children: [
2916
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3026
+ ) }),
3027
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Passport Number", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2917
3028
  Input,
2918
3029
  {
2919
- type: "number",
2920
- min: 0,
2921
- max: 11,
2922
- value: form.timeAtAddressMonths,
2923
- onChange: (e) => setStr("timeAtAddressMonths")(e.target.value),
2924
- placeholder: "0"
3030
+ value: form.passport,
3031
+ onChange: (e) => setStr("passport")(e.target.value),
3032
+ placeholder: "e.g. PA1234567"
2925
3033
  }
2926
- ),
2927
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("span", { className: "text-sm text-muted-foreground shrink-0", children: "mo" })
3034
+ ) })
3035
+ ] }),
3036
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
3037
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Property in Trust", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3038
+ Select,
3039
+ {
3040
+ value: form.propertyInTrust,
3041
+ onValueChange: setStr("propertyInTrust"),
3042
+ children: [
3043
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
3044
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: PROPERTY_IN_TRUST_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: o, children: o }, o)) })
3045
+ ]
3046
+ }
3047
+ ) }),
3048
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Company Ownership", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3049
+ Select,
3050
+ {
3051
+ value: form.companyOwnership,
3052
+ onValueChange: setStr("companyOwnership"),
3053
+ children: [
3054
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
3055
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: COMPANY_OWNERSHIP_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: o, children: o }, o)) })
3056
+ ]
3057
+ }
3058
+ ) })
2928
3059
  ] })
2929
- ] }) })
2930
- ] }),
2931
- parseInt(form.timeAtAddressYears || "99") < 2 && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Previous Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2932
- AddressAutocomplete,
2933
- {
2934
- value: form.previousAddress,
2935
- onValueChange: setStr("previousAddress"),
2936
- onSelect: (opt) => setStr("previousAddress")(opt.label)
2937
- }
2938
- ) }),
2939
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2940
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Driver's Licence", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2941
- Input,
2942
- {
2943
- value: form.driversLicence,
2944
- onChange: (e) => setStr("driversLicence")(e.target.value),
2945
- placeholder: "e.g. 12345678"
2946
- }
2947
- ) }),
2948
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Passport Number", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2949
- Input,
2950
- {
2951
- value: form.passport,
2952
- onChange: (e) => setStr("passport")(e.target.value),
2953
- placeholder: "e.g. PA1234567"
2954
- }
2955
- ) })
2956
- ] }),
2957
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
2958
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Property in Trust", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2959
- Select,
2960
- {
2961
- value: form.propertyInTrust,
2962
- onValueChange: setStr("propertyInTrust"),
2963
- children: [
2964
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2965
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: PROPERTY_IN_TRUST_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: o, children: o }, o)) })
2966
- ]
2967
- }
2968
- ) }),
2969
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Company Ownership", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
2970
- Select,
2971
- {
2972
- value: form.companyOwnership,
2973
- onValueChange: setStr("companyOwnership"),
2974
- children: [
2975
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select" }) }),
2976
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: COMPANY_OWNERSHIP_OPTIONS.map((o) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: o, children: o }, o)) })
2977
- ]
2978
- }
2979
- ) })
2980
- ] })
2981
- ] }),
2982
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
2983
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
2984
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
2985
- Button,
2986
- {
2987
- onClick: () => {
2988
- onSave(form);
2989
- onOpenChange(false);
2990
- },
2991
- children: "Save"
2992
- }
2993
- )
2994
- ] })
2995
- ] }) });
3060
+ ] }),
3061
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
3062
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
3063
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3064
+ Button,
3065
+ {
3066
+ disabled: !isDirty,
3067
+ onClick: () => {
3068
+ onSave(form);
3069
+ onOpenChange(false);
3070
+ },
3071
+ children: "Save"
3072
+ }
3073
+ )
3074
+ ] })
3075
+ ]
3076
+ }
3077
+ ) });
2996
3078
  }
2997
3079
  function EditIncomeModal({
2998
3080
  open,
@@ -3000,6 +3082,7 @@ function EditIncomeModal({
3000
3082
  applicantLabel = "Applicant",
3001
3083
  initialData,
3002
3084
  onSave,
3085
+ container,
3003
3086
  className
3004
3087
  }) {
3005
3088
  const defaultItems = React8.useMemo(
@@ -3011,204 +3094,214 @@ function EditIncomeModal({
3011
3094
  // eslint-disable-line react-hooks/exhaustive-deps
3012
3095
  );
3013
3096
  const [items, setItems] = React8.useState(defaultItems);
3097
+ const initialSnapshot = React8.useRef("");
3014
3098
  React8.useEffect(() => {
3015
3099
  var _a;
3016
3100
  if (open) {
3017
- setItems(
3018
- ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultIncomeItem()]
3019
- );
3101
+ const data = ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultIncomeItem()];
3102
+ setItems(data);
3103
+ initialSnapshot.current = JSON.stringify(data);
3020
3104
  }
3021
3105
  }, [open]);
3106
+ const isDirty = JSON.stringify(items) !== initialSnapshot.current;
3022
3107
  const updateItem = (id, key, val) => setItems(
3023
3108
  (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
3024
3109
  );
3025
3110
  const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
3026
3111
  const addItem = () => setItems((prev) => [...prev, makeDefaultIncomeItem()]);
3027
3112
  const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
3028
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogContent, { className: cn("max-w-lg", className), children: [
3029
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogTitle, { children: [
3030
- "Edit Income ",
3031
- applicantLabel
3032
- ] }) }),
3033
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
3034
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3035
- Accordion,
3036
- {
3037
- multiple: true,
3038
- defaultValue: defaultOpenItems,
3039
- className: "w-full",
3040
- children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(AccordionItem, { value: item.id, children: [
3041
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3042
- AccordionItemHeader,
3043
- {
3044
- label: `Income ${index + 1} \u2014 ${item.incomeType || "New Income"}`,
3045
- onRemove: () => removeItem(item.id),
3046
- removeLabel: "Remove income item"
3047
- }
3048
- ),
3049
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AccordionContent, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-4 pt-1", children: [
3050
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Income Type", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3051
- Select,
3052
- {
3053
- value: item.incomeType,
3054
- onValueChange: (val) => updateItem(item.id, "incomeType", val),
3055
- children: [
3056
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select type" }) }),
3057
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: INCOME_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
3058
- ]
3059
- }
3060
- ) }),
3061
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Job Title", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3062
- Input,
3063
- {
3064
- value: item.jobTitle,
3065
- onChange: (e) => updateItem(item.id, "jobTitle", e.target.value),
3066
- placeholder: "Job title"
3067
- }
3068
- ) }),
3069
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
3070
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Start Date", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3071
- DatePicker,
3072
- {
3073
- value: item.startDate ? new Date(item.startDate) : void 0,
3074
- onChange: (d) => updateItem(
3075
- item.id,
3076
- "startDate",
3077
- d ? d.toISOString().slice(0, 10) : ""
3078
- ),
3079
- calendarProps: {
3080
- fromYear: 1950,
3081
- toYear: (/* @__PURE__ */ new Date()).getFullYear()
3082
- }
3083
- }
3084
- ) }),
3085
- !item.stillInPosition && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "End Date", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3086
- DatePicker,
3087
- {
3088
- value: item.endDate ? new Date(item.endDate) : void 0,
3089
- onChange: (d) => updateItem(
3090
- item.id,
3091
- "endDate",
3092
- d ? d.toISOString().slice(0, 10) : ""
3093
- ),
3094
- calendarProps: {
3095
- fromYear: 1950,
3096
- toYear: (/* @__PURE__ */ new Date()).getFullYear()
3097
- }
3098
- }
3099
- ) })
3100
- ] }),
3101
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
3113
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3114
+ DialogContent,
3115
+ {
3116
+ className: cn("max-w-lg", className),
3117
+ container,
3118
+ children: [
3119
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogTitle, { children: [
3120
+ "Edit Income ",
3121
+ applicantLabel
3122
+ ] }) }),
3123
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
3124
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3125
+ Accordion,
3126
+ {
3127
+ multiple: true,
3128
+ defaultValue: defaultOpenItems,
3129
+ className: "w-full",
3130
+ children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(AccordionItem, { value: item.id, children: [
3102
3131
  /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3103
- Checkbox,
3132
+ AccordionItemHeader,
3104
3133
  {
3105
- id: `still-in-position-${item.id}`,
3106
- checked: item.stillInPosition,
3107
- onCheckedChange: (checked) => updateItem(
3108
- item.id,
3109
- "stillInPosition",
3110
- checked === true
3111
- )
3134
+ label: `Income ${index + 1} \u2014 ${item.incomeType || "New Income"}`,
3135
+ onRemove: () => removeItem(item.id),
3136
+ removeLabel: "Remove income item"
3112
3137
  }
3113
3138
  ),
3114
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3115
- "label",
3116
- {
3117
- htmlFor: `still-in-position-${item.id}`,
3118
- className: "text-sm cursor-pointer select-none",
3119
- children: "Still in position"
3120
- }
3121
- )
3122
- ] }),
3123
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Company Name", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3124
- Input,
3125
- {
3126
- value: item.companyName,
3127
- onChange: (e) => updateItem(item.id, "companyName", e.target.value),
3128
- placeholder: "Company name"
3129
- }
3130
- ) }),
3131
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Company Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3132
- AddressAutocomplete,
3133
- {
3134
- value: item.companyAddress,
3135
- onValueChange: (val) => updateItem(item.id, "companyAddress", val),
3136
- placeholder: "Search company address"
3137
- }
3138
- ) }),
3139
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-start gap-3", children: [
3140
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Income Amount", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3141
- CurrencyInputWithSlider,
3142
- {
3143
- value: item.incomeAmount,
3144
- min: 0,
3145
- max: 1e6,
3146
- step: 1e3,
3147
- onValueChange: (val) => updateItem(item.id, "incomeAmount", val)
3148
- }
3149
- ) }) }),
3150
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3151
- FrequencyToggle,
3152
- {
3153
- value: item.frequency,
3154
- onValueChange: (val) => updateItem(item.id, "frequency", val)
3155
- }
3156
- ) })
3157
- ] }),
3158
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Type of Company", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3159
- RadioGroup,
3160
- {
3161
- value: item.companyType,
3162
- onValueChange: (val) => updateItem(
3163
- item.id,
3164
- "companyType",
3165
- val
3166
- ),
3167
- className: "flex gap-4",
3168
- children: ["Public", "Private"].map((opt) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3169
- "label",
3139
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AccordionContent, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-4 pt-1", children: [
3140
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Income Type", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3141
+ Select,
3170
3142
  {
3171
- className: "flex items-center gap-2 cursor-pointer text-sm",
3143
+ value: item.incomeType,
3144
+ onValueChange: (val) => updateItem(item.id, "incomeType", val),
3172
3145
  children: [
3173
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RadioGroupItem, { value: opt }),
3174
- opt
3146
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select type" }) }),
3147
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: INCOME_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
3175
3148
  ]
3176
- },
3177
- opt
3178
- ))
3179
- }
3180
- ) })
3181
- ] }) })
3182
- ] }, item.id))
3183
- }
3184
- ),
3185
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3186
- Button,
3187
- {
3188
- variant: "outline",
3189
- onClick: addItem,
3190
- className: "w-full gap-1.5",
3191
- children: [
3192
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react10.Plus, { className: "h-4 w-4" }),
3193
- "Add More"
3194
- ]
3195
- }
3196
- )
3197
- ] }),
3198
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
3199
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
3200
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3201
- Button,
3202
- {
3203
- onClick: () => {
3204
- onSave({ items });
3205
- onOpenChange(false);
3206
- },
3207
- children: "Save"
3208
- }
3209
- )
3210
- ] })
3211
- ] }) });
3149
+ }
3150
+ ) }),
3151
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Job Title", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3152
+ Input,
3153
+ {
3154
+ value: item.jobTitle,
3155
+ onChange: (e) => updateItem(item.id, "jobTitle", e.target.value),
3156
+ placeholder: "Job title"
3157
+ }
3158
+ ) }),
3159
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "grid grid-cols-2 gap-4", children: [
3160
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Start Date", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3161
+ DatePicker,
3162
+ {
3163
+ value: item.startDate ? new Date(item.startDate) : void 0,
3164
+ onChange: (d) => updateItem(
3165
+ item.id,
3166
+ "startDate",
3167
+ d ? d.toISOString().slice(0, 10) : ""
3168
+ ),
3169
+ calendarProps: {
3170
+ fromYear: 1950,
3171
+ toYear: (/* @__PURE__ */ new Date()).getFullYear()
3172
+ }
3173
+ }
3174
+ ) }),
3175
+ !item.stillInPosition && /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "End Date", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3176
+ DatePicker,
3177
+ {
3178
+ value: item.endDate ? new Date(item.endDate) : void 0,
3179
+ onChange: (d) => updateItem(
3180
+ item.id,
3181
+ "endDate",
3182
+ d ? d.toISOString().slice(0, 10) : ""
3183
+ ),
3184
+ calendarProps: {
3185
+ fromYear: 1950,
3186
+ toYear: (/* @__PURE__ */ new Date()).getFullYear()
3187
+ }
3188
+ }
3189
+ ) })
3190
+ ] }),
3191
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-center gap-2", children: [
3192
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3193
+ Checkbox,
3194
+ {
3195
+ id: `still-in-position-${item.id}`,
3196
+ checked: item.stillInPosition,
3197
+ onCheckedChange: (checked) => updateItem(
3198
+ item.id,
3199
+ "stillInPosition",
3200
+ checked === true
3201
+ )
3202
+ }
3203
+ ),
3204
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3205
+ "label",
3206
+ {
3207
+ htmlFor: `still-in-position-${item.id}`,
3208
+ className: "text-sm cursor-pointer select-none",
3209
+ children: "Still in position"
3210
+ }
3211
+ )
3212
+ ] }),
3213
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Company Name", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3214
+ Input,
3215
+ {
3216
+ value: item.companyName,
3217
+ onChange: (e) => updateItem(item.id, "companyName", e.target.value),
3218
+ placeholder: "Company name"
3219
+ }
3220
+ ) }),
3221
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Company Address", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3222
+ AddressAutocomplete,
3223
+ {
3224
+ value: item.companyAddress,
3225
+ onValueChange: (val) => updateItem(item.id, "companyAddress", val),
3226
+ placeholder: "Search company address"
3227
+ }
3228
+ ) }),
3229
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-start gap-3", children: [
3230
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Income Amount", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3231
+ CurrencyInputWithSlider,
3232
+ {
3233
+ value: item.incomeAmount,
3234
+ min: 0,
3235
+ max: 1e6,
3236
+ step: 1e3,
3237
+ onValueChange: (val) => updateItem(item.id, "incomeAmount", val)
3238
+ }
3239
+ ) }) }),
3240
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3241
+ FrequencyToggle,
3242
+ {
3243
+ value: item.frequency,
3244
+ onValueChange: (val) => updateItem(item.id, "frequency", val)
3245
+ }
3246
+ ) })
3247
+ ] }),
3248
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Type of Company", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3249
+ RadioGroup,
3250
+ {
3251
+ value: item.companyType,
3252
+ onValueChange: (val) => updateItem(
3253
+ item.id,
3254
+ "companyType",
3255
+ val
3256
+ ),
3257
+ className: "flex gap-4",
3258
+ children: ["Public", "Private"].map((opt) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3259
+ "label",
3260
+ {
3261
+ className: "flex items-center gap-2 cursor-pointer text-sm",
3262
+ children: [
3263
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(RadioGroupItem, { value: opt }),
3264
+ opt
3265
+ ]
3266
+ },
3267
+ opt
3268
+ ))
3269
+ }
3270
+ ) })
3271
+ ] }) })
3272
+ ] }, item.id))
3273
+ }
3274
+ ),
3275
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3276
+ Button,
3277
+ {
3278
+ variant: "outline",
3279
+ onClick: addItem,
3280
+ className: "w-full gap-1.5",
3281
+ children: [
3282
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react10.Plus, { className: "h-4 w-4" }),
3283
+ "Add More"
3284
+ ]
3285
+ }
3286
+ )
3287
+ ] }),
3288
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
3289
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
3290
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3291
+ Button,
3292
+ {
3293
+ disabled: !isDirty,
3294
+ onClick: () => {
3295
+ onSave({ items });
3296
+ onOpenChange(false);
3297
+ },
3298
+ children: "Save"
3299
+ }
3300
+ )
3301
+ ] })
3302
+ ]
3303
+ }
3304
+ ) });
3212
3305
  }
3213
3306
  function EditExpensesModal({
3214
3307
  open,
@@ -3216,6 +3309,7 @@ function EditExpensesModal({
3216
3309
  applicantLabel = "Applicant",
3217
3310
  initialData,
3218
3311
  onSave,
3312
+ container,
3219
3313
  className
3220
3314
  }) {
3221
3315
  const defaultItems = React8.useMemo(
@@ -3227,127 +3321,137 @@ function EditExpensesModal({
3227
3321
  // eslint-disable-line react-hooks/exhaustive-deps
3228
3322
  );
3229
3323
  const [items, setItems] = React8.useState(defaultItems);
3324
+ const initialSnapshot = React8.useRef("");
3230
3325
  React8.useEffect(() => {
3231
3326
  var _a;
3232
3327
  if (open) {
3233
- setItems(
3234
- ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultExpenseItem()]
3235
- );
3328
+ const data = ((_a = initialData == null ? void 0 : initialData.items) == null ? void 0 : _a.length) ? initialData.items : [makeDefaultExpenseItem()];
3329
+ setItems(data);
3330
+ initialSnapshot.current = JSON.stringify(data);
3236
3331
  }
3237
3332
  }, [open]);
3333
+ const isDirty = JSON.stringify(items) !== initialSnapshot.current;
3238
3334
  const updateItem = (id, key, val) => setItems(
3239
3335
  (prev) => prev.map((item) => item.id === id ? __spreadProps(__spreadValues({}, item), { [key]: val }) : item)
3240
3336
  );
3241
3337
  const removeItem = (id) => setItems((prev) => prev.filter((item) => item.id !== id));
3242
3338
  const addItem = () => setItems((prev) => [...prev, makeDefaultExpenseItem()]);
3243
3339
  const defaultOpenItems = items.length > 0 ? [items[0].id] : [];
3244
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogContent, { className: cn("max-w-lg", className), children: [
3245
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogTitle, { children: [
3246
- "Edit Expenses ",
3247
- applicantLabel
3248
- ] }) }),
3249
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
3250
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3251
- Accordion,
3252
- {
3253
- multiple: true,
3254
- defaultValue: defaultOpenItems,
3255
- className: "w-full",
3256
- children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(AccordionItem, { value: item.id, children: [
3257
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3258
- AccordionItemHeader,
3259
- {
3260
- label: `Expense ${index + 1} \u2014 ${item.expenseType || "New Expense"}`,
3261
- onRemove: () => removeItem(item.id),
3262
- removeLabel: "Remove expense item"
3263
- }
3264
- ),
3265
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AccordionContent, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-4 pt-1", children: [
3266
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Expense Type", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3267
- Select,
3268
- {
3269
- value: item.expenseType,
3270
- onValueChange: (val) => updateItem(item.id, "expenseType", val),
3271
- children: [
3272
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select type" }) }),
3273
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: EXPENSE_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
3274
- ]
3275
- }
3276
- ) }),
3277
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-start gap-3", children: [
3278
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Amount", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3279
- CurrencyInputWithSlider,
3280
- {
3281
- value: item.amount,
3282
- min: 0,
3283
- max: 1e5,
3284
- step: 100,
3285
- onValueChange: (val) => updateItem(item.id, "amount", val)
3286
- }
3287
- ) }) }),
3288
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3289
- FrequencyToggle,
3340
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Dialog, { open, onOpenChange, children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3341
+ DialogContent,
3342
+ {
3343
+ className: cn("max-w-lg", className),
3344
+ container,
3345
+ children: [
3346
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogTitle, { children: [
3347
+ "Edit Expenses ",
3348
+ applicantLabel
3349
+ ] }) }),
3350
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(ModalScroll, { children: [
3351
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3352
+ Accordion,
3353
+ {
3354
+ multiple: true,
3355
+ defaultValue: defaultOpenItems,
3356
+ className: "w-full",
3357
+ children: items.map((item, index) => /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(AccordionItem, { value: item.id, children: [
3358
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3359
+ AccordionItemHeader,
3290
3360
  {
3291
- value: item.frequency,
3292
- onValueChange: (val) => updateItem(item.id, "frequency", val)
3361
+ label: `Expense ${index + 1} \u2014 ${item.expenseType || "New Expense"}`,
3362
+ onRemove: () => removeItem(item.id),
3363
+ removeLabel: "Remove expense item"
3293
3364
  }
3294
- ) })
3295
- ] }),
3296
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3297
- OwnershipSplit,
3298
- {
3299
- owners: [
3365
+ ),
3366
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(AccordionContent, { children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex flex-col gap-4 pt-1", children: [
3367
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Expense Type", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3368
+ Select,
3300
3369
  {
3301
- id: "main",
3302
- name: "Main Applicant",
3303
- share: item.mainShare
3304
- },
3370
+ value: item.expenseType,
3371
+ onValueChange: (val) => updateItem(item.id, "expenseType", val),
3372
+ children: [
3373
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectValue, { placeholder: "Select type" }) }),
3374
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectContent, { children: EXPENSE_TYPES.map((t) => /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(SelectItem, { value: t, children: t }, t)) })
3375
+ ]
3376
+ }
3377
+ ) }),
3378
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)("div", { className: "flex items-start gap-3", children: [
3379
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "flex-1", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Amount", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3380
+ CurrencyInputWithSlider,
3381
+ {
3382
+ value: item.amount,
3383
+ min: 0,
3384
+ max: 1e5,
3385
+ step: 100,
3386
+ onValueChange: (val) => updateItem(item.id, "amount", val)
3387
+ }
3388
+ ) }) }),
3389
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)("div", { className: "shrink-0 mt-[1.625rem]", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3390
+ FrequencyToggle,
3391
+ {
3392
+ value: item.frequency,
3393
+ onValueChange: (val) => updateItem(item.id, "frequency", val)
3394
+ }
3395
+ ) })
3396
+ ] }),
3397
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(FormField, { label: "Ownership (%)", children: /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3398
+ OwnershipSplit,
3305
3399
  {
3306
- id: "co",
3307
- name: "Co-Applicant",
3308
- share: item.coShare
3400
+ owners: [
3401
+ {
3402
+ id: "main",
3403
+ name: "Main Applicant",
3404
+ share: item.mainShare
3405
+ },
3406
+ {
3407
+ id: "co",
3408
+ name: "Co-Applicant",
3409
+ share: item.coShare
3410
+ }
3411
+ ],
3412
+ onOwnersChange: (owners) => {
3413
+ var _a, _b, _c, _d;
3414
+ const main = (_b = (_a = owners.find((o) => o.id === "main")) == null ? void 0 : _a.share) != null ? _b : item.mainShare;
3415
+ const co = (_d = (_c = owners.find((o) => o.id === "co")) == null ? void 0 : _c.share) != null ? _d : item.coShare;
3416
+ updateItem(item.id, "mainShare", main);
3417
+ updateItem(item.id, "coShare", co);
3418
+ }
3309
3419
  }
3310
- ],
3311
- onOwnersChange: (owners) => {
3312
- var _a, _b, _c, _d;
3313
- const main = (_b = (_a = owners.find((o) => o.id === "main")) == null ? void 0 : _a.share) != null ? _b : item.mainShare;
3314
- const co = (_d = (_c = owners.find((o) => o.id === "co")) == null ? void 0 : _c.share) != null ? _d : item.coShare;
3315
- updateItem(item.id, "mainShare", main);
3316
- updateItem(item.id, "coShare", co);
3317
- }
3318
- }
3319
- ) })
3320
- ] }) })
3321
- ] }, item.id))
3322
- }
3323
- ),
3324
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3325
- Button,
3326
- {
3327
- variant: "outline",
3328
- onClick: addItem,
3329
- className: "w-full gap-1.5",
3330
- children: [
3331
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react10.Plus, { className: "h-4 w-4" }),
3332
- "Add More"
3333
- ]
3334
- }
3335
- )
3336
- ] }),
3337
- /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
3338
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
3339
- /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3340
- Button,
3341
- {
3342
- onClick: () => {
3343
- onSave({ items });
3344
- onOpenChange(false);
3345
- },
3346
- children: "Save"
3347
- }
3348
- )
3349
- ] })
3350
- ] }) });
3420
+ ) })
3421
+ ] }) })
3422
+ ] }, item.id))
3423
+ }
3424
+ ),
3425
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(
3426
+ Button,
3427
+ {
3428
+ variant: "outline",
3429
+ onClick: addItem,
3430
+ className: "w-full gap-1.5",
3431
+ children: [
3432
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(import_lucide_react10.Plus, { className: "h-4 w-4" }),
3433
+ "Add More"
3434
+ ]
3435
+ }
3436
+ )
3437
+ ] }),
3438
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsxs)(DialogFooter, { children: [
3439
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Button, { variant: "outline", onClick: () => onOpenChange(false), children: "Cancel" }),
3440
+ /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
3441
+ Button,
3442
+ {
3443
+ disabled: !isDirty,
3444
+ onClick: () => {
3445
+ onSave({ items });
3446
+ onOpenChange(false);
3447
+ },
3448
+ children: "Save"
3449
+ }
3450
+ )
3451
+ ] })
3452
+ ]
3453
+ }
3454
+ ) });
3351
3455
  }
3352
3456
  // Annotate the CommonJS export names for ESM import in node:
3353
3457
  0 && (module.exports = {