@gusto/embedded-react-sdk 0.46.2 → 0.46.3

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 (172) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/dist/components/Common/DataView/DataTable/DataTable.js +76 -72
  3. package/dist/components/Common/DataView/DataTable/DataTable.js.map +1 -1
  4. package/dist/components/Common/DataView/DataTable/DataTable.module.scss.js +8 -0
  5. package/dist/components/Common/DataView/DataTable/DataTable.module.scss.js.map +1 -0
  6. package/dist/components/Common/DataView/useDataView.d.ts +2 -0
  7. package/dist/components/Common/DataView/useDataView.js.map +1 -1
  8. package/dist/components/Common/DocumentViewer/DocumentViewer.js +10 -10
  9. package/dist/components/Common/DocumentViewer/DocumentViewer.js.map +1 -1
  10. package/dist/components/Common/DocumentViewer/DocumentViewer.module.scss.js +9 -9
  11. package/dist/components/Common/PaginationControl/PaginationControl.js +11 -10
  12. package/dist/components/Common/PaginationControl/PaginationControl.js.map +1 -1
  13. package/dist/components/Common/PaginationControl/PaginationControlTypes.d.ts +1 -1
  14. package/dist/components/Common/UI/DescriptionList/DescriptionList.js +11 -10
  15. package/dist/components/Common/UI/DescriptionList/DescriptionList.js.map +1 -1
  16. package/dist/components/Common/UI/DescriptionList/DescriptionList.module.scss.js +4 -4
  17. package/dist/components/Common/UI/Input/InputTypes.d.ts +1 -1
  18. package/dist/components/Common/UI/Input/InputTypes.js.map +1 -1
  19. package/dist/components/Common/UI/NumberInput/NumberInput.js +51 -48
  20. package/dist/components/Common/UI/NumberInput/NumberInput.js.map +1 -1
  21. package/dist/components/Common/VisuallyHidden/VisuallyHidden.d.ts +1 -1
  22. package/dist/components/Common/VisuallyHidden/VisuallyHidden.js.map +1 -1
  23. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -4
  24. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  25. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -4
  26. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  27. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -6
  28. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  29. package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
  30. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  31. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -4
  32. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  33. package/dist/components/Company/DocumentSigner/shared/useSignCompanyForm/fields.js +4 -4
  34. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +5 -6
  35. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  36. package/dist/components/Company/Industry/Context.js +6 -7
  37. package/dist/components/Company/Industry/Context.js.map +1 -1
  38. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -4
  39. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  40. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -4
  41. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  42. package/dist/components/Company/OnboardingOverview/context.js +3 -4
  43. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  44. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js +5 -5
  45. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -4
  46. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  47. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -4
  48. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  49. package/dist/components/Contractor/Address/useAddress.js +5 -6
  50. package/dist/components/Contractor/Address/useAddress.js.map +1 -1
  51. package/dist/components/Contractor/Profile/useContractorProfile.js +33 -34
  52. package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
  53. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js +14 -11
  54. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js.map +1 -1
  55. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js +0 -2
  56. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js.map +1 -1
  57. package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js +18 -18
  58. package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js.map +1 -1
  59. package/dist/components/Employee/Compensation/onboarding/JobsList/JobsListPresentation.js +36 -36
  60. package/dist/components/Employee/Compensation/onboarding/JobsList/JobsListPresentation.js.map +1 -1
  61. package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js +4 -4
  62. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +140 -140
  63. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
  64. package/dist/components/Employee/Compensation/shared/useJobForm/fields.js +6 -6
  65. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.d.ts +6 -5
  66. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +162 -131
  67. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
  68. package/dist/components/Employee/Dashboard/BasicDetailsView.js +74 -88
  69. package/dist/components/Employee/Dashboard/BasicDetailsView.js.map +1 -1
  70. package/dist/components/Employee/Dashboard/Dashboard.js +53 -51
  71. package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
  72. package/dist/components/Employee/Dashboard/DocumentsView.js +17 -10
  73. package/dist/components/Employee/Dashboard/DocumentsView.js.map +1 -1
  74. package/dist/components/Employee/Dashboard/JobAndPayView.js +383 -357
  75. package/dist/components/Employee/Dashboard/JobAndPayView.js.map +1 -1
  76. package/dist/components/Employee/Dashboard/TaxesView.js +114 -101
  77. package/dist/components/Employee/Dashboard/TaxesView.js.map +1 -1
  78. package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js +36 -36
  79. package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js.map +1 -1
  80. package/dist/components/Employee/Deductions/DeductionsForm/StandardDeductionForm.js +57 -57
  81. package/dist/components/Employee/Deductions/DeductionsForm/StandardDeductionForm.js.map +1 -1
  82. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.d.ts +14 -5
  83. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.js +55 -36
  84. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.js.map +1 -1
  85. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/fields.js +8 -8
  86. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/useChildSupportGarnishmentForm.js +18 -18
  87. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/useChildSupportGarnishmentForm.js.map +1 -1
  88. package/dist/components/Employee/Deductions/shared/useDeductionForm/fields.js +4 -4
  89. package/dist/components/Employee/Deductions/shared/useDeductionForm/useDeductionForm.d.ts +3 -3
  90. package/dist/components/Employee/Deductions/shared/useDeductionForm/useDeductionForm.js.map +1 -1
  91. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -4
  92. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  93. package/dist/components/Employee/Documents/shared/useSignEmployeeForm/fields.js +1 -1
  94. package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/fields.js +4 -4
  95. package/dist/components/Employee/HomeAddress/management/HomeAddressView.js +157 -147
  96. package/dist/components/Employee/HomeAddress/management/HomeAddressView.js.map +1 -1
  97. package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js +56 -55
  98. package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js.map +1 -1
  99. package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js +20 -20
  100. package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js.map +1 -1
  101. package/dist/components/Employee/PaymentMethod/shared/useBankForm/fields.js +1 -1
  102. package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.d.ts +1 -1
  103. package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js +4 -4
  104. package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js.map +1 -1
  105. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/fields.js +8 -8
  106. package/dist/components/Employee/Profile/shared/useHomeAddressForm/fields.js +5 -5
  107. package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.d.ts +0 -1
  108. package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.js +11 -12
  109. package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.js.map +1 -1
  110. package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.test.d.ts +1 -0
  111. package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.d.ts +6 -1
  112. package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.js +95 -94
  113. package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.js.map +1 -1
  114. package/dist/components/Employee/Profile/shared/useWorkAddressForm/fields.js +4 -4
  115. package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.d.ts +6 -1
  116. package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.js +87 -86
  117. package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.js.map +1 -1
  118. package/dist/components/Employee/StateTaxes/shared/EmployeeStateTaxesView.js +18 -18
  119. package/dist/components/Employee/StateTaxes/shared/EmployeeStateTaxesView.js.map +1 -1
  120. package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +8 -8
  121. package/dist/components/Employee/Taxes/useTaxes.js +3 -4
  122. package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
  123. package/dist/components/Employee/WorkAddress/management/WorkAddressView.js +5 -1
  124. package/dist/components/Employee/WorkAddress/management/WorkAddressView.js.map +1 -1
  125. package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js +61 -60
  126. package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js.map +1 -1
  127. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +2 -3
  128. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
  129. package/dist/components/Payroll/usePreparedPayrollData.js +2 -3
  130. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  131. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js +6 -7
  132. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js.map +1 -1
  133. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.d.ts +1 -1
  134. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js +52 -68
  135. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js.map +1 -1
  136. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.module.scss.js +4 -4
  137. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentationTypes.d.ts +0 -11
  138. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js +137 -163
  139. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js.map +1 -1
  140. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js +36 -35
  141. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js.map +1 -1
  142. package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetailPresentation.js +34 -34
  143. package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetailPresentation.js.map +1 -1
  144. package/dist/helpers/breadcrumbHelpers.d.ts +1 -1
  145. package/dist/helpers/breadcrumbHelpers.js.map +1 -1
  146. package/dist/helpers/federalEin.d.ts +1 -0
  147. package/dist/helpers/federalEin.js.map +1 -1
  148. package/dist/helpers/mask.d.ts +8 -4
  149. package/dist/helpers/mask.js.map +1 -1
  150. package/dist/helpers/rem.d.ts +2 -1
  151. package/dist/helpers/rem.js.map +1 -1
  152. package/dist/hooks/useAsyncError.d.ts +1 -0
  153. package/dist/hooks/useAsyncError.js.map +1 -1
  154. package/dist/hooks/useForkRef/useForkRef.d.ts +1 -0
  155. package/dist/hooks/useForkRef/useForkRef.js.map +1 -1
  156. package/dist/i18n/I18n.d.ts +9 -1
  157. package/dist/i18n/I18n.js.map +1 -1
  158. package/dist/i18n/en/Company.TimeOff.EmployeeTable.json.js +14 -14
  159. package/dist/i18n/en/Company.TimeOff.SelectEmployees.json.js +12 -18
  160. package/dist/i18n/en/Company.TimeOff.SelectEmployees.json.js.map +1 -1
  161. package/dist/i18n/en/Employee.Compensation.json.js +24 -24
  162. package/dist/i18n/en/Employee.Dashboard.json.js +22 -20
  163. package/dist/i18n/en/Employee.Dashboard.json.js.map +1 -1
  164. package/dist/i18n/en/Employee.PaymentMethod.json.js +25 -25
  165. package/dist/i18n/en/Employee.StateTaxes.json.js +12 -10
  166. package/dist/i18n/en/Employee.StateTaxes.json.js.map +1 -1
  167. package/dist/style.css +1 -1
  168. package/dist/types/hooks.d.ts +1 -1
  169. package/dist/types/i18next.d.ts +4 -17
  170. package/dist/types/observability.d.ts +1 -1
  171. package/package.json +30 -27
  172. package/dist/components/Employee/Dashboard/CompensationCard.d.ts +0 -13
@@ -1 +1 @@
1
- {"version":3,"file":"WorkAddressView.js","sources":["../../../../../src/components/Employee/WorkAddress/management/WorkAddressView.tsx"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef, useState } from 'react'\nimport { Trans, useTranslation } from 'react-i18next'\nimport type { Location } from '@gusto/embedded-api/models/components/location'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport {\n formatPendingWorkAddressLine,\n getPendingFutureWorkAddress,\n} from './getPendingFutureWorkAddress'\nimport ListIcon from '@/assets/icons/list.svg?react'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport TrashCanSvg from '@/assets/icons/trashcan.svg?react'\nimport {\n ActionsLayout,\n DataView,\n EmptyData,\n Grid,\n HamburgerMenu,\n useDataView,\n} from '@/components/Common'\nimport { Flex, FlexItem } from '@/components/Common/Flex/Flex'\nimport {\n LocationField,\n EffectiveDateField,\n} from '@/components/Employee/Profile/shared/useWorkAddressForm/fields'\nimport { WorkAddressErrorCodes } from '@/components/Employee/Profile/shared/useWorkAddressForm/workAddressSchema'\nimport type { UseWorkAddressFormReady } from '@/components/Employee/Profile/shared/useWorkAddressForm'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport type { HookSubmitResult } from '@/partner-hook-utils/types'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { addDays, formatDateLongWithYear, normalizeToDate } from '@/helpers/dateFormatting'\nimport { getCityStateZip, getStreet } from '@/helpers/formattedStrings'\n\nexport interface WorkAddressViewProps {\n editWorkAddressForm: UseWorkAddressFormReady\n changeWorkAddressForm: UseWorkAddressFormReady\n /** Full list for history table, pending-future alert, and delete-confirmation lookup. */\n workAddresses: EmployeeWorkAddress[] | undefined\n editTargetUuid: string | undefined\n onEditTargetUuidChange: (uuid: string | undefined) => void\n employeeDisplayName: string\n onConfirmDelete: (workAddressUuid: string) => Promise<boolean>\n onWorkAddressSaved: (result: HookSubmitResult<EmployeeWorkAddress>) => void\n onBack: () => void\n isDeletePending?: boolean\n}\n\nfunction resolveLocation(\n row: EmployeeWorkAddress,\n companyLocations: Location[] | undefined,\n): Location | undefined {\n if (!row.locationUuid || !companyLocations?.length) {\n return undefined\n }\n return companyLocations.find(loc => loc.uuid === row.locationUuid)\n}\n\nfunction formatWorkAddressLines(\n row: EmployeeWorkAddress,\n companyLocations: Location[] | undefined,\n): { primary: string; secondary: string } {\n const location = resolveLocation(row, companyLocations)\n if (location) {\n const street = getStreet(location).trim()\n const locality = getCityStateZip(location).trim()\n return { primary: street, secondary: locality }\n }\n const street = getStreet(row).trim()\n const locality = getCityStateZip(row).trim()\n return { primary: street, secondary: locality }\n}\n\nexport function WorkAddressView({\n editWorkAddressForm,\n changeWorkAddressForm,\n workAddresses,\n editTargetUuid,\n onEditTargetUuidChange,\n employeeDisplayName,\n onConfirmDelete,\n onWorkAddressSaved,\n onBack,\n isDeletePending = false,\n}: WorkAddressViewProps) {\n const { t } = useTranslation('Employee.WorkAddress.Management')\n const Components = useComponentContext()\n const [addressModal, setAddressModal] = useState<'edit' | 'create' | null>(null)\n const [deleteConfirmUuid, setDeleteConfirmUuid] = useState<string | null>(null)\n const addressModalContainerRef = useRef<HTMLDivElement>(null)\n const [addressModalPortal, setAddressModalPortal] = useState<HTMLElement | undefined>(undefined)\n\n useLayoutEffect(() => {\n if (!addressModal) {\n setAddressModalPortal(undefined)\n return\n }\n const syncPortal = () => {\n setAddressModalPortal(addressModalContainerRef.current ?? undefined)\n }\n syncPortal()\n if (addressModalContainerRef.current == null) {\n const id = requestAnimationFrame(syncPortal)\n return () => {\n cancelAnimationFrame(id)\n }\n }\n }, [addressModal])\n\n const {\n data: { workAddress, companyLocations },\n status: editStatus,\n form: { Fields: editFormFields },\n } = editWorkAddressForm\n\n const editShowsEffectiveDateField = editFormFields.EffectiveDate != null\n\n const { status: createStatus } = changeWorkAddressForm\n\n const locationValidation = {\n [WorkAddressErrorCodes.REQUIRED]: t('form.locationRequired'),\n }\n\n const startDateValidation = {\n [WorkAddressErrorCodes.REQUIRED]: t('form.startDateRequired'),\n }\n\n const pendingFutureAddress = useMemo(\n () => getPendingFutureWorkAddress(workAddresses),\n [workAddresses],\n )\n\n const addressForDeleteModal = useMemo(() => {\n if (!deleteConfirmUuid || !workAddresses) {\n return undefined\n }\n return workAddresses.find(a => a.uuid === deleteConfirmUuid)\n }, [deleteConfirmUuid, workAddresses])\n\n const changePendingPossessiveLabel = useMemo(() => {\n const trimmed = employeeDisplayName.trim()\n return trimmed ? `${trimmed}'s` : t('changePendingPossessiveFallback')\n }, [employeeDisplayName, t])\n\n const chronologicalAsc = useMemo(() => {\n return [...(workAddresses ?? [])].sort((a, b) => {\n const aDate = a.effectiveDate ?? ''\n const bDate = b.effectiveDate ?? ''\n if (!aDate && !bDate) return 0\n if (!aDate) return 1\n if (!bDate) return -1\n return aDate.localeCompare(bDate)\n })\n }, [workAddresses])\n\n const historyAddresses = useMemo(\n () => chronologicalAsc.filter(address => address.active !== true),\n [chronologicalAsc],\n )\n\n const sortedHistory = useMemo(() => [...historyAddresses].reverse(), [historyAddresses])\n\n const historyEndDate = (row: EmployeeWorkAddress) => {\n const idx = chronologicalAsc.findIndex(a => a.uuid === row.uuid)\n if (idx === -1 || idx >= chronologicalAsc.length - 1) return '—'\n const nextStart = chronologicalAsc[idx + 1]?.effectiveDate\n if (!nextStart) return '—'\n const nextDate = normalizeToDate(nextStart)\n if (!nextDate) return '—'\n const endDate = addDays(nextDate, -1)\n const y = endDate.getFullYear()\n const m = String(endDate.getMonth() + 1).padStart(2, '0')\n const d = String(endDate.getDate()).padStart(2, '0')\n return formatDateLongWithYear(`${y}-${m}-${d}`)\n }\n\n const historyDataView = useDataView({\n data: sortedHistory,\n columns: [\n {\n title: t('columns.location'),\n render: (row: EmployeeWorkAddress) => {\n const lines = formatWorkAddressLines(row, companyLocations)\n return (\n <Flex flexDirection=\"column\" gap={0}>\n <Components.Text weight=\"medium\">{lines.primary}</Components.Text>\n <Components.Text variant=\"supporting\">{lines.secondary}</Components.Text>\n </Flex>\n )\n },\n },\n {\n title: t('columns.startDate'),\n render: (row: EmployeeWorkAddress) =>\n row.effectiveDate ? formatDateLongWithYear(row.effectiveDate) : '—',\n },\n {\n title: t('columns.endDate'),\n render: (row: EmployeeWorkAddress) => historyEndDate(row),\n },\n ],\n itemMenu: (row: EmployeeWorkAddress) => (\n <HamburgerMenu\n triggerLabel={t('rowMenuAriaLabel')}\n items={[\n {\n label: t('rowEdit'),\n onClick: () => {\n onEditTargetUuidChange(row.uuid)\n setAddressModal('edit')\n },\n icon: <PencilSvg aria-hidden />,\n },\n {\n label: t('rowDelete'),\n onClick: () => {\n if (row.active === true) {\n return\n }\n setDeleteConfirmUuid(row.uuid)\n },\n icon: <TrashCanSvg aria-hidden />,\n },\n ]}\n />\n ),\n emptyState: () => (\n <div data-testid=\"work-address-history-empty\">\n <EmptyData\n icon={<ListIcon aria-hidden />}\n title={t('historyEmptyTitle')}\n description={t('historyEmptyDescription')}\n />\n </div>\n ),\n })\n\n const closeAddressModal = () => {\n setAddressModal(null)\n onEditTargetUuidChange(undefined)\n }\n\n const handleDeleteModalConfirm = async () => {\n if (!deleteConfirmUuid) {\n return\n }\n const deleted = await onConfirmDelete(deleteConfirmUuid)\n if (deleted) {\n setDeleteConfirmUuid(null)\n }\n }\n\n const handleSave = async () => {\n if (!addressModal) {\n return\n }\n\n if (addressModal === 'edit') {\n const result = await editWorkAddressForm.actions.onSubmit(\n undefined,\n editShowsEffectiveDateField ? undefined : { effectiveDate: workAddress?.effectiveDate },\n )\n if (result) {\n onWorkAddressSaved(result)\n closeAddressModal()\n }\n return\n }\n\n const result = await changeWorkAddressForm.actions.onSubmit()\n if (result) {\n onWorkAddressSaved(result)\n closeAddressModal()\n }\n }\n\n const modalPending = addressModal === 'edit' ? editStatus.isPending : createStatus.isPending\n\n const currentLines = workAddress ? formatWorkAddressLines(workAddress, companyLocations) : null\n const currentLocation =\n workAddress && companyLocations ? resolveLocation(workAddress, companyLocations) : undefined\n\n return (\n <Flex flexDirection=\"column\" gap={24}>\n <Flex flexDirection=\"column\" gap={4} alignItems=\"flex-start\">\n <Components.Heading as=\"h1\" styledAs=\"h2\">\n {t('title')}\n </Components.Heading>\n <Components.Text variant=\"supporting\">{t('description')}</Components.Text>\n </Flex>\n\n <Components.Box\n header={\n <Components.BoxHeader\n title={t('currentSectionTitle')}\n action={\n workAddress ? (\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEditTargetUuidChange(undefined)\n setAddressModal('edit')\n }}\n isLoading={editStatus.isPending}\n >\n {t('editCta')}\n </Components.Button>\n ) : undefined\n }\n />\n }\n footer={\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEditTargetUuidChange(undefined)\n setAddressModal('create')\n }}\n isLoading={createStatus.isPending}\n >\n {t('changeCta')}\n </Components.Button>\n }\n >\n <Flex flexDirection=\"column\" gap={16}>\n {workAddress && currentLines ? (\n <Flex flexDirection=\"column\" gap={4}>\n <FlexItem>\n {currentLocation ? (\n <>\n <Components.Text weight=\"medium\">\n {getStreet(currentLocation).trim()}\n </Components.Text>\n <Components.Text weight=\"medium\">\n {getCityStateZip(currentLocation)}\n </Components.Text>\n </>\n ) : (\n <>\n <Components.Text weight=\"medium\">{currentLines.primary}</Components.Text>\n <Components.Text weight=\"medium\">{currentLines.secondary}</Components.Text>\n </>\n )}\n </FlexItem>\n {workAddress.effectiveDate ? (\n <Components.Text variant=\"supporting\">\n {t('currentSince', {\n date: formatDateLongWithYear(workAddress.effectiveDate),\n })}\n </Components.Text>\n ) : null}\n </Flex>\n ) : (\n <Components.Text>{t('currentEmpty')}</Components.Text>\n )}\n {pendingFutureAddress ? (\n <Components.Alert status=\"warning\" label={t('changePendingTitle')}>\n <Components.Text variant=\"supporting\">\n {t('changePendingDescription', {\n possessiveLabel: changePendingPossessiveLabel,\n newAddress: formatPendingWorkAddressLine(pendingFutureAddress, companyLocations),\n effectiveDate: pendingFutureAddress.effectiveDate\n ? formatDateLongWithYear(pendingFutureAddress.effectiveDate)\n : '—',\n })}\n </Components.Text>\n </Components.Alert>\n ) : null}\n </Flex>\n </Components.Box>\n\n <Flex flexDirection=\"column\" gap={12}>\n <Components.Heading as=\"h2\" styledAs=\"h4\">\n {t('historySectionTitle')}\n </Components.Heading>\n <DataView label={t('historySectionTitle')} {...historyDataView} />\n </Flex>\n\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={onBack}>\n {t('backCta')}\n </Components.Button>\n </ActionsLayout>\n\n <Components.Modal\n isOpen={addressModal !== null}\n onClose={closeAddressModal}\n shouldCloseOnBackdropClick={false}\n containerRef={addressModalContainerRef}\n footer={\n <Flex flexDirection=\"row\" gap={12} justifyContent=\"flex-end\">\n <Components.Button variant=\"secondary\" onClick={closeAddressModal}>\n {t('cancelCta')}\n </Components.Button>\n <Components.Button\n variant=\"primary\"\n onClick={() => {\n void handleSave()\n }}\n isLoading={modalPending}\n >\n {t('submitCta')}\n </Components.Button>\n </Flex>\n }\n >\n <Flex flexDirection=\"column\" gap={16}>\n <Components.Heading as=\"h2\">\n {addressModal === 'edit' ? t('editModalTitle') : t('changeModalTitle')}\n </Components.Heading>\n <Components.Text variant=\"supporting\">\n {addressModal === 'edit' ? t('editModalDescription') : t('changeModalDescription')}\n </Components.Text>\n {addressModal === 'edit' && editShowsEffectiveDateField ? (\n <Components.Alert status=\"warning\" label={t('editPastAddressAlertTitle')} />\n ) : null}\n {addressModal === 'edit' ? (\n <SDKFormProvider formHookResult={editWorkAddressForm}>\n <Grid\n gridTemplateColumns={{\n base: '1fr',\n small: '1fr',\n }}\n gap={20}\n >\n <LocationField\n label={\n editShowsEffectiveDateField\n ? t('form.editInactiveLocationLabel')\n : t('form.editLocationLabel')\n }\n description={t('form.editLocationDescription')}\n validationMessages={locationValidation}\n portalContainer={addressModalPortal}\n />\n {editShowsEffectiveDateField ? (\n <EffectiveDateField\n label={t('form.startDateLabel')}\n description={t('form.editInactiveStartDateDescription')}\n validationMessages={startDateValidation}\n portalContainer={addressModalPortal}\n />\n ) : null}\n </Grid>\n </SDKFormProvider>\n ) : null}\n {addressModal === 'create' ? (\n <SDKFormProvider formHookResult={changeWorkAddressForm}>\n <Grid\n gridTemplateColumns={{\n base: '1fr',\n small: '1fr',\n }}\n gap={20}\n >\n <LocationField\n label={t('form.newWorkAddressLabel')}\n description={t('form.newWorkAddressDescription')}\n validationMessages={locationValidation}\n portalContainer={addressModalPortal}\n />\n <EffectiveDateField\n label={t('form.startDateLabel')}\n description={t('form.startDateDescription')}\n validationMessages={startDateValidation}\n portalContainer={addressModalPortal}\n />\n </Grid>\n </SDKFormProvider>\n ) : null}\n </Flex>\n </Components.Modal>\n\n <Components.Modal\n isOpen={deleteConfirmUuid !== null}\n onClose={() => {\n setDeleteConfirmUuid(null)\n }}\n shouldCloseOnBackdropClick={false}\n footer={\n <Flex flexDirection=\"row\" gap={12} justifyContent=\"flex-end\">\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n setDeleteConfirmUuid(null)\n }}\n >\n {t('cancelCta')}\n </Components.Button>\n <Components.Button\n variant=\"error\"\n onClick={() => {\n void handleDeleteModalConfirm()\n }}\n isLoading={isDeletePending && deleteConfirmUuid !== null}\n >\n {t('deleteModalConfirmCta')}\n </Components.Button>\n </Flex>\n }\n >\n <Flex flexDirection=\"column\" gap={16}>\n <Components.Heading as=\"h2\">{t('deleteModalTitle')}</Components.Heading>\n <Components.Text variant=\"supporting\">\n {addressForDeleteModal ? (\n <Trans\n t={t}\n i18nKey=\"deleteModalDescription\"\n values={{\n address: formatPendingWorkAddressLine(addressForDeleteModal, companyLocations),\n }}\n components={{\n strong: <Components.Text weight=\"medium\" as=\"span\" />,\n }}\n />\n ) : null}\n </Components.Text>\n </Flex>\n </Components.Modal>\n </Flex>\n )\n}\n"],"names":["resolveLocation","row","companyLocations","loc","formatWorkAddressLines","location","street","getStreet","locality","getCityStateZip","WorkAddressView","editWorkAddressForm","changeWorkAddressForm","workAddresses","editTargetUuid","onEditTargetUuidChange","employeeDisplayName","onConfirmDelete","onWorkAddressSaved","onBack","isDeletePending","useTranslation","Components","useComponentContext","addressModal","setAddressModal","useState","deleteConfirmUuid","setDeleteConfirmUuid","addressModalContainerRef","useRef","addressModalPortal","setAddressModalPortal","useLayoutEffect","syncPortal","id","workAddress","editStatus","editFormFields","editShowsEffectiveDateField","createStatus","locationValidation","WorkAddressErrorCodes","startDateValidation","pendingFutureAddress","useMemo","getPendingFutureWorkAddress","addressForDeleteModal","a","changePendingPossessiveLabel","trimmed","chronologicalAsc","b","aDate","bDate","historyAddresses","address","sortedHistory","historyEndDate","idx","nextStart","nextDate","normalizeToDate","endDate","addDays","y","m","d","formatDateLongWithYear","historyDataView","useDataView","lines","jsxs","Flex","jsx","HamburgerMenu","PencilSvg","TrashCanSvg","EmptyData","ListIcon","closeAddressModal","handleDeleteModalConfirm","handleSave","result","modalPending","currentLines","currentLocation","FlexItem","Fragment","formatPendingWorkAddressLine","DataView","ActionsLayout","SDKFormProvider","Grid","LocationField","EffectiveDateField","Trans"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8CA,SAASA,EACPC,GACAC,GACsB;AACtB,MAAI,GAACD,EAAI,gBAAgB,CAACC,GAAkB;AAG5C,WAAOA,EAAiB,KAAK,CAAAC,MAAOA,EAAI,SAASF,EAAI,YAAY;AACnE;AAEA,SAASG,EACPH,GACAC,GACwC;AACxC,QAAMG,IAAWL,EAAgBC,GAAKC,CAAgB;AACtD,MAAIG,GAAU;AACZ,UAAMC,IAASC,EAAUF,CAAQ,EAAE,KAAA,GAC7BG,IAAWC,EAAgBJ,CAAQ,EAAE,KAAA;AAC3C,WAAO,EAAE,SAASC,GAAQ,WAAWE,EAAAA;AAAAA,EACvC;AACA,QAAMF,IAASC,EAAUN,CAAG,EAAE,KAAA,GACxBO,IAAWC,EAAgBR,CAAG,EAAE,KAAA;AACtC,SAAO,EAAE,SAASK,GAAQ,WAAWE,EAAA;AACvC;AAEO,SAASE,GAAgB;AAAA,EAC9B,qBAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,wBAAAC;AAAA,EACA,qBAAAC;AAAA,EACA,iBAAAC;AAAA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ressView.js","sources":["../../../../../src/components/Employee/WorkAddress/management/WorkAddressView.tsx"],"sourcesContent":["import { useLayoutEffect, useMemo, useRef, useState } from 'react'\nimport { Trans, useTranslation } from 'react-i18next'\nimport type { Location } from '@gusto/embedded-api/models/components/location'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport {\n formatPendingWorkAddressLine,\n getPendingFutureWorkAddress,\n} from './getPendingFutureWorkAddress'\nimport ListIcon from '@/assets/icons/list.svg?react'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport TrashCanSvg from '@/assets/icons/trashcan.svg?react'\nimport {\n ActionsLayout,\n DataView,\n EmptyData,\n Grid,\n HamburgerMenu,\n useDataView,\n} from '@/components/Common'\nimport { Flex, FlexItem } from '@/components/Common/Flex/Flex'\nimport {\n LocationField,\n EffectiveDateField,\n} from '@/components/Employee/Profile/shared/useWorkAddressForm/fields'\nimport { WorkAddressErrorCodes } from '@/components/Employee/Profile/shared/useWorkAddressForm/workAddressSchema'\nimport type { UseWorkAddressFormReady } from '@/components/Employee/Profile/shared/useWorkAddressForm'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport type { HookSubmitResult } from '@/partner-hook-utils/types'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { addDays, formatDateLongWithYear, normalizeToDate } from '@/helpers/dateFormatting'\nimport { getCityStateZip, getStreet } from '@/helpers/formattedStrings'\n\nexport interface WorkAddressViewProps {\n editWorkAddressForm: UseWorkAddressFormReady\n changeWorkAddressForm: UseWorkAddressFormReady\n /** Full list for history table, pending-future alert, and delete-confirmation lookup. */\n workAddresses: EmployeeWorkAddress[] | undefined\n editTargetUuid: string | undefined\n onEditTargetUuidChange: (uuid: string | undefined) => void\n employeeDisplayName: string\n onConfirmDelete: (workAddressUuid: string) => Promise<boolean>\n onWorkAddressSaved: (result: HookSubmitResult<EmployeeWorkAddress>) => void\n onBack: () => void\n isDeletePending?: boolean\n}\n\nfunction resolveLocation(\n row: EmployeeWorkAddress,\n companyLocations: Location[] | undefined,\n): Location | undefined {\n if (!row.locationUuid || !companyLocations?.length) {\n return undefined\n }\n return companyLocations.find(loc => loc.uuid === row.locationUuid)\n}\n\nfunction formatWorkAddressLines(\n row: EmployeeWorkAddress,\n companyLocations: Location[] | undefined,\n): { primary: string; secondary: string } {\n const location = resolveLocation(row, companyLocations)\n if (location) {\n const street = getStreet(location).trim()\n const locality = getCityStateZip(location).trim()\n return { primary: street, secondary: locality }\n }\n const street = getStreet(row).trim()\n const locality = getCityStateZip(row).trim()\n return { primary: street, secondary: locality }\n}\n\nexport function WorkAddressView({\n editWorkAddressForm,\n changeWorkAddressForm,\n workAddresses,\n editTargetUuid,\n onEditTargetUuidChange,\n employeeDisplayName,\n onConfirmDelete,\n onWorkAddressSaved,\n onBack,\n isDeletePending = false,\n}: WorkAddressViewProps) {\n const { t } = useTranslation('Employee.WorkAddress.Management')\n const Components = useComponentContext()\n const [addressModal, setAddressModal] = useState<'edit' | 'create' | null>(null)\n const [deleteConfirmUuid, setDeleteConfirmUuid] = useState<string | null>(null)\n const addressModalContainerRef = useRef<HTMLDivElement>(null)\n const [addressModalPortal, setAddressModalPortal] = useState<HTMLElement | undefined>(undefined)\n\n useLayoutEffect(() => {\n if (!addressModal) {\n setAddressModalPortal(undefined)\n return\n }\n const syncPortal = () => {\n setAddressModalPortal(addressModalContainerRef.current ?? undefined)\n }\n syncPortal()\n if (addressModalContainerRef.current == null) {\n const id = requestAnimationFrame(syncPortal)\n return () => {\n cancelAnimationFrame(id)\n }\n }\n }, [addressModal])\n\n const {\n data: { workAddress, companyLocations },\n status: editStatus,\n form: { Fields: editFormFields },\n } = editWorkAddressForm\n\n const editShowsEffectiveDateField = editFormFields.EffectiveDate != null\n\n const { status: createStatus } = changeWorkAddressForm\n\n const locationValidation = {\n [WorkAddressErrorCodes.REQUIRED]: t('form.locationRequired'),\n }\n\n const startDateValidation = {\n [WorkAddressErrorCodes.REQUIRED]: t('form.startDateRequired'),\n }\n\n const pendingFutureAddress = useMemo(\n () => getPendingFutureWorkAddress(workAddresses),\n [workAddresses],\n )\n\n const addressForDeleteModal = useMemo(() => {\n if (!deleteConfirmUuid || !workAddresses) {\n return undefined\n }\n return workAddresses.find(a => a.uuid === deleteConfirmUuid)\n }, [deleteConfirmUuid, workAddresses])\n\n const changePendingPossessiveLabel = useMemo(() => {\n const trimmed = employeeDisplayName.trim()\n return trimmed ? `${trimmed}'s` : t('changePendingPossessiveFallback')\n }, [employeeDisplayName, t])\n\n const chronologicalAsc = useMemo(() => {\n return [...(workAddresses ?? [])].sort((a, b) => {\n const aDate = a.effectiveDate ?? ''\n const bDate = b.effectiveDate ?? ''\n if (!aDate && !bDate) return 0\n if (!aDate) return 1\n if (!bDate) return -1\n return aDate.localeCompare(bDate)\n })\n }, [workAddresses])\n\n const historyAddresses = useMemo(\n () => chronologicalAsc.filter(address => address.active !== true),\n [chronologicalAsc],\n )\n\n const sortedHistory = useMemo(() => [...historyAddresses].reverse(), [historyAddresses])\n\n const historyEndDate = (row: EmployeeWorkAddress) => {\n const idx = chronologicalAsc.findIndex(a => a.uuid === row.uuid)\n if (idx === -1 || idx >= chronologicalAsc.length - 1) return '—'\n const nextStart = chronologicalAsc[idx + 1]?.effectiveDate\n if (!nextStart) return '—'\n const nextDate = normalizeToDate(nextStart)\n if (!nextDate) return '—'\n const endDate = addDays(nextDate, -1)\n const y = endDate.getFullYear()\n const m = String(endDate.getMonth() + 1).padStart(2, '0')\n const d = String(endDate.getDate()).padStart(2, '0')\n return formatDateLongWithYear(`${y}-${m}-${d}`)\n }\n\n const historyDataView = useDataView({\n data: sortedHistory,\n columns: [\n {\n title: t('columns.location'),\n render: (row: EmployeeWorkAddress) => {\n const lines = formatWorkAddressLines(row, companyLocations)\n return (\n <Flex flexDirection=\"column\" gap={0}>\n <Components.Text weight=\"medium\">{lines.primary}</Components.Text>\n <Components.Text variant=\"supporting\">{lines.secondary}</Components.Text>\n </Flex>\n )\n },\n },\n {\n title: t('columns.startDate'),\n render: (row: EmployeeWorkAddress) =>\n row.effectiveDate ? formatDateLongWithYear(row.effectiveDate) : '—',\n },\n {\n title: t('columns.endDate'),\n render: (row: EmployeeWorkAddress) => historyEndDate(row),\n },\n ],\n itemMenu: (row: EmployeeWorkAddress) => (\n <HamburgerMenu\n triggerLabel={t('rowMenuAriaLabel')}\n items={[\n {\n label: t('rowEdit'),\n onClick: () => {\n onEditTargetUuidChange(row.uuid)\n setAddressModal('edit')\n },\n icon: <PencilSvg aria-hidden />,\n },\n {\n label: t('rowDelete'),\n onClick: () => {\n if (row.active === true) {\n return\n }\n setDeleteConfirmUuid(row.uuid)\n },\n icon: <TrashCanSvg aria-hidden />,\n },\n ]}\n />\n ),\n emptyState: () => (\n <div data-testid=\"work-address-history-empty\">\n <EmptyData\n icon={<ListIcon aria-hidden />}\n title={t('historyEmptyTitle')}\n description={t('historyEmptyDescription')}\n />\n </div>\n ),\n })\n\n const closeAddressModal = () => {\n setAddressModal(null)\n onEditTargetUuidChange(undefined)\n }\n\n const handleDeleteModalConfirm = async () => {\n if (!deleteConfirmUuid) {\n return\n }\n const deleted = await onConfirmDelete(deleteConfirmUuid)\n if (deleted) {\n setDeleteConfirmUuid(null)\n }\n }\n\n const handleSave = async () => {\n if (!addressModal) {\n return\n }\n\n if (addressModal === 'edit') {\n const result = await editWorkAddressForm.actions.onSubmit(\n undefined,\n editShowsEffectiveDateField ? undefined : { effectiveDate: workAddress?.effectiveDate },\n )\n if (result) {\n onWorkAddressSaved(result)\n closeAddressModal()\n }\n return\n }\n\n const result = await changeWorkAddressForm.actions.onSubmit()\n if (result) {\n onWorkAddressSaved(result)\n closeAddressModal()\n }\n }\n\n const modalPending = addressModal === 'edit' ? editStatus.isPending : createStatus.isPending\n\n const currentLines = workAddress ? formatWorkAddressLines(workAddress, companyLocations) : null\n const currentLocation =\n workAddress && companyLocations ? resolveLocation(workAddress, companyLocations) : undefined\n\n return (\n <Flex flexDirection=\"column\" gap={24}>\n <Flex flexDirection=\"column\" gap={4} alignItems=\"flex-start\">\n <Components.Heading as=\"h1\" styledAs=\"h2\">\n {t('title')}\n </Components.Heading>\n <Components.Text variant=\"supporting\">{t('description')}</Components.Text>\n </Flex>\n\n <Components.Box\n header={\n <Components.BoxHeader\n title={t('currentSectionTitle')}\n action={\n workAddress ? (\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEditTargetUuidChange(undefined)\n setAddressModal('edit')\n }}\n isLoading={editStatus.isPending}\n >\n {t('editCta')}\n </Components.Button>\n ) : undefined\n }\n />\n }\n footer={\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n onEditTargetUuidChange(undefined)\n setAddressModal('create')\n }}\n isLoading={createStatus.isPending}\n >\n {t('changeCta')}\n </Components.Button>\n }\n >\n <Flex flexDirection=\"column\" gap={16}>\n {workAddress && currentLines ? (\n <Flex flexDirection=\"column\" gap={4}>\n <FlexItem>\n {currentLocation ? (\n <>\n <Components.Text weight=\"medium\">\n {getStreet(currentLocation).trim()}\n </Components.Text>\n <Components.Text weight=\"medium\">\n {getCityStateZip(currentLocation)}\n </Components.Text>\n </>\n ) : (\n <>\n <Components.Text weight=\"medium\">{currentLines.primary}</Components.Text>\n <Components.Text weight=\"medium\">{currentLines.secondary}</Components.Text>\n </>\n )}\n </FlexItem>\n {workAddress.effectiveDate ? (\n <Components.Text variant=\"supporting\">\n {t('currentSince', {\n date: formatDateLongWithYear(workAddress.effectiveDate),\n })}\n </Components.Text>\n ) : null}\n </Flex>\n ) : (\n <Components.Text>{t('currentEmpty')}</Components.Text>\n )}\n {pendingFutureAddress ? (\n <Components.Alert status=\"warning\" label={t('changePendingTitle')}>\n <Components.Text variant=\"supporting\">\n {t('changePendingDescription', {\n possessiveLabel: changePendingPossessiveLabel,\n newAddress: formatPendingWorkAddressLine(pendingFutureAddress, companyLocations),\n effectiveDate: pendingFutureAddress.effectiveDate\n ? formatDateLongWithYear(pendingFutureAddress.effectiveDate)\n : '—',\n // Values are inserted into JSX text, so the browser already\n // escapes them. Telling i18next to escape too produces\n // double-encoded entities like `&#39;` showing as text.\n interpolation: { escapeValue: false },\n })}\n </Components.Text>\n </Components.Alert>\n ) : null}\n </Flex>\n </Components.Box>\n\n <Flex flexDirection=\"column\" gap={12}>\n <Components.Heading as=\"h2\" styledAs=\"h4\">\n {t('historySectionTitle')}\n </Components.Heading>\n <DataView label={t('historySectionTitle')} {...historyDataView} />\n </Flex>\n\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={onBack}>\n {t('backCta')}\n </Components.Button>\n </ActionsLayout>\n\n <Components.Modal\n isOpen={addressModal !== null}\n onClose={closeAddressModal}\n shouldCloseOnBackdropClick={false}\n containerRef={addressModalContainerRef}\n footer={\n <Flex flexDirection=\"row\" gap={12} justifyContent=\"flex-end\">\n <Components.Button variant=\"secondary\" onClick={closeAddressModal}>\n {t('cancelCta')}\n </Components.Button>\n <Components.Button\n variant=\"primary\"\n onClick={() => {\n void handleSave()\n }}\n isLoading={modalPending}\n >\n {t('submitCta')}\n </Components.Button>\n </Flex>\n }\n >\n <Flex flexDirection=\"column\" gap={16}>\n <Components.Heading as=\"h2\">\n {addressModal === 'edit' ? t('editModalTitle') : t('changeModalTitle')}\n </Components.Heading>\n <Components.Text variant=\"supporting\">\n {addressModal === 'edit' ? t('editModalDescription') : t('changeModalDescription')}\n </Components.Text>\n {addressModal === 'edit' && editShowsEffectiveDateField ? (\n <Components.Alert status=\"warning\" label={t('editPastAddressAlertTitle')} />\n ) : null}\n {addressModal === 'edit' ? (\n <SDKFormProvider formHookResult={editWorkAddressForm}>\n <Grid\n gridTemplateColumns={{\n base: '1fr',\n small: '1fr',\n }}\n gap={20}\n >\n <LocationField\n label={\n editShowsEffectiveDateField\n ? t('form.editInactiveLocationLabel')\n : t('form.editLocationLabel')\n }\n description={t('form.editLocationDescription')}\n validationMessages={locationValidation}\n portalContainer={addressModalPortal}\n />\n {editShowsEffectiveDateField ? (\n <EffectiveDateField\n label={t('form.startDateLabel')}\n description={t('form.editInactiveStartDateDescription')}\n validationMessages={startDateValidation}\n portalContainer={addressModalPortal}\n />\n ) : null}\n </Grid>\n </SDKFormProvider>\n ) : null}\n {addressModal === 'create' ? (\n <SDKFormProvider formHookResult={changeWorkAddressForm}>\n <Grid\n gridTemplateColumns={{\n base: '1fr',\n small: '1fr',\n }}\n gap={20}\n >\n <LocationField\n label={t('form.newWorkAddressLabel')}\n description={t('form.newWorkAddressDescription')}\n validationMessages={locationValidation}\n portalContainer={addressModalPortal}\n />\n <EffectiveDateField\n label={t('form.startDateLabel')}\n description={t('form.startDateDescription')}\n validationMessages={startDateValidation}\n portalContainer={addressModalPortal}\n />\n </Grid>\n </SDKFormProvider>\n ) : null}\n </Flex>\n </Components.Modal>\n\n <Components.Modal\n isOpen={deleteConfirmUuid !== null}\n onClose={() => {\n setDeleteConfirmUuid(null)\n }}\n shouldCloseOnBackdropClick={false}\n footer={\n <Flex flexDirection=\"row\" gap={12} justifyContent=\"flex-end\">\n <Components.Button\n variant=\"secondary\"\n onClick={() => {\n setDeleteConfirmUuid(null)\n }}\n >\n {t('cancelCta')}\n </Components.Button>\n <Components.Button\n variant=\"error\"\n onClick={() => {\n void handleDeleteModalConfirm()\n }}\n isLoading={isDeletePending && deleteConfirmUuid !== null}\n >\n {t('deleteModalConfirmCta')}\n </Components.Button>\n </Flex>\n }\n >\n <Flex flexDirection=\"column\" gap={16}>\n <Components.Heading as=\"h2\">{t('deleteModalTitle')}</Components.Heading>\n <Components.Text variant=\"supporting\">\n {addressForDeleteModal ? (\n <Trans\n t={t}\n i18nKey=\"deleteModalDescription\"\n values={{\n address: formatPendingWorkAddressLine(addressForDeleteModal, companyLocations),\n }}\n components={{\n strong: <Components.Text weight=\"medium\" as=\"span\" />,\n }}\n />\n ) : null}\n </Components.Text>\n </Flex>\n </Components.Modal>\n </Flex>\n )\n}\n"],"names":["resolveLocation","row","companyLocations","loc","formatWorkAddressLines","location","street","getStreet","locality","getCityStateZip","WorkAddressView","editWorkAddressForm","changeWorkAddressForm","workAddresses","editTargetUuid","onEditTargetUuidChange","employeeDisplayName","onConfirmDelete","onWorkAddressSaved","onBack","isDeletePending","useTranslation","Components","useComponentContext","addressModal","setAddressModal","useState","deleteConfirmUuid","setDeleteConfirmUuid","addressModalContainerRef","useRef","addressModalPortal","setAddressModalPortal","useLayoutEffect","syncPortal","id","workAddress","editStatus","editFormFields","editShowsEffectiveDateField","createStatus","locationValidation","WorkAddressErrorCodes","startDateValidation","pendingFutureAddress","useMemo","getPendingFutureWorkAddress","addressForDeleteModal","a","changePendingPossessiveLabel","trimmed","chronologicalAsc","b","aDate","bDate","historyAddresses","address","sortedHistory","historyEndDate","idx","nextStart","nextDate","normalizeToDate","endDate","addDays","y","m","d","formatDateLongWithYear","historyDataView","useDataView","lines","jsxs","Flex","jsx","HamburgerMenu","PencilSvg","TrashCanSvg","EmptyData","ListIcon","closeAddressModal","handleDeleteModalConfirm","handleSave","result","modalPending","currentLines","currentLocation","FlexItem","Fragment","formatPendingWorkAddressLine","DataView","ActionsLayout","SDKFormProvider","Grid","LocationField","EffectiveDateField","Trans"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8CA,SAASA,EACPC,GACAC,GACsB;AACtB,MAAI,GAACD,EAAI,gBAAgB,CAACC,GAAkB;AAG5C,WAAOA,EAAiB,KAAK,CAAAC,MAAOA,EAAI,SAASF,EAAI,YAAY;AACnE;AAEA,SAASG,EACPH,GACAC,GACwC;AACxC,QAAMG,IAAWL,EAAgBC,GAAKC,CAAgB;AACtD,MAAIG,GAAU;AACZ,UAAMC,IAASC,EAAUF,CAAQ,EAAE,KAAA,GAC7BG,IAAWC,EAAgBJ,CAAQ,EAAE,KAAA;AAC3C,WAAO,EAAE,SAASC,GAAQ,WAAWE,EAAAA;AAAAA,EACvC;AACA,QAAMF,IAASC,EAAUN,CAAG,EAAE,KAAA,GACxBO,IAAWC,EAAgBR,CAAG,EAAE,KAAA;AACtC,SAAO,EAAE,SAAS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,cAAA;AAAA,cAE/E,YAAY;AAAA,gBACV,0BAASoB,EAAW,MAAX,EAAgB,QAAO,UAAS,IAAG,OAAA,CAAO;AAAA,cAAA;AAAA,YACrD;AAAA,UAAA,IAEA,KAAA,CACN;AAAA,QAAA,EAAA,CACF;AAAA,MAAA;AAAA,IAAA;AAAA,EACF,GACF;AAEJ;"}
@@ -1,67 +1,68 @@
1
- import { useState as N, useMemo as g } from "react";
2
- import { useEmployeeAddressesDeleteWorkAddressMutation as T } from "@gusto/embedded-api/react-query/employeeAddressesDeleteWorkAddress";
3
- import { useEmployeeAddressesGetWorkAddresses as C } from "@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses";
4
- import { useEmployeesGet as K } from "@gusto/embedded-api/react-query/employeesGet";
5
- import { useBaseSubmit as O } from "../../../Base/useBaseSubmit.js";
6
- import { useWorkAddressForm as W } from "../../Profile/shared/useWorkAddressForm/useWorkAddressForm.js";
7
- import { composeErrorHandler as Q } from "../../../../partner-hook-utils/composeErrorHandler.js";
8
- import { firstLastName as q } from "../../../../helpers/formattedStrings.js";
9
- import { normalizeToSDKError as G, SDKInternalError as n } from "../../../../types/sdkError.js";
10
- import { componentEvents as x } from "../../../../shared/constants.js";
11
- function te(e) {
1
+ import { useState as T, useMemo as E } from "react";
2
+ import { useEmployeeAddressesDeleteWorkAddressMutation as C } from "@gusto/embedded-api/react-query/employeeAddressesDeleteWorkAddress";
3
+ import { useEmployeeAddressesGetWorkAddresses as K } from "@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses";
4
+ import { useEmployeesGet as O } from "@gusto/embedded-api/react-query/employeesGet";
5
+ import { useBaseSubmit as Q } from "../../../Base/useBaseSubmit.js";
6
+ import { useWorkAddressForm as h } from "../../Profile/shared/useWorkAddressForm/useWorkAddressForm.js";
7
+ import { composeErrorHandler as q } from "../../../../partner-hook-utils/composeErrorHandler.js";
8
+ import { firstLastName as G } from "../../../../helpers/formattedStrings.js";
9
+ import { normalizeToSDKError as x, SDKInternalError as d } from "../../../../types/sdkError.js";
10
+ import { componentEvents as z } from "../../../../shared/constants.js";
11
+ function ie(e) {
12
12
  return e.isLoading ? !1 : !e.status.isEmployeeError;
13
13
  }
14
- function z(e, d) {
14
+ function B(e, n) {
15
15
  if (e.isLoading)
16
- throw new n("Edit work address form is still loading");
17
- if (d.isLoading)
18
- throw new n("Change work address form is still loading");
16
+ throw new d("Edit work address form is still loading");
17
+ if (n.isLoading)
18
+ throw new d("Change work address form is still loading");
19
19
  return {
20
20
  editWorkAddressForm: e,
21
- changeWorkAddressForm: d
21
+ changeWorkAddressForm: n
22
22
  };
23
23
  }
24
- function ie({
24
+ function de({
25
25
  employeeId: e,
26
- onEvent: d
26
+ onEvent: n
27
27
  }) {
28
28
  const {
29
- baseSubmitHandler: h,
30
- error: D,
31
- setError: F
32
- } = O("Employee.WorkAddress.Management"), l = T(), [t, S] = N(void 0), o = K({ employeeId: e }, { enabled: !!e }), a = o.data?.employee?.companyUuid, f = C(
29
+ baseSubmitHandler: D,
30
+ error: F,
31
+ setError: S
32
+ } = Q("Employee.WorkAddress.Management"), l = C(), [t, v] = T(void 0), o = O({ employeeId: e }, { enabled: !!e }), a = o.data?.employee?.companyUuid, f = K(
33
33
  { employeeId: e },
34
34
  { enabled: !!e && !!a }
35
- ), r = f.data?.employeeWorkAddressesList, b = g(() => r?.length ? r.find((s) => s.active) ?? r[0] ?? null : null, [r]), v = t ?? b?.uuid, E = g(() => {
35
+ ), r = f.data?.employeeWorkAddressesList, b = E(() => r?.length ? r.find((s) => s.active) ?? r[0] ?? null : null, [r]), g = t ?? b?.uuid, p = E(() => {
36
36
  if (!(!t || !r))
37
37
  return r.find((s) => s.uuid === t);
38
- }, [t, r]), R = E ? E.active !== !0 : !1, m = W({
38
+ }, [t, r]), R = g ? r?.find((s) => s.uuid === g) : void 0, M = p ? p.active !== !0 : !1, u = h({
39
39
  companyId: a,
40
40
  employeeId: e,
41
- workAddressUuid: v,
42
- withEffectiveDateField: R
43
- }), u = W({
41
+ workAddressUuid: g,
42
+ initialAddress: R,
43
+ withEffectiveDateField: M
44
+ }), m = h({
44
45
  companyId: a,
45
46
  employeeId: e,
46
47
  withEffectiveDateField: !0
47
- }), p = g(() => {
48
+ }), y = E(() => {
48
49
  const s = o.data?.employee;
49
- return s ? q({
50
+ return s ? G({
50
51
  first_name: s.firstName,
51
52
  last_name: s.lastName
52
53
  }).trim() : "";
53
- }, [o.data?.employee]), y = !!o.data?.employee && !a, i = Q(
54
+ }, [o.data?.employee]), k = !!o.data?.employee && !a, i = q(
54
55
  [
55
56
  o,
56
57
  f,
57
- m,
58
58
  u,
59
- ...y ? [
59
+ m,
60
+ ...k ? [
60
61
  {
61
62
  errorHandling: {
62
63
  errors: [
63
- G(
64
- new n(
64
+ x(
65
+ new d(
65
66
  "Employee record is missing companyUuid, which is required to load work address locations."
66
67
  )
67
68
  )
@@ -74,70 +75,70 @@ function ie({
74
75
  }
75
76
  ] : []
76
77
  ],
77
- { submitError: D, setSubmitError: F }
78
- ), k = {
79
- setEditTargetUuid: S,
78
+ { submitError: F, setSubmitError: S }
79
+ ), A = {
80
+ setEditTargetUuid: v,
80
81
  confirmDeleteWorkAddress: async (s) => {
81
- const _ = r?.find((c) => c.uuid === s) ?? null;
82
+ const H = r?.find((c) => c.uuid === s) ?? null;
82
83
  let w = !1;
83
- return await h(
84
- { workAddressUuid: s, snapshot: _ },
85
- async ({ workAddressUuid: c, snapshot: A }) => {
86
- const L = r?.find((H) => H.uuid === c);
84
+ return await D(
85
+ { workAddressUuid: s, snapshot: H },
86
+ async ({ workAddressUuid: c, snapshot: W }) => {
87
+ const L = r?.find((N) => N.uuid === c);
87
88
  if (!L)
88
- throw new n("Work address not found");
89
+ throw new d("Work address not found");
89
90
  if (L.active === !0)
90
- throw new n("Cannot delete the active work address");
91
+ throw new d("Cannot delete the active work address");
91
92
  await l.mutateAsync({
92
93
  request: { workAddressUuid: c }
93
- }), w = !0, A && d(x.EMPLOYEE_WORK_ADDRESS_DELETED, A);
94
+ }), w = !0, W && n(z.EMPLOYEE_WORK_ADDRESS_DELETED, W);
94
95
  }
95
96
  ), w;
96
97
  }
97
- }, M = {
98
- employeeDisplayName: p,
98
+ }, U = {
99
+ employeeDisplayName: y,
99
100
  employeeWorkAddresses: r,
100
101
  editTargetUuid: t,
101
- editWorkAddressForm: m,
102
- changeWorkAddressForm: u
102
+ editWorkAddressForm: u,
103
+ changeWorkAddressForm: m
103
104
  };
104
105
  if (o.isLoading)
105
106
  return { isLoading: !0, errorHandling: i };
106
- if (o.isError || y)
107
+ if (o.isError || k)
107
108
  return {
108
109
  isLoading: !1,
109
- data: M,
110
+ data: U,
110
111
  status: {
111
112
  isDeletePending: l.isPending,
112
113
  isEmployeeError: !0
113
114
  },
114
115
  errorHandling: i,
115
- actions: k
116
+ actions: A
116
117
  };
117
118
  if (f.isLoading)
118
119
  return { isLoading: !0, errorHandling: i };
119
- if (m.isLoading || u.isLoading)
120
+ if (u.isLoading || m.isLoading)
120
121
  return { isLoading: !0, errorHandling: i };
121
- const { editWorkAddressForm: U, changeWorkAddressForm: P } = z(m, u);
122
+ const { editWorkAddressForm: P, changeWorkAddressForm: _ } = B(u, m);
122
123
  return {
123
124
  isLoading: !1,
124
125
  data: {
125
- employeeDisplayName: p,
126
+ employeeDisplayName: y,
126
127
  employeeWorkAddresses: r,
127
128
  editTargetUuid: t,
128
- editWorkAddressForm: U,
129
- changeWorkAddressForm: P
129
+ editWorkAddressForm: P,
130
+ changeWorkAddressForm: _
130
131
  },
131
132
  status: {
132
133
  isDeletePending: l.isPending,
133
134
  isEmployeeError: !1
134
135
  },
135
136
  errorHandling: i,
136
- actions: k
137
+ actions: A
137
138
  };
138
139
  }
139
140
  export {
140
- te as isUseWorkAddressManagementSuccess,
141
- ie as useWorkAddressManagement
141
+ ie as isUseWorkAddressManagementSuccess,
142
+ de as useWorkAddressManagement
142
143
  };
143
144
  //# sourceMappingURL=useWorkAddressManagement.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useWorkAddressManagement.js","sources":["../../../../../src/components/Employee/WorkAddress/management/useWorkAddressManagement.tsx"],"sourcesContent":["import { useMemo, useState } from 'react'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { useEmployeeAddressesDeleteWorkAddressMutation } from '@gusto/embedded-api/react-query/employeeAddressesDeleteWorkAddress'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { useWorkAddressForm } from '@/components/Employee/Profile/shared/useWorkAddressForm'\nimport type {\n UseWorkAddressFormReady,\n UseWorkAddressFormResult,\n} from '@/components/Employee/Profile/shared/useWorkAddressForm'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseHookReady,\n HookErrorHandling,\n HookLoadingResult,\n} from '@/partner-hook-utils/types'\nimport { firstLastName } from '@/helpers/formattedStrings'\nimport { normalizeToSDKError, SDKInternalError } from '@/types/sdkError'\nimport { componentEvents, type EventType } from '@/shared/constants'\n\nexport interface UseWorkAddressManagementParams {\n employeeId: string\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport interface UseWorkAddressManagementDataPendingForms extends Record<string, unknown> {\n employeeDisplayName: string\n employeeWorkAddresses: EmployeeWorkAddress[] | undefined\n editTargetUuid: string | undefined\n editWorkAddressForm: UseWorkAddressFormResult\n changeWorkAddressForm: UseWorkAddressFormResult\n}\n\nexport interface UseWorkAddressManagementDataReady extends Record<string, unknown> {\n employeeDisplayName: string\n employeeWorkAddresses: EmployeeWorkAddress[] | undefined\n editTargetUuid: string | undefined\n editWorkAddressForm: UseWorkAddressFormReady\n changeWorkAddressForm: UseWorkAddressFormReady\n}\n\nexport interface UseWorkAddressManagementStatusEmployeeError extends Record<string, unknown> {\n isDeletePending: boolean\n isEmployeeError: true\n}\n\nexport interface UseWorkAddressManagementStatusSuccess extends Record<string, unknown> {\n isDeletePending: boolean\n isEmployeeError: false\n}\n\nexport interface UseWorkAddressManagementActions {\n setEditTargetUuid: (workAddressUuid: string | undefined) => void\n confirmDeleteWorkAddress: (workAddressUuid: string) => Promise<boolean>\n}\n\nexport interface UseWorkAddressManagementReadyEmployeeError extends BaseHookReady<\n UseWorkAddressManagementDataPendingForms,\n UseWorkAddressManagementStatusEmployeeError\n> {\n actions: UseWorkAddressManagementActions\n}\n\nexport interface UseWorkAddressManagementReadySuccess extends BaseHookReady<\n UseWorkAddressManagementDataReady,\n UseWorkAddressManagementStatusSuccess\n> {\n actions: UseWorkAddressManagementActions\n}\n\nexport type UseWorkAddressManagementReady =\n | UseWorkAddressManagementReadyEmployeeError\n | UseWorkAddressManagementReadySuccess\n\nexport type UseWorkAddressManagementResult = HookLoadingResult | UseWorkAddressManagementReady\n\nexport function isUseWorkAddressManagementSuccess(\n value: UseWorkAddressManagementResult,\n): value is UseWorkAddressManagementReadySuccess {\n if (value.isLoading) {\n return false\n }\n return !value.status.isEmployeeError\n}\n\nfunction workAddressFormsReady(\n editWorkAddressForm: UseWorkAddressFormResult,\n changeWorkAddressForm: UseWorkAddressFormResult,\n): Pick<UseWorkAddressManagementDataReady, 'editWorkAddressForm' | 'changeWorkAddressForm'> {\n if (editWorkAddressForm.isLoading) {\n throw new SDKInternalError('Edit work address form is still loading')\n }\n if (changeWorkAddressForm.isLoading) {\n throw new SDKInternalError('Change work address form is still loading')\n }\n return {\n editWorkAddressForm,\n changeWorkAddressForm,\n }\n}\n\nexport function useWorkAddressManagement({\n employeeId,\n onEvent,\n}: UseWorkAddressManagementParams): UseWorkAddressManagementResult {\n const {\n baseSubmitHandler,\n error: rootSubmitError,\n setError: setRootSubmitError,\n } = useBaseSubmit('Employee.WorkAddress.Management')\n const deleteWorkAddressMutation = useEmployeeAddressesDeleteWorkAddressMutation()\n const [editTargetUuid, setEditTargetUuid] = useState<string | undefined>(undefined)\n\n const employeeQuery = useEmployeesGet({ employeeId }, { enabled: !!employeeId })\n const companyId = employeeQuery.data?.employee?.companyUuid\n\n const workAddressesQuery = useEmployeeAddressesGetWorkAddresses(\n { employeeId },\n { enabled: !!employeeId && !!companyId },\n )\n\n const employeeWorkAddresses = workAddressesQuery.data?.employeeWorkAddressesList\n\n const currentWorkAddress = useMemo<EmployeeWorkAddress | null>(() => {\n if (!employeeWorkAddresses?.length) {\n return null\n }\n return employeeWorkAddresses.find(w => w.active) ?? employeeWorkAddresses[0] ?? null\n }, [employeeWorkAddresses])\n\n const workAddressUuidForEdit = editTargetUuid ?? currentWorkAddress?.uuid\n\n const editInactiveRow = useMemo(() => {\n if (!editTargetUuid || !employeeWorkAddresses) {\n return undefined\n }\n return employeeWorkAddresses.find(w => w.uuid === editTargetUuid)\n }, [editTargetUuid, employeeWorkAddresses])\n\n const withEffectiveDateOnEdit = editInactiveRow ? editInactiveRow.active !== true : false\n\n const editWorkAddressForm = useWorkAddressForm({\n companyId,\n employeeId,\n workAddressUuid: workAddressUuidForEdit,\n withEffectiveDateField: withEffectiveDateOnEdit,\n })\n\n const changeWorkAddressForm = useWorkAddressForm({\n companyId,\n employeeId,\n withEffectiveDateField: true,\n })\n\n const employeeDisplayName = useMemo(() => {\n const employee = employeeQuery.data?.employee\n if (!employee) {\n return ''\n }\n return firstLastName({\n first_name: employee.firstName,\n last_name: employee.lastName,\n }).trim()\n }, [employeeQuery.data?.employee])\n\n const isMissingCompany = !!employeeQuery.data?.employee && !companyId\n\n const errorHandling: HookErrorHandling = composeErrorHandler(\n [\n employeeQuery,\n workAddressesQuery,\n editWorkAddressForm,\n changeWorkAddressForm,\n ...(isMissingCompany\n ? [\n {\n errorHandling: {\n errors: [\n normalizeToSDKError(\n new SDKInternalError(\n 'Employee record is missing companyUuid, which is required to load work address locations.',\n ),\n ),\n ],\n retryQueries: () => {},\n clearSubmitError: () => {},\n },\n },\n ]\n : []),\n ],\n { submitError: rootSubmitError, setSubmitError: setRootSubmitError },\n )\n\n const confirmDeleteWorkAddress = async (workAddressUuid: string): Promise<boolean> => {\n const snapshot = employeeWorkAddresses?.find(w => w.uuid === workAddressUuid) ?? null\n\n let succeeded = false\n await baseSubmitHandler(\n { workAddressUuid, snapshot },\n async ({ workAddressUuid: uuid, snapshot: snap }) => {\n const target = employeeWorkAddresses?.find(w => w.uuid === uuid)\n if (!target) {\n throw new SDKInternalError('Work address not found')\n }\n if (target.active === true) {\n throw new SDKInternalError('Cannot delete the active work address')\n }\n\n await deleteWorkAddressMutation.mutateAsync({\n request: { workAddressUuid: uuid },\n })\n succeeded = true\n if (snap) {\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS_DELETED, snap)\n }\n },\n )\n return succeeded\n }\n\n const actions: UseWorkAddressManagementActions = {\n setEditTargetUuid,\n confirmDeleteWorkAddress,\n }\n\n const dataPayloadPendingForms: UseWorkAddressManagementDataPendingForms = {\n employeeDisplayName,\n employeeWorkAddresses,\n editTargetUuid,\n editWorkAddressForm,\n changeWorkAddressForm,\n }\n\n if (employeeQuery.isLoading) {\n return { isLoading: true, errorHandling }\n }\n\n if (employeeQuery.isError || isMissingCompany) {\n return {\n isLoading: false,\n data: dataPayloadPendingForms,\n status: {\n isDeletePending: deleteWorkAddressMutation.isPending,\n isEmployeeError: true,\n },\n errorHandling,\n actions,\n }\n }\n\n if (workAddressesQuery.isLoading) {\n return { isLoading: true, errorHandling }\n }\n\n const isFormsLoading = editWorkAddressForm.isLoading || changeWorkAddressForm.isLoading\n if (isFormsLoading) {\n return { isLoading: true, errorHandling }\n }\n\n const { editWorkAddressForm: editReady, changeWorkAddressForm: changeReady } =\n workAddressFormsReady(editWorkAddressForm, changeWorkAddressForm)\n\n const dataReady: UseWorkAddressManagementDataReady = {\n employeeDisplayName,\n employeeWorkAddresses,\n editTargetUuid,\n editWorkAddressForm: editReady,\n changeWorkAddressForm: changeReady,\n }\n\n return {\n isLoading: false,\n data: dataReady,\n status: {\n isDeletePending: deleteWorkAddressMutation.isPending,\n isEmployeeError: false,\n },\n errorHandling,\n actions,\n }\n}\n"],"names":["isUseWorkAddressManagementSuccess","value","workAddressFormsReady","editWorkAddressForm","changeWorkAddressForm","SDKInternalError","useWorkAddressManagement","employeeId","onEvent","baseSubmitHandler","rootSubmitError","setRootSubmitError","useBaseSubmit","deleteWorkAddressMutation","useEmployeeAddressesDeleteWorkAddressMutation","editTargetUuid","setEditTargetUuid","useState","employeeQuery","useEmployeesGet","companyId","workAddressesQuery","useEmployeeAddressesGetWorkAddresses","employeeWorkAddresses","currentWorkAddress","useMemo","w","workAddressUuidForEdit","editInactiveRow","withEffectiveDateOnEdit","useWorkAddressForm","employeeDisplayName","employee","firstLastName","isMissingCompany","errorHandling","composeErrorHandler","normalizeToSDKError","actions","workAddressUuid","snapshot","succeeded","uuid","snap","target","componentEvents","dataPayloadPendingForms","editReady","changeReady"],"mappings":";;;;;;;;;;AA8EO,SAASA,GACdC,GAC+C;AAC/C,SAAIA,EAAM,YACD,KAEF,CAACA,EAAM,OAAO;AACvB;AAEA,SAASC,EACPC,GACAC,GAC0F;AAC1F,MAAID,EAAoB;AACtB,UAAM,IAAIE,EAAiB,yCAAyC;AAEtE,MAAID,EAAsB;AACxB,UAAM,IAAIC,EAAiB,2CAA2C;AAExE,SAAO;AAAA,IACL,qBAAAF;AAAA,IACA,uBAAAC;AAAA,EAAA;AAEJ;AAEO,SAASE,GAAyB;AAAA,EACvC,YAAAC;AAAA,EACA,SAAAC;AACF,GAAmE;AACjE,QAAM;AAAA,IACJ,mBAAAC;AAAA,IACA,OAAOC;AAAA,IACP,UAAUC;AAAA,EAAA,IACRC,EAAc,iCAAiC,GAC7CC,IAA4BC,EAAA,GAC5B,CAACC,GAAgBC,CAAiB,IAAIC,EAA6B,MAAS,GAE5EC,IAAgBC,EAAgB,EAAE,YAAAZ,EAAA,GAAc,EAAE,SAAS,CAAC,CAACA,GAAY,GACzEa,IAAYF,EAAc,MAAM,UAAU,aA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3C,iBAAiB;AAAA,MAAA;AAAA,MAEnB,eAAAsB;AAAA,MACA,SAAAG;AAAA,IAAA;AAIJ,MAAIjB,EAAmB;AACrB,WAAO,EAAE,WAAW,IAAM,eAAAc,EAAA;AAI5B,MADuBhC,EAAoB,aAAaC,EAAsB;AAE5E,WAAO,EAAE,WAAW,IAAM,eAAA+B,EAAA;AAG5B,QAAM,EAAE,qBAAqBY,GAAW,uBAAuBC,MAC7D9C,EAAsBC,GAAqBC,CAAqB;AAUlE,SAAO;AAAA,IACL,WAAW;AAAA,IACX,MAVmD;AAAA,MACnD,qBAAA2B;AAAA,MACA,uBAAAR;AAAA,MACA,gBAAAR;AAAA,MACA,qBAAqBgC;AAAA,MACrB,uBAAuBC;AAAA,IAAA;AAAA,IAMvB,QAAQ;AAAA,MACN,iBAAiBnC,EAA0B;AAAA,MAC3C,iBAAiB;AAAA,IAAA;AAAA,IAEnB,eAAAsB;AAAA,IACA,SAAAG;AAAA,EAAA;AAEJ;"}
1
+ {"version":3,"file":"useWorkAddressManagement.js","sources":["../../../../../src/components/Employee/WorkAddress/management/useWorkAddressManagement.tsx"],"sourcesContent":["import { useMemo, useState } from 'react'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { useEmployeeAddressesDeleteWorkAddressMutation } from '@gusto/embedded-api/react-query/employeeAddressesDeleteWorkAddress'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { useWorkAddressForm } from '@/components/Employee/Profile/shared/useWorkAddressForm'\nimport type {\n UseWorkAddressFormReady,\n UseWorkAddressFormResult,\n} from '@/components/Employee/Profile/shared/useWorkAddressForm'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseHookReady,\n HookErrorHandling,\n HookLoadingResult,\n} from '@/partner-hook-utils/types'\nimport { firstLastName } from '@/helpers/formattedStrings'\nimport { normalizeToSDKError, SDKInternalError } from '@/types/sdkError'\nimport { componentEvents, type EventType } from '@/shared/constants'\n\nexport interface UseWorkAddressManagementParams {\n employeeId: string\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport interface UseWorkAddressManagementDataPendingForms extends Record<string, unknown> {\n employeeDisplayName: string\n employeeWorkAddresses: EmployeeWorkAddress[] | undefined\n editTargetUuid: string | undefined\n editWorkAddressForm: UseWorkAddressFormResult\n changeWorkAddressForm: UseWorkAddressFormResult\n}\n\nexport interface UseWorkAddressManagementDataReady extends Record<string, unknown> {\n employeeDisplayName: string\n employeeWorkAddresses: EmployeeWorkAddress[] | undefined\n editTargetUuid: string | undefined\n editWorkAddressForm: UseWorkAddressFormReady\n changeWorkAddressForm: UseWorkAddressFormReady\n}\n\nexport interface UseWorkAddressManagementStatusEmployeeError extends Record<string, unknown> {\n isDeletePending: boolean\n isEmployeeError: true\n}\n\nexport interface UseWorkAddressManagementStatusSuccess extends Record<string, unknown> {\n isDeletePending: boolean\n isEmployeeError: false\n}\n\nexport interface UseWorkAddressManagementActions {\n setEditTargetUuid: (workAddressUuid: string | undefined) => void\n confirmDeleteWorkAddress: (workAddressUuid: string) => Promise<boolean>\n}\n\nexport interface UseWorkAddressManagementReadyEmployeeError extends BaseHookReady<\n UseWorkAddressManagementDataPendingForms,\n UseWorkAddressManagementStatusEmployeeError\n> {\n actions: UseWorkAddressManagementActions\n}\n\nexport interface UseWorkAddressManagementReadySuccess extends BaseHookReady<\n UseWorkAddressManagementDataReady,\n UseWorkAddressManagementStatusSuccess\n> {\n actions: UseWorkAddressManagementActions\n}\n\nexport type UseWorkAddressManagementReady =\n | UseWorkAddressManagementReadyEmployeeError\n | UseWorkAddressManagementReadySuccess\n\nexport type UseWorkAddressManagementResult = HookLoadingResult | UseWorkAddressManagementReady\n\nexport function isUseWorkAddressManagementSuccess(\n value: UseWorkAddressManagementResult,\n): value is UseWorkAddressManagementReadySuccess {\n if (value.isLoading) {\n return false\n }\n return !value.status.isEmployeeError\n}\n\nfunction workAddressFormsReady(\n editWorkAddressForm: UseWorkAddressFormResult,\n changeWorkAddressForm: UseWorkAddressFormResult,\n): Pick<UseWorkAddressManagementDataReady, 'editWorkAddressForm' | 'changeWorkAddressForm'> {\n if (editWorkAddressForm.isLoading) {\n throw new SDKInternalError('Edit work address form is still loading')\n }\n if (changeWorkAddressForm.isLoading) {\n throw new SDKInternalError('Change work address form is still loading')\n }\n return {\n editWorkAddressForm,\n changeWorkAddressForm,\n }\n}\n\nexport function useWorkAddressManagement({\n employeeId,\n onEvent,\n}: UseWorkAddressManagementParams): UseWorkAddressManagementResult {\n const {\n baseSubmitHandler,\n error: rootSubmitError,\n setError: setRootSubmitError,\n } = useBaseSubmit('Employee.WorkAddress.Management')\n const deleteWorkAddressMutation = useEmployeeAddressesDeleteWorkAddressMutation()\n const [editTargetUuid, setEditTargetUuid] = useState<string | undefined>(undefined)\n\n const employeeQuery = useEmployeesGet({ employeeId }, { enabled: !!employeeId })\n const companyId = employeeQuery.data?.employee?.companyUuid\n\n const workAddressesQuery = useEmployeeAddressesGetWorkAddresses(\n { employeeId },\n { enabled: !!employeeId && !!companyId },\n )\n\n const employeeWorkAddresses = workAddressesQuery.data?.employeeWorkAddressesList\n\n const currentWorkAddress = useMemo<EmployeeWorkAddress | null>(() => {\n if (!employeeWorkAddresses?.length) {\n return null\n }\n return employeeWorkAddresses.find(w => w.active) ?? employeeWorkAddresses[0] ?? null\n }, [employeeWorkAddresses])\n\n const workAddressUuidForEdit = editTargetUuid ?? currentWorkAddress?.uuid\n\n const editInactiveRow = useMemo(() => {\n if (!editTargetUuid || !employeeWorkAddresses) {\n return undefined\n }\n return employeeWorkAddresses.find(w => w.uuid === editTargetUuid)\n }, [editTargetUuid, employeeWorkAddresses])\n\n const editingWorkAddressRow = workAddressUuidForEdit\n ? employeeWorkAddresses?.find(w => w.uuid === workAddressUuidForEdit)\n : undefined\n\n const withEffectiveDateOnEdit = editInactiveRow ? editInactiveRow.active !== true : false\n\n const editWorkAddressForm = useWorkAddressForm({\n companyId,\n employeeId,\n workAddressUuid: workAddressUuidForEdit,\n initialAddress: editingWorkAddressRow,\n withEffectiveDateField: withEffectiveDateOnEdit,\n })\n\n const changeWorkAddressForm = useWorkAddressForm({\n companyId,\n employeeId,\n withEffectiveDateField: true,\n })\n\n const employeeDisplayName = useMemo(() => {\n const employee = employeeQuery.data?.employee\n if (!employee) {\n return ''\n }\n return firstLastName({\n first_name: employee.firstName,\n last_name: employee.lastName,\n }).trim()\n }, [employeeQuery.data?.employee])\n\n const isMissingCompany = !!employeeQuery.data?.employee && !companyId\n\n const errorHandling: HookErrorHandling = composeErrorHandler(\n [\n employeeQuery,\n workAddressesQuery,\n editWorkAddressForm,\n changeWorkAddressForm,\n ...(isMissingCompany\n ? [\n {\n errorHandling: {\n errors: [\n normalizeToSDKError(\n new SDKInternalError(\n 'Employee record is missing companyUuid, which is required to load work address locations.',\n ),\n ),\n ],\n retryQueries: () => {},\n clearSubmitError: () => {},\n },\n },\n ]\n : []),\n ],\n { submitError: rootSubmitError, setSubmitError: setRootSubmitError },\n )\n\n const confirmDeleteWorkAddress = async (workAddressUuid: string): Promise<boolean> => {\n const snapshot = employeeWorkAddresses?.find(w => w.uuid === workAddressUuid) ?? null\n\n let succeeded = false\n await baseSubmitHandler(\n { workAddressUuid, snapshot },\n async ({ workAddressUuid: uuid, snapshot: snap }) => {\n const target = employeeWorkAddresses?.find(w => w.uuid === uuid)\n if (!target) {\n throw new SDKInternalError('Work address not found')\n }\n if (target.active === true) {\n throw new SDKInternalError('Cannot delete the active work address')\n }\n\n await deleteWorkAddressMutation.mutateAsync({\n request: { workAddressUuid: uuid },\n })\n succeeded = true\n if (snap) {\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS_DELETED, snap)\n }\n },\n )\n return succeeded\n }\n\n const actions: UseWorkAddressManagementActions = {\n setEditTargetUuid,\n confirmDeleteWorkAddress,\n }\n\n const dataPayloadPendingForms: UseWorkAddressManagementDataPendingForms = {\n employeeDisplayName,\n employeeWorkAddresses,\n editTargetUuid,\n editWorkAddressForm,\n changeWorkAddressForm,\n }\n\n if (employeeQuery.isLoading) {\n return { isLoading: true, errorHandling }\n }\n\n if (employeeQuery.isError || isMissingCompany) {\n return {\n isLoading: false,\n data: dataPayloadPendingForms,\n status: {\n isDeletePending: deleteWorkAddressMutation.isPending,\n isEmployeeError: true,\n },\n errorHandling,\n actions,\n }\n }\n\n if (workAddressesQuery.isLoading) {\n return { isLoading: true, errorHandling }\n }\n\n const isFormsLoading = editWorkAddressForm.isLoading || changeWorkAddressForm.isLoading\n if (isFormsLoading) {\n return { isLoading: true, errorHandling }\n }\n\n const { editWorkAddressForm: editReady, changeWorkAddressForm: changeReady } =\n workAddressFormsReady(editWorkAddressForm, changeWorkAddressForm)\n\n const dataReady: UseWorkAddressManagementDataReady = {\n employeeDisplayName,\n employeeWorkAddresses,\n editTargetUuid,\n editWorkAddressForm: editReady,\n changeWorkAddressForm: changeReady,\n }\n\n return {\n isLoading: false,\n data: dataReady,\n status: {\n isDeletePending: deleteWorkAddressMutation.isPending,\n isEmployeeError: false,\n },\n errorHandling,\n actions,\n }\n}\n"],"names":["isUseWorkAddressManagementSuccess","value","workAddressFormsReady","editWorkAddressForm","changeWorkAddressForm","SDKInternalError","useWorkAddressManagement","employeeId","onEvent","baseSubmitHandler","rootSubmitError","setRootSubmitError","useBaseSubmit","deleteWorkAddressMutation","useEmployeeAddressesDeleteWorkAddressMutation","editTargetUuid","setEditTargetUuid","useState","employeeQuery","useEmployeesGet","companyId","workAddressesQuery","useEmployeeAddressesGetWorkAddresses","employeeWorkAddresses","currentWorkAddress","useMemo","w","workAddressUuidForEdit","editInactiveRow","editingWorkAddressRow","withEffectiveDateOnEdit","useWorkAddressForm","employeeDisplayName","employee","firstLastName","isMissingCompany","errorHandling","composeErrorHandler","normalizeToSDKError","actions","workAddressUuid","snapshot","succeeded","uuid","snap","target","componentEvents","dataPayloadPendingForms","editReady","changeReady"],"mappings":";;;;;;;;;;AA8EO,SAASA,GACdC,GAC+C;AAC/C,SAAIA,EAAM,YACD,KAEF,CAACA,EAAM,OAAO;AACvB;AAEA,SAASC,EACPC,GACAC,GAC0F;AAC1F,MAAID,EAAoB;AACtB,UAAM,IAAIE,EAAiB,yCAAyC;AAEtE,MAAID,EAAsB;AACxB,UAAM,IAAIC,EAAiB,2CAA2C;AAExE,SAAO;AAAA,IACL,qBAAAF;AAAA,IACA,uBAAAC;AAAA,EAAA;AAEJ;AAEO,SAASE,GAAyB;AAAA,EACvC,YAAAC;AAAA,EACA,SAAAC;AACF,GAAmE;AACjE,QAAM;AAAA,IACJ,mBAAAC;AAAA,IACA,OAAOC;AAAA,IACP,UAAUC;AAAA,EAAA,IACRC,EAAc,iCAAiC,GAC7CC,IAA4BC,EAAA,GAC5B,CAACC,GAAgBC,CAAiB,IAAIC,EAA6B,MAAS,GAE5EC,IAAgBC,EAAgB,EAAE,YAAAZ,EAAA,GAAc,EAAE,SAAS,CAAC,CAACA,GAAY,GACzEa,IAAYF,EAAc,MAAM,UAAU,aAE1CG,IAAqBC;AAAA,IACzB,EAAE,YAAAf,EAAA;AAAA,IACF,EAAE,SAAS,CAAC,CAACA,KAAc,CAAC,CAACa,EAAA;AAAA,EAAU,GAGnCG,IAAwBF,EAAmB,MAAM,2BAEjDG,IAAqBC,EAAoC,MACxDF,GAAuB,SAGrBA,EAAsB,KAAK,CAAAG,MAAKA,EAAE,MAAM,KAAKH,EAAsB,CAAC,KAAK,OAFvE,MAGR,CAACA,CAAqB,CAAC,GAEpBI,IAAyBZ,KAAkBS,GAAoB,MAE/DI,IAAkBH,EAAQ,MAAM;AACpC,QAAI,GAACV,KAAkB,CAACQ;AAGxB,aAAOA,EAAsB,KAAK,CAAAG,MAAKA,EAAE,SAASX,CAAc;AAAA,EAClE,GAAG,CAACA,GAAgBQ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AAAT;AAAA,MACA,gBAAAR;AAAA,MACA,qBAAqBiC;AAAA,MACrB,uBAAuBC;AAAA,IAAA;AAAA,IAMvB,QAAQ;AAAA,MACN,iBAAiBpC,EAA0B;AAAA,MAC3C,iBAAiB;AAAA,IAAA;AAAA,IAEnB,eAAAuB;AAAA,IACA,SAAAG;AAAA,EAAA;AAEJ;"}
@@ -19,13 +19,12 @@ import "@gusto/embedded-api/models/errors/unprocessableentityerror";
19
19
  import "@gusto/embedded-api/models/errors/httpclienterrors";
20
20
  import { formatNumberAsCurrency as L } from "../../../helpers/formattedStrings.js";
21
21
  import { useComponentContext as V } from "../../../contexts/ComponentAdapter/useComponentContext.js";
22
- import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
23
22
  import { useI18n as E } from "../../../i18n/I18n.js";
24
23
  import { NumberInputField as T } from "../../Common/Fields/NumberInputField/NumberInputField.js";
25
24
  const q = P.object({
26
25
  netPay: P.number().positive()
27
26
  });
28
- function ye({ isOpen: n, onCalculateGrossUp: w, onApply: A, onCancel: d }) {
27
+ function fe({ isOpen: n, onCalculateGrossUp: w, onApply: A, onCancel: d }) {
29
28
  E("Payroll.GrossUpModal");
30
29
  const { t: r } = k("Payroll.GrossUpModal"), { Modal: M, Heading: u, Text: p, Button: i, Alert: f } = V(), { baseSubmitHandler: y } = H(), N = R(null), [l, c] = o(null), [h, m] = o(null), [g, b] = o(!1), [x, v] = o(!1), s = U({
31
30
  resolver: z(q),
@@ -112,6 +111,6 @@ function ye({ isOpen: n, onCalculateGrossUp: w, onApply: A, onCancel: d }) {
112
111
  );
113
112
  }
114
113
  export {
115
- ye as GrossUpModal
114
+ fe as GrossUpModal
116
115
  };
117
116
  //# sourceMappingURL=GrossUpModal.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"GrossUpModal.js","sources":["../../../../src/components/Payroll/GrossUpModal/GrossUpModal.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { GrossUpModalProps } from './GrossUpModalTypes'\nimport styles from './GrossUpModal.module.scss'\nimport { ActionsLayout, Flex, NumberInputField } from '@/components/Common'\nimport { useBase } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { formatNumberAsCurrency } from '@/helpers/formattedStrings'\n\nconst GrossUpFormSchema = z.object({\n netPay: z.number().positive(),\n})\n\ntype GrossUpFormValues = z.infer<typeof GrossUpFormSchema>\n\nexport function GrossUpModal({ isOpen, onCalculateGrossUp, onApply, onCancel }: GrossUpModalProps) {\n useI18n('Payroll.GrossUpModal')\n const { t } = useTranslation('Payroll.GrossUpModal')\n const { Modal, Heading, Text, Button, Alert } = useComponentContext()\n const { baseSubmitHandler } = useBase()\n const modalContainerRef = useRef<HTMLDivElement>(null)\n\n const [calculatedGrossUp, setCalculatedGrossUp] = useState<string | null>(null)\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n const [isCalculating, setIsCalculating] = useState(false)\n const [isApplying, setIsApplying] = useState(false)\n\n const formHandlers = useForm<GrossUpFormValues>({\n resolver: zodResolver(GrossUpFormSchema),\n defaultValues: { netPay: 0 },\n })\n\n useEffect(() => {\n if (!isOpen) {\n formHandlers.reset({ netPay: 0 })\n setCalculatedGrossUp(null)\n setErrorMessage(null)\n }\n }, [isOpen, formHandlers.reset])\n\n const handleCalculate = async (data: GrossUpFormValues) => {\n setErrorMessage(null)\n setCalculatedGrossUp(null)\n setIsCalculating(true)\n\n await baseSubmitHandler(null, async () => {\n try {\n const result = await onCalculateGrossUp(data.netPay)\n\n if (result) {\n setCalculatedGrossUp(result)\n } else {\n setErrorMessage(t('errorMessage'))\n }\n } finally {\n setIsCalculating(false)\n }\n })\n }\n\n const handleApply = async () => {\n if (calculatedGrossUp) {\n setIsApplying(true)\n await baseSubmitHandler(null, async () => {\n try {\n await onApply(calculatedGrossUp)\n } finally {\n setIsApplying(false)\n }\n })\n }\n }\n\n return (\n <Modal\n isOpen={isOpen}\n onClose={onCancel}\n containerRef={modalContainerRef}\n footer={\n <ActionsLayout>\n <Button\n variant=\"primary\"\n isDisabled={!calculatedGrossUp}\n onClick={handleApply}\n isLoading={isApplying}\n >\n {t('applyCta')}\n </Button>\n <Button variant=\"secondary\" onClick={onCancel}>\n {t('cancelCta')}\n </Button>\n </ActionsLayout>\n }\n >\n <FormProvider {...formHandlers}>\n <div className={styles.header}>\n <Heading as=\"h2\" styledAs=\"h3\">\n {t('title')}\n </Heading>\n <Text variant=\"supporting\" as=\"p\">\n {t('description')}\n </Text>\n </div>\n\n <div className={styles.content}>\n {errorMessage && (\n <div className={styles.alert}>\n <Alert label={errorMessage} status=\"error\" disableScrollIntoView />\n </div>\n )}\n\n <div className={styles.alert}>\n <Alert label={t('warning')} status=\"warning\" disableScrollIntoView />\n </div>\n\n <Flex flexDirection=\"row\" gap={8}>\n <NumberInputField\n name=\"netPay\"\n label={t('netPayLabel')}\n format=\"currency\"\n errorMessage={t('validations.netPay')}\n min={0}\n isRequired\n />\n <Button\n variant=\"secondary\"\n className={styles.calculateButton}\n isDisabled={isCalculating}\n onClick={formHandlers.handleSubmit(handleCalculate)}\n >\n {isCalculating ? t('calculatingCta') : t('calculateCta')}\n </Button>\n </Flex>\n\n {calculatedGrossUp && (\n <>\n <div className={styles.result}>\n <Text size=\"sm\" variant=\"supporting\" weight=\"semibold\">\n {t('grossPayResult')}\n </Text>\n <Heading as=\"h3\">{formatNumberAsCurrency(parseFloat(calculatedGrossUp))}</Heading>\n </div>\n </>\n )}\n </div>\n </FormProvider>\n </Modal>\n )\n}\n"],"names":["GrossUpFormSchema","z","GrossUpModal","isOpen","onCalculateGrossUp","onApply","onCancel","useI18n","t","useTranslation","Modal","Heading","Text","Button","Alert","useComponentContext","baseSubmitHandler","useBase","modalContainerRef","useRef","calculatedGrossUp","setCalculatedGrossUp","useState","errorMessage","setErrorMessage","isCalculating","setIsCalculating","isApplying","setIsApplying","formHandlers","useForm","zodResolver","useEffect","handleCalculate","data","result","jsx","ActionsLayout","jsxs","FormProvider","styles","Flex","NumberInputField","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAMA,IAAoBC,EAAE,OAAO;AAAA,EACjC,QAAQA,EAAE,OAAA,EAAS,SAAA;AACrB,CAAC;AAIM,SAASC,GAAa,EAAE,QAAAC,GAAQ,oBAAAC,GAAoB,SAAAC,GAAS,UAAAC,KAA+B;AACjG,EAAAC,EAAQ,sBAAsB;AAC9B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,sBAAsB,GAC7C,EAAE,OAAAC,GAAO,SAAAC,GAAS,MAAAC,GAAM,QAAAC,GAAQ,OAAAC,EAAA,IAAUC,EAAA,GAC1C,EAAE,mBAAAC,EAAA,IAAsBC,EAAA,GACxBC,IAAoBC,EAAuB,IAAI,GAE/C,CAACC,GAAmBC,CAAoB,IAAIC,EAAwB,IAAI,GACxE,CAACC,GAAcC,CAAe,IAAIF,EAAwB,IAAI,GAC9D,CAACG,GAAeC,CAAgB,IAAIJ,EAAS,EAAK,GAClD,CAACK,GAAYC,CAAa,IAAIN,EAAS,EAAK,GAE5CO,IAAeC,EAA2B;AAAA,IAC9C,UAAUC,EAAY/B,CAAiB;AAAA,IACvC,eAAe,EAAE,QAAQ,EAAA;AAAA,EAAE,CAC5B;AAED,EAAAgC,EAAU,MAAM;AACd,IAAK7B,MACH0B,EAAa,MAAM,EAAE,QAAQ,EAAA,CAAG,GAChCR,EAAqB,IAAI,GACzBG,EAAgB,IAAI;AAAA,EAExB,GAAG,CAACrB,GAAQ0B,EAAa,KAAK,CAAC;AAE/B,QAAMI,IAAkB,OAAOC,MAA4B;AACzD,IAAAV,EAAgB,IAAI,GACpBH,EAAqB,IAAI,GACzBK,EAAiB,EAAI,GAErB,MAAMV,EAAkB,MAAM,YAAY;AACxC,UAAI;AACF,cAAMm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ossUpModal.js","sources":["../../../../src/components/Payroll/GrossUpModal/GrossUpModal.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { GrossUpModalProps } from './GrossUpModalTypes'\nimport styles from './GrossUpModal.module.scss'\nimport { ActionsLayout, Flex, NumberInputField } from '@/components/Common'\nimport { useBase } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { formatNumberAsCurrency } from '@/helpers/formattedStrings'\n\nconst GrossUpFormSchema = z.object({\n netPay: z.number().positive(),\n})\n\ntype GrossUpFormValues = z.infer<typeof GrossUpFormSchema>\n\nexport function GrossUpModal({ isOpen, onCalculateGrossUp, onApply, onCancel }: GrossUpModalProps) {\n useI18n('Payroll.GrossUpModal')\n const { t } = useTranslation('Payroll.GrossUpModal')\n const { Modal, Heading, Text, Button, Alert } = useComponentContext()\n const { baseSubmitHandler } = useBase()\n const modalContainerRef = useRef<HTMLDivElement>(null)\n\n const [calculatedGrossUp, setCalculatedGrossUp] = useState<string | null>(null)\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n const [isCalculating, setIsCalculating] = useState(false)\n const [isApplying, setIsApplying] = useState(false)\n\n const formHandlers = useForm<GrossUpFormValues>({\n resolver: zodResolver(GrossUpFormSchema),\n defaultValues: { netPay: 0 },\n })\n\n useEffect(() => {\n if (!isOpen) {\n formHandlers.reset({ netPay: 0 })\n setCalculatedGrossUp(null)\n setErrorMessage(null)\n }\n }, [isOpen, formHandlers.reset])\n\n const handleCalculate = async (data: GrossUpFormValues) => {\n setErrorMessage(null)\n setCalculatedGrossUp(null)\n setIsCalculating(true)\n\n await baseSubmitHandler(null, async () => {\n try {\n const result = await onCalculateGrossUp(data.netPay)\n\n if (result) {\n setCalculatedGrossUp(result)\n } else {\n setErrorMessage(t('errorMessage'))\n }\n } finally {\n setIsCalculating(false)\n }\n })\n }\n\n const handleApply = async () => {\n if (calculatedGrossUp) {\n setIsApplying(true)\n await baseSubmitHandler(null, async () => {\n try {\n await onApply(calculatedGrossUp)\n } finally {\n setIsApplying(false)\n }\n })\n }\n }\n\n return (\n <Modal\n isOpen={isOpen}\n onClose={onCancel}\n containerRef={modalContainerRef}\n footer={\n <ActionsLayout>\n <Button\n variant=\"primary\"\n isDisabled={!calculatedGrossUp}\n onClick={handleApply}\n isLoading={isApplying}\n >\n {t('applyCta')}\n </Button>\n <Button variant=\"secondary\" onClick={onCancel}>\n {t('cancelCta')}\n </Button>\n </ActionsLayout>\n }\n >\n <FormProvider {...formHandlers}>\n <div className={styles.header}>\n <Heading as=\"h2\" styledAs=\"h3\">\n {t('title')}\n </Heading>\n <Text variant=\"supporting\" as=\"p\">\n {t('description')}\n </Text>\n </div>\n\n <div className={styles.content}>\n {errorMessage && (\n <div className={styles.alert}>\n <Alert label={errorMessage} status=\"error\" disableScrollIntoView />\n </div>\n )}\n\n <div className={styles.alert}>\n <Alert label={t('warning')} status=\"warning\" disableScrollIntoView />\n </div>\n\n <Flex flexDirection=\"row\" gap={8}>\n <NumberInputField\n name=\"netPay\"\n label={t('netPayLabel')}\n format=\"currency\"\n errorMessage={t('validations.netPay')}\n min={0}\n isRequired\n />\n <Button\n variant=\"secondary\"\n className={styles.calculateButton}\n isDisabled={isCalculating}\n onClick={formHandlers.handleSubmit(handleCalculate)}\n >\n {isCalculating ? t('calculatingCta') : t('calculateCta')}\n </Button>\n </Flex>\n\n {calculatedGrossUp && (\n <>\n <div className={styles.result}>\n <Text size=\"sm\" variant=\"supporting\" weight=\"semibold\">\n {t('grossPayResult')}\n </Text>\n <Heading as=\"h3\">{formatNumberAsCurrency(parseFloat(calculatedGrossUp))}</Heading>\n </div>\n </>\n )}\n </div>\n </FormProvider>\n </Modal>\n )\n}\n"],"names":["GrossUpFormSchema","z","GrossUpModal","isOpen","onCalculateGrossUp","onApply","onCancel","useI18n","t","useTranslation","Modal","Heading","Text","Button","Alert","useComponentContext","baseSubmitHandler","useBase","modalContainerRef","useRef","calculatedGrossUp","setCalculatedGrossUp","useState","errorMessage","setErrorMessage","isCalculating","setIsCalculating","isApplying","setIsApplying","formHandlers","useForm","zodResolver","useEffect","handleCalculate","data","result","jsx","ActionsLayout","jsxs","FormProvider","styles","Flex","NumberInputField","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAMA,IAAoBC,EAAE,OAAO;AAAA,EACjC,QAAQA,EAAE,OAAA,EAAS,SAAA;AACrB,CAAC;AAIM,SAASC,GAAa,EAAE,QAAAC,GAAQ,oBAAAC,GAAoB,SAAAC,GAAS,UAAAC,KAA+B;AACjG,EAAAC,EAAQ,sBAAsB;AAC9B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,sBAAsB,GAC7C,EAAE,OAAAC,GAAO,SAAAC,GAAS,MAAAC,GAAM,QAAAC,GAAQ,OAAAC,EAAA,IAAUC,EAAA,GAC1C,EAAE,mBAAAC,EAAA,IAAsBC,EAAA,GACxBC,IAAoBC,EAAuB,IAAI,GAE/C,CAACC,GAAmBC,CAAoB,IAAIC,EAAwB,IAAI,GACxE,CAACC,GAAcC,CAAe,IAAIF,EAAwB,IAAI,GAC9D,CAACG,GAAeC,CAAgB,IAAIJ,EAAS,EAAK,GAClD,CAACK,GAAYC,CAAa,IAAIN,EAAS,EAAK,GAE5CO,IAAeC,EAA2B;AAAA,IAC9C,UAAUC,EAAY/B,CAAiB;AAAA,IACvC,eAAe,EAAE,QAAQ,EAAA;AAAA,EAAE,CAC5B;AAED,EAAAgC,EAAU,MAAM;AACd,IAAK7B,MACH0B,EAAa,MAAM,EAAE,QAAQ,EAAA,CAAG,GAChCR,EAAqB,IAAI,GACzBG,EAAgB,IAAI;AAAA,EAExB,GAAG,CAACrB,GAAQ0B,EAAa,KAAK,CAAC;AAE/B,QAAMI,IAAkB,OAAOC,MAA4B;AAC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,CAC1E,EAAA,CACF;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -16,9 +16,8 @@ import "../../contexts/LocaleProvider/useLocale.js";
16
16
  import "../../shared/constants.js";
17
17
  import "classnames";
18
18
  import "../../contexts/ComponentAdapter/useComponentContext.js";
19
- import "../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
20
19
  import { retryAsync as x } from "../../helpers/retryAsync.js";
21
- const q = 4, v = 1500, B = (e) => e instanceof T ? e.errors.some((r) => r.category === "invalid_operation") : !1, ee = ({
20
+ const q = 4, v = 1500, B = (e) => e instanceof T ? e.errors.some((r) => r.category === "invalid_operation") : !1, $ = ({
22
21
  companyId: e,
23
22
  payrollId: r,
24
23
  employeeUuids: a,
@@ -69,6 +68,6 @@ const q = 4, v = 1500, B = (e) => e instanceof T ? e.errors.some((r) => r.catego
69
68
  };
70
69
  };
71
70
  export {
72
- ee as usePreparedPayrollData
71
+ $ as usePreparedPayrollData
73
72
  };
74
73
  //# sourceMappingURL=usePreparedPayrollData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePreparedPayrollData.js","sources":["../../../src/components/Payroll/usePreparedPayrollData.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from 'react'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/payroll'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport type { QueryParamSortBy } from '@gusto/embedded-api/models/operations/putv1companiescompanyidpayrollspayrollidprepare'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport { useBase } from '../Base'\nimport { retryAsync } from '@/helpers/retryAsync'\n\ninterface UsePreparedPayrollDataParams {\n companyId: string\n payrollId: string\n employeeUuids?: string[]\n sortBy?: QueryParamSortBy\n onDataReady?: (preparedPayroll: PayrollPrepared) => void\n}\n\ninterface UsePreparedPayrollDataReturn {\n handlePreparePayroll: () => Promise<void>\n preparedPayroll: PayrollPrepared | undefined\n paySchedule: PayScheduleShow | undefined\n isLoading: boolean\n isPaginating: boolean\n hasInitialData: boolean\n}\n\nconst PREPARE_MAX_ATTEMPTS = 4\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst isPayrollBeingProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\nexport const usePreparedPayrollData = ({\n companyId,\n payrollId,\n employeeUuids,\n sortBy,\n onDataReady,\n}: UsePreparedPayrollDataParams): UsePreparedPayrollDataReturn => {\n const { mutateAsync: preparePayroll, isPending: isPreparePayrollPending } =\n usePayrollsPrepareMutation()\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const hasInitialDataRef = useRef(false)\n const hasFiredRef = useRef(false)\n const { baseSubmitHandler } = useBase()\n\n const employeeUuidsKey = useMemo(() => employeeUuids?.join(',') ?? '', [employeeUuids])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid,\n },\n )\n\n const executePrepare = useCallback(async () => {\n const result = await preparePayroll({\n request: {\n companyId,\n payrollId,\n sortBy,\n requestBody: {\n employeeUuids,\n },\n },\n })\n setPreparedPayroll(result.payrollPrepared)\n if (result.payrollPrepared) {\n hasInitialDataRef.current = true\n onDataReady?.(result.payrollPrepared)\n }\n }, [companyId, payrollId, preparePayroll, employeeUuidsKey, sortBy, onDataReady])\n\n const handlePreparePayroll = useCallback(async () => {\n await baseSubmitHandler(null, () =>\n retryAsync(executePrepare, {\n maxAttempts: PREPARE_MAX_ATTEMPTS,\n delayMs: PREPARE_RETRY_DELAY_MS,\n shouldRetry: isPayrollBeingProcessedError,\n }),\n )\n }, [baseSubmitHandler, executePrepare])\n\n useEffect(() => {\n if (hasFiredRef.current) return\n hasFiredRef.current = true\n void handlePreparePayroll()\n }, [handlePreparePayroll])\n\n const isInitialLoading = isPreparePayrollPending && !hasInitialDataRef.current\n const isPaginating = isPreparePayrollPending && hasInitialDataRef.current\n const isLoading = isInitialLoading || isPayScheduleLoading\n\n return {\n handlePreparePayroll,\n preparedPayroll,\n paySchedule: payScheduleData?.payScheduleShow,\n isLoading,\n isPaginating,\n hasInitialData: hasInitialDataRef.current,\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityError","e","usePreparedPayrollData","companyId","payrollId","employeeUuids","sortBy","onDataReady","preparePayroll","isPreparePayrollPending","usePayrollsPrepareMutation","preparedPayroll","setPreparedPayroll","useState","hasInitialDataRef","useRef","hasFiredRef","baseSubmitHandler","useBase","employeeUuidsKey","useMemo","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","executePrepare","useCallback","result","handlePreparePayroll","retryAsync","useEffect","isInitialLoading","isPaginating","isLoading"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2BA,MAAMA,IAAuB,GACvBC,IAAyB,MAEzBC,IAA+B,CAACC,MAC9BA,aAAiBC,IAChBD,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADP,IAI9CC,KAAyB,CAAC;AAAA,EACrC,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC;AACF,MAAkE;AAChE,QAAM,EAAE,aAAaC,GAAgB,WAAWC,EAAA,IAC9CC,EAAA,GACI,CAACC,GAAiBC,CAAkB,IAAIC,EAAA,GACxCC,IAAoBC,EAAO,EAAK,GAChCC,IAAcD,EAAO,EAAK,GAC1B,EAAE,mBAAAE,EAAA,I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AAAA,IACA,gBAAgBjB,EAAkB;AAAA,EAAA;AAEtC;"}
1
+ {"version":3,"file":"usePreparedPayrollData.js","sources":["../../../src/components/Payroll/usePreparedPayrollData.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from 'react'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/payroll'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport type { QueryParamSortBy } from '@gusto/embedded-api/models/operations/putv1companiescompanyidpayrollspayrollidprepare'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport { useBase } from '../Base'\nimport { retryAsync } from '@/helpers/retryAsync'\n\ninterface UsePreparedPayrollDataParams {\n companyId: string\n payrollId: string\n employeeUuids?: string[]\n sortBy?: QueryParamSortBy\n onDataReady?: (preparedPayroll: PayrollPrepared) => void\n}\n\ninterface UsePreparedPayrollDataReturn {\n handlePreparePayroll: () => Promise<void>\n preparedPayroll: PayrollPrepared | undefined\n paySchedule: PayScheduleShow | undefined\n isLoading: boolean\n isPaginating: boolean\n hasInitialData: boolean\n}\n\nconst PREPARE_MAX_ATTEMPTS = 4\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst isPayrollBeingProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\nexport const usePreparedPayrollData = ({\n companyId,\n payrollId,\n employeeUuids,\n sortBy,\n onDataReady,\n}: UsePreparedPayrollDataParams): UsePreparedPayrollDataReturn => {\n const { mutateAsync: preparePayroll, isPending: isPreparePayrollPending } =\n usePayrollsPrepareMutation()\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const hasInitialDataRef = useRef(false)\n const hasFiredRef = useRef(false)\n const { baseSubmitHandler } = useBase()\n\n const employeeUuidsKey = useMemo(() => employeeUuids?.join(',') ?? '', [employeeUuids])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid,\n },\n )\n\n const executePrepare = useCallback(async () => {\n const result = await preparePayroll({\n request: {\n companyId,\n payrollId,\n sortBy,\n requestBody: {\n employeeUuids,\n },\n },\n })\n setPreparedPayroll(result.payrollPrepared)\n if (result.payrollPrepared) {\n hasInitialDataRef.current = true\n onDataReady?.(result.payrollPrepared)\n }\n }, [companyId, payrollId, preparePayroll, employeeUuidsKey, sortBy, onDataReady])\n\n const handlePreparePayroll = useCallback(async () => {\n await baseSubmitHandler(null, () =>\n retryAsync(executePrepare, {\n maxAttempts: PREPARE_MAX_ATTEMPTS,\n delayMs: PREPARE_RETRY_DELAY_MS,\n shouldRetry: isPayrollBeingProcessedError,\n }),\n )\n }, [baseSubmitHandler, executePrepare])\n\n useEffect(() => {\n if (hasFiredRef.current) return\n hasFiredRef.current = true\n void handlePreparePayroll()\n }, [handlePreparePayroll])\n\n const isInitialLoading = isPreparePayrollPending && !hasInitialDataRef.current\n const isPaginating = isPreparePayrollPending && hasInitialDataRef.current\n const isLoading = isInitialLoading || isPayScheduleLoading\n\n return {\n handlePreparePayroll,\n preparedPayroll,\n paySchedule: payScheduleData?.payScheduleShow,\n isLoading,\n isPaginating,\n hasInitialData: hasInitialDataRef.current,\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityError","e","usePreparedPayrollData","companyId","payrollId","employeeUuids","sortBy","onDataReady","preparePayroll","isPreparePayrollPending","usePayrollsPrepareMutation","preparedPayroll","setPreparedPayroll","useState","hasInitialDataRef","useRef","hasFiredRef","baseSubmitHandler","useBase","employeeUuidsKey","useMemo","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","executePrepare","useCallback","result","handlePreparePayroll","retryAsync","useEffect","isInitialLoading","isPaginating","isLoading"],"mappings":";;;;;;;;;;;;;;;;;;;AA2BA,MAAMA,IAAuB,GACvBC,IAAyB,MAEzBC,IAA+B,CAACC,MAC9BA,aAAiBC,IAChBD,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADP,IAI9CC,IAAyB,CAAC;AAAA,EACrC,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC;AACF,MAAkE;AAChE,QAAM,EAAE,aAAaC,GAAgB,WAAWC,EAAA,IAC9CC,EAAA,GACI,CAACC,GAAiBC,CAAkB,IAAIC,EAAA,GACxCC,IAAoBC,EAAO,EAAK,GAChCC,IAAcD,EAAO,EAAK,GAC1B,EAAE,mBAAAE,EAAA,IAAsBC,EAAA,GAExBC,IAAmBC,EAAQ,MAAMf,GAAe,KAAK,GAAG,KAAK,IAAI,CAACA,CAAa,CAAC,GAEhF,EAAE,MAAMgB,GAAiB,WAAWC,MAAyBC;AAAA,IACjE;AAAA,MACE,WAAApB;AAAA,MACA,eAAeQ,GAAiB,WAAW,mBAAmB;AAAA,IAAA;AAAA,IAEhE;AAAA,MACE,SAAS,CAAC,CAACA,GAAiB,WAAW;AAAA,IAAA;AAAA,EACzC,GAGIa,IAAiBC,EAAY,YAAY;AAC7C,UAAMC,IAAS,MAAMlB,EAAe;AAAA,MAClC,SAAS;AAAA,QACP,WAAAL;AAAA,QACA,WAAAC;AAAA,QACA,QAAAE;AAAA,QACA,aAAa;AAAA,UACX,eAAAD;AAAA,QAAA;AAAA,MACF;AAAA,IACF,CACD;AACD,IAAAO,EAAmBc,EAAO,eAAe,GACrCA,EAAO,oBACTZ,EAAkB,UAAU,IAC5BP,IAAcmB,EAAO,eAAe;AAAA,EAExC,GAAG,CAACvB,GAAWC,GAAWI,GAAgBW,GAAkBb,GAAQC,CAAW,CAAC,GAE1EoB,IAAuBF,EAAY,YAAY;AACnD,UAAMR;AAAA,MAAkB;AAAA,MAAM,MAC5BW,EAAWJ,GAAgB;AAAA,QACzB,aAAa5B;AAAA,QACb,SAASC;AAAA,QACT,aAAaC;AAAA,MAAA,CACd;AAAA,IAAA;AAAA,EAEL,GAAG,CAACmB,GAAmBO,CAAc,CAAC;AAEtC,EAAAK,EAAU,MAAM;AACd,IAAIb,EAAY,YAChBA,EAAY,UAAU,IACjBW,EAAA;AAAA,EACP,GAAG,CAACA,CAAoB,CAAC;AAEzB,QAAMG,IAAmBrB,KAA2B,CAACK,EAAkB,SACjEiB,IAAetB,KAA2BK,EAAkB,SAC5DkB,IAAYF,KAAoBR;AAEtC,SAAO;AAAA,IACL,sBAAAK;AAAA,IACA,iBAAAhB;AAAA,IACA,aAAaU,GAAiB;AAAA,IAC9B,WAAAW;AAAA,IACA,cAAAD;AAAA,IACA,gBAAgBjB,EAAkB;AAAA,EAAA;AAEtC;"}
@@ -7,7 +7,7 @@ import { SelectEmployeesPresentation as v } from "./SelectEmployeesPresentation.
7
7
  import { useSelectEmployeesData as I } from "./useSelectEmployeesData.js";
8
8
  import { useBase as q } from "../../../Base/useBase.js";
9
9
  import { componentEvents as l } from "../../../../shared/constants.js";
10
- function K(e) {
10
+ function R(e) {
11
11
  return e.mode === "wizard" ? /* @__PURE__ */ r(E, { ...e, mode: "wizard" }) : /* @__PURE__ */ r(x, { ...e });
12
12
  }
13
13
  function x(e) {
@@ -46,8 +46,8 @@ function E({
46
46
  handleSelect: A,
47
47
  handleSelectAll: _,
48
48
  handleSearchChange: D,
49
- handleSearchClear: g
50
- } = I(e, n), { mutateAsync: m, isPending: O } = M(), C = p(async () => {
49
+ handleSearchClear: O
50
+ } = I(e, n), { mutateAsync: m, isPending: g } = M(), C = p(async () => {
51
51
  const y = [...d];
52
52
  if (t === "wizard") {
53
53
  o(l.TIME_OFF_HOLIDAY_ADD_EMPLOYEES_DONE, {
@@ -95,18 +95,17 @@ function E({
95
95
  onSelect: A,
96
96
  onSelectAll: _,
97
97
  onSearchChange: D,
98
- onSearchClear: g,
98
+ onSearchClear: O,
99
99
  onBack: H,
100
100
  onContinue: C,
101
- showReassignmentWarning: !1,
102
101
  isHolidayPolicy: !0,
103
102
  pagination: h,
104
103
  isFetching: S,
105
- isPending: O
104
+ isPending: g
106
105
  }
107
106
  );
108
107
  }
109
108
  export {
110
- K as SelectEmployeesHoliday
109
+ R as SelectEmployeesHoliday
111
110
  };
112
111
  //# sourceMappingURL=SelectEmployeesHoliday.js.map