@splpi/estore-shared-components 7.0.4 → 7.0.5

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.
package/dist/index.mjs CHANGED
@@ -230,7 +230,7 @@ var STANDARD_ICON_BUTTON_STYLES = {
230
230
  var OCR_STORAGE_KEY = "ocrResult";
231
231
  var readStored = () => {
232
232
  try {
233
- const raw = localStorage.getItem(OCR_STORAGE_KEY);
233
+ const raw = sessionStorage.getItem(OCR_STORAGE_KEY);
234
234
  return raw ? JSON.parse(raw) : null;
235
235
  } catch {
236
236
  return null;
@@ -247,7 +247,7 @@ var markOcrApplied = (section) => {
247
247
  const stored = readStored();
248
248
  if (!stored || stored.applied?.[section]) return false;
249
249
  try {
250
- localStorage.setItem(
250
+ sessionStorage.setItem(
251
251
  OCR_STORAGE_KEY,
252
252
  JSON.stringify({ ...stored, applied: { ...stored.applied, [section]: true } })
253
253
  );
@@ -259,14 +259,14 @@ var markOcrApplied = (section) => {
259
259
  var saveOcrResult = (value) => {
260
260
  if (typeof window === "undefined") return;
261
261
  try {
262
- localStorage.setItem(OCR_STORAGE_KEY, JSON.stringify(value));
262
+ sessionStorage.setItem(OCR_STORAGE_KEY, JSON.stringify(value));
263
263
  } catch {
264
264
  }
265
265
  };
266
266
  var clearOcrResult = () => {
267
267
  if (typeof window === "undefined") return;
268
268
  try {
269
- localStorage.removeItem(OCR_STORAGE_KEY);
269
+ sessionStorage.removeItem(OCR_STORAGE_KEY);
270
270
  } catch {
271
271
  }
272
272
  };
@@ -388,22 +388,22 @@ var LifePlanApplication1 = ({
388
388
  onUpdate
389
389
  }) => {
390
390
  const [formData, setFormData] = useState2(() => applyOcr({
391
- firstName: initialData?.firstName ?? "Juan",
392
- middleName: initialData?.middleName ?? "Santos",
393
- lastName: initialData?.lastName ?? "Dela Cruz",
391
+ firstName: initialData?.firstName ?? "",
392
+ middleName: initialData?.middleName ?? "",
393
+ lastName: initialData?.lastName ?? "",
394
394
  suffix: initialData?.suffix ?? "",
395
- birthDate: initialData?.birthDate ?? "1990-05-15",
396
- idType: initialData?.idType ?? "national_id",
397
- idNumber: initialData?.idNumber ?? "1234-5678-9012",
398
- height: initialData?.height ?? 5.7,
399
- weight: initialData?.weight ?? 154,
400
- gender: initialData?.gender ?? "male",
401
- civilStatus: initialData?.civilStatus ?? "married",
402
- nationality: initialData?.nationality ?? "Filipino",
403
- mobileNumber: initialData?.mobileNumber ?? "0917-123-4567",
404
- emailAddress: initialData?.emailAddress ?? "juan.delacruz@example.com",
405
- mailingAddress: initialData?.mailingAddress ?? "123 Mabini Street, Barangay San Antonio, Makati City",
406
- landLineNumber: initialData?.landLineNumber ?? "02-8123-4567"
395
+ birthDate: initialData?.birthDate ?? "",
396
+ idType: initialData?.idType ?? "",
397
+ idNumber: initialData?.idNumber ?? "",
398
+ height: initialData?.height ?? 0,
399
+ weight: initialData?.weight ?? 0,
400
+ gender: initialData?.gender ?? "",
401
+ civilStatus: initialData?.civilStatus ?? "",
402
+ nationality: initialData?.nationality ?? "",
403
+ mobileNumber: initialData?.mobileNumber ?? "",
404
+ emailAddress: initialData?.emailAddress ?? "",
405
+ mailingAddress: initialData?.mailingAddress ?? "",
406
+ landLineNumber: initialData?.landLineNumber ?? ""
407
407
  }, readOcrResult("personal")));
408
408
  const updateFormData = (nextData) => {
409
409
  setFormData(nextData);
@@ -882,15 +882,16 @@ var matchOption = (candidates, options) => {
882
882
  return "";
883
883
  };
884
884
  var LifePlanApplication2 = ({
885
+ initialData,
885
886
  onAddressUpdate,
886
887
  parseAddress
887
888
  }) => {
888
- const [lot, setLot] = useState3("");
889
- const [street, setStreet] = useState3("");
890
- const [city, setCity] = useState3("");
891
- const [province, setProvince] = useState3("");
892
- const [district, setDistrict] = useState3("");
893
- const [barangay, setBarangay] = useState3("");
889
+ const [lot, setLot] = useState3(initialData?.lot ?? "");
890
+ const [street, setStreet] = useState3(initialData?.street ?? "");
891
+ const [city, setCity] = useState3(initialData?.city ?? "");
892
+ const [province, setProvince] = useState3(initialData?.province ?? "");
893
+ const [district, setDistrict] = useState3(initialData?.district ?? "");
894
+ const [barangay, setBarangay] = useState3(initialData?.barangay ?? "");
894
895
  useEffect2(() => {
895
896
  if (!parseAddress) return;
896
897
  const ocr = readOcrResult("address");
@@ -1013,13 +1014,13 @@ var LifePlanApplication3 = ({
1013
1014
  onUpdate
1014
1015
  }) => {
1015
1016
  const [formData, setFormData] = React.useState({
1016
- occupation: initialData?.occupation ?? "Software Engineer",
1017
- employerName: initialData?.employerName ?? "ABC Technologies Inc.",
1018
- employmentStatus: initialData?.employmentStatus ?? "Regular",
1019
- officeAddress: initialData?.officeAddress ?? "456 Ayala Avenue, Bel-Air, Makati City",
1020
- TIN: initialData?.TIN ?? "123-456-789-000",
1021
- SSS: initialData?.SSS ?? "34-1234567-8",
1022
- sourceOfIncome: initialData?.sourceOfIncome ?? "Salary"
1017
+ occupation: initialData?.occupation ?? "",
1018
+ employerName: initialData?.employerName ?? "",
1019
+ employmentStatus: initialData?.employmentStatus ?? "",
1020
+ officeAddress: initialData?.officeAddress ?? "",
1021
+ TIN: initialData?.TIN ?? "",
1022
+ SSS: initialData?.SSS ?? "",
1023
+ sourceOfIncome: initialData?.sourceOfIncome ?? ""
1023
1024
  });
1024
1025
  const updateFormData = (nextData) => {
1025
1026
  setFormData(nextData);
@@ -1169,6 +1170,7 @@ var RowItem = ({
1169
1170
 
1170
1171
  // src/lib/applicationData.ts
1171
1172
  var LIFE_PLAN_APPLICATION_KEY = "LifePlanApplication";
1173
+ var APPLICATION_DATA_CHANGE_EVENT = "lifeplan-application:change";
1172
1174
  var createEmptyApplicationData = () => ({
1173
1175
  personalInfo: {
1174
1176
  firstName: "",
@@ -1213,19 +1215,57 @@ var createEmptyApplicationData = () => ({
1213
1215
  healthDeclaration4: false
1214
1216
  }
1215
1217
  });
1216
- var loadApplicationDataFromLocalStorage = (storageKey = LIFE_PLAN_APPLICATION_KEY) => {
1218
+ var getStorage = () => {
1217
1219
  if (typeof window === "undefined") return null;
1218
1220
  try {
1219
- const stored = window.localStorage.getItem(storageKey);
1221
+ return window.sessionStorage;
1222
+ } catch {
1223
+ return null;
1224
+ }
1225
+ };
1226
+ var notifyChange = (storageKey) => {
1227
+ window.dispatchEvent(
1228
+ new CustomEvent(APPLICATION_DATA_CHANGE_EVENT, { detail: { storageKey } })
1229
+ );
1230
+ };
1231
+ var loadApplicationData = (storageKey = LIFE_PLAN_APPLICATION_KEY) => {
1232
+ const storage = getStorage();
1233
+ if (!storage) return null;
1234
+ try {
1235
+ const stored = storage.getItem(storageKey);
1220
1236
  return stored ? JSON.parse(stored) : null;
1221
1237
  } catch {
1222
1238
  return null;
1223
1239
  }
1224
1240
  };
1225
- var saveApplicationDataToLocalStorage = (data, storageKey = LIFE_PLAN_APPLICATION_KEY) => {
1226
- if (typeof window === "undefined") return;
1227
- window.localStorage.setItem(storageKey, JSON.stringify(data));
1241
+ var saveApplicationData = (data, storageKey = LIFE_PLAN_APPLICATION_KEY) => {
1242
+ const storage = getStorage();
1243
+ if (!storage) return;
1244
+ try {
1245
+ storage.setItem(storageKey, JSON.stringify(data));
1246
+ } catch {
1247
+ return;
1248
+ }
1249
+ notifyChange(storageKey);
1228
1250
  };
1251
+ var updateApplicationData = (patch, storageKey = LIFE_PLAN_APPLICATION_KEY) => {
1252
+ const current = loadApplicationData(storageKey) ?? createEmptyApplicationData();
1253
+ const next = { ...current, ...patch };
1254
+ saveApplicationData(next, storageKey);
1255
+ return next;
1256
+ };
1257
+ var clearApplicationData = (storageKey = LIFE_PLAN_APPLICATION_KEY) => {
1258
+ const storage = getStorage();
1259
+ if (!storage) return;
1260
+ try {
1261
+ storage.removeItem(storageKey);
1262
+ } catch {
1263
+ return;
1264
+ }
1265
+ notifyChange(storageKey);
1266
+ };
1267
+ var loadApplicationDataFromLocalStorage = loadApplicationData;
1268
+ var saveApplicationDataToLocalStorage = saveApplicationData;
1229
1269
 
1230
1270
  // src/NewSaleForm/beneficiary.tsx
1231
1271
  import { Fragment, jsx as jsx6, jsxs as jsxs6 } from "react/jsx-runtime";
@@ -1279,13 +1319,13 @@ var Beneficiary = ({ onUpdate }) => {
1279
1319
  contingent.length > 0 ? contingent[0] : void 0,
1280
1320
  allBeneficiaries
1281
1321
  );
1282
- const currentData = loadApplicationDataFromLocalStorage() ?? createEmptyApplicationData();
1322
+ const currentData = loadApplicationData() ?? createEmptyApplicationData();
1283
1323
  const {
1284
1324
  principalBeneficiary: _oldPrincipal,
1285
1325
  contingentBeneficiary: _oldContingent,
1286
1326
  ...restData
1287
1327
  } = currentData;
1288
- saveApplicationDataToLocalStorage({
1328
+ saveApplicationData({
1289
1329
  ...restData,
1290
1330
  beneficiaries: allBeneficiaries,
1291
1331
  ...principal[0] ? { principalBeneficiary: principal[0] } : {},
@@ -1294,7 +1334,7 @@ var Beneficiary = ({ onUpdate }) => {
1294
1334
  };
1295
1335
  useEffect3(() => {
1296
1336
  const timeoutId = window.setTimeout(() => {
1297
- const currentData = loadApplicationDataFromLocalStorage();
1337
+ const currentData = loadApplicationData();
1298
1338
  if (!currentData) return;
1299
1339
  const storedBeneficiaries = currentData.beneficiaries ?? [];
1300
1340
  let principalFromStorage = storedBeneficiaries.filter(
@@ -1954,29 +1994,18 @@ var HealthDeclaration = () => {
1954
1994
  healthDeclaration3: false,
1955
1995
  healthDeclaration4: false
1956
1996
  });
1997
+ const [hydrated, setHydrated] = useState5(false);
1957
1998
  useEffect4(() => {
1958
- let appData = loadApplicationDataFromLocalStorage();
1959
- if (!appData) {
1960
- appData = createEmptyApplicationData();
1961
- saveApplicationDataToLocalStorage(appData);
1962
- }
1963
- if (appData && appData.healthDeclaration) {
1999
+ const appData = loadApplicationData();
2000
+ if (appData?.healthDeclaration) {
1964
2001
  setHealthDeclarationValues(appData.healthDeclaration);
1965
2002
  }
2003
+ setHydrated(true);
1966
2004
  }, []);
1967
2005
  useEffect4(() => {
1968
- return () => {
1969
- const appData = loadApplicationDataFromLocalStorage();
1970
- if (appData) {
1971
- appData.healthDeclaration = healthDeclarationValues;
1972
- saveApplicationDataToLocalStorage(appData);
1973
- console.log(
1974
- "Health Declaration saved to localStorage",
1975
- healthDeclarationValues
1976
- );
1977
- }
1978
- };
1979
- }, [healthDeclarationValues]);
2006
+ if (!hydrated) return;
2007
+ updateApplicationData({ healthDeclaration: healthDeclarationValues });
2008
+ }, [healthDeclarationValues, hydrated]);
1980
2009
  const items = [
1981
2010
  {
1982
2011
  value: "first-item",
@@ -2292,7 +2321,7 @@ var LifePlanApplicationFormWrapper = ({
2292
2321
  const [openSections, setOpenSections] = useState7(["personal"]);
2293
2322
  useEffect5(() => {
2294
2323
  const timeoutId = window.setTimeout(() => {
2295
- const saved = loadApplicationDataFromLocalStorage();
2324
+ const saved = loadApplicationData();
2296
2325
  if (saved) setApplicationData(saved);
2297
2326
  setHydrated(true);
2298
2327
  }, 0);
@@ -2300,7 +2329,11 @@ var LifePlanApplicationFormWrapper = ({
2300
2329
  }, []);
2301
2330
  useEffect5(() => {
2302
2331
  if (!hydrated) return;
2303
- saveApplicationDataToLocalStorage(applicationData);
2332
+ updateApplicationData({
2333
+ personalInfo: applicationData.personalInfo,
2334
+ address: applicationData.address,
2335
+ employment: applicationData.employment
2336
+ });
2304
2337
  }, [applicationData, hydrated]);
2305
2338
  const isComplete = isPersonalComplete(applicationData.personalInfo) && isAddressComplete(applicationData.address);
2306
2339
  useEffect5(() => {
@@ -2361,6 +2394,7 @@ var LifePlanApplicationFormWrapper = ({
2361
2394
  page: /* @__PURE__ */ jsx10(
2362
2395
  LifePlanApplication2_default,
2363
2396
  {
2397
+ initialData: applicationData.address,
2364
2398
  onAddressUpdate: handleAddressUpdate,
2365
2399
  ...parseAddress ? { parseAddress } : {}
2366
2400
  }
@@ -2388,6 +2422,7 @@ var LifePlanApplicationFormWrapper = ({
2388
2422
  (prev) => prev.includes(value) ? prev.filter((sectionValue) => sectionValue !== value) : [...prev, value]
2389
2423
  );
2390
2424
  };
2425
+ if (!hydrated) return null;
2391
2426
  return /* @__PURE__ */ jsxs10(Box9, { w: "full", children: [
2392
2427
  /* @__PURE__ */ jsx10(
2393
2428
  Flex4,
@@ -2438,7 +2473,7 @@ var LifePlanApplicationFormWrapper_default = LifePlanApplicationFormWrapper;
2438
2473
 
2439
2474
  // src/NewSaleForm/SharedLifePlanApplication.tsx
2440
2475
  import { Box as Box14 } from "@chakra-ui/react";
2441
- import { useState as useState11 } from "react";
2476
+ import { useState as useState12 } from "react";
2442
2477
 
2443
2478
  // src/NewSaleForm/data/lifePlanSteps.tsx
2444
2479
  import { FaClipboardCheck, FaFileSignature, FaRegUser as FaRegUser3 } from "react-icons/fa";
@@ -2465,7 +2500,7 @@ import { FaRegAddressCard as FaRegAddressCard2 } from "react-icons/fa6";
2465
2500
  import { FaRegUser as FaRegUser2 } from "react-icons/fa";
2466
2501
  import { IoIosInformationCircleOutline as IoIosInformationCircleOutline2 } from "react-icons/io";
2467
2502
  import { FiEdit2 } from "react-icons/fi";
2468
- import { useEffect as useEffect6, useState as useState9 } from "react";
2503
+ import { useEffect as useEffect7, useState as useState10 } from "react";
2469
2504
 
2470
2505
  // src/NewSaleForm/data/checkBoxList.tsx
2471
2506
  import { Box as Box10, Separator as Separator2 } from "@chakra-ui/react";
@@ -2568,9 +2603,22 @@ var checkboxList = [
2568
2603
  }
2569
2604
  ];
2570
2605
 
2606
+ // src/hooks/useApplicationData.ts
2607
+ import { useEffect as useEffect6, useState as useState8 } from "react";
2608
+ function useApplicationData(storageKey = LIFE_PLAN_APPLICATION_KEY) {
2609
+ const [data, setData] = useState8(null);
2610
+ useEffect6(() => {
2611
+ const refresh = () => setData(loadApplicationData(storageKey));
2612
+ refresh();
2613
+ window.addEventListener(APPLICATION_DATA_CHANGE_EVENT, refresh);
2614
+ return () => window.removeEventListener(APPLICATION_DATA_CHANGE_EVENT, refresh);
2615
+ }, [storageKey]);
2616
+ return data;
2617
+ }
2618
+
2571
2619
  // src/NewSaleForm/ui/info-card-accordion.tsx
2572
2620
  import { Box as Box11, Button as Button2, Flex as Flex5, Icon as Icon2, Text as Text6 } from "@chakra-ui/react";
2573
- import { useState as useState8 } from "react";
2621
+ import { useState as useState9 } from "react";
2574
2622
  import { LuChevronDown as LuChevronDown2, LuChevronUp as LuChevronUp2, LuHash as LuHash2, LuPencil as LuPencil2 } from "react-icons/lu";
2575
2623
  import { jsx as jsx12, jsxs as jsxs12 } from "react/jsx-runtime";
2576
2624
  function InfoCardAccordion({
@@ -2584,7 +2632,7 @@ function InfoCardAccordion({
2584
2632
  onToggle,
2585
2633
  onEdit
2586
2634
  }) {
2587
- const [internalOpen, setInternalOpen] = useState8(defaultOpen);
2635
+ const [internalOpen, setInternalOpen] = useState9(defaultOpen);
2588
2636
  const isControlled = controlledOpen !== void 0;
2589
2637
  const isOpen = isControlled ? controlledOpen : internalOpen;
2590
2638
  const toggle = () => {
@@ -2697,6 +2745,12 @@ var modeLabel = (mode) => {
2697
2745
  return mode || "-";
2698
2746
  }
2699
2747
  };
2748
+ var display = (value) => {
2749
+ if (value === void 0 || value === null) return void 0;
2750
+ if (typeof value === "number") return value > 0 ? String(value) : void 0;
2751
+ return value.trim() !== "" ? value : void 0;
2752
+ };
2753
+ var classLabel = (beneficiaryClass) => beneficiaryClass === "contingent" ? "Contingent" : "Principal";
2700
2754
  var ApplicationAccordion = ({
2701
2755
  items,
2702
2756
  onEdit
@@ -2768,23 +2822,18 @@ var SectionCard = ({
2768
2822
  }
2769
2823
  );
2770
2824
  var Confirmation = ({ onAllAcceptedChange, onEdit }) => {
2771
- const [cartItems, setCartItems] = useState9(null);
2772
- const [lifePlanApplication, setLifePlanApplication] = useState9(null);
2773
- const [openDialog, setOpenDialog] = useState9(false);
2774
- const [pendingCheck, setPendingCheck] = useState9(null);
2775
- const [acceptedAgreements, setAcceptedAgreements] = useState9(
2825
+ const [cartItems, setCartItems] = useState10(null);
2826
+ const lifePlanApplication = useApplicationData();
2827
+ const [openDialog, setOpenDialog] = useState10(false);
2828
+ const [pendingCheck, setPendingCheck] = useState10(null);
2829
+ const [acceptedAgreements, setAcceptedAgreements] = useState10(
2776
2830
  () => checkboxList.map(() => false)
2777
2831
  );
2778
- useEffect6(() => {
2832
+ useEffect7(() => {
2779
2833
  const loadStoredData = () => {
2780
2834
  try {
2781
2835
  const checkoutStored = sessionStorage.getItem("CheckoutCart");
2782
2836
  const cartStored = sessionStorage.getItem("Cart");
2783
- const lifePlanApplicationStored = localStorage.getItem(
2784
- "LifePlanApplication"
2785
- );
2786
- const parsedApplicationData = lifePlanApplicationStored ? JSON.parse(lifePlanApplicationStored) : null;
2787
- setLifePlanApplication(parsedApplicationData);
2788
2837
  if (checkoutStored) {
2789
2838
  const parsedCheckout = JSON.parse(checkoutStored);
2790
2839
  setCartItems(
@@ -2810,23 +2859,18 @@ var Confirmation = ({ onAllAcceptedChange, onEdit }) => {
2810
2859
  const acceptedCount = acceptedAgreements.filter(Boolean).length;
2811
2860
  const allAccepted = checkboxList.length > 0 && acceptedCount === checkboxList.length;
2812
2861
  const pendingAgreement = pendingCheck !== null ? checkboxList[pendingCheck] : null;
2813
- useEffect6(() => {
2862
+ useEffect7(() => {
2814
2863
  onAllAcceptedChange?.(allAccepted);
2815
2864
  }, [allAccepted, onAllAcceptedChange]);
2816
- const beneficiaries = [
2817
- {
2818
- name: "John Doe",
2819
- relationship: "Relative",
2820
- dob: "1990-11-02",
2821
- address: "Sample Street, Sample Barangay, Sample City"
2822
- },
2823
- {
2824
- name: "Jane Smith",
2825
- relationship: "Relative",
2826
- dob: "1992-04-15",
2827
- address: "Sample Avenue, Sample District, Sample City"
2828
- }
2829
- ];
2865
+ const beneficiaries = (lifePlanApplication?.beneficiaries ?? []).map(
2866
+ (beneficiary) => ({
2867
+ name: [beneficiary.firstName, beneficiary.middleInitial, beneficiary.lastName].map((part) => part?.trim()).filter(Boolean).join(" "),
2868
+ beneficiaryClass: classLabel(beneficiary.beneficiaryClass),
2869
+ relationship: beneficiary.relationship,
2870
+ dob: beneficiary.birthDate,
2871
+ address: beneficiary.address
2872
+ })
2873
+ );
2830
2874
  const confirmAgreement = () => {
2831
2875
  if (pendingCheck === null) return;
2832
2876
  setAcceptedAgreements((prev) => {
@@ -2845,75 +2889,54 @@ var Confirmation = ({ onAllAcceptedChange, onEdit }) => {
2845
2889
  value: selectedPlan ? `\u20B1 ${selectedPlan.total}` : void 0
2846
2890
  }
2847
2891
  ];
2892
+ const personal = lifePlanApplication?.personalInfo;
2893
+ const address = lifePlanApplication?.address;
2894
+ const employment = lifePlanApplication?.employment;
2848
2895
  const personalRows = [
2849
- { label: "Uploaded ID", value: lifePlanApplication?.personalInfo.idType },
2850
- { label: "Last Name", value: lifePlanApplication?.personalInfo.lastName },
2851
- { label: "First Name", value: lifePlanApplication?.personalInfo.firstName },
2852
- {
2853
- label: "Middle Name",
2854
- value: lifePlanApplication?.personalInfo.middleName
2855
- },
2856
- { label: "Suffix", value: lifePlanApplication?.personalInfo.suffix },
2857
- {
2858
- label: "Date of Birth",
2859
- value: lifePlanApplication?.personalInfo.birthDate
2860
- },
2861
- { label: "Gender", value: lifePlanApplication?.personalInfo.gender },
2862
- {
2863
- label: "Contact Number",
2864
- value: lifePlanApplication?.personalInfo.mobileNumber
2865
- },
2866
- { label: "Email", value: lifePlanApplication?.personalInfo.emailAddress },
2867
- {
2868
- label: "Landline Number",
2869
- value: lifePlanApplication?.personalInfo.landLineNumber
2870
- },
2871
- {
2872
- label: "Mailing Address",
2873
- value: lifePlanApplication?.personalInfo.mailingAddress
2874
- },
2875
- {
2876
- label: "Civil Status",
2877
- value: lifePlanApplication?.personalInfo.civilStatus
2878
- }
2896
+ { label: "Uploaded ID", value: display(personal?.idType) },
2897
+ { label: "ID Number", value: display(personal?.idNumber) },
2898
+ { label: "Last Name", value: display(personal?.lastName) },
2899
+ { label: "First Name", value: display(personal?.firstName) },
2900
+ { label: "Middle Name", value: display(personal?.middleName) },
2901
+ { label: "Suffix", value: display(personal?.suffix) },
2902
+ { label: "Date of Birth", value: display(personal?.birthDate) },
2903
+ { label: "Gender", value: display(personal?.gender) },
2904
+ { label: "Civil Status", value: display(personal?.civilStatus) },
2905
+ { label: "Nationality", value: display(personal?.nationality) },
2906
+ { label: "Height", value: display(personal?.height) },
2907
+ { label: "Weight", value: display(personal?.weight) },
2908
+ { label: "Contact Number", value: display(personal?.mobileNumber) },
2909
+ { label: "Email", value: display(personal?.emailAddress) },
2910
+ { label: "Landline Number", value: display(personal?.landLineNumber) },
2911
+ { label: "Mailing Address", value: display(personal?.mailingAddress) }
2879
2912
  ];
2880
2913
  const addressRows = [
2881
- { label: "Lot #", value: lifePlanApplication?.address.lot },
2882
- { label: "Street", value: lifePlanApplication?.address.street },
2883
- { label: "Barangay", value: lifePlanApplication?.address.barangay },
2884
- { label: "City", value: lifePlanApplication?.address.city },
2885
- { label: "Province", value: lifePlanApplication?.address.province }
2914
+ { label: "Lot #", value: display(address?.lot) },
2915
+ { label: "Street", value: display(address?.street) },
2916
+ { label: "Barangay", value: display(address?.barangay) },
2917
+ { label: "District", value: display(address?.district) },
2918
+ { label: "City", value: display(address?.city) },
2919
+ { label: "Province", value: display(address?.province) }
2886
2920
  ];
2887
2921
  const employmentRows = [
2888
- { label: "Occupation", value: lifePlanApplication?.employment.occupation },
2889
- {
2890
- label: "Employer Name",
2891
- value: lifePlanApplication?.employment.employerName
2892
- },
2893
- {
2894
- label: "Employment Status",
2895
- value: lifePlanApplication?.employment.employmentStatus
2896
- },
2897
- {
2898
- label: "Office Address",
2899
- value: lifePlanApplication?.employment.officeAddress
2900
- },
2901
- { label: "TIN", value: lifePlanApplication?.employment.TIN },
2902
- { label: "SSS/GSIS", value: lifePlanApplication?.employment.SSS },
2903
- {
2904
- label: "Source of Income",
2905
- value: lifePlanApplication?.employment.sourceOfIncome
2906
- }
2922
+ { label: "Occupation", value: display(employment?.occupation) },
2923
+ { label: "Employer Name", value: display(employment?.employerName) },
2924
+ { label: "Employment Status", value: display(employment?.employmentStatus) },
2925
+ { label: "Office Address", value: display(employment?.officeAddress) },
2926
+ { label: "TIN", value: display(employment?.TIN) },
2927
+ { label: "SSS/GSIS", value: display(employment?.SSS) },
2928
+ { label: "Source of Income", value: display(employment?.sourceOfIncome) }
2907
2929
  ];
2908
- const beneficiaryItems = /* @__PURE__ */ jsx13(VStack6, { align: "stretch", gap: 4, children: beneficiaries.map((beneficiary, index) => /* @__PURE__ */ jsxs13(Box12, { children: [
2909
- /* @__PURE__ */ jsx13(Text7, { fontWeight: "semibold", fontSize: "sm", mb: 1, children: beneficiary.name }),
2930
+ const beneficiaryItems = beneficiaries.length === 0 ? /* @__PURE__ */ jsx13(Text7, { fontSize: "sm", color: "gray.500", children: "No beneficiaries added." }) : /* @__PURE__ */ jsx13(VStack6, { align: "stretch", gap: 4, children: beneficiaries.map((beneficiary, index) => /* @__PURE__ */ jsxs13(Box12, { children: [
2931
+ /* @__PURE__ */ jsx13(Text7, { fontWeight: "semibold", fontSize: "sm", mb: 1, children: display(beneficiary.name) ?? "-" }),
2910
2932
  /* @__PURE__ */ jsx13(
2911
2933
  ReviewRows2,
2912
2934
  {
2913
2935
  rows: [
2914
- { label: "Relationship", value: beneficiary.relationship },
2915
- { label: "Date of Birth", value: beneficiary.dob },
2916
- { label: "Address", value: beneficiary.address }
2936
+ { label: "Type", value: beneficiary.beneficiaryClass },
2937
+ { label: "Relationship", value: display(beneficiary.relationship) },
2938
+ { label: "Date of Birth", value: display(beneficiary.dob) },
2939
+ { label: "Address", value: display(beneficiary.address) }
2917
2940
  ]
2918
2941
  }
2919
2942
  )
@@ -3166,7 +3189,7 @@ var createLifePlanSteps = (confirmationProps) => [
3166
3189
  ];
3167
3190
 
3168
3191
  // src/NewSaleForm/ui/horizontal-stepper.tsx
3169
- import { useRef, useState as useState10 } from "react";
3192
+ import { useRef, useState as useState11 } from "react";
3170
3193
  import { Box as Box13, ButtonGroup, Flex as Flex7, Steps, Text as Text8 } from "@chakra-ui/react";
3171
3194
  import { PrimaryMdButton as PrimaryMdButton2, SecondaryMdButton as SecondaryMdButton2 } from "st-peter-ui";
3172
3195
  import { LuChevronLeft, LuChevronRight, LuCheck as LuCheck2 } from "react-icons/lu";
@@ -3185,7 +3208,7 @@ var HorizontalStepper = ({
3185
3208
  nextDisabled,
3186
3209
  submitButtonText = "Proceed To Payment"
3187
3210
  }) => {
3188
- const [localActiveStep, setLocalActiveStep] = useState10(0);
3211
+ const [localActiveStep, setLocalActiveStep] = useState11(0);
3189
3212
  const activeStep = controlledActiveStep !== void 0 ? controlledActiveStep : localActiveStep;
3190
3213
  const formTopRef = useRef(null);
3191
3214
  const isCompact = steps.length < 3;
@@ -3643,12 +3666,12 @@ var SharedLifePlanApplication = ({
3643
3666
  onCheckout = defaultCheckout,
3644
3667
  parseAddress = GeoApifyService.parseAddress
3645
3668
  }) => {
3646
- const [currentStep, setCurrentStep] = useState11(0);
3647
- const [loading, setLoading] = useState11(false);
3648
- const [allAgreementsAccepted, setAllAgreementsAccepted] = useState11(false);
3649
- const [applicationSection, setApplicationSection] = useState11();
3650
- const [applicationSectionKey, setApplicationSectionKey] = useState11(0);
3651
- const [applicationValid, setApplicationValid] = useState11(false);
3669
+ const [currentStep, setCurrentStep] = useState12(0);
3670
+ const [loading, setLoading] = useState12(false);
3671
+ const [allAgreementsAccepted, setAllAgreementsAccepted] = useState12(false);
3672
+ const [applicationSection, setApplicationSection] = useState12();
3673
+ const [applicationSectionKey, setApplicationSectionKey] = useState12(0);
3674
+ const [applicationValid, setApplicationValid] = useState12(false);
3652
3675
  const steps = createLifePlanSteps({
3653
3676
  onAllAcceptedChange: setAllAgreementsAccepted,
3654
3677
  ...applicationSection ? { applicationSection } : {},
@@ -3673,7 +3696,7 @@ var SharedLifePlanApplication = ({
3673
3696
  if (items.length === 0) {
3674
3697
  throw new Error("No items to checkout");
3675
3698
  }
3676
- const applicationData = loadApplicationDataFromLocalStorage() ?? createEmptyApplicationData();
3699
+ const applicationData = loadApplicationData() ?? createEmptyApplicationData();
3677
3700
  const checkoutPayload = items.map((item) => ({
3678
3701
  planDesc: item.planDesc,
3679
3702
  mode: item.mode,
@@ -3717,11 +3740,11 @@ var LifePlanApplicationStepWrapper = (props) => {
3717
3740
  var LifePlanApplicationStepWrapper_default = LifePlanApplicationStepWrapper;
3718
3741
 
3719
3742
  // src/hooks/useOcr.ts
3720
- import { useCallback as useCallback2, useState as useState12 } from "react";
3743
+ import { useCallback as useCallback2, useState as useState13 } from "react";
3721
3744
  function useOcr(scanIdFn) {
3722
- const [data, setData] = useState12(null);
3723
- const [loading, setLoading] = useState12(false);
3724
- const [error, setError] = useState12(null);
3745
+ const [data, setData] = useState13(null);
3746
+ const [loading, setLoading] = useState13(false);
3747
+ const [error, setError] = useState13(null);
3725
3748
  const scanId = useCallback2(
3726
3749
  async (file) => {
3727
3750
  setLoading(true);
@@ -3762,7 +3785,7 @@ import {
3762
3785
  CloseButton as CloseButton3,
3763
3786
  Input as Input4
3764
3787
  } from "@chakra-ui/react";
3765
- import { useState as useState14 } from "react";
3788
+ import { useState as useState15 } from "react";
3766
3789
  import { LuIdCard, LuSignature } from "react-icons/lu";
3767
3790
 
3768
3791
  // src/GetStarted/Container.tsx
@@ -3785,7 +3808,7 @@ var Container = ({ children }) => {
3785
3808
  var Container_default = Container;
3786
3809
 
3787
3810
  // src/GetStarted/DocumentUploadCard.tsx
3788
- import { useEffect as useEffect7, useRef as useRef2, useState as useState13 } from "react";
3811
+ import { useEffect as useEffect8, useRef as useRef2, useState as useState14 } from "react";
3789
3812
  import { Box as Box16, Flex as Flex8, Spinner, Text as Text9, useBreakpointValue as useBreakpointValue2 } from "@chakra-ui/react";
3790
3813
  import {
3791
3814
  LuUpload,
@@ -3824,7 +3847,7 @@ var validate = (file, config) => {
3824
3847
  return null;
3825
3848
  };
3826
3849
  var useDocumentSlot = (config, onProcess, notifyError = defaultNotifyError) => {
3827
- const [slot, setSlot] = useState13({ status: "idle" });
3850
+ const [slot, setSlot] = useState14({ status: "idle" });
3828
3851
  const timers = useRef2([]);
3829
3852
  const runId = useRef2(0);
3830
3853
  const clearTimers = () => {
@@ -4069,12 +4092,12 @@ function DocumentUploadCard({
4069
4092
  const notifyError = onError ?? defaultNotifyError;
4070
4093
  const { slot, uploadDocument, retryDocument, removeDocument } = useDocumentSlot(config, onProcess, notifyError);
4071
4094
  const status = slot?.status ?? "idle";
4072
- useEffect7(() => {
4095
+ useEffect8(() => {
4073
4096
  onStatusChange?.(status);
4074
4097
  }, [status, onStatusChange]);
4075
4098
  const browseRef = useRef2(null);
4076
4099
  const cameraRef = useRef2(null);
4077
- const [dragging, setDragging] = useState13(false);
4100
+ const [dragging, setDragging] = useState14(false);
4078
4101
  const Icon6 = config.icon;
4079
4102
  const isPdf = slot?.fileType === "application/pdf";
4080
4103
  const handleFiles = (files) => {
@@ -4513,9 +4536,9 @@ var GetStarted = ({
4513
4536
  onContinue,
4514
4537
  notify = defaultNotify
4515
4538
  }) => {
4516
- const [uploadDialogOpen, setUploadDialogOpen] = useState14(false);
4517
- const [referralDialogOpen, setReferralDialogOpen] = useState14(false);
4518
- const [governmentIdStatus, setGovernmentIdStatus] = useState14("idle");
4539
+ const [uploadDialogOpen, setUploadDialogOpen] = useState15(false);
4540
+ const [referralDialogOpen, setReferralDialogOpen] = useState15(false);
4541
+ const [governmentIdStatus, setGovernmentIdStatus] = useState15("idle");
4519
4542
  const { scanId } = useOcr(scanIdFn);
4520
4543
  return /* @__PURE__ */ jsx20(Container_default, { children: /* @__PURE__ */ jsxs16(
4521
4544
  Box17,
@@ -4961,18 +4984,18 @@ var BottomQuickActions = ({
4961
4984
  var BottomQuickActions_default = BottomQuickActions;
4962
4985
 
4963
4986
  // src/Generic/NotifyInstall.tsx
4964
- import { useEffect as useEffect9, useState as useState16 } from "react";
4987
+ import { useEffect as useEffect10, useState as useState17 } from "react";
4965
4988
  import { Button as Button4, Flex as Flex10, HStack as HStack5, Icon as Icon5, Text as Text11, VStack as VStack9 } from "@chakra-ui/react";
4966
4989
  import { AnimatePresence, motion } from "motion/react";
4967
4990
  import { FiDownload, FiPlusSquare, FiShare, FiX } from "react-icons/fi";
4968
4991
 
4969
4992
  // src/hooks/useNotifyInstall.ts
4970
- import { useEffect as useEffect8, useState as useState15 } from "react";
4993
+ import { useEffect as useEffect9, useState as useState16 } from "react";
4971
4994
  function useNotifyInstall() {
4972
- const [isInstalled, setIsInstalled] = useState15(false);
4973
- const [isMobile, setIsMobile] = useState15(false);
4974
- const [installPrompt, setInstallPrompt] = useState15(null);
4975
- useEffect8(() => {
4995
+ const [isInstalled, setIsInstalled] = useState16(false);
4996
+ const [isMobile, setIsMobile] = useState16(false);
4997
+ const [installPrompt, setInstallPrompt] = useState16(null);
4998
+ useEffect9(() => {
4976
4999
  const mobile = /Android|iPhone|iPad|iPod/i.test(navigator.userAgent);
4977
5000
  setIsMobile(mobile);
4978
5001
  const installed = window.matchMedia("(display-mode: standalone)").matches || window.navigator.standalone === true;
@@ -5015,8 +5038,8 @@ function NotifyInstall({
5015
5038
  appName
5016
5039
  }) {
5017
5040
  const { isInstalled, isMobile, canInstall, install } = useNotifyInstall();
5018
- const [isDismissed, setIsDismissed] = useState16(true);
5019
- useEffect9(() => {
5041
+ const [isDismissed, setIsDismissed] = useState17(true);
5042
+ useEffect10(() => {
5020
5043
  if (localStorage.getItem(DISMISSED_KEY) !== "true") {
5021
5044
  setIsDismissed(false);
5022
5045
  }
@@ -5173,7 +5196,7 @@ function NotifyInstall({
5173
5196
  }
5174
5197
 
5175
5198
  // src/UserProfile/UserProfile.tsx
5176
- import { useEffect as useEffect10, useMemo, useState as useState17 } from "react";
5199
+ import { useEffect as useEffect11, useMemo, useState as useState18 } from "react";
5177
5200
  import {
5178
5201
  Avatar,
5179
5202
  Badge as Badge2,
@@ -5529,28 +5552,28 @@ function ReusableProfile({
5529
5552
  onTwoFactorChange,
5530
5553
  onToast = noopToast
5531
5554
  }) {
5532
- const [profileView, setProfileView] = useState17("main");
5533
- const [fallbackColorMode, setFallbackColorMode] = useState17("light");
5555
+ const [profileView, setProfileView] = useState18("main");
5556
+ const [fallbackColorMode, setFallbackColorMode] = useState18("light");
5534
5557
  const colorMode = controlledColorMode ?? fallbackColorMode;
5535
- const [fontSize, setFontSizeLocal] = useState17("md");
5536
- const [quickNavHrefs, setQuickNavHrefs] = useState17(initialQuickNavHrefs);
5537
- const [replacingIdx, setReplacingIdx] = useState17(null);
5538
- const [editName, setEditName] = useState17(user.displayName);
5539
- const [editLoading, setEditLoading] = useState17(false);
5540
- const [currentPw, setCurrentPw] = useState17("");
5541
- const [newPw, setNewPw] = useState17("");
5542
- const [confirmPw, setConfirmPw] = useState17("");
5543
- const [showCurrentPw, setShowCurrentPw] = useState17(false);
5544
- const [showNewPw, setShowNewPw] = useState17(false);
5545
- const [showConfirmPw, setShowConfirmPw] = useState17(false);
5546
- const [pwLoading, setPwLoading] = useState17(false);
5547
- const [twoFactorEnabled, setTwoFactorEnabled] = useState17(
5558
+ const [fontSize, setFontSizeLocal] = useState18("md");
5559
+ const [quickNavHrefs, setQuickNavHrefs] = useState18(initialQuickNavHrefs);
5560
+ const [replacingIdx, setReplacingIdx] = useState18(null);
5561
+ const [editName, setEditName] = useState18(user.displayName);
5562
+ const [editLoading, setEditLoading] = useState18(false);
5563
+ const [currentPw, setCurrentPw] = useState18("");
5564
+ const [newPw, setNewPw] = useState18("");
5565
+ const [confirmPw, setConfirmPw] = useState18("");
5566
+ const [showCurrentPw, setShowCurrentPw] = useState18(false);
5567
+ const [showNewPw, setShowNewPw] = useState18(false);
5568
+ const [showConfirmPw, setShowConfirmPw] = useState18(false);
5569
+ const [pwLoading, setPwLoading] = useState18(false);
5570
+ const [twoFactorEnabled, setTwoFactorEnabled] = useState18(
5548
5571
  initialTwoFactorEnabled
5549
5572
  );
5550
- const [isMounted, setIsMounted] = useState17(false);
5573
+ const [isMounted, setIsMounted] = useState18(false);
5551
5574
  const isDesktopRaw = useBreakpointValue3({ base: false, md: true });
5552
5575
  const isDesktop = isMounted ? isDesktopRaw ?? false : false;
5553
- useEffect10(() => {
5576
+ useEffect11(() => {
5554
5577
  setIsMounted(true);
5555
5578
  if (!enableLocalStorage || typeof window === "undefined") return;
5556
5579
  setFontSizeLocal(localStorage.getItem(FONT_SIZE_STORAGE_KEY) ?? "md");
@@ -5561,7 +5584,7 @@ function ReusableProfile({
5561
5584
  setQuickNavHrefs(initialQuickNavHrefs);
5562
5585
  }
5563
5586
  }, [enableLocalStorage, initialQuickNavHrefs, storageKey]);
5564
- useEffect10(() => {
5587
+ useEffect11(() => {
5565
5588
  setEditName(user.displayName);
5566
5589
  }, [user.displayName]);
5567
5590
  const availableOptions = useMemo(
@@ -6680,12 +6703,14 @@ function ReusableProfile({
6680
6703
  var UserProfile_default = ReusableProfile;
6681
6704
  export {
6682
6705
  APIError,
6706
+ APPLICATION_DATA_CHANGE_EVENT,
6683
6707
  beneficiary_default as Beneficiary,
6684
6708
  BottomQuickActions_default as BottomQuickActions,
6685
6709
  DocumentUploadCard,
6686
6710
  GeoApifyService,
6687
6711
  GetStarted_default as GetStarted,
6688
6712
  HealthDeclaration_default as HealthDeclaration,
6713
+ LIFE_PLAN_APPLICATION_KEY,
6689
6714
  LifePlanApplication1_default as LifePlanApplication1,
6690
6715
  LifePlanApplication2_default as LifePlanApplication2,
6691
6716
  LifePlanApplication3_default as LifePlanApplication3,
@@ -6699,14 +6724,19 @@ export {
6699
6724
  UserProfile_default as UserProfile,
6700
6725
  api,
6701
6726
  apiClient,
6727
+ clearApplicationData,
6702
6728
  clearOcrResult,
6703
6729
  configureApi,
6704
6730
  createEmptyApplicationData,
6731
+ loadApplicationData,
6705
6732
  loadApplicationDataFromLocalStorage,
6706
6733
  markOcrApplied,
6707
6734
  readOcrResult,
6735
+ saveApplicationData,
6708
6736
  saveApplicationDataToLocalStorage,
6709
6737
  saveOcrResult,
6738
+ updateApplicationData,
6739
+ useApplicationData,
6710
6740
  useOcr
6711
6741
  };
6712
6742
  //# sourceMappingURL=index.mjs.map