@gusto/embedded-react-sdk 0.45.0 → 0.46.2

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 (233) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/dist/components/Common/DataView/DataCards/DataCards.d.ts +2 -1
  3. package/dist/components/Common/DataView/DataCards/DataCards.js +14 -13
  4. package/dist/components/Common/DataView/DataCards/DataCards.js.map +1 -1
  5. package/dist/components/Common/DataView/DataTable/DataTable.d.ts +2 -1
  6. package/dist/components/Common/DataView/DataTable/DataTable.js +51 -50
  7. package/dist/components/Common/DataView/DataTable/DataTable.js.map +1 -1
  8. package/dist/components/Common/DataView/DataView.d.ts +1 -0
  9. package/dist/components/Common/DataView/DataView.js.map +1 -1
  10. package/dist/components/Common/DataView/useDataView.d.ts +8 -1
  11. package/dist/components/Common/DataView/useDataView.js +20 -17
  12. package/dist/components/Common/DataView/useDataView.js.map +1 -1
  13. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +20 -4
  14. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  15. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +20 -4
  16. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  17. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +22 -6
  18. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  19. package/dist/components/Company/BankAccount/BankAccountForm/context.js +20 -4
  20. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  21. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +20 -4
  22. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  23. package/dist/components/Company/DocumentSigner/shared/useSignCompanyForm/fields.js +4 -4
  24. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +28 -12
  25. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  26. package/dist/components/Company/Industry/Context.js +23 -7
  27. package/dist/components/Company/Industry/Context.js.map +1 -1
  28. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +20 -4
  29. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  30. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +20 -4
  31. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  32. package/dist/components/Company/OnboardingOverview/context.js +20 -4
  33. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  34. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js +5 -5
  35. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +20 -4
  36. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  37. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +20 -4
  38. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  39. package/dist/components/Contractor/Address/useAddress.js +22 -6
  40. package/dist/components/Contractor/Address/useAddress.js.map +1 -1
  41. package/dist/components/Contractor/Profile/useContractorProfile.js +52 -42
  42. package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
  43. package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.d.ts +9 -0
  44. package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.js +76 -0
  45. package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.js.map +1 -0
  46. package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.module.scss.js +8 -0
  47. package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.module.scss.js.map +1 -0
  48. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.d.ts +11 -0
  49. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js +85 -0
  50. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js.map +1 -0
  51. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.module.scss.js +8 -0
  52. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.module.scss.js.map +1 -0
  53. package/dist/components/Employee/Compensation/management/EditCompensation/index.d.ts +3 -0
  54. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.d.ts +25 -0
  55. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js +81 -0
  56. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js.map +1 -0
  57. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.module.scss.js +8 -0
  58. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.module.scss.js.map +1 -0
  59. package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.d.ts +18 -0
  60. package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js +171 -0
  61. package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js.map +1 -0
  62. package/dist/components/Employee/Compensation/management/index.d.ts +6 -0
  63. package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.d.ts +6 -1
  64. package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js +67 -209
  65. package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js.map +1 -1
  66. package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.d.ts +18 -0
  67. package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.js +169 -0
  68. package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.js.map +1 -0
  69. package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.d.ts +16 -0
  70. package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.js +36 -30
  71. package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.js.map +1 -1
  72. package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.d.ts +1 -1
  73. package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js +4 -4
  74. package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js.map +1 -1
  75. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +212 -187
  76. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
  77. package/dist/components/Employee/Compensation/shared/useJobForm/fields.js +6 -6
  78. package/dist/components/Employee/Compensation/shared/useJobForm/jobSchema.d.ts +8 -0
  79. package/dist/components/Employee/Compensation/shared/useJobForm/jobSchema.js +22 -17
  80. package/dist/components/Employee/Compensation/shared/useJobForm/jobSchema.js.map +1 -1
  81. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.d.ts +12 -2
  82. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +115 -110
  83. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
  84. package/dist/components/Employee/Dashboard/BasicDetailsView.d.ts +8 -3
  85. package/dist/components/Employee/Dashboard/BasicDetailsView.js +108 -84
  86. package/dist/components/Employee/Dashboard/BasicDetailsView.js.map +1 -1
  87. package/dist/components/Employee/Dashboard/Dashboard.d.ts +2 -0
  88. package/dist/components/Employee/Dashboard/Dashboard.js +86 -68
  89. package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
  90. package/dist/components/Employee/Dashboard/DashboardComponents.d.ts +8 -4
  91. package/dist/components/Employee/Dashboard/DashboardComponents.js +147 -93
  92. package/dist/components/Employee/Dashboard/DashboardComponents.js.map +1 -1
  93. package/dist/components/Employee/Dashboard/DocumentsView.js +18 -11
  94. package/dist/components/Employee/Dashboard/DocumentsView.js.map +1 -1
  95. package/dist/components/Employee/Dashboard/JobAndPayView.js +304 -264
  96. package/dist/components/Employee/Dashboard/JobAndPayView.js.map +1 -1
  97. package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js +10 -0
  98. package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js.map +1 -0
  99. package/dist/components/Employee/Dashboard/TaxesView.d.ts +7 -2
  100. package/dist/components/Employee/Dashboard/TaxesView.js +68 -54
  101. package/dist/components/Employee/Dashboard/TaxesView.js.map +1 -1
  102. package/dist/components/Employee/Dashboard/dashboardStateMachine.js +152 -142
  103. package/dist/components/Employee/Dashboard/dashboardStateMachine.js.map +1 -1
  104. package/dist/components/Employee/Dashboard/getPendingCompensationChanges.d.ts +6 -0
  105. package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js +13 -12
  106. package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js.map +1 -1
  107. package/dist/components/Employee/Dashboard/hooks/useEmployeeBasicDetails.d.ts +12 -5
  108. package/dist/components/Employee/Dashboard/hooks/useEmployeeBasicDetails.js +21 -21
  109. package/dist/components/Employee/Dashboard/hooks/useEmployeeBasicDetails.js.map +1 -1
  110. package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.d.ts +13 -3
  111. package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js +53 -55
  112. package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js.map +1 -1
  113. package/dist/components/Employee/Dashboard/hooks/useEmployeeForms.d.ts +10 -4
  114. package/dist/components/Employee/Dashboard/hooks/useEmployeeForms.js +10 -12
  115. package/dist/components/Employee/Dashboard/hooks/useEmployeeForms.js.map +1 -1
  116. package/dist/components/Employee/Dashboard/hooks/useEmployeeTaxes.d.ts +10 -3
  117. package/dist/components/Employee/Dashboard/hooks/useEmployeeTaxes.js +19 -14
  118. package/dist/components/Employee/Dashboard/hooks/useEmployeeTaxes.js.map +1 -1
  119. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/fields.js +8 -8
  120. package/dist/components/Employee/Deductions/shared/useDeductionForm/fields.js +4 -4
  121. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +20 -4
  122. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  123. package/dist/components/Employee/Documents/shared/useSignEmployeeForm/fields.js +1 -1
  124. package/dist/components/Employee/EmployeeList/management/ManagementEmployeeList.js +37 -40
  125. package/dist/components/Employee/EmployeeList/management/ManagementEmployeeList.js.map +1 -1
  126. package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.d.ts +1 -2
  127. package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.js +64 -71
  128. package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.js.map +1 -1
  129. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.d.ts +2 -0
  130. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js +25 -0
  131. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js.map +1 -0
  132. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.d.ts +13 -0
  133. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.js +37 -0
  134. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.js.map +1 -0
  135. package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.d.ts +6 -0
  136. package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js +69 -0
  137. package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js.map +1 -0
  138. package/dist/components/Employee/EmployeeListFlow/index.d.ts +3 -0
  139. package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/fields.js +4 -4
  140. package/dist/components/Employee/HomeAddress/management/HomeAddress.js +15 -12
  141. package/dist/components/Employee/HomeAddress/management/HomeAddress.js.map +1 -1
  142. package/dist/components/Employee/HomeAddress/management/HomeAddressView.d.ts +2 -1
  143. package/dist/components/Employee/HomeAddress/management/HomeAddressView.js +86 -83
  144. package/dist/components/Employee/HomeAddress/management/HomeAddressView.js.map +1 -1
  145. package/dist/components/Employee/PaymentMethod/shared/useBankForm/fields.js +1 -1
  146. package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js +4 -4
  147. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/fields.js +8 -8
  148. package/dist/components/Employee/Profile/shared/useHomeAddressForm/fields.js +5 -5
  149. package/dist/components/Employee/Profile/shared/useWorkAddressForm/fields.js +4 -4
  150. package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +8 -8
  151. package/dist/components/Employee/Taxes/useTaxes.js +20 -4
  152. package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
  153. package/dist/components/Employee/WorkAddress/management/WorkAddress.js +14 -11
  154. package/dist/components/Employee/WorkAddress/management/WorkAddress.js.map +1 -1
  155. package/dist/components/Employee/WorkAddress/management/WorkAddressView.d.ts +2 -1
  156. package/dist/components/Employee/WorkAddress/management/WorkAddressView.js +92 -89
  157. package/dist/components/Employee/WorkAddress/management/WorkAddressView.js.map +1 -1
  158. package/dist/components/Employee/exports/employeeManagement.d.ts +2 -0
  159. package/dist/components/Employee/exports/employeeManagement.js +18 -16
  160. package/dist/components/Employee/exports/employeeManagement.js.map +1 -1
  161. package/dist/components/Employee/index.d.ts +2 -0
  162. package/dist/components/Employee/index.js +32 -30
  163. package/dist/components/Employee/index.js.map +1 -1
  164. package/dist/components/Flow/FlowHeader.js +34 -31
  165. package/dist/components/Flow/FlowHeader.js.map +1 -1
  166. package/dist/components/Flow/useFlow.d.ts +12 -0
  167. package/dist/components/Flow/useFlow.js.map +1 -1
  168. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +34 -26
  169. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
  170. package/dist/components/Payroll/usePreparedPayrollData.js +36 -22
  171. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  172. package/dist/components/TimeOff/PolicyList/PolicyList.js +92 -69
  173. package/dist/components/TimeOff/PolicyList/PolicyList.js.map +1 -1
  174. package/dist/components/TimeOff/PolicyList/PolicyListPresentation.js +23 -23
  175. package/dist/components/TimeOff/PolicyList/PolicyListPresentation.js.map +1 -1
  176. package/dist/components/TimeOff/PolicySettings/PolicySettingsPresentation.js +52 -40
  177. package/dist/components/TimeOff/PolicySettings/PolicySettingsPresentation.js.map +1 -1
  178. package/dist/components/TimeOff/TimeOffFlow/TimeOffFlowComponents.d.ts +1 -1
  179. package/dist/components/TimeOff/TimeOffFlow/TimeOffFlowComponents.js.map +1 -1
  180. package/dist/components/TimeOff/TimeOffFlow/timeOffStateMachine.js +73 -56
  181. package/dist/components/TimeOff/TimeOffFlow/timeOffStateMachine.js.map +1 -1
  182. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationForm.js +58 -58
  183. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationForm.js.map +1 -1
  184. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.d.ts +1 -1
  185. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.js +91 -87
  186. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.js.map +1 -1
  187. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormTypes.d.ts +2 -0
  188. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js +91 -124
  189. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js.map +1 -1
  190. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.d.ts +1 -1
  191. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js +72 -87
  192. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js.map +1 -1
  193. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentationTypes.d.ts +1 -6
  194. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js +160 -220
  195. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js.map +1 -1
  196. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.d.ts +7 -3
  197. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js +77 -54
  198. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js.map +1 -1
  199. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.test.d.ts +1 -0
  200. package/dist/components/TimeOff/TimeOffPolicyDetail/EditEmployeeBalanceModal.js +12 -11
  201. package/dist/components/TimeOff/TimeOffPolicyDetail/EditEmployeeBalanceModal.js.map +1 -1
  202. package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetail.js +177 -147
  203. package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetail.js.map +1 -1
  204. package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.d.ts +1 -1
  205. package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js +38 -36
  206. package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js.map +1 -1
  207. package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTableTypes.d.ts +2 -0
  208. package/dist/i18n/en/Company.TimeOff.SelectEmployees.json.js +10 -10
  209. package/dist/i18n/en/Company.TimeOff.TimeOffPolicies.json.js +17 -15
  210. package/dist/i18n/en/Company.TimeOff.TimeOffPolicies.json.js.map +1 -1
  211. package/dist/i18n/en/Company.TimeOff.TimeOffPolicyDetails.json.js +9 -9
  212. package/dist/i18n/en/Employee.Compensation.json.js +68 -56
  213. package/dist/i18n/en/Employee.Compensation.json.js.map +1 -1
  214. package/dist/i18n/en/Employee.Dashboard.json.js +26 -24
  215. package/dist/i18n/en/Employee.Dashboard.json.js.map +1 -1
  216. package/dist/i18n/en/Employee.DocumentManager.json.js +1 -1
  217. package/dist/i18n/en/Employee.HomeAddress.Management.json.js +12 -10
  218. package/dist/i18n/en/Employee.HomeAddress.Management.json.js.map +1 -1
  219. package/dist/i18n/en/Employee.ManagementEmployeeList.json.js +32 -30
  220. package/dist/i18n/en/Employee.ManagementEmployeeList.json.js.map +1 -1
  221. package/dist/i18n/en/Employee.WorkAddress.Management.json.js +16 -14
  222. package/dist/i18n/en/Employee.WorkAddress.Management.json.js.map +1 -1
  223. package/dist/i18n/en/common.json.d.ts +21 -0
  224. package/dist/partner-hook-utils/form/fields/DatePickerHookField.js +33 -32
  225. package/dist/partner-hook-utils/form/fields/DatePickerHookField.js.map +1 -1
  226. package/dist/partner-hook-utils/types.d.ts +4 -0
  227. package/dist/shared/constants.d.ts +4 -0
  228. package/dist/shared/constants.js +20 -18
  229. package/dist/shared/constants.js.map +1 -1
  230. package/dist/style.css +1 -1
  231. package/dist/types/i18next.d.ts +45 -11
  232. package/docs/reference/endpoint-inventory.json +24 -8
  233. package/package.json +1 -1
@@ -1,103 +1,126 @@
1
- import { jsx as a } from "react/jsx-runtime";
2
- import { useState as P } from "react";
3
- import { useTranslation as w } from "react-i18next";
4
- import { useQueryClient as b } from "@tanstack/react-query";
5
- import { useTimeOffPoliciesGetAllSuspense as U, invalidateAllTimeOffPoliciesGetAll as v } from "@gusto/embedded-api/react-query/timeOffPoliciesGetAll";
6
- import { useTimeOffPoliciesDeactivateMutation as B } from "@gusto/embedded-api/react-query/timeOffPoliciesDeactivate";
7
- import { useEmployeesListSuspense as G } from "@gusto/embedded-api/react-query/employeesList";
8
- import { useHolidayPayPoliciesGet as Y, invalidateAllHolidayPayPoliciesGet as q } from "@gusto/embedded-api/react-query/holidayPayPoliciesGet";
9
- import { useHolidayPayPoliciesDeleteMutation as x } from "@gusto/embedded-api/react-query/holidayPayPoliciesDelete";
10
- import { PolicyListPresentation as N } from "./PolicyListPresentation.js";
11
- import { isListedTimeOffPolicyType as Q } from "../TimeOffFlow/timeOffPolicyTypes.js";
12
- import { BaseBoundaries as R, BaseLayout as V } from "../../Base/Base.js";
1
+ import { jsx as n } from "react/jsx-runtime";
2
+ import { useState as T } from "react";
3
+ import { useTranslation as U } from "react-i18next";
4
+ import { useQueryClient as v } from "@tanstack/react-query";
5
+ import { useTimeOffPoliciesGetAllSuspense as R, invalidateAllTimeOffPoliciesGetAll as G } from "@gusto/embedded-api/react-query/timeOffPoliciesGetAll";
6
+ import { useTimeOffPoliciesDeactivateMutation as Y } from "@gusto/embedded-api/react-query/timeOffPoliciesDeactivate";
7
+ import { useEmployeesListSuspense as j } from "@gusto/embedded-api/react-query/employeesList";
8
+ import { useHolidayPayPoliciesGet as x, invalidateAllHolidayPayPoliciesGet as N } from "@gusto/embedded-api/react-query/holidayPayPoliciesGet";
9
+ import { useHolidayPayPoliciesDeleteMutation as Q } from "@gusto/embedded-api/react-query/holidayPayPoliciesDelete";
10
+ import { UnprocessableEntityError as V } from "@gusto/embedded-api/models/errors/unprocessableentityerror";
11
+ import { PolicyListPresentation as W } from "./PolicyListPresentation.js";
12
+ import { isListedTimeOffPolicyType as k } from "../TimeOffFlow/timeOffPolicyTypes.js";
13
+ import { BaseBoundaries as K, BaseLayout as z } from "../../Base/Base.js";
13
14
  import "../../Base/useBase.js";
14
- import { useBaseSubmit as W } from "../../Base/useBaseSubmit.js";
15
- import { composeErrorHandler as j } from "../../../partner-hook-utils/composeErrorHandler.js";
16
- import { componentEvents as s } from "../../../shared/constants.js";
17
- import { useI18n as k } from "../../../i18n/I18n.js";
18
- function ye({ FallbackComponent: i, ...o }) {
19
- return /* @__PURE__ */ a(
20
- R,
15
+ import { useBaseSubmit as J } from "../../Base/useBaseSubmit.js";
16
+ import { SDKInternalError as E } from "../../../types/sdkError.js";
17
+ import { composeErrorHandler as X } from "../../../partner-hook-utils/composeErrorHandler.js";
18
+ import { componentEvents as a } from "../../../shared/constants.js";
19
+ import { useI18n as Z } from "../../../i18n/I18n.js";
20
+ function Oe({ FallbackComponent: o, ...t }) {
21
+ return /* @__PURE__ */ n(
22
+ K,
21
23
  {
22
24
  componentName: "Company.TimeOff.TimeOffPolicies",
23
- FallbackComponent: i,
24
- children: /* @__PURE__ */ a(z, { ...o })
25
+ FallbackComponent: o,
26
+ children: /* @__PURE__ */ n($, { ...t })
25
27
  }
26
28
  );
27
29
  }
28
- function z({ companyId: i, onEvent: o }) {
29
- k("Company.TimeOff.TimeOffPolicies");
30
- const { t } = w("Company.TimeOff.TimeOffPolicies"), m = b(), {
31
- baseSubmitHandler: T,
32
- error: O,
33
- setError: h
34
- } = W("Company.TimeOff.TimeOffPolicies"), [E, r] = P(null), [D, c] = P(null), { data: C } = U({
35
- companyUuid: i
36
- }), I = (C.timeOffPolicies ?? []).filter(
37
- (e) => e.isActive && Q(e.policyType)
38
- ), u = Y(
39
- { companyUuid: i },
30
+ function $({ companyId: o, onEvent: t }) {
31
+ Z("Company.TimeOff.TimeOffPolicies");
32
+ const { t: i } = U("Company.TimeOff.TimeOffPolicies"), u = v(), {
33
+ baseSubmitHandler: O,
34
+ error: D,
35
+ setError: g
36
+ } = J("Company.TimeOff.TimeOffPolicies"), [C, m] = T(null), [I, y] = T(null), { data: _ } = R({
37
+ companyUuid: o
38
+ }), w = (_.timeOffPolicies ?? []).filter(
39
+ (e) => e.isActive && k(e.policyType)
40
+ ), p = x(
41
+ { companyUuid: o },
40
42
  {
41
43
  throwOnError: () => !1
42
44
  }
43
- ), n = u.data?.holidayPayPolicy, { data: _ } = G({
44
- companyId: i,
45
+ ), c = p.data?.holidayPayPolicy, { data: L } = j({
46
+ companyId: o,
45
47
  terminated: !1
46
- }), A = _.showEmployees?.length ?? 0, y = B(), f = x(), L = j([u], { submitError: O, setSubmitError: h }), g = y.isPending || f.isPending, p = (e) => e > 0 && e === A ? t("allEmployeesLabel") : e > 0 ? t("employeeCount", { count: e }) : t("enrolledDash"), d = I.map((e) => ({
48
+ }), A = L.showEmployees?.length ?? 0, f = Y(), d = Q(), F = X([p], { submitError: D, setSubmitError: g }), S = f.isPending || d.isPending, P = (e) => e > 0 && e === A ? i("allEmployeesLabel") : e > 0 ? i("employeeCount", { count: e }) : i("enrolledDash"), h = w.map((e) => ({
47
49
  uuid: e.uuid,
48
50
  name: e.name,
49
51
  policyType: e.policyType,
50
52
  isComplete: e.complete ?? !1,
51
- enrolledDisplay: p(e.employees.length)
52
- })).sort((e, l) => e.name.localeCompare(l.name));
53
- n && d.push({
54
- uuid: n.companyUuid,
55
- name: t("holidayPayPolicy"),
53
+ enrolledDisplay: P(e.employees.length)
54
+ })).sort((e, s) => e.name.localeCompare(s.name));
55
+ c && h.push({
56
+ uuid: c.companyUuid,
57
+ name: i("holidayPayPolicy"),
56
58
  policyType: "holiday",
57
59
  isComplete: !0,
58
- enrolledDisplay: p(n.employees.length),
60
+ enrolledDisplay: P(c.employees.length),
59
61
  isHoliday: !0
60
62
  });
61
- const F = () => {
62
- o(s.TIME_OFF_CREATE_POLICY);
63
- }, S = (e) => {
64
- o(s.TIME_OFF_VIEW_POLICY, {
63
+ const H = () => {
64
+ t(a.TIME_OFF_CREATE_POLICY);
65
+ }, M = (e) => {
66
+ t(a.TIME_OFF_VIEW_POLICY, {
65
67
  policyId: e.uuid,
66
68
  policyType: e.policyType
67
69
  });
68
- }, H = (e) => {
69
- o(s.TIME_OFF_VIEW_POLICY, {
70
+ }, b = (e) => {
71
+ t(a.TIME_OFF_VIEW_POLICY, {
70
72
  policyId: e.uuid,
71
73
  policyType: e.policyType
72
74
  });
73
- }, M = async (e) => {
74
- let l = !1;
75
- return c(e.uuid), await T({}, async () => {
76
- e.isHoliday ? (await f.mutateAsync({
77
- request: { companyUuid: i }
78
- }), await q(m), r(t("flash.holidayDeleted"))) : (await y.mutateAsync({
79
- request: { timeOffPolicyUuid: e.uuid }
80
- }), await v(m), r(t("flash.policyDeleted", { name: e.name }))), o(s.TIME_OFF_DELETE_POLICY_DONE, { policyId: e.uuid }), l = !0;
81
- }), c(null), l;
75
+ }, q = async (e) => {
76
+ let s = !1;
77
+ return y(e.uuid), await O({}, async () => {
78
+ if (e.isHoliday)
79
+ await d.mutateAsync({
80
+ request: { companyUuid: o }
81
+ }), await N(u), m(i("flash.holidayDeleted"));
82
+ else {
83
+ try {
84
+ await f.mutateAsync({
85
+ request: { timeOffPolicyUuid: e.uuid }
86
+ });
87
+ } catch (r) {
88
+ if (r instanceof V) {
89
+ if (r.errors.some(
90
+ (l) => l.message?.toLowerCase().includes("pending") || l.message?.toLowerCase().includes("approved")
91
+ ))
92
+ throw new E(
93
+ i("errors.pendingRequestsBlockDeletion", { name: e.name }),
94
+ "api_error"
95
+ );
96
+ const B = r.errors.map((l) => l.message).filter(Boolean);
97
+ throw new E(B.join(". ") || i("errors.deleteFailed"), "api_error");
98
+ }
99
+ throw r;
100
+ }
101
+ await G(u), m(i("flash.policyDeleted", { name: e.name }));
102
+ }
103
+ t(a.TIME_OFF_DELETE_POLICY_DONE, { policyId: e.uuid }), s = !0;
104
+ }), y(null), s;
82
105
  };
83
- return /* @__PURE__ */ a(V, { error: L.errors, children: /* @__PURE__ */ a(
84
- N,
106
+ return /* @__PURE__ */ n(z, { error: F.errors, children: /* @__PURE__ */ n(
107
+ W,
85
108
  {
86
- policies: d,
87
- onCreatePolicy: F,
88
- onEditPolicy: S,
89
- onFinishSetup: H,
90
- onDeletePolicy: M,
91
- deleteSuccessAlert: E,
109
+ policies: h,
110
+ onCreatePolicy: H,
111
+ onEditPolicy: M,
112
+ onFinishSetup: b,
113
+ onDeletePolicy: q,
114
+ deleteSuccessAlert: C,
92
115
  onDismissDeleteAlert: () => {
93
- r(null);
116
+ m(null);
94
117
  },
95
- isDeletingPolicyId: D,
96
- isPending: g
118
+ isDeletingPolicyId: I,
119
+ isPending: S
97
120
  }
98
121
  ) });
99
122
  }
100
123
  export {
101
- ye as PolicyList
124
+ Oe as PolicyList
102
125
  };
103
126
  //# sourceMappingURL=PolicyList.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PolicyList.js","sources":["../../../../src/components/TimeOff/PolicyList/PolicyList.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useQueryClient } from '@tanstack/react-query'\nimport {\n useTimeOffPoliciesGetAllSuspense,\n invalidateAllTimeOffPoliciesGetAll,\n} from '@gusto/embedded-api/react-query/timeOffPoliciesGetAll'\nimport { useTimeOffPoliciesDeactivateMutation } from '@gusto/embedded-api/react-query/timeOffPoliciesDeactivate'\nimport { useEmployeesListSuspense } from '@gusto/embedded-api/react-query/employeesList'\nimport {\n useHolidayPayPoliciesGet,\n invalidateAllHolidayPayPoliciesGet,\n} from '@gusto/embedded-api/react-query/holidayPayPoliciesGet'\nimport { useHolidayPayPoliciesDeleteMutation } from '@gusto/embedded-api/react-query/holidayPayPoliciesDelete'\nimport type { TimeOffPolicy } from '@gusto/embedded-api/models/components/timeoffpolicy'\nimport { PolicyListPresentation } from './PolicyListPresentation'\nimport type { PolicyListItem } from './PolicyListTypes'\nimport { isListedTimeOffPolicyType } from '@/components/TimeOff/TimeOffFlow/timeOffPolicyTypes'\nimport { BaseBoundaries, BaseLayout, type BaseComponentInterface } from '@/components/Base'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { componentEvents } from '@/shared/constants'\nimport { useI18n } from '@/i18n'\n\nexport interface PolicyListProps extends BaseComponentInterface<'Company.TimeOff.TimeOffPolicies'> {\n companyId: string\n}\n\nexport function PolicyList({ FallbackComponent, ...props }: PolicyListProps) {\n return (\n <BaseBoundaries\n componentName=\"Company.TimeOff.TimeOffPolicies\"\n FallbackComponent={FallbackComponent}\n >\n <Root {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction Root({ companyId, onEvent }: PolicyListProps) {\n useI18n('Company.TimeOff.TimeOffPolicies')\n const { t } = useTranslation('Company.TimeOff.TimeOffPolicies')\n const queryClient = useQueryClient()\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('Company.TimeOff.TimeOffPolicies')\n\n const [deleteSuccessAlert, setDeleteSuccessAlert] = useState<string | null>(null)\n const [isDeletingPolicyId, setIsDeletingPolicyId] = useState<string | null>(null)\n\n const { data: policiesData } = useTimeOffPoliciesGetAllSuspense({\n companyUuid: companyId,\n })\n const timeOffPolicies = (policiesData.timeOffPolicies ?? []).filter(\n policy => policy.isActive && isListedTimeOffPolicyType(policy.policyType),\n )\n\n // Holiday pay policy is auxiliary to the main time-off list; never crash the\n // boundary on its failure. composeErrorHandler below surfaces the error as\n // an inline alert via BaseLayout when it isn't an expected 204/404.\n const holidayQuery = useHolidayPayPoliciesGet(\n { companyUuid: companyId },\n {\n throwOnError: () => false,\n },\n )\n const holidayPayPolicy = holidayQuery.data?.holidayPayPolicy\n\n const { data: employeesData } = useEmployeesListSuspense({\n companyId,\n terminated: false,\n })\n const totalActiveEmployees = employeesData.showEmployees?.length ?? 0\n\n const deactivatePolicyMutation = useTimeOffPoliciesDeactivateMutation()\n const deleteHolidayMutation = useHolidayPayPoliciesDeleteMutation()\n\n const errorHandling = composeErrorHandler([holidayQuery], { submitError, setSubmitError })\n const isPending = deactivatePolicyMutation.isPending || deleteHolidayMutation.isPending\n\n const getEnrolledDisplay = (enrolledCount: number) => {\n if (enrolledCount > 0 && enrolledCount === totalActiveEmployees) {\n return t('allEmployeesLabel')\n } else if (enrolledCount > 0) {\n return t('employeeCount', { count: enrolledCount })\n }\n return t('enrolledDash')\n }\n\n const policies: PolicyListItem[] = timeOffPolicies\n .map((policy: TimeOffPolicy) => ({\n uuid: policy.uuid,\n name: policy.name,\n policyType: policy.policyType,\n isComplete: policy.complete ?? false,\n enrolledDisplay: getEnrolledDisplay(policy.employees.length),\n }))\n .sort((a, b) => a.name.localeCompare(b.name))\n\n if (holidayPayPolicy) {\n policies.push({\n uuid: holidayPayPolicy.companyUuid,\n name: t('holidayPayPolicy'),\n policyType: 'holiday',\n isComplete: true,\n enrolledDisplay: getEnrolledDisplay(holidayPayPolicy.employees.length),\n isHoliday: true,\n })\n }\n\n const handleCreatePolicy = () => {\n onEvent(componentEvents.TIME_OFF_CREATE_POLICY)\n }\n\n const handleEditPolicy = (policy: PolicyListItem) => {\n onEvent(componentEvents.TIME_OFF_VIEW_POLICY, {\n policyId: policy.uuid,\n policyType: policy.policyType,\n })\n }\n\n const handleFinishSetup = (policy: PolicyListItem) => {\n onEvent(componentEvents.TIME_OFF_VIEW_POLICY, {\n policyId: policy.uuid,\n policyType: policy.policyType,\n })\n }\n\n const handleDeletePolicy = async (policy: PolicyListItem): Promise<boolean> => {\n let success = false\n setIsDeletingPolicyId(policy.uuid)\n await baseSubmitHandler({}, async () => {\n if (policy.isHoliday) {\n await deleteHolidayMutation.mutateAsync({\n request: { companyUuid: companyId },\n })\n await invalidateAllHolidayPayPoliciesGet(queryClient)\n setDeleteSuccessAlert(t('flash.holidayDeleted'))\n } else {\n await deactivatePolicyMutation.mutateAsync({\n request: { timeOffPolicyUuid: policy.uuid },\n })\n await invalidateAllTimeOffPoliciesGetAll(queryClient)\n setDeleteSuccessAlert(t('flash.policyDeleted', { name: policy.name }))\n }\n onEvent(componentEvents.TIME_OFF_DELETE_POLICY_DONE, { policyId: policy.uuid })\n success = true\n })\n setIsDeletingPolicyId(null)\n return success\n }\n\n return (\n <BaseLayout error={errorHandling.errors}>\n <PolicyListPresentation\n policies={policies}\n onCreatePolicy={handleCreatePolicy}\n onEditPolicy={handleEditPolicy}\n onFinishSetup={handleFinishSetup}\n onDeletePolicy={handleDeletePolicy}\n deleteSuccessAlert={deleteSuccessAlert}\n onDismissDeleteAlert={() => {\n setDeleteSuccessAlert(null)\n }}\n isDeletingPolicyId={isDeletingPolicyId}\n isPending={isPending}\n />\n </BaseLayout>\n )\n}\n"],"names":["PolicyList","FallbackComponent","props","jsx","BaseBoundaries","Root","companyId","onEvent","useI18n","useTranslation","queryClient","useQueryClient","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","deleteSuccessAlert","setDeleteSuccessAlert","useState","isDeletingPolicyId","setIsDeletingPolicyId","policiesData","useTimeOffPoliciesGetAllSuspense","timeOffPolicies","policy","isListedTimeOffPolicyType","holidayQuery","useHolidayPayPoliciesGet","holidayPayPolicy","employeesData","useEmployeesListSuspense","totalActiveEmployees","deactivatePolicyMutation","useTimeOffPoliciesDeactivateMutation","deleteHolidayMutation","useHolidayPayPoliciesDeleteMutation","errorHandling","composeErrorHandler","isPending","getEnrolledDisplay","enrolledCount","policies","a","b","handleCreatePolicy","componentEvents","handleEditPolicy","handleFinishSetup","handleDeletePolicy","success","invalidateAllHolidayPayPoliciesGet","invalidateAllTimeOffPoliciesGetAll","BaseLayout","PolicyListPresentation"],"mappings":";;;;;;;;;;;;;;;;;AA4BO,SAASA,GAAW,EAAE,mBAAAC,GAAmB,GAAGC,KAA0B;AAC3E,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,eAAc;AAAA,MACd,mBAAAH;AAAA,MAEA,UAAA,gBAAAE,EAACE,GAAA,EAAM,GAAGH,EAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAGvB;AAEA,SAASG,EAAK,EAAE,WAAAC,GAAW,SAAAC,KAA4B;AACrD,EAAAC,EAAQ,iCAAiC;AACzC,QAAM,EAAE,EAAA,IAAMC,EAAe,iCAAiC,GACxDC,IAAcC,EAAA,GAEd;AAAA,IACJ,mBAAAC;AAAA,IACA,OAAOC;AAAA,IACP,UAAUC;AAAA,EAAA,IACRC,EAAc,iCAAiC,GAE7C,CAACC,GAAoBC,CAAqB,IAAIC,EAAwB,IAAI,GAC1E,CAACC,GAAoBC,CAAqB,IAAIF,EAAwB,IAAI,GAE1E,EAAE,MAAMG,EAAA,IAAiBC,EAAiC;AAAA,IAC9D,aAAahB;AAAA,EAAA,CACd,GACKiB,KAAmBF,EAAa,mBAAmB,CAAA,GAAI;AAAA,IAC3D,CAAAG,MAAUA,EAAO,YAAYC,EAA0BD,EAAO,UAAU;AAAA,EAAA,GAMpEE,IAAeC;AAAA,IACnB,EAAE,aAAarB,EAAA;AAAA,IACf;AAAA,MACE,cAAc,MAAM;AAAA,IAAA;AAAA,EACtB,GAEIsB,IAAmBF,EAAa,MAAM,kBAEtC,EAAE,MAAMG,EAAA,IAAkBC,EAAyB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AYA,EAAO;AAAA,IAAA,CACpB;AAAA,EACH,GAEMwB,IAAqB,OAAOxB,MAA6C;AAC7E,QAAIyB,IAAU;AACd,WAAA7B,EAAsBI,EAAO,IAAI,GACjC,MAAMZ,EAAkB,CAAA,GAAI,YAAY;AACtC,MAAIY,EAAO,aACT,MAAMU,EAAsB,YAAY;AAAA,QACtC,SAAS,EAAE,aAAa5B,EAAA;AAAA,MAAU,CACnC,GACD,MAAM4C,EAAmCxC,CAAW,GACpDO,EAAsB,EAAE,sBAAsB,CAAC,MAE/C,MAAMe,EAAyB,YAAY;AAAA,QACzC,SAAS,EAAE,mBAAmBR,EAAO,KAAA;AAAA,MAAK,CAC3C,GACD,MAAM2B,EAAmCzC,CAAW,GACpDO,EAAsB,EAAE,uBAAuB,EAAE,MAAMO,EAAO,KAAA,CAAM,CAAC,IAEvEjB,EAAQsC,EAAgB,6BAA6B,EAAE,UAAUrB,EAAO,MAAM,GAC9EyB,IAAU;AAAA,IACZ,CAAC,GACD7B,EAAsB,IAAI,GACnB6B;AAAA,EACT;AAEA,SACE,gBAAA9C,EAACiD,GAAA,EAAW,OAAOhB,EAAc,QAC/B,UAAA,gBAAAjC;AAAA,IAACkD;AAAA,IAAA;AAAA,MACC,UAAAZ;AAAA,MACA,gBAAgBG;AAAA,MAChB,cAAcE;AAAA,MACd,eAAeC;AAAA,MACf,gBAAgBC;AAAA,MAChB,oBAAAhC;AAAA,MACA,sBAAsB,MAAM;AAC1B,QAAAC,EAAsB,IAAI;AAAA,MAC5B;AAAA,MACA,oBAAAE;AAAA,MACA,WAAAmB;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
1
+ {"version":3,"file":"PolicyList.js","sources":["../../../../src/components/TimeOff/PolicyList/PolicyList.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useQueryClient } from '@tanstack/react-query'\nimport {\n useTimeOffPoliciesGetAllSuspense,\n invalidateAllTimeOffPoliciesGetAll,\n} from '@gusto/embedded-api/react-query/timeOffPoliciesGetAll'\nimport { useTimeOffPoliciesDeactivateMutation } from '@gusto/embedded-api/react-query/timeOffPoliciesDeactivate'\nimport { useEmployeesListSuspense } from '@gusto/embedded-api/react-query/employeesList'\nimport {\n useHolidayPayPoliciesGet,\n invalidateAllHolidayPayPoliciesGet,\n} from '@gusto/embedded-api/react-query/holidayPayPoliciesGet'\nimport { useHolidayPayPoliciesDeleteMutation } from '@gusto/embedded-api/react-query/holidayPayPoliciesDelete'\nimport type { TimeOffPolicy } from '@gusto/embedded-api/models/components/timeoffpolicy'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport { PolicyListPresentation } from './PolicyListPresentation'\nimport type { PolicyListItem } from './PolicyListTypes'\nimport { isListedTimeOffPolicyType } from '@/components/TimeOff/TimeOffFlow/timeOffPolicyTypes'\nimport { BaseBoundaries, BaseLayout, type BaseComponentInterface } from '@/components/Base'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { componentEvents } from '@/shared/constants'\nimport { useI18n } from '@/i18n'\n\nexport interface PolicyListProps extends BaseComponentInterface<'Company.TimeOff.TimeOffPolicies'> {\n companyId: string\n}\n\nexport function PolicyList({ FallbackComponent, ...props }: PolicyListProps) {\n return (\n <BaseBoundaries\n componentName=\"Company.TimeOff.TimeOffPolicies\"\n FallbackComponent={FallbackComponent}\n >\n <Root {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction Root({ companyId, onEvent }: PolicyListProps) {\n useI18n('Company.TimeOff.TimeOffPolicies')\n const { t } = useTranslation('Company.TimeOff.TimeOffPolicies')\n const queryClient = useQueryClient()\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('Company.TimeOff.TimeOffPolicies')\n\n const [deleteSuccessAlert, setDeleteSuccessAlert] = useState<string | null>(null)\n const [isDeletingPolicyId, setIsDeletingPolicyId] = useState<string | null>(null)\n\n const { data: policiesData } = useTimeOffPoliciesGetAllSuspense({\n companyUuid: companyId,\n })\n const timeOffPolicies = (policiesData.timeOffPolicies ?? []).filter(\n policy => policy.isActive && isListedTimeOffPolicyType(policy.policyType),\n )\n\n // Holiday pay policy is auxiliary to the main time-off list; never crash the\n // boundary on its failure. composeErrorHandler below surfaces the error as\n // an inline alert via BaseLayout when it isn't an expected 204/404.\n const holidayQuery = useHolidayPayPoliciesGet(\n { companyUuid: companyId },\n {\n throwOnError: () => false,\n },\n )\n const holidayPayPolicy = holidayQuery.data?.holidayPayPolicy\n\n const { data: employeesData } = useEmployeesListSuspense({\n companyId,\n terminated: false,\n })\n const totalActiveEmployees = employeesData.showEmployees?.length ?? 0\n\n const deactivatePolicyMutation = useTimeOffPoliciesDeactivateMutation()\n const deleteHolidayMutation = useHolidayPayPoliciesDeleteMutation()\n\n const errorHandling = composeErrorHandler([holidayQuery], { submitError, setSubmitError })\n const isPending = deactivatePolicyMutation.isPending || deleteHolidayMutation.isPending\n\n const getEnrolledDisplay = (enrolledCount: number) => {\n if (enrolledCount > 0 && enrolledCount === totalActiveEmployees) {\n return t('allEmployeesLabel')\n } else if (enrolledCount > 0) {\n return t('employeeCount', { count: enrolledCount })\n }\n return t('enrolledDash')\n }\n\n const policies: PolicyListItem[] = timeOffPolicies\n .map((policy: TimeOffPolicy) => ({\n uuid: policy.uuid,\n name: policy.name,\n policyType: policy.policyType,\n isComplete: policy.complete ?? false,\n enrolledDisplay: getEnrolledDisplay(policy.employees.length),\n }))\n .sort((a, b) => a.name.localeCompare(b.name))\n\n if (holidayPayPolicy) {\n policies.push({\n uuid: holidayPayPolicy.companyUuid,\n name: t('holidayPayPolicy'),\n policyType: 'holiday',\n isComplete: true,\n enrolledDisplay: getEnrolledDisplay(holidayPayPolicy.employees.length),\n isHoliday: true,\n })\n }\n\n const handleCreatePolicy = () => {\n onEvent(componentEvents.TIME_OFF_CREATE_POLICY)\n }\n\n const handleEditPolicy = (policy: PolicyListItem) => {\n onEvent(componentEvents.TIME_OFF_VIEW_POLICY, {\n policyId: policy.uuid,\n policyType: policy.policyType,\n })\n }\n\n const handleFinishSetup = (policy: PolicyListItem) => {\n onEvent(componentEvents.TIME_OFF_VIEW_POLICY, {\n policyId: policy.uuid,\n policyType: policy.policyType,\n })\n }\n\n const handleDeletePolicy = async (policy: PolicyListItem): Promise<boolean> => {\n let success = false\n setIsDeletingPolicyId(policy.uuid)\n await baseSubmitHandler({}, async () => {\n if (policy.isHoliday) {\n await deleteHolidayMutation.mutateAsync({\n request: { companyUuid: companyId },\n })\n await invalidateAllHolidayPayPoliciesGet(queryClient)\n setDeleteSuccessAlert(t('flash.holidayDeleted'))\n } else {\n try {\n await deactivatePolicyMutation.mutateAsync({\n request: { timeOffPolicyUuid: policy.uuid },\n })\n } catch (err) {\n if (err instanceof UnprocessableEntityError) {\n const hasPendingRequests = err.errors.some(\n e =>\n e.message?.toLowerCase().includes('pending') ||\n e.message?.toLowerCase().includes('approved'),\n )\n if (hasPendingRequests) {\n throw new SDKInternalError(\n t('errors.pendingRequestsBlockDeletion', { name: policy.name }),\n 'api_error',\n )\n }\n const messages = err.errors.map(e => e.message).filter(Boolean)\n throw new SDKInternalError(messages.join('. ') || t('errors.deleteFailed'), 'api_error')\n }\n throw err\n }\n await invalidateAllTimeOffPoliciesGetAll(queryClient)\n setDeleteSuccessAlert(t('flash.policyDeleted', { name: policy.name }))\n }\n onEvent(componentEvents.TIME_OFF_DELETE_POLICY_DONE, { policyId: policy.uuid })\n success = true\n })\n setIsDeletingPolicyId(null)\n return success\n }\n\n return (\n <BaseLayout error={errorHandling.errors}>\n <PolicyListPresentation\n policies={policies}\n onCreatePolicy={handleCreatePolicy}\n onEditPolicy={handleEditPolicy}\n onFinishSetup={handleFinishSetup}\n onDeletePolicy={handleDeletePolicy}\n deleteSuccessAlert={deleteSuccessAlert}\n onDismissDeleteAlert={() => {\n setDeleteSuccessAlert(null)\n }}\n isDeletingPolicyId={isDeletingPolicyId}\n isPending={isPending}\n />\n </BaseLayout>\n )\n}\n"],"names":["PolicyList","FallbackComponent","props","jsx","BaseBoundaries","Root","companyId","onEvent","useI18n","t","useTranslation","queryClient","useQueryClient","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","deleteSuccessAlert","setDeleteSuccessAlert","useState","isDeletingPolicyId","setIsDeletingPolicyId","policiesData","useTimeOffPoliciesGetAllSuspense","timeOffPolicies","policy","isListedTimeOffPolicyType","holidayQuery","useHolidayPayPoliciesGet","holidayPayPolicy","employeesData","useEmployeesListSuspense","totalActiveEmployees","deactivatePolicyMutation","useTimeOffPoliciesDeactivateMutation","deleteHolidayMutation","useHolidayPayPoliciesDeleteMutation","errorHandling","composeErrorHandler","isPending","getEnrolledDisplay","enrolledCount","policies","a","b","handleCreatePolicy","componentEvents","handleEditPolicy","handleFinishSetup","handleDeletePolicy","success","invalidateAllHolidayPayPoliciesGet","err","UnprocessableEntityError","e","SDKInternalError","messages","invalidateAllTimeOffPoliciesGetAll","BaseLayout","PolicyListPresentation"],"mappings":";;;;;;;;;;;;;;;;;;;AA8BO,SAASA,GAAW,EAAE,mBAAAC,GAAmB,GAAGC,KAA0B;AAC3E,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,eAAc;AAAA,MACd,mBAAAH;AAAA,MAEA,UAAA,gBAAAE,EAACE,GAAA,EAAM,GAAGH,EAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAGvB;AAEA,SAASG,EAAK,EAAE,WAAAC,GAAW,SAAAC,KAA4B;AACrD,EAAAC,EAAQ,iCAAiC;AACzC,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,iCAAiC,GACxDC,IAAcC,EAAA,GAEd;AAAA,IACJ,mBAAAC;AAAA,IACA,OAAOC;AAAA,IACP,UAAUC;AAAA,EAAA,IACRC,EAAc,iCAAiC,GAE7C,CAACC,GAAoBC,CAAqB,IAAIC,EAAwB,IA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I,OAAKE,EAAE,OAAO,EAAE,OAAO,OAAO;AAC9D,kBAAM,IAAIC,EAAiBC,EAAS,KAAK,IAAI,KAAK/C,EAAE,qBAAqB,GAAG,WAAW;AAAA,UACzF;AACA,gBAAM2C;AAAA,QACR;AACA,cAAMK,EAAmC9C,CAAW,GACpDO,EAAsBT,EAAE,uBAAuB,EAAE,MAAMgB,EAAO,KAAA,CAAM,CAAC;AAAA,MACvE;AACA,MAAAlB,EAAQuC,EAAgB,6BAA6B,EAAE,UAAUrB,EAAO,MAAM,GAC9EyB,IAAU;AAAA,IACZ,CAAC,GACD7B,EAAsB,IAAI,GACnB6B;AAAA,EACT;AAEA,SACE,gBAAA/C,EAACuD,GAAA,EAAW,OAAOrB,EAAc,QAC/B,UAAA,gBAAAlC;AAAA,IAACwD;AAAA,IAAA;AAAA,MACC,UAAAjB;AAAA,MACA,gBAAgBG;AAAA,MAChB,cAAcE;AAAA,MACd,eAAeC;AAAA,MACf,gBAAgBC;AAAA,MAChB,oBAAAhC;AAAA,MACA,sBAAsB,MAAM;AAC1B,QAAAC,EAAsB,IAAI;AAAA,MAC5B;AAAA,MACA,oBAAAE;AAAA,MACA,WAAAmB;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
@@ -2,7 +2,7 @@ import { jsxs as a, jsx as t } from "react/jsx-runtime";
2
2
  import { useState as H } from "react";
3
3
  import { useTranslation as k } from "react-i18next";
4
4
  import v from "./PolicyListPresentation.module.scss.js";
5
- import { Flex as y } from "../../Common/Flex/Flex.js";
5
+ import { Flex as p } from "../../Common/Flex/Flex.js";
6
6
  import "classnames";
7
7
  import "../../../shared/constants.js";
8
8
  import { EmptyData as S } from "../../Common/EmptyData/EmptyData.js";
@@ -14,29 +14,29 @@ import { HamburgerMenu as E } from "../../Common/HamburgerMenu/HamburgerMenu.js"
14
14
  import { useDataView as F } from "../../Common/DataView/useDataView.js";
15
15
  import { DataView as M } from "../../Common/DataView/DataView.js";
16
16
  function $({
17
- policies: n,
18
- onCreatePolicy: r,
19
- onEditPolicy: s,
17
+ policies: y,
18
+ onCreatePolicy: n,
19
+ onEditPolicy: r,
20
20
  onFinishSetup: f,
21
21
  onDeletePolicy: u,
22
- deleteSuccessAlert: m,
22
+ deleteSuccessAlert: s,
23
23
  onDismissDeleteAlert: g,
24
24
  isDeletingPolicyId: D,
25
25
  isPending: C
26
26
  }) {
27
- const { Button: l, Heading: b, Alert: h, Dialog: P } = j();
27
+ const { Button: l, Heading: b, Alert: P, Dialog: h } = j();
28
28
  I("Company.TimeOff.TimeOffPolicies");
29
- const { t: e } = k("Company.TimeOff.TimeOffPolicies"), [o, c] = H({
29
+ const { t: e } = k("Company.TimeOff.TimeOffPolicies"), [o, m] = H({
30
30
  isOpen: !1,
31
31
  policy: null
32
32
  }), O = (i) => {
33
- c({ isOpen: !0, policy: i });
34
- }, d = () => {
35
- c({ isOpen: !1, policy: null });
33
+ m({ isOpen: !0, policy: i });
34
+ }, c = () => {
35
+ m({ isOpen: !1, policy: null });
36
36
  }, T = async () => {
37
- o.policy && (await u(o.policy), d());
37
+ o.policy && (await u(o.policy), c());
38
38
  }, { ...L } = F({
39
- data: n,
39
+ data: y,
40
40
  columns: [
41
41
  {
42
42
  title: e("tableHeaders.name"),
@@ -48,11 +48,11 @@ function $({
48
48
  }
49
49
  ],
50
50
  itemMenu: (i) => {
51
- const w = D === i.uuid, p = V(i.policyType), x = p ? [
51
+ const w = D === i.uuid, d = V(i.policyType), x = d ? [
52
52
  {
53
53
  label: e("actions.viewPolicy"),
54
54
  onClick: () => {
55
- s(i);
55
+ r(i);
56
56
  }
57
57
  },
58
58
  {
@@ -65,12 +65,12 @@ function $({
65
65
  {
66
66
  label: e("actions.viewPolicy"),
67
67
  onClick: () => {
68
- s(i);
68
+ r(i);
69
69
  }
70
70
  }
71
71
  ];
72
72
  return /* @__PURE__ */ a("div", { className: v.actionsCell, children: [
73
- p && !i.isComplete && /* @__PURE__ */ t(
73
+ d && !i.isComplete && /* @__PURE__ */ t(
74
74
  l,
75
75
  {
76
76
  variant: "secondary",
@@ -91,12 +91,12 @@ function $({
91
91
  )
92
92
  ] });
93
93
  },
94
- emptyState: () => /* @__PURE__ */ t(S, { title: e("emptyState.heading"), description: e("emptyState.body"), children: /* @__PURE__ */ t(A, { justifyContent: "center", children: /* @__PURE__ */ t(l, { variant: "secondary", onClick: r, children: e("createPolicyCta") }) }) })
94
+ emptyState: () => /* @__PURE__ */ t(S, { title: e("emptyState.heading"), description: e("emptyState.body"), children: /* @__PURE__ */ t(A, { justifyContent: "center", children: /* @__PURE__ */ t(l, { variant: "secondary", onClick: n, children: e("createPolicyCta") }) }) })
95
95
  });
96
- return /* @__PURE__ */ a(y, { flexDirection: "column", gap: 16, children: [
97
- m && /* @__PURE__ */ t(h, { status: "success", label: m, onDismiss: g }),
96
+ return /* @__PURE__ */ a(p, { flexDirection: "column", gap: 16, children: [
97
+ s && /* @__PURE__ */ t(P, { status: "success", label: s, onDismiss: g }),
98
98
  /* @__PURE__ */ a(
99
- y,
99
+ p,
100
100
  {
101
101
  flexDirection: { base: "column", medium: "row" },
102
102
  justifyContent: "space-between",
@@ -104,16 +104,16 @@ function $({
104
104
  gap: { base: 12, medium: 24 },
105
105
  children: [
106
106
  /* @__PURE__ */ t(b, { as: "h2", children: e("pageTitle") }),
107
- n.length > 0 && /* @__PURE__ */ t(l, { variant: "primary", onClick: r, children: e("createPolicyCta") })
107
+ /* @__PURE__ */ t(l, { variant: "primary", onClick: n, children: e("createPolicyCta") })
108
108
  ]
109
109
  }
110
110
  ),
111
111
  /* @__PURE__ */ t(M, { label: e("tableLabel"), ...L }),
112
112
  /* @__PURE__ */ t(
113
- P,
113
+ h,
114
114
  {
115
115
  isOpen: o.isOpen,
116
- onClose: d,
116
+ onClose: c,
117
117
  onPrimaryActionClick: T,
118
118
  isPrimaryActionLoading: C,
119
119
  isDestructive: !0,
@@ -1 +1 @@
1
- {"version":3,"file":"PolicyListPresentation.js","sources":["../../../../src/components/TimeOff/PolicyList/PolicyListPresentation.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport type { PolicyListPresentationProps, PolicyListItem } from './PolicyListTypes'\nimport styles from './PolicyListPresentation.module.scss'\nimport {\n DataView,\n Flex,\n EmptyData,\n ActionsLayout,\n HamburgerMenu,\n useDataView,\n} from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { isEditableTimeOffPolicyType } from '@/components/TimeOff/TimeOffFlow/timeOffPolicyTypes'\n\nexport function PolicyListPresentation({\n policies,\n onCreatePolicy,\n onEditPolicy,\n onFinishSetup,\n onDeletePolicy,\n deleteSuccessAlert,\n onDismissDeleteAlert,\n isDeletingPolicyId,\n isPending,\n}: PolicyListPresentationProps) {\n const { Button, Heading, Alert, Dialog } = useComponentContext()\n useI18n('Company.TimeOff.TimeOffPolicies')\n const { t } = useTranslation('Company.TimeOff.TimeOffPolicies')\n\n const [deletePolicyDialogState, setDeletePolicyDialogState] = useState<{\n isOpen: boolean\n policy: PolicyListItem | null\n }>({\n isOpen: false,\n policy: null,\n })\n\n const handleOpenDeleteDialog = (policy: PolicyListItem) => {\n setDeletePolicyDialogState({ isOpen: true, policy })\n }\n\n const handleCloseDeleteDialog = () => {\n setDeletePolicyDialogState({ isOpen: false, policy: null })\n }\n\n const handleConfirmDelete = async () => {\n if (deletePolicyDialogState.policy) {\n await onDeletePolicy(deletePolicyDialogState.policy)\n handleCloseDeleteDialog()\n }\n }\n\n const { ...dataViewProps } = useDataView({\n data: policies,\n columns: [\n {\n title: t('tableHeaders.name'),\n render: (policy: PolicyListItem) => policy.name,\n },\n {\n title: t('tableHeaders.enrolled'),\n render: (policy: PolicyListItem) => policy.enrolledDisplay,\n },\n ],\n itemMenu: (policy: PolicyListItem) => {\n const isDeleting = isDeletingPolicyId === policy.uuid\n const isEditable = isEditableTimeOffPolicyType(policy.policyType)\n\n const menuItems = isEditable\n ? [\n {\n label: t('actions.viewPolicy'),\n onClick: () => {\n onEditPolicy(policy)\n },\n },\n {\n label: t('actions.deletePolicy'),\n onClick: () => {\n handleOpenDeleteDialog(policy)\n },\n },\n ]\n : [\n {\n label: t('actions.viewPolicy'),\n onClick: () => {\n onEditPolicy(policy)\n },\n },\n ]\n\n return (\n <div className={styles.actionsCell}>\n {isEditable && !policy.isComplete && (\n <Button\n variant=\"secondary\"\n onClick={() => {\n onFinishSetup(policy)\n }}\n >\n {t('finishSetupCta')}\n </Button>\n )}\n <HamburgerMenu\n isLoading={isDeleting}\n triggerLabel={t('actions.menuTrigger', { name: policy.name })}\n menuLabel={t('actions.menuFor', { name: policy.name })}\n items={menuItems}\n />\n </div>\n )\n },\n emptyState: () => (\n <EmptyData title={t('emptyState.heading')} description={t('emptyState.body')}>\n <ActionsLayout justifyContent=\"center\">\n <Button variant=\"secondary\" onClick={onCreatePolicy}>\n {t('createPolicyCta')}\n </Button>\n </ActionsLayout>\n </EmptyData>\n ),\n })\n\n return (\n <Flex flexDirection=\"column\" gap={16}>\n {deleteSuccessAlert && (\n <Alert status=\"success\" label={deleteSuccessAlert} onDismiss={onDismissDeleteAlert} />\n )}\n\n <Flex\n flexDirection={{ base: 'column', medium: 'row' }}\n justifyContent=\"space-between\"\n alignItems=\"flex-start\"\n gap={{ base: 12, medium: 24 }}\n >\n <Heading as=\"h2\">{t('pageTitle')}</Heading>\n {policies.length > 0 && (\n <Button variant=\"primary\" onClick={onCreatePolicy}>\n {t('createPolicyCta')}\n </Button>\n )}\n </Flex>\n\n <DataView label={t('tableLabel')} {...dataViewProps} />\n\n <Dialog\n isOpen={deletePolicyDialogState.isOpen}\n onClose={handleCloseDeleteDialog}\n onPrimaryActionClick={handleConfirmDelete}\n isPrimaryActionLoading={isPending}\n isDestructive\n title={\n deletePolicyDialogState.policy?.isHoliday\n ? t('deleteHolidayDialog.title')\n : t('deletePolicyDialog.title', {\n name: deletePolicyDialogState.policy?.name ?? '',\n })\n }\n primaryActionLabel={t('deletePolicyDialog.confirmCta')}\n closeActionLabel={t('deletePolicyDialog.cancelCta')}\n >\n {deletePolicyDialogState.policy?.isHoliday\n ? t('deleteHolidayDialog.description')\n : t('deletePolicyDialog.description', {\n name: deletePolicyDialogState.policy?.name ?? '',\n })}\n </Dialog>\n </Flex>\n )\n}\n"],"names":["PolicyListPresentation","policies","onCreatePolicy","onEditPolicy","onFinishSetup","onDeletePolicy","deleteSuccessAlert","onDismissDeleteAlert","isDeletingPolicyId","isPending","Button","Heading","Alert","Dialog","useComponentContext","useI18n","t","useTranslation","deletePolicyDialogState","setDeletePolicyDialogState","useState","handleOpenDeleteDialog","policy","handleCloseDeleteDialog","handleConfirmDelete","dataViewProps","useDataView","isDeleting","isEditable","isEditableTimeOffPolicyType","menuItems","jsxs","styles","jsx","HamburgerMenu","EmptyData","ActionsLayout","Flex","DataView"],"mappings":";;;;;;;;;;;;;;;AAgBO,SAASA,EAAuB;AAAA,EACrC,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,WAAAC;AACF,GAAgC;AAC9B,QAAM,EAAE,QAAAC,GAAQ,SAAAC,GAAS,OAAAC,GAAO,QAAAC,EAAA,IAAWC,EAAA;AAC3C,EAAAC,EAAQ,iCAAiC;AACzC,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,iCAAiC,GAExD,CAACC,GAAyBC,CAA0B,IAAIC,EAG3D;AAAA,IACD,QAAQ;AAAA,IACR,QAAQ;AAAA,EAAA,CACT,GAEKC,IAAyB,CAACC,MAA2B;AACzD,IAAAH,EAA2B,EAAE,QAAQ,IAAM,QAAAG,EAAA,CAAQ;AAAA,EACrD,GAEMC,IAA0B,MAAM;AACpC,IAAAJ,EAA2B,EAAE,QAAQ,IAAO,QAAQ,MAAM;AAAA,EAC5D,GAEMK,IAAsB,YAAY;AACtC,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,OACES,EAAwB,QAAQ,YAC5BF,EAAE,2BAA2B,IAC7BA,EAAE,4BAA4B;AAAA,UAC5B,MAAME,EAAwB,QAAQ,QAAQ;AAAA,QAAA,CAC/C;AAAA,QAEP,oBAAoBF,EAAE,+BAA+B;AAAA,QACrD,kBAAkBA,EAAE,8BAA8B;AAAA,QAEjD,YAAwB,QAAQ,YAC7BA,EAAE,iCAAiC,IACnCA,EAAE,kCAAkC;AAAA,UAClC,MAAME,EAAwB,QAAQ,QAAQ;AAAA,QAAA,CAC/C;AAAA,MAAA;AAAA,IAAA;AAAA,EACP,GACF;AAEJ;"}
1
+ {"version":3,"file":"PolicyListPresentation.js","sources":["../../../../src/components/TimeOff/PolicyList/PolicyListPresentation.tsx"],"sourcesContent":["import { useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport type { PolicyListPresentationProps, PolicyListItem } from './PolicyListTypes'\nimport styles from './PolicyListPresentation.module.scss'\nimport {\n DataView,\n Flex,\n EmptyData,\n ActionsLayout,\n HamburgerMenu,\n useDataView,\n} from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { isEditableTimeOffPolicyType } from '@/components/TimeOff/TimeOffFlow/timeOffPolicyTypes'\n\nexport function PolicyListPresentation({\n policies,\n onCreatePolicy,\n onEditPolicy,\n onFinishSetup,\n onDeletePolicy,\n deleteSuccessAlert,\n onDismissDeleteAlert,\n isDeletingPolicyId,\n isPending,\n}: PolicyListPresentationProps) {\n const { Button, Heading, Alert, Dialog } = useComponentContext()\n useI18n('Company.TimeOff.TimeOffPolicies')\n const { t } = useTranslation('Company.TimeOff.TimeOffPolicies')\n\n const [deletePolicyDialogState, setDeletePolicyDialogState] = useState<{\n isOpen: boolean\n policy: PolicyListItem | null\n }>({\n isOpen: false,\n policy: null,\n })\n\n const handleOpenDeleteDialog = (policy: PolicyListItem) => {\n setDeletePolicyDialogState({ isOpen: true, policy })\n }\n\n const handleCloseDeleteDialog = () => {\n setDeletePolicyDialogState({ isOpen: false, policy: null })\n }\n\n const handleConfirmDelete = async () => {\n if (deletePolicyDialogState.policy) {\n await onDeletePolicy(deletePolicyDialogState.policy)\n handleCloseDeleteDialog()\n }\n }\n\n const { ...dataViewProps } = useDataView({\n data: policies,\n columns: [\n {\n title: t('tableHeaders.name'),\n render: (policy: PolicyListItem) => policy.name,\n },\n {\n title: t('tableHeaders.enrolled'),\n render: (policy: PolicyListItem) => policy.enrolledDisplay,\n },\n ],\n itemMenu: (policy: PolicyListItem) => {\n const isDeleting = isDeletingPolicyId === policy.uuid\n const isEditable = isEditableTimeOffPolicyType(policy.policyType)\n\n const menuItems = isEditable\n ? [\n {\n label: t('actions.viewPolicy'),\n onClick: () => {\n onEditPolicy(policy)\n },\n },\n {\n label: t('actions.deletePolicy'),\n onClick: () => {\n handleOpenDeleteDialog(policy)\n },\n },\n ]\n : [\n {\n label: t('actions.viewPolicy'),\n onClick: () => {\n onEditPolicy(policy)\n },\n },\n ]\n\n return (\n <div className={styles.actionsCell}>\n {isEditable && !policy.isComplete && (\n <Button\n variant=\"secondary\"\n onClick={() => {\n onFinishSetup(policy)\n }}\n >\n {t('finishSetupCta')}\n </Button>\n )}\n <HamburgerMenu\n isLoading={isDeleting}\n triggerLabel={t('actions.menuTrigger', { name: policy.name })}\n menuLabel={t('actions.menuFor', { name: policy.name })}\n items={menuItems}\n />\n </div>\n )\n },\n emptyState: () => (\n <EmptyData title={t('emptyState.heading')} description={t('emptyState.body')}>\n <ActionsLayout justifyContent=\"center\">\n <Button variant=\"secondary\" onClick={onCreatePolicy}>\n {t('createPolicyCta')}\n </Button>\n </ActionsLayout>\n </EmptyData>\n ),\n })\n\n return (\n <Flex flexDirection=\"column\" gap={16}>\n {deleteSuccessAlert && (\n <Alert status=\"success\" label={deleteSuccessAlert} onDismiss={onDismissDeleteAlert} />\n )}\n\n <Flex\n flexDirection={{ base: 'column', medium: 'row' }}\n justifyContent=\"space-between\"\n alignItems=\"flex-start\"\n gap={{ base: 12, medium: 24 }}\n >\n <Heading as=\"h2\">{t('pageTitle')}</Heading>\n <Button variant=\"primary\" onClick={onCreatePolicy}>\n {t('createPolicyCta')}\n </Button>\n </Flex>\n\n <DataView label={t('tableLabel')} {...dataViewProps} />\n\n <Dialog\n isOpen={deletePolicyDialogState.isOpen}\n onClose={handleCloseDeleteDialog}\n onPrimaryActionClick={handleConfirmDelete}\n isPrimaryActionLoading={isPending}\n isDestructive\n title={\n deletePolicyDialogState.policy?.isHoliday\n ? t('deleteHolidayDialog.title')\n : t('deletePolicyDialog.title', {\n name: deletePolicyDialogState.policy?.name ?? '',\n })\n }\n primaryActionLabel={t('deletePolicyDialog.confirmCta')}\n closeActionLabel={t('deletePolicyDialog.cancelCta')}\n >\n {deletePolicyDialogState.policy?.isHoliday\n ? t('deleteHolidayDialog.description')\n : t('deletePolicyDialog.description', {\n name: deletePolicyDialogState.policy?.name ?? '',\n })}\n </Dialog>\n </Flex>\n )\n}\n"],"names":["PolicyListPresentation","policies","onCreatePolicy","onEditPolicy","onFinishSetup","onDeletePolicy","deleteSuccessAlert","onDismissDeleteAlert","isDeletingPolicyId","isPending","Button","Heading","Alert","Dialog","useComponentContext","useI18n","t","useTranslation","deletePolicyDialogState","setDeletePolicyDialogState","useState","handleOpenDeleteDialog","policy","handleCloseDeleteDialog","handleConfirmDelete","dataViewProps","useDataView","isDeleting","isEditable","isEditableTimeOffPolicyType","menuItems","jsxs","styles","jsx","HamburgerMenu","EmptyData","ActionsLayout","Flex","DataView"],"mappings":";;;;;;;;;;;;;;;AAgBO,SAASA,EAAuB;AAAA,EACrC,UAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,WAAAC;AACF,GAAgC;AAC9B,QAAM,EAAE,QAAAC,GAAQ,SAAAC,GAAS,OAAAC,GAAO,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AAG,MAAM,UAAAK,EAAE,WAAW,GAAE;AAAA,UACjC,gBAAAiB,EAACvB,KAAO,SAAQ,WAAU,SAASR,GAChC,UAAAc,EAAE,iBAAiB,EAAA,CACtB;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,sBAGDsB,GAAA,EAAS,OAAOtB,EAAE,YAAY,GAAI,GAAGS,GAAe;AAAA,IAErD,gBAAAQ;AAAA,MAACpB;AAAA,MAAA;AAAA,QACC,QAAQK,EAAwB;AAAA,QAChC,SAASK;AAAA,QACT,sBAAsBC;AAAA,QACtB,wBAAwBf;AAAA,QACxB,eAAa;AAAA,QACb,OACES,EAAwB,QAAQ,YAC5BF,EAAE,2BAA2B,IAC7BA,EAAE,4BAA4B;AAAA,UAC5B,MAAME,EAAwB,QAAQ,QAAQ;AAAA,QAAA,CAC/C;AAAA,QAEP,oBAAoBF,EAAE,+BAA+B;AAAA,QACrD,kBAAkBA,EAAE,8BAA8B;AAAA,QAEjD,YAAwB,QAAQ,YAC7BA,EAAE,iCAAiC,IACnCA,EAAE,kCAAkC;AAAA,UAClC,MAAME,EAAwB,QAAQ,QAAQ;AAAA,QAAA,CAC/C;AAAA,MAAA;AAAA,IAAA;AAAA,EACP,GACF;AAEJ;"}
@@ -1,43 +1,57 @@
1
- import { jsx as e, jsxs as l, Fragment as L } from "react/jsx-runtime";
2
- import { useId as n } from "react";
3
- import { useForm as k, useWatch as s, FormProvider as R } from "react-hook-form";
4
- import { useTranslation as U } from "react-i18next";
1
+ import { jsx as e, jsxs as l, Fragment as O } from "react/jsx-runtime";
2
+ import { useId as t } from "react";
3
+ import { useForm as k, useWatch as s, FormProvider as U } from "react-hook-form";
4
+ import { useTranslation as W } from "react-i18next";
5
+ import { z as n } from "zod";
6
+ import { zodResolver as _ } from "@hookform/resolvers/zod";
5
7
  import a from "./PolicySettings.module.scss.js";
6
- import { Flex as N } from "../../Common/Flex/Flex.js";
8
+ import { Flex as L } from "../../Common/Flex/Flex.js";
7
9
  import "classnames";
8
10
  import "../../../shared/constants.js";
9
- import { ActionsLayout as W } from "../../Common/ActionsLayout/ActionsLayout.js";
10
- import { Form as _ } from "../../Common/Form/Form.js";
11
- import { useComponentContext as j } from "../../../contexts/ComponentAdapter/useComponentContext.js";
12
- import { useI18n as A } from "../../../i18n/I18n.js";
11
+ import { ActionsLayout as j } from "../../Common/ActionsLayout/ActionsLayout.js";
12
+ import { Form as z } from "../../Common/Form/Form.js";
13
+ import { useComponentContext as A } from "../../../contexts/ComponentAdapter/useComponentContext.js";
14
+ import { useI18n as B } from "../../../i18n/I18n.js";
13
15
  import { NumberInputField as c } from "../../Common/Fields/NumberInputField/NumberInputField.js";
14
- import { SwitchField as t } from "../../Common/Fields/SwitchField/SwitchField.js";
15
- function li({
16
+ import { SwitchField as r } from "../../Common/Fields/SwitchField/SwitchField.js";
17
+ const q = n.object({
18
+ accrualMaximumEnabled: n.boolean(),
19
+ accrualMaximum: n.number().optional(),
20
+ balanceMaximumEnabled: n.boolean(),
21
+ balanceMaximum: n.number().optional(),
22
+ carryOverLimitEnabled: n.boolean(),
23
+ carryOverLimit: n.number().optional(),
24
+ waitingPeriodEnabled: n.boolean(),
25
+ waitingPeriod: n.number().int().optional(),
26
+ paidOutOnTermination: n.boolean()
27
+ });
28
+ function si({
16
29
  accrualMethod: d,
17
- onContinue: P,
30
+ onContinue: M,
18
31
  onBack: E,
19
- defaultValues: M,
32
+ defaultValues: P,
20
33
  mode: w,
21
34
  editingPolicyName: u,
22
- isPending: p = !1
35
+ isPending: b = !1
23
36
  }) {
24
- A("Company.TimeOff.CreateTimeOffPolicy");
25
- const { t: i } = U("Company.TimeOff.CreateTimeOffPolicy"), { Heading: H, Button: b } = j(), g = n(), y = n(), h = n(), f = n(), x = n(), m = k({
37
+ B("Company.TimeOff.CreateTimeOffPolicy");
38
+ const { t: i } = W("Company.TimeOff.CreateTimeOffPolicy"), { Heading: N, Button: p } = A(), g = t(), y = t(), h = t(), f = t(), x = t(), m = k({
39
+ resolver: _(q),
26
40
  defaultValues: {
27
41
  accrualMaximumEnabled: !1,
28
42
  balanceMaximumEnabled: !1,
29
43
  carryOverLimitEnabled: !1,
30
44
  waitingPeriodEnabled: !1,
31
45
  paidOutOnTermination: !1,
32
- ...M
46
+ ...P
33
47
  }
34
- }), { control: r } = m, C = s({ control: r, name: "accrualMaximumEnabled" }), F = s({ control: r, name: "balanceMaximumEnabled" }), I = s({ control: r, name: "carryOverLimitEnabled" }), S = s({ control: r, name: "waitingPeriodEnabled" }), v = d === "hours_worked", O = d === "fixed_per_pay_period", T = v || O, D = v || O, V = (o) => {
35
- P(o);
48
+ }), { control: o } = m, H = s({ control: o, name: "accrualMaximumEnabled" }), C = s({ control: o, name: "balanceMaximumEnabled" }), F = s({ control: o, name: "carryOverLimitEnabled" }), I = s({ control: o, name: "waitingPeriodEnabled" }), S = d === "hours_worked", v = d === "fixed_per_pay_period", T = S || v, D = S || v, R = (V) => {
49
+ M(V);
36
50
  };
37
- return /* @__PURE__ */ e(R, { ...m, children: /* @__PURE__ */ e(_, { "aria-labelledby": g, onSubmit: m.handleSubmit(V), children: /* @__PURE__ */ e("div", { className: a.policySettings, children: /* @__PURE__ */ l(N, { flexDirection: "column", gap: 32, children: [
38
- /* @__PURE__ */ e(H, { as: "h2", id: g, children: w === "edit" && u ? i("policySettings.editTitle", { name: u }) : i("policySettings.createTitle") }),
39
- /* @__PURE__ */ l(N, { flexDirection: "column", gap: 20, children: [
40
- T && /* @__PURE__ */ l(L, { children: [
51
+ return /* @__PURE__ */ e(U, { ...m, children: /* @__PURE__ */ e(z, { "aria-labelledby": g, onSubmit: m.handleSubmit(R), children: /* @__PURE__ */ e("div", { className: a.policySettings, children: /* @__PURE__ */ l(L, { flexDirection: "column", gap: 32, children: [
52
+ /* @__PURE__ */ e(N, { as: "h2", id: g, children: w === "edit" && u ? i("policySettings.editTitle", { name: u }) : i("policySettings.createTitle") }),
53
+ /* @__PURE__ */ l(L, { flexDirection: "column", gap: 20, children: [
54
+ T && /* @__PURE__ */ l(O, { children: [
41
55
  /* @__PURE__ */ l("div", { className: a.settingRow, children: [
42
56
  /* @__PURE__ */ e(
43
57
  c,
@@ -49,13 +63,13 @@ function li({
49
63
  description: i("policySettings.accrualMaximumHint"),
50
64
  adornmentEnd: i("policySettings.hoursUnit"),
51
65
  placeholder: i("policySettings.numberOfHoursPlaceholder"),
52
- isDisabled: !C,
66
+ isDisabled: !H,
53
67
  min: 0,
54
68
  max: 2e4
55
69
  }
56
70
  ),
57
71
  /* @__PURE__ */ e("div", { className: a.toggleCell, children: /* @__PURE__ */ e(
58
- t,
72
+ r,
59
73
  {
60
74
  name: "accrualMaximumEnabled",
61
75
  label: i("policySettings.accrualMaximumLabel"),
@@ -77,13 +91,13 @@ function li({
77
91
  description: i("policySettings.balanceMaximumHint"),
78
92
  adornmentEnd: i("policySettings.hoursUnit"),
79
93
  placeholder: i("policySettings.numberOfHoursPlaceholder"),
80
- isDisabled: !F,
94
+ isDisabled: !C,
81
95
  min: 0,
82
96
  max: 2e4
83
97
  }
84
98
  ),
85
99
  /* @__PURE__ */ e("div", { className: a.toggleCell, children: /* @__PURE__ */ e(
86
- t,
100
+ r,
87
101
  {
88
102
  name: "balanceMaximumEnabled",
89
103
  label: i("policySettings.balanceMaximumLabel"),
@@ -104,13 +118,13 @@ function li({
104
118
  description: i("policySettings.carryOverLimitHint"),
105
119
  adornmentEnd: i("policySettings.hoursUnit"),
106
120
  placeholder: i("policySettings.numberOfHoursPlaceholder"),
107
- isDisabled: !I,
121
+ isDisabled: !F,
108
122
  min: 0,
109
123
  max: 2e4
110
124
  }
111
125
  ),
112
126
  /* @__PURE__ */ e("div", { className: a.toggleCell, children: /* @__PURE__ */ e(
113
- t,
127
+ r,
114
128
  {
115
129
  name: "carryOverLimitEnabled",
116
130
  label: i("policySettings.carryOverLimitLabel"),
@@ -120,7 +134,7 @@ function li({
120
134
  ) })
121
135
  ] }),
122
136
  /* @__PURE__ */ e("hr", { className: a.divider }),
123
- D && /* @__PURE__ */ l(L, { children: [
137
+ D && /* @__PURE__ */ l(O, { children: [
124
138
  /* @__PURE__ */ l("div", { className: a.settingRow, children: [
125
139
  /* @__PURE__ */ e(
126
140
  c,
@@ -132,17 +146,15 @@ function li({
132
146
  description: i("policySettings.waitingPeriodHint"),
133
147
  adornmentEnd: i("policySettings.daysUnit"),
134
148
  placeholder: i("policySettings.numberOfDaysPlaceholder"),
135
- isDisabled: !S,
149
+ isDisabled: !I,
136
150
  min: 0,
137
151
  max: 2e4,
138
152
  maximumFractionDigits: 0,
139
- rules: {
140
- validate: (o) => S && !isNaN(o) && !Number.isInteger(o) ? i("policySettings.errors.waitingPeriodMustBeWholeNumber") : !0
141
- }
153
+ errorMessage: i("policySettings.errors.waitingPeriodMustBeWholeNumber")
142
154
  }
143
155
  ),
144
156
  /* @__PURE__ */ e("div", { className: a.toggleCell, children: /* @__PURE__ */ e(
145
- t,
157
+ r,
146
158
  {
147
159
  name: "waitingPeriodEnabled",
148
160
  label: i("policySettings.waitingPeriodLabel"),
@@ -154,7 +166,7 @@ function li({
154
166
  /* @__PURE__ */ e("hr", { className: a.divider })
155
167
  ] }),
156
168
  /* @__PURE__ */ e(
157
- t,
169
+ r,
158
170
  {
159
171
  name: "paidOutOnTermination",
160
172
  label: i("policySettings.paidOutOnTerminationLabel"),
@@ -162,14 +174,14 @@ function li({
162
174
  }
163
175
  ),
164
176
  /* @__PURE__ */ e("hr", { className: a.divider }),
165
- /* @__PURE__ */ l(W, { children: [
166
- /* @__PURE__ */ e(b, { variant: "secondary", onClick: E, isDisabled: p, children: i("backCta") }),
167
- /* @__PURE__ */ e(b, { variant: "primary", type: "submit", isLoading: p, children: i("policySettings.continueCta") })
177
+ /* @__PURE__ */ l(j, { children: [
178
+ /* @__PURE__ */ e(p, { variant: "secondary", onClick: E, isDisabled: b, children: i("backCta") }),
179
+ /* @__PURE__ */ e(p, { variant: "primary", type: "submit", isLoading: b, children: i("policySettings.continueCta") })
168
180
  ] })
169
181
  ] })
170
182
  ] }) }) }) });
171
183
  }
172
184
  export {
173
- li as PolicySettingsPresentation
185
+ si as PolicySettingsPresentation
174
186
  };
175
187
  //# sourceMappingURL=PolicySettingsPresentation.js.map