@gusto/embedded-react-sdk 0.57.2 → 0.58.0

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 (425) hide show
  1. package/CHANGELOG.md +108 -0
  2. package/dist/components/Common/DataView/DataCards/DataCards.js +98 -66
  3. package/dist/components/Common/DataView/DataCards/DataCards.js.map +1 -1
  4. package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js +11 -9
  5. package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js.map +1 -1
  6. package/dist/components/Common/DataView/DataTable/DataTable.js +86 -75
  7. package/dist/components/Common/DataView/DataTable/DataTable.js.map +1 -1
  8. package/dist/components/Common/DataView/DataView.js.map +1 -1
  9. package/dist/components/Common/DataView/getSortControls.js +22 -0
  10. package/dist/components/Common/DataView/getSortControls.js.map +1 -0
  11. package/dist/components/Common/DataView/useDataView.js +30 -24
  12. package/dist/components/Common/DataView/useDataView.js.map +1 -1
  13. package/dist/components/Common/DateRangeFilter/DateRangeFilter.js +32 -32
  14. package/dist/components/Common/DateRangeFilter/DateRangeFilter.js.map +1 -1
  15. package/dist/components/Common/OnboardingStatusBadge/index.js.map +1 -1
  16. package/dist/components/Common/UI/Table/Table.js +65 -25
  17. package/dist/components/Common/UI/Table/Table.js.map +1 -1
  18. package/dist/components/Common/UI/Table/Table.module.scss.js +8 -4
  19. package/dist/components/Common/UI/Table/Table.module.scss.js.map +1 -1
  20. package/dist/components/Common/UI/Table/TableTypes.js.map +1 -1
  21. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -4
  22. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  23. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -4
  24. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  25. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -6
  26. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  27. package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
  28. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  29. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -4
  30. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  31. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +5 -6
  32. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  33. package/dist/components/Company/Industry/Context.js +6 -7
  34. package/dist/components/Company/Industry/Context.js.map +1 -1
  35. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -4
  36. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  37. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -4
  38. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  39. package/dist/components/Company/OnboardingOverview/context.js +3 -4
  40. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  41. package/dist/components/Company/PaySchedule/PaySchedule.js +30 -45
  42. package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
  43. package/dist/components/Company/PaySchedule/PayScheduleComponents.js +11 -12
  44. package/dist/components/Company/PaySchedule/PayScheduleComponents.js.map +1 -1
  45. package/dist/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.js.map +1 -1
  46. package/dist/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.js.map +1 -1
  47. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js +34 -14
  48. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js.map +1 -1
  49. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.js +106 -0
  50. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.js.map +1 -0
  51. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.js +136 -0
  52. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.js.map +1 -0
  53. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js +38 -20
  54. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js.map +1 -1
  55. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js +78 -44
  56. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js.map +1 -1
  57. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js +45 -37
  58. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js.map +1 -1
  59. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js +244 -95
  60. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js.map +1 -1
  61. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js +22 -0
  62. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js.map +1 -0
  63. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.js +13 -0
  64. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.js.map +1 -0
  65. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js +48 -43
  66. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js.map +1 -1
  67. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.js.map +1 -1
  68. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.js +57 -0
  69. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.js.map +1 -0
  70. package/dist/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.js.map +1 -1
  71. package/dist/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.js +83 -0
  72. package/dist/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.js.map +1 -0
  73. package/dist/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.js +84 -0
  74. package/dist/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.js.map +1 -0
  75. package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js.map +1 -1
  76. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js +109 -39
  77. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js.map +1 -1
  78. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js.map +1 -1
  79. package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js.map +1 -1
  80. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js.map +1 -1
  81. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/payScheduleSchema.js.map +1 -1
  82. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.js +78 -83
  83. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.js.map +1 -1
  84. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -4
  85. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  86. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -4
  87. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  88. package/dist/components/Company/StateTaxes/TaxRateManagement/context.js +3 -4
  89. package/dist/components/Company/StateTaxes/TaxRateManagement/context.js.map +1 -1
  90. package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js +5 -5
  91. package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js.map +1 -1
  92. package/dist/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.js +1 -1
  93. package/dist/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.js.map +1 -1
  94. package/dist/components/Contractor/Compensation/management/CompensationEditForm.js +45 -54
  95. package/dist/components/Contractor/Compensation/management/CompensationEditForm.js.map +1 -1
  96. package/dist/components/Contractor/Compensation/shared/useContractorCompensationSummary/useContractorCompensationSummary.js +4 -4
  97. package/dist/components/Contractor/Compensation/shared/useContractorCompensationSummary/useContractorCompensationSummary.js.map +1 -1
  98. package/dist/components/Contractor/Compensation/shared/useContractorPayForm/contractorPaySchema.js +17 -22
  99. package/dist/components/Contractor/Compensation/shared/useContractorPayForm/contractorPaySchema.js.map +1 -1
  100. package/dist/components/Contractor/Compensation/shared/useContractorPayForm/useContractorPayForm.js +3 -3
  101. package/dist/components/Contractor/Compensation/shared/useContractorPayForm/useContractorPayForm.js.map +1 -1
  102. package/dist/components/Contractor/ContractorList/management/ManagementContractorList.js +1 -0
  103. package/dist/components/Contractor/ContractorList/management/ManagementContractorList.js.map +1 -1
  104. package/dist/components/Contractor/ContractorList/management/ManagementContractorListView.js +122 -113
  105. package/dist/components/Contractor/ContractorList/management/ManagementContractorListView.js.map +1 -1
  106. package/dist/components/Contractor/ContractorList/shared/useContractorList.js +63 -54
  107. package/dist/components/Contractor/ContractorList/shared/useContractorList.js.map +1 -1
  108. package/dist/components/Contractor/Dashboard/Dashboard.js +20 -20
  109. package/dist/components/Contractor/Dashboard/Dashboard.js.map +1 -1
  110. package/dist/components/Contractor/Dismissal/useDismissal/useDismissal.js +10 -10
  111. package/dist/components/Contractor/Dismissal/useDismissal/useDismissal.js.map +1 -1
  112. package/dist/components/Contractor/Landing/Landing.js +43 -39
  113. package/dist/components/Contractor/Landing/Landing.js.map +1 -1
  114. package/dist/components/Contractor/NewHireReport/NewHireReport.js +3 -3
  115. package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
  116. package/dist/components/Contractor/PaymentMethod/onboarding/PaymentMethod.js +39 -48
  117. package/dist/components/Contractor/PaymentMethod/onboarding/PaymentMethod.js.map +1 -1
  118. package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js +1 -1
  119. package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js.map +1 -1
  120. package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js +10 -10
  121. package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -1
  122. package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js +4 -4
  123. package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js.map +1 -1
  124. package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js +8 -8
  125. package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js.map +1 -1
  126. package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js +5 -5
  127. package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js.map +1 -1
  128. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js +3 -3
  129. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js.map +1 -1
  130. package/dist/components/Contractor/Profile/onboarding/ContractorProfile.js +76 -69
  131. package/dist/components/Contractor/Profile/onboarding/ContractorProfile.js.map +1 -1
  132. package/dist/components/Contractor/Profile/onboarding/SelfOnboardingContractorProfile.js +1 -1
  133. package/dist/components/Contractor/Profile/onboarding/SelfOnboardingContractorProfile.js.map +1 -1
  134. package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/contractorDetailsSchema.js +27 -29
  135. package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/contractorDetailsSchema.js.map +1 -1
  136. package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js +15 -13
  137. package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js.map +1 -1
  138. package/dist/components/Contractor/Profile/shared/useContractorProfileSummary/useContractorProfileSummary.js +1 -1
  139. package/dist/components/Contractor/Profile/shared/useContractorProfileSummary/useContractorProfileSummary.js.map +1 -1
  140. package/dist/components/Contractor/SelfOnboardingFlow/SelfOnboardingComponents.js +2 -9
  141. package/dist/components/Contractor/SelfOnboardingFlow/SelfOnboardingComponents.js.map +1 -1
  142. package/dist/components/Contractor/Submit/Submit.js +18 -18
  143. package/dist/components/Contractor/Submit/Submit.js.map +1 -1
  144. package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js +6 -6
  145. package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js.map +1 -1
  146. package/dist/components/Contractor/shared/hourlyRate.js +14 -0
  147. package/dist/components/Contractor/shared/hourlyRate.js.map +1 -0
  148. package/dist/components/Employee/Compensation/management/CompensationCard/CompensationCard.js +63 -63
  149. package/dist/components/Employee/Compensation/management/CompensationCard/CompensationCard.js.map +1 -1
  150. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +25 -25
  151. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
  152. package/dist/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.js +15 -15
  153. package/dist/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.js.map +1 -1
  154. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +1 -1
  155. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
  156. package/dist/components/Employee/Dashboard/Dashboard.js +25 -25
  157. package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
  158. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -4
  159. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  160. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js +7 -7
  161. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js.map +1 -1
  162. package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js +1 -1
  163. package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js.map +1 -1
  164. package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js +6 -6
  165. package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js.map +1 -1
  166. package/dist/components/Employee/Landing/Landing.js +37 -33
  167. package/dist/components/Employee/Landing/Landing.js.map +1 -1
  168. package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js +27 -27
  169. package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js.map +1 -1
  170. package/dist/components/Employee/PaymentMethod/onboarding/ListView.js +65 -74
  171. package/dist/components/Employee/PaymentMethod/onboarding/ListView.js.map +1 -1
  172. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js +6 -6
  173. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js.map +1 -1
  174. package/dist/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.js +1 -1
  175. package/dist/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.js.map +1 -1
  176. package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.js +8 -15
  177. package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.js.map +1 -1
  178. package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js +11 -11
  179. package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js.map +1 -1
  180. package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js +12 -12
  181. package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js.map +1 -1
  182. package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js +26 -26
  183. package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js.map +1 -1
  184. package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js +16 -16
  185. package/dist/components/Payroll/Dismissal/DismissalPayPeriodSelection/DismissalPayPeriodSelection.js.map +1 -1
  186. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +2 -3
  187. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
  188. package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +84 -82
  189. package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
  190. package/dist/components/Payroll/OffCycleTaxWithholdingTable/getDefaultWithholdingPayPeriod.js +8 -0
  191. package/dist/components/Payroll/OffCycleTaxWithholdingTable/getDefaultWithholdingPayPeriod.js.map +1 -0
  192. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +97 -92
  193. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
  194. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +1 -1
  195. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
  196. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js +18 -18
  197. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
  198. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +146 -134
  199. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
  200. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.module.scss.js +14 -12
  201. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.module.scss.js.map +1 -1
  202. package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js +34 -33
  203. package/dist/components/Payroll/PayrollEditEmployee/TimeOffField.js.map +1 -1
  204. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.js +49 -48
  205. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.js.map +1 -1
  206. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js +1 -1
  207. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js.map +1 -1
  208. package/dist/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.js.map +1 -1
  209. package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js +0 -4
  210. package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js.map +1 -1
  211. package/dist/components/Payroll/PayrollFlow/PayrollFlow.js.map +1 -1
  212. package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.js +51 -38
  213. package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.js.map +1 -1
  214. package/dist/components/Payroll/PayrollFlow/payrollStateMachine.js +121 -102
  215. package/dist/components/Payroll/PayrollFlow/payrollStateMachine.js.map +1 -1
  216. package/dist/components/Payroll/PayrollHistory/PayrollHistory.js.map +1 -1
  217. package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +6 -6
  218. package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
  219. package/dist/components/Payroll/PayrollLanding/PayrollLanding.js.map +1 -1
  220. package/dist/components/Payroll/PayrollList/PayrollList.js +79 -74
  221. package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
  222. package/dist/components/Payroll/PayrollList/PayrollListPresentation.js +9 -9
  223. package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
  224. package/dist/components/Payroll/PayrollOverview/PayrollOverview.js +92 -83
  225. package/dist/components/Payroll/PayrollOverview/PayrollOverview.js.map +1 -1
  226. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
  227. package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js +23 -27
  228. package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js.map +1 -1
  229. package/dist/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.js +82 -75
  230. package/dist/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.js.map +1 -1
  231. package/dist/components/Payroll/RropPayrollEditEmployee/RropPayrollEditEmployee.js +416 -0
  232. package/dist/components/Payroll/RropPayrollEditEmployee/RropPayrollEditEmployee.js.map +1 -0
  233. package/dist/components/Payroll/{UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.module.scss.js → RropPayrollEditEmployee/RropPayrollEditEmployee.module.scss.js} +1 -1
  234. package/dist/components/Payroll/RropPayrollEditEmployee/RropPayrollEditEmployee.module.scss.js.map +1 -0
  235. package/dist/components/Payroll/TransitionConfiguration/TransitionConfiguration.js +97 -0
  236. package/dist/components/Payroll/TransitionConfiguration/TransitionConfiguration.js.map +1 -0
  237. package/dist/components/Payroll/TransitionConfiguration/TransitionConfigurationPresentation.js +106 -0
  238. package/dist/components/Payroll/TransitionConfiguration/TransitionConfigurationPresentation.js.map +1 -0
  239. package/dist/components/Payroll/{TransitionCreation/TransitionCreationPresentation.module.scss.js → TransitionConfiguration/TransitionConfigurationPresentation.module.scss.js} +1 -1
  240. package/dist/components/Payroll/TransitionConfiguration/TransitionConfigurationPresentation.module.scss.js.map +1 -0
  241. package/dist/components/Payroll/TransitionConfiguration/TransitionConfigurationTypes.js +10 -0
  242. package/dist/components/Payroll/TransitionConfiguration/TransitionConfigurationTypes.js.map +1 -0
  243. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js +86 -64
  244. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlert.js.map +1 -1
  245. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js +126 -77
  246. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.js.map +1 -1
  247. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.module.scss.js +8 -0
  248. package/dist/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.module.scss.js.map +1 -0
  249. package/dist/components/Payroll/helpers.js +1 -1
  250. package/dist/components/Payroll/helpers.js.map +1 -1
  251. package/dist/components/Payroll/index.js +16 -20
  252. package/dist/components/Payroll/index.js.map +1 -1
  253. package/dist/components/Payroll/payrollTypes.js +1 -1
  254. package/dist/components/Payroll/payrollTypes.js.map +1 -1
  255. package/dist/components/Payroll/usePreparedPayrollData.js +2 -3
  256. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  257. package/dist/components/Payroll/useUnprocessedTransitionPayPeriods.js +11 -14
  258. package/dist/components/Payroll/useUnprocessedTransitionPayPeriods.js.map +1 -1
  259. package/dist/contexts/ApiProvider/ApiProvider.js +18 -17
  260. package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
  261. package/dist/contexts/ApiProvider/payScheduleCustomNameHook.js +31 -0
  262. package/dist/contexts/ApiProvider/payScheduleCustomNameHook.js.map +1 -0
  263. package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js +1 -1
  264. package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js.map +1 -1
  265. package/dist/contexts/FeaturesProvider/FeaturesProvider.js +14 -0
  266. package/dist/contexts/FeaturesProvider/FeaturesProvider.js.map +1 -0
  267. package/dist/contexts/FeaturesProvider/useFeature.js +7 -0
  268. package/dist/contexts/FeaturesProvider/useFeature.js.map +1 -0
  269. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +32 -30
  270. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
  271. package/dist/contexts/UnstableFeaturesProvider/useUnstableFeature.js.map +1 -1
  272. package/dist/i18n/I18n.js +2 -3
  273. package/dist/i18n/I18n.js.map +1 -1
  274. package/dist/i18n/en/Company.Management.PaySchedule.json.js +31 -13
  275. package/dist/i18n/en/Company.Management.PaySchedule.json.js.map +1 -1
  276. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js +20 -12
  277. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js.map +1 -1
  278. package/dist/i18n/en/Contractor.Profile.json.js +1 -1
  279. package/dist/i18n/en/Payroll.PayrollEditEmployee.json.js +29 -23
  280. package/dist/i18n/en/Payroll.PayrollEditEmployee.json.js.map +1 -1
  281. package/dist/i18n/en/Payroll.PayrollHistory.json.js +1 -1
  282. package/dist/i18n/en/Payroll.PayrollLanding.json.js +1 -1
  283. package/dist/i18n/en/Payroll.PayrollList.json.js +5 -5
  284. package/dist/i18n/en/{Payroll.UNSTABLE_PayrollEditEmployee.json.js → Payroll.RropPayrollEditEmployee.json.js} +42 -38
  285. package/dist/i18n/en/Payroll.RropPayrollEditEmployee.json.js.map +1 -0
  286. package/dist/i18n/en/Payroll.TransitionConfiguration.json.js +28 -0
  287. package/dist/i18n/en/Payroll.TransitionConfiguration.json.js.map +1 -0
  288. package/dist/i18n/en/Payroll.TransitionPayrollAlert.json.js +16 -12
  289. package/dist/i18n/en/Payroll.TransitionPayrollAlert.json.js.map +1 -1
  290. package/dist/i18n/en/common.json.js +1 -1
  291. package/dist/package.json.js +1 -1
  292. package/dist/partner-hook-utils/form/composeSubmitHandler.js +55 -48
  293. package/dist/partner-hook-utils/form/composeSubmitHandler.js.map +1 -1
  294. package/dist/partner-hook-utils/form/fields/RadioGroupHookField.js +31 -29
  295. package/dist/partner-hook-utils/form/fields/RadioGroupHookField.js.map +1 -1
  296. package/dist/shared/constants.js +7 -6
  297. package/dist/shared/constants.js.map +1 -1
  298. package/dist/src/components/Common/DataView/DataCards/DataCards.d.ts +3 -1
  299. package/dist/src/components/Common/DataView/DataTable/DataTable.d.ts +3 -1
  300. package/dist/src/components/Common/DataView/DataView.d.ts +2 -0
  301. package/dist/src/components/Common/DataView/getSortControls.d.ts +24 -0
  302. package/dist/src/components/Common/DataView/useDataView.d.ts +22 -1
  303. package/dist/src/components/Common/DateRangeFilter/DateRangeFilter.d.ts +2 -2
  304. package/dist/src/components/Common/OnboardingStatusBadge/index.d.ts +1 -1
  305. package/dist/src/components/Common/UI/Table/TableTypes.d.ts +71 -2
  306. package/dist/src/components/Company/PaySchedule/PaySchedule.d.ts +1 -9
  307. package/dist/src/components/Company/PaySchedule/PayScheduleComponents.d.ts +0 -1
  308. package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.d.ts +1 -1
  309. package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.d.ts +1 -1
  310. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.d.ts +10 -3
  311. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.d.ts +21 -0
  312. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.d.ts +34 -0
  313. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.d.ts +9 -3
  314. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.d.ts +5 -1
  315. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.d.ts +10 -10
  316. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.d.ts +12 -4
  317. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.d.ts +19 -0
  318. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.d.ts +17 -0
  319. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.d.ts +1 -1
  320. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.d.ts +34 -0
  321. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/usePayScheduleAssignment.d.ts +16 -3
  322. package/dist/src/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.d.ts +1 -1
  323. package/dist/src/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.d.ts +23 -0
  324. package/dist/src/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.d.ts +25 -0
  325. package/dist/src/components/Company/PaySchedule/management/PayScheduleManagementComponents.d.ts +1 -1
  326. package/dist/src/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.d.ts +1 -1
  327. package/dist/src/components/Company/PaySchedule/shared/usePayScheduleForm/fields.d.ts +1 -1
  328. package/dist/src/components/Company/PaySchedule/shared/usePayScheduleForm/payScheduleSchema.d.ts +1 -1
  329. package/dist/src/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.d.ts +4 -15
  330. package/dist/src/components/Contractor/ContractorList/management/ManagementContractorListView.d.ts +2 -2
  331. package/dist/src/components/Contractor/ContractorList/shared/index.d.ts +1 -1
  332. package/dist/src/components/Contractor/ContractorList/shared/useContractorList.d.ts +38 -0
  333. package/dist/src/components/Contractor/Landing/Landing.d.ts +5 -2
  334. package/dist/src/components/Contractor/shared/hourlyRate.d.ts +23 -0
  335. package/dist/src/components/Employee/Landing/Landing.d.ts +5 -2
  336. package/dist/src/components/Payroll/OffCycleTaxWithholdingTable/getDefaultWithholdingPayPeriod.d.ts +9 -0
  337. package/dist/src/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.d.ts +1 -1
  338. package/dist/src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.d.ts +1 -1
  339. package/dist/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.d.ts +1 -1
  340. package/dist/src/components/Payroll/PayrollEditEmployee/TimeOffField.d.ts +3 -1
  341. package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.d.ts +2 -0
  342. package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.d.ts +2 -2
  343. package/dist/src/components/Payroll/PayrollExecutionFlow/PayrollExecutionFlow.d.ts +8 -6
  344. package/dist/src/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.d.ts +0 -8
  345. package/dist/src/components/Payroll/PayrollFlow/PayrollFlow.d.ts +5 -3
  346. package/dist/src/components/Payroll/PayrollFlow/PayrollFlowComponents.d.ts +2 -3
  347. package/dist/src/components/Payroll/PayrollFlow/payrollStateMachine.d.ts +1 -1
  348. package/dist/src/components/Payroll/PayrollHistory/PayrollHistoryPresentation.d.ts +1 -1
  349. package/dist/src/components/Payroll/PayrollLanding/PayrollLanding.d.ts +18 -5
  350. package/dist/src/components/Payroll/PayrollList/PayrollList.d.ts +11 -5
  351. package/dist/src/components/Payroll/PayrollList/PayrollListPresentation.d.ts +2 -2
  352. package/dist/src/components/Payroll/PayrollOverview/PayrollOverviewPresentation.d.ts +1 -1
  353. package/dist/src/components/Payroll/{UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.d.ts → RropPayrollEditEmployee/RropPayrollEditEmployee.d.ts} +9 -5
  354. package/dist/src/components/Payroll/TransitionConfiguration/TransitionConfiguration.d.ts +55 -0
  355. package/dist/src/components/Payroll/TransitionConfiguration/TransitionConfigurationPresentation.d.ts +9 -0
  356. package/dist/src/components/Payroll/TransitionConfiguration/TransitionConfigurationTypes.d.ts +52 -0
  357. package/dist/src/components/Payroll/TransitionConfiguration/index.d.ts +2 -0
  358. package/dist/src/components/Payroll/TransitionPayrollAlert/TransitionPayrollAlertPresentation.d.ts +5 -2
  359. package/dist/src/components/Payroll/helpers.d.ts +2 -2
  360. package/dist/src/components/Payroll/index.d.ts +2 -6
  361. package/dist/src/components/Payroll/usePreparedPayrollData.d.ts +2 -2
  362. package/dist/src/contexts/ApiProvider/payScheduleCustomNameHook.d.ts +14 -0
  363. package/dist/src/contexts/ApiProvider/payScheduleCustomNameHook.test.d.ts +1 -0
  364. package/dist/src/contexts/ComponentAdapter/componentAdapterTypes.d.ts +1 -1
  365. package/dist/src/contexts/FeaturesProvider/FeaturesProvider.d.ts +21 -0
  366. package/dist/src/contexts/FeaturesProvider/useFeature.d.ts +53 -0
  367. package/dist/src/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +3 -0
  368. package/dist/src/contexts/UnstableFeaturesProvider/useUnstableFeature.d.ts +38 -10
  369. package/dist/src/contexts/index.d.ts +1 -0
  370. package/dist/src/i18n/en/common.json.d.ts +5 -1
  371. package/dist/src/i18n/types.d.ts +195 -70
  372. package/dist/src/models/external.d.ts +63 -48
  373. package/dist/src/partner-hook-utils/form/fields/RadioGroupHookField.d.ts +9 -7
  374. package/dist/src/shared/constants.d.ts +5 -3
  375. package/dist/src/test-utils/renderWithProviders.d.ts +2 -0
  376. package/dist/style.css +1 -1
  377. package/docs/guides/endpoint-inventory.json +57 -40
  378. package/package.json +23 -22
  379. package/dist/components/Payroll/PayrollFlow/TransitionFlowContextual.js +0 -29
  380. package/dist/components/Payroll/PayrollFlow/TransitionFlowContextual.js.map +0 -1
  381. package/dist/components/Payroll/Transition/TransitionFlow.js +0 -60
  382. package/dist/components/Payroll/Transition/TransitionFlow.js.map +0 -1
  383. package/dist/components/Payroll/Transition/TransitionFlowComponents.js +0 -31
  384. package/dist/components/Payroll/Transition/TransitionFlowComponents.js.map +0 -1
  385. package/dist/components/Payroll/Transition/transitionStateMachine.js +0 -49
  386. package/dist/components/Payroll/Transition/transitionStateMachine.js.map +0 -1
  387. package/dist/components/Payroll/TransitionCreation/TransitionCreation.js +0 -100
  388. package/dist/components/Payroll/TransitionCreation/TransitionCreation.js.map +0 -1
  389. package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.js +0 -110
  390. package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.js.map +0 -1
  391. package/dist/components/Payroll/TransitionCreation/TransitionCreationPresentation.module.scss.js.map +0 -1
  392. package/dist/components/Payroll/TransitionCreation/TransitionCreationTypes.js +0 -21
  393. package/dist/components/Payroll/TransitionCreation/TransitionCreationTypes.js.map +0 -1
  394. package/dist/components/Payroll/TransitionPayroll/TransitionPayroll.js +0 -48
  395. package/dist/components/Payroll/TransitionPayroll/TransitionPayroll.js.map +0 -1
  396. package/dist/components/Payroll/TransitionPayroll/TransitionPayrollComponents.js +0 -35
  397. package/dist/components/Payroll/TransitionPayroll/TransitionPayrollComponents.js.map +0 -1
  398. package/dist/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.js +0 -23
  399. package/dist/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.js.map +0 -1
  400. package/dist/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.js +0 -29
  401. package/dist/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.js.map +0 -1
  402. package/dist/components/Payroll/UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.js +0 -411
  403. package/dist/components/Payroll/UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.js.map +0 -1
  404. package/dist/components/Payroll/UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee.module.scss.js.map +0 -1
  405. package/dist/i18n/en/Payroll.Transition.json.js +0 -8
  406. package/dist/i18n/en/Payroll.Transition.json.js.map +0 -1
  407. package/dist/i18n/en/Payroll.TransitionCreation.json.js +0 -26
  408. package/dist/i18n/en/Payroll.TransitionCreation.json.js.map +0 -1
  409. package/dist/i18n/en/Payroll.UNSTABLE_PayrollEditEmployee.json.js.map +0 -1
  410. package/dist/src/components/Payroll/PayrollFlow/TransitionFlowContextual.d.ts +0 -7
  411. package/dist/src/components/Payroll/Transition/TransitionFlow.d.ts +0 -55
  412. package/dist/src/components/Payroll/Transition/TransitionFlowComponents.d.ts +0 -52
  413. package/dist/src/components/Payroll/Transition/index.d.ts +0 -2
  414. package/dist/src/components/Payroll/Transition/transitionStateMachine.d.ts +0 -29
  415. package/dist/src/components/Payroll/TransitionCreation/TransitionCreation.d.ts +0 -22
  416. package/dist/src/components/Payroll/TransitionCreation/TransitionCreationPresentation.d.ts +0 -9
  417. package/dist/src/components/Payroll/TransitionCreation/TransitionCreationTypes.d.ts +0 -57
  418. package/dist/src/components/Payroll/TransitionCreation/index.d.ts +0 -2
  419. package/dist/src/components/Payroll/TransitionPayroll/TransitionPayroll.d.ts +0 -55
  420. package/dist/src/components/Payroll/TransitionPayroll/TransitionPayrollComponents.d.ts +0 -24
  421. package/dist/src/components/Payroll/TransitionPayroll/TransitionPayrollTypes.d.ts +0 -23
  422. package/dist/src/components/Payroll/TransitionPayroll/index.d.ts +0 -2
  423. package/dist/src/components/Payroll/TransitionPayroll/transitionPayrollStateMachine.d.ts +0 -15
  424. package/dist/src/components/Payroll/TransitionPayroll/useResolveTransitionPayroll.d.ts +0 -28
  425. /package/dist/src/components/{Payroll/Transition/transitionStateMachine.test.d.ts → Common/DataView/getSortControls.test.d.ts} +0 -0
@@ -1,17 +1,17 @@
1
1
  import { jsx as E } from "react/jsx-runtime";
2
- import { MAX_HOURS as D, MAX_REIMBURSEMENT_AMOUNT as R } from "./payrollEditEmployeeSchema.js";
2
+ import { MAX_HOURS as g, MAX_REIMBURSEMENT_AMOUNT as v } from "./payrollEditEmployeeSchema.js";
3
3
  import { TextInputField as j } from "../../../../Common/Fields/TextInputField/TextInputField.js";
4
- import { useFieldErrorMessage as I } from "../../../../../partner-hook-utils/form/useFieldErrorMessage.js";
5
- import { PayrollCategory as P } from "../../../payrollTypes.js";
6
- import { COMPENSATION_NAME_OVERTIME as _, COMPENSATION_NAME_DOUBLE_OVERTIME as v } from "../../../../../shared/constants.js";
7
- import { stripLeadingZeros as S } from "../../../../../helpers/formattedStrings.js";
8
- import { RadioGroupHookField as x } from "../../../../../partner-hook-utils/form/fields/RadioGroupHookField.js";
4
+ import { useFieldErrorMessage as D } from "../../../../../partner-hook-utils/form/useFieldErrorMessage.js";
5
+ import { PayrollCategory as I } from "../../../payrollTypes.js";
6
+ import { COMPENSATION_NAME_OVERTIME as P, COMPENSATION_NAME_DOUBLE_OVERTIME as _ } from "../../../../../shared/constants.js";
7
+ import { stripLeadingZeros as H } from "../../../../../helpers/formattedStrings.js";
8
+ import { RadioGroupHookField as S } from "../../../../../partner-hook-utils/form/fields/RadioGroupHookField.js";
9
9
  function J(t) {
10
10
  return !Array.isArray(t);
11
11
  }
12
- function d(t, o, r) {
12
+ function f(t, o, r) {
13
13
  return function(l) {
14
- const m = I(
14
+ const a = D(
15
15
  t,
16
16
  o
17
17
  );
@@ -23,53 +23,53 @@ function d(t, o, r) {
23
23
  type: "number",
24
24
  min: 0,
25
25
  max: r,
26
- transform: S,
27
- errorMessage: m
26
+ transform: H,
27
+ errorMessage: a
28
28
  }
29
29
  );
30
30
  };
31
31
  }
32
- function C() {
32
+ function x() {
33
33
  return function(o) {
34
- return /* @__PURE__ */ E(x, { ...o, name: "paymentMethod" });
34
+ return /* @__PURE__ */ E(S, { ...o, name: "paymentMethod" });
35
35
  };
36
36
  }
37
- function k(t) {
37
+ function C(t) {
38
38
  return function(r) {
39
39
  return /* @__PURE__ */ E(j, { ...r, name: t });
40
40
  };
41
41
  }
42
42
  function K(t) {
43
43
  return {
44
- Description: k("reimbursementDraft.description"),
45
- Amount: d("reimbursementDraft.amount", t, R)
44
+ Description: C("reimbursementDraft.description"),
45
+ Amount: f("reimbursementDraft.amount", t, v)
46
46
  };
47
47
  }
48
- function H(t, o) {
48
+ function k(t, o) {
49
49
  return t == null ? null : parseFloat(t) - (parseFloat(o ?? "") || 0);
50
50
  }
51
- function U(t, o, r, s, l, m) {
52
- const f = t.filter(
51
+ function U(t, o, r, s, l, a) {
52
+ const d = t.filter(
53
53
  (n) => !!n.jobUuid && !!n.name
54
- ), a = (n, i, u) => ({
54
+ ), m = (n, i, u) => ({
55
55
  key: u ? `${n.jobUuid}:${n.name}:${i}` : `${n.jobUuid}:${n.name}`,
56
56
  jobUuid: n.jobUuid,
57
57
  name: n.name,
58
58
  ...u ? { workweekStart: i } : {},
59
- Field: d(
59
+ Field: f(
60
60
  `${r}.${n.jobUuid}.${n.name}.${i}`,
61
- m,
62
- r === "hours" ? D : void 0
61
+ a,
62
+ r === "hours" ? g : void 0
63
63
  )
64
64
  });
65
65
  if (o.length > 1 && s && l) {
66
66
  const n = {};
67
67
  for (const i of o)
68
- n[i.startDate] = f.map((u) => a(u, i.startDate, !0));
68
+ n[i.startDate] = d.map((u) => m(u, i.startDate, !0));
69
69
  return n;
70
70
  }
71
71
  const c = o[0]?.startDate ?? "";
72
- return f.map((n) => a(n, c, !1));
72
+ return d.map((n) => m(n, c, !1));
73
73
  }
74
74
  function Q({
75
75
  employeeCompensation: t,
@@ -77,33 +77,33 @@ function Q({
77
77
  workweeks: r,
78
78
  payrollCategory: s,
79
79
  hasDirectDepositSetup: l,
80
- overtimeEarningNames: m,
81
- isOvertimeEligible: f,
82
- withOvertime: a,
80
+ overtimeEarningNames: a,
81
+ isOvertimeEligible: d,
82
+ withOvertime: m,
83
83
  jobTitlesByUuid: c,
84
84
  timeOffAccrualByName: n,
85
85
  errorMessages: i
86
86
  }) {
87
87
  const u = t?.hourlyCompensations ?? [], y = o.filter(
88
- (e) => e.name != null && m.has(e.name)
88
+ (e) => e.name != null && a.has(e.name)
89
89
  ), O = o.filter(
90
- (e) => e.name == null || !m.has(e.name)
90
+ (e) => e.name == null || !a.has(e.name)
91
91
  ), p = [];
92
92
  for (const e of [...u, ...y])
93
93
  e.jobUuid && !p.includes(e.jobUuid) && p.push(e.jobUuid);
94
- const M = (e) => e === _ || e === v, h = p.map((e) => {
94
+ const M = (e) => e === P || e === _, h = p.map((e) => {
95
95
  const $ = u.filter(
96
96
  (b) => b.jobUuid === e
97
- ), g = a ? $ : $.filter((b) => !M(b.name));
97
+ ), B = m ? $ : $.filter((b) => !M(b.name));
98
98
  return {
99
99
  jobUuid: e,
100
100
  title: c.get(e),
101
101
  hours: U(
102
- g,
102
+ B,
103
103
  r,
104
104
  "hours",
105
- f,
106
- a,
105
+ d,
106
+ m,
107
107
  i
108
108
  )
109
109
  };
@@ -111,41 +111,42 @@ function Q({
111
111
  y,
112
112
  r,
113
113
  "overtimeIncludedEarnings",
114
- f,
115
- a,
114
+ d,
115
+ m,
116
116
  i
117
- ), T = O.filter(
117
+ ), N = O.filter(
118
118
  (e) => !!e.jobUuid && !!e.name
119
119
  ).map((e) => ({
120
120
  key: `${e.jobUuid}:${e.name}`,
121
121
  id: e.name,
122
- Field: d(
122
+ Field: f(
123
123
  `overtimeExcludedEarnings.${e.jobUuid}.${e.name}`,
124
124
  i
125
125
  )
126
- })), F = (t?.paidTimeOff ?? []).filter((e) => e.name), B = F.map((e) => ({
126
+ })), F = (t?.paidTimeOff ?? []).filter((e) => e.name), R = F.map((e) => ({
127
127
  key: `timeOff:${e.name}`,
128
128
  name: e.name,
129
- Field: d(`timeOff.${e.name}`, i),
129
+ Field: f(`timeOff.${e.name}`, i),
130
130
  // Seeded from the initial entered hours; the hook recomputes it live.
131
- remaining: H(n.get(e.name), e.hours)
132
- })), N = s === P.Dismissal ? F.map((e) => ({
131
+ remaining: k(n.get(e.name), e.hours),
132
+ approvedRequestHours: Number(e.approvedRequestHours || 0)
133
+ })), T = s === I.Dismissal ? F.map((e) => ({
133
134
  key: `finalPayout:${e.name}`,
134
135
  name: e.name,
135
- Field: d(`finalPayout.${e.name}`, i),
136
+ Field: f(`finalPayout.${e.name}`, i),
136
137
  remaining: null
137
138
  })) : void 0;
138
139
  return {
139
140
  jobs: h,
140
141
  overtimeIncludedEarnings: A,
141
- overtimeExcludedEarnings: T,
142
- timeOff: B,
143
- finalPayout: N,
144
- paymentMethod: l ? C() : void 0
142
+ overtimeExcludedEarnings: N,
143
+ timeOff: R,
144
+ finalPayout: T,
145
+ paymentMethod: l ? x() : void 0
145
146
  };
146
147
  }
147
148
  export {
148
- H as computeTimeOffRemaining,
149
+ k as computeTimeOffRemaining,
149
150
  Q as createPayrollEditEmployeeFields,
150
151
  K as createReimbursementDraftFields,
151
152
  J as isSplitByWorkweek
@@ -1 +1 @@
1
- {"version":3,"file":"fields.js","sources":["../../../../../../src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollUpdatePaymentMethod } from '@gusto/embedded-api/models/components/payrollupdate'\nimport type { NormalizedWorkweek } from './payrollEditEmployeeHelpers'\nimport {\n MAX_HOURS,\n MAX_REIMBURSEMENT_AMOUNT,\n type PayrollEditEmployeeErrorCode,\n} from './payrollEditEmployeeSchema'\nimport { TextInputField } from '@/components/Common/Fields/TextInputField/TextInputField'\nimport { useFieldErrorMessage } from '@/partner-hook-utils/form/useFieldErrorMessage'\nimport { RadioGroupHookField } from '@/partner-hook-utils/form/fields'\nimport type { RadioGroupHookFieldProps } from '@/partner-hook-utils/form/fields/RadioGroupHookField'\nimport type { HookFieldProps, ValidationMessages } from '@/partner-hook-utils/types'\nimport type { TextInputProps } from '@/components/Common/UI/TextInput/TextInputTypes'\nimport { PayrollCategory } from '@/components/Payroll/payrollTypes'\nimport { COMPENSATION_NAME_DOUBLE_OVERTIME, COMPENSATION_NAME_OVERTIME } from '@/shared/constants'\nimport { stripLeadingZeros } from '@/helpers/formattedStrings'\n\n/**\n * Display copy for each validation error code a bound field can surface, so the\n * consumer supplies error text once (keyed by code) rather than reconstructing\n * form paths or hardcoding which rule each field can fail. Partial: a missing\n * code falls back to the raw error code.\n *\n * @public\n */\nexport type PayrollEditEmployeeErrorMessages = Partial<Record<PayrollEditEmployeeErrorCode, string>>\n\n/**\n * Presentation props accepted by a bound numeric field in the payroll editor.\n *\n * @remarks\n * The hook binds the react-hook-form `name`, forces `type=\"number\"`, and\n * resolves the field's own validation message internally; the UI supplies copy\n * and layout props (label, adornments, `shouldVisuallyHideLabel`, required\n * state, `description`).\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldProps = Omit<\n TextInputProps,\n 'name' | 'value' | 'onChange' | 'isInvalid' | 'type' | 'min' | 'errorMessage'\n>\n\n/**\n * A numeric field component pre-bound by the hook to a specific form path.\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldComponent = ComponentType<PayrollEditEmployeeFieldProps>\n\n/**\n * Presentation props accepted by the bound payment-method field.\n *\n * @remarks\n * The hook binds the `name` and publishes the option values on\n * `fieldsMetadata.paymentMethod`; the UI passes `getOptionLabel` to translate\n * each {@link PayrollUpdatePaymentMethod} value, rather than passing `options`.\n *\n * @public\n */\nexport type PayrollEditEmployeePaymentMethodFieldProps = HookFieldProps<\n RadioGroupHookFieldProps<never, PayrollUpdatePaymentMethod>\n>\n\n/**\n * The payment-method radio field component pre-bound by the hook.\n *\n * @public\n */\nexport type PayrollEditEmployeePaymentMethodField =\n ComponentType<PayrollEditEmployeePaymentMethodFieldProps>\n\n/**\n * One hours input within the hours section.\n *\n * @remarks\n * `key` is an opaque, stable React key. `jobUuid`, `name`, and (when the pay\n * period is multi-workweek) `workweekStart` are reach-in handles the UI uses to\n * group and label entries. When the section is a flat array, `workweekStart` is\n * omitted (single-workweek degenerate case); when it is a `Record` keyed by\n * workweek start, each entry carries its `workweekStart`.\n *\n * @public\n */\nexport interface HourEntry {\n /** Opaque, stable React key. */\n key: string\n /** The job this hours line belongs to. */\n jobUuid: string\n /** The compensation name (e.g. the API hours-compensation name). */\n name: string\n /** The workweek start date (`YYYY-MM-DD`) when the section is workweek-keyed. */\n workweekStart?: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * One earning input, used by the additional-earnings section.\n *\n * @remarks\n * Same shape as {@link HourEntry}. Whether an earning feeds the overtime\n * (regular rate of pay) calculation is decided by the hook, which sorts it into\n * the workweek-breakdown additional-earnings section or the flat other\n * section. The UI just renders whichever section an entry appears in.\n *\n * @public\n */\nexport type EarningEntry = HourEntry\n\n/**\n * One time-off or final-payout input.\n *\n * @remarks\n * Time off is never workweek-breakdown, so this section is always a flat array.\n *\n * @public\n */\nexport interface TimeOffEntry {\n /** Opaque, stable React key. */\n key: string\n /** The time-off policy compensation name. */\n name: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n /**\n * The policy's remaining balance after the entered hours are subtracted,\n * recomputed live as the user edits. `null` when the policy has no tracked\n * accrual balance (e.g. final-payout rows). Feed it into the field's own\n * `description` to render it as the input's help text.\n */\n remaining: number | null\n}\n\n/**\n * One entry in the flat `overtimeExcludedEarnings` section.\n *\n * @remarks\n * Intentionally opaque: `overtimeExcludedEarnings` collects earnings that are not overtime-affecting\n * and whose input type the partner does not need to reason about. Render each\n * entry's `Field` keyed by `key`; use `id` as a reach-in handle for labeling.\n *\n * @public\n */\nexport interface OtherEntry {\n /** Opaque, stable React key. */\n key: string\n /** Reach-in handle identifying the underlying earning (its compensation name). */\n id: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * A single job's hours section.\n *\n * @remarks\n * An employee can hold multiple jobs, each with its own hourly lines. `hours` is\n * either a flat `Entry[]` (single-workweek, or an overtime-ineligible employee)\n * OR a `Record<workweekStart, Entry[]>` (multi-workweek and overtime-eligible).\n * The value type is the signal — array is flat, object is split by workweek; use\n * {@link isSplitByWorkweek} to discriminate. `title` is the job's display title\n * (entity data, not copy) for rendering a per-job heading. Earnings are not\n * job-scoped: they live in the employee-level `overtimeIncludedEarnings` and\n * `overtimeExcludedEarnings` sections on {@link PayrollEditEmployeeFields}.\n *\n * @public\n */\nexport interface JobFields {\n /** The job identifier. */\n jobUuid: string\n /** The job's display title, when available, for a per-job heading. */\n title?: string\n /**\n * Hours inputs for this job. Excludes Overtime/Double-overtime rows while\n * `data.withOvertime` is `false`.\n */\n hours: HourEntry[] | Record<string, HourEntry[]>\n}\n\n/**\n * Presentation props accepted by a bound reimbursement description (text) field.\n *\n * @remarks\n * The hook binds the react-hook-form `name` internally; the UI supplies copy and\n * layout props (label, placeholder, `shouldVisuallyHideLabel`).\n *\n * @public\n */\nexport type ReimbursementDescriptionFieldProps = Omit<\n TextInputProps,\n 'name' | 'value' | 'onChange' | 'isInvalid' | 'type'\n>\n\n/**\n * The draft \"add reimbursement\" field group exposed on\n * `form.Fields.reimbursementDraft`.\n *\n * @remarks\n * A single in-progress row the UI reveals when the user starts adding a\n * reimbursement. `Description` and `Amount` bind to `reimbursementDraft.description`\n * / `reimbursementDraft.amount`. The UI shows them while `form.reimbursementDraft.isAdding`\n * is `true`, then calls `actions.saveReimbursement` (commits to the list) or\n * `actions.cancelReimbursement` (discards). Committed rows are rendered from\n * `data.reimbursements`, not from bound fields.\n *\n * @public\n */\nexport interface ReimbursementDraftFields {\n /** Description field pre-bound to the draft's form path. */\n Description: ComponentType<ReimbursementDescriptionFieldProps>\n /** Amount field pre-bound to the draft's form path. */\n Amount: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * A committed reimbursement row for display in the consumer's table.\n *\n * @remarks\n * Exposed on `data.reimbursements`, seeded from the employee's existing\n * reimbursements and appended to as the user saves drafts. Display-only: the UI\n * renders `description`, `amount`, and the recurring/one-time `type`, plus a\n * remove control wired to `actions.removeReimbursement(index)`. `index` is the\n * row's position in the underlying form array (the removal handle); `uuid` is\n * present for rows that already exist server-side.\n *\n * @public\n */\nexport interface ReimbursementRow {\n /** Opaque, stable React key. */\n key: string\n /** The row's index in the reimbursements form array; pass to `removeReimbursement`. */\n index: number\n /** The reimbursement's server UUID, when it already exists. */\n uuid?: string\n /** The reimbursement description (may be blank; the UI supplies a fallback). */\n description: string\n /** The reimbursement amount as a decimal string. */\n amount: string\n /** Whether this reimbursement recurs. Recurring rows are managed outside payroll. */\n recurring: boolean\n}\n\n/**\n * The render-ready field collections exposed on `form.Fields`.\n *\n * @remarks\n * Hours are grouped under `jobs`, one entry per job, so multi-job employees\n * render correctly. All earnings and the remaining sections are employee-scoped\n * and stay top-level: `overtimeIncludedEarnings` (overtime-affecting) and\n * `overtimeExcludedEarnings` (non-overtime) each render as a single section spanning every\n * job, alongside time off, final payout, payment method, and reimbursements.\n *\n * @public\n */\nexport interface PayrollEditEmployeeFields {\n /** Per-job hours sections; one entry per job. */\n jobs: JobFields[]\n /**\n * Overtime-affecting earnings across all jobs, as a single employee-level\n * section. Flat `Entry[]` when unsplit, or `Record<workweekStart, Entry[]>`\n * when split by workweek; use {@link isSplitByWorkweek} to discriminate.\n */\n overtimeIncludedEarnings: EarningEntry[] | Record<string, EarningEntry[]>\n /** Non-overtime earnings (e.g. tips), always flat; opaque render entries. */\n overtimeExcludedEarnings: OtherEntry[]\n /** Time-off inputs (never workweek-breakdown). */\n timeOff: TimeOffEntry[]\n /** Final-payout inputs, present only for dismissal payrolls. */\n finalPayout?: TimeOffEntry[]\n /** Payment-method selector, present only when the employee has direct deposit set up. */\n paymentMethod?: PayrollEditEmployeePaymentMethodField\n /**\n * The draft \"add reimbursement\" field group, present only for itemized\n * (non-off-cycle) payrolls. Render while `form.reimbursementDraft.isAdding` is\n * `true`; committed rows come from `data.reimbursements`.\n */\n reimbursementDraft?: ReimbursementDraftFields\n}\n\n/**\n * Discriminates a workweek-breakdown section: `false` for the flat\n * (single-workweek) `Entry[]` form, `true` for the workweek-keyed\n * `Record<workweekStart, Entry[]>` form.\n *\n * @typeParam TEntry - The section's entry type.\n * @param section - A `form.Fields` section that may be flat or workweek-keyed.\n * @returns `true` when the section is keyed by workweek start date.\n * @public\n */\nexport function isSplitByWorkweek<TEntry>(\n section: TEntry[] | Record<string, TEntry[]>,\n): section is Record<string, TEntry[]> {\n return !Array.isArray(section)\n}\n\n// ── Bound field factories ──────────────────────────────────────────────\n\nfunction createNumberField(\n name: string,\n errorMessages?: PayrollEditEmployeeErrorMessages,\n max?: number,\n): PayrollEditEmployeeFieldComponent {\n return function BoundNumberField(props: PayrollEditEmployeeFieldProps) {\n // The field resolves its own validation copy from its bound path, so the\n // consumer supplies error copy once (keyed by code) and never reconstructs\n // form paths or guesses which rule a field can fail. name, type, min, max,\n // transform, and errorMessage are applied after the spread so callers can't\n // override the binding or the numeric contract via custom props.\n const errorMessage = useFieldErrorMessage(\n name,\n errorMessages as ValidationMessages<PayrollEditEmployeeErrorCode> | undefined,\n )\n return (\n <TextInputField\n {...props}\n name={name}\n type=\"number\"\n min={0}\n max={max}\n transform={stripLeadingZeros}\n errorMessage={errorMessage}\n />\n )\n }\n}\n\nfunction createPaymentMethodField(): PayrollEditEmployeePaymentMethodField {\n return function BoundPaymentMethodField(props: PayrollEditEmployeePaymentMethodFieldProps) {\n return (\n <RadioGroupHookField<never, PayrollUpdatePaymentMethod> {...props} name=\"paymentMethod\" />\n )\n }\n}\n\nfunction createTextField(name: string): ComponentType<ReimbursementDescriptionFieldProps> {\n return function BoundTextField(props: ReimbursementDescriptionFieldProps) {\n return <TextInputField {...props} name={name} />\n }\n}\n\n/**\n * Builds the draft \"add reimbursement\" field group, binding its Description and\n * Amount fields to the `reimbursementDraft` form path.\n *\n * @param errorMessages - Copy for each validation error code, baked into the amount field so it self-resolves.\n * @returns The pre-bound draft field group for `form.Fields.reimbursementDraft`.\n * @internal\n */\nexport function createReimbursementDraftFields(\n errorMessages?: PayrollEditEmployeeErrorMessages,\n): ReimbursementDraftFields {\n return {\n Description: createTextField('reimbursementDraft.description'),\n Amount: createNumberField('reimbursementDraft.amount', errorMessages, MAX_REIMBURSEMENT_AMOUNT),\n }\n}\n\n// ── Builders ───────────────────────────────────────────────────────────\n\n/** @internal */\nexport interface CreatePayrollEditEmployeeFieldsOptions {\n employeeCompensation: PayrollEmployeeCompensationsType | undefined\n /**\n * Fixed compensations to render, already merged with blank placeholders for\n * every company earning type (see `resolveEditableFixedCompensations`).\n */\n fixedCompensations: NonNullable<PayrollEmployeeCompensationsType['fixedCompensations']>\n workweeks: NormalizedWorkweek[]\n payrollCategory: PayrollCategory\n hasDirectDepositSetup: boolean\n /** Names of earning types included in the regular-rate-of-pay overtime calculation. */\n overtimeEarningNames: Set<string>\n /** Whether the employee is overtime-eligible (nonexempt family). Gates per-workweek splitting. */\n isOvertimeEligible: boolean\n /**\n * Gates per-workweek splitting\n * alongside `isOvertimeEligible`, and whether Overtime/Double-overtime rows\n * are included in `hours`.\n */\n withOvertime: boolean\n /** Job title lookup by job UUID, for per-job section headings. */\n jobTitlesByUuid: Map<string, string>\n /** Accrual balance by time-off policy name, for the remaining-balance display. */\n timeOffAccrualByName: Map<string, string>\n /** Copy for each validation error code, baked into every bound field so it self-resolves. */\n errorMessages?: PayrollEditEmployeeErrorMessages\n}\n\n/**\n * A time-off policy's remaining balance: its accrual balance minus the entered\n * hours. `null` when the policy has no tracked accrual balance (final-payout\n * rows). Shared by the field builder (seeding the initial value) and the hook\n * (recomputing it live as the user edits).\n *\n * @param accrualBalance - The policy's accrual balance, or `undefined` when untracked.\n * @param enteredHours - The currently entered hours for the policy.\n * @returns The remaining balance, or `null` when untracked.\n * @internal\n */\nexport function computeTimeOffRemaining(\n accrualBalance: string | undefined,\n enteredHours: string | null | undefined,\n): number | null {\n if (accrualBalance == null) return null\n return parseFloat(accrualBalance) - (parseFloat(enteredHours ?? '') || 0)\n}\n\nfunction buildBreakdownSection(\n compensations: Array<{ jobUuid?: string; name?: string }>,\n workweeks: NormalizedWorkweek[],\n pathPrefix: 'hours' | 'overtimeIncludedEarnings',\n isOvertimeEligible: boolean,\n withOvertime: boolean,\n errorMessages: PayrollEditEmployeeErrorMessages | undefined,\n): HourEntry[] | Record<string, HourEntry[]> {\n const rows = compensations.filter(\n (compensation): compensation is { jobUuid: string; name: string } =>\n Boolean(compensation.jobUuid) && Boolean(compensation.name),\n )\n\n const toEntry = (\n row: { jobUuid: string; name: string },\n weekStart: string,\n includeWorkweek: boolean,\n ): HourEntry => ({\n key: includeWorkweek ? `${row.jobUuid}:${row.name}:${weekStart}` : `${row.jobUuid}:${row.name}`,\n jobUuid: row.jobUuid,\n name: row.name,\n ...(includeWorkweek ? { workweekStart: weekStart } : {}),\n Field: createNumberField(\n `${pathPrefix}.${row.jobUuid}.${row.name}.${weekStart}`,\n errorMessages,\n pathPrefix === 'hours' ? MAX_HOURS : undefined,\n ),\n })\n\n // Split into per-workweek columns only for overtime-eligible employees while\n // `withOvertime` is on; workweek breakdowns exist solely to compute overtime\n // premiums, so an ineligible employee renders flat even on a multi-workweek\n // payroll, and an eligible one stays flat until `withOvertime` is set.\n if (workweeks.length > 1 && isOvertimeEligible && withOvertime) {\n const byWeek: Record<string, HourEntry[]> = {}\n for (const workweek of workweeks) {\n byWeek[workweek.startDate] = rows.map(row => toEntry(row, workweek.startDate, true))\n }\n return byWeek\n }\n\n const weekStart = workweeks[0]?.startDate ?? ''\n return rows.map(row => toEntry(row, weekStart, false))\n}\n\n/**\n * Builds the render-ready {@link PayrollEditEmployeeFields} from the prepared\n * compensation.\n *\n * @remarks\n * Hours and overtime-affecting earnings are grouped per job into `jobs` (a job\n * appears if it has hourly lines or overtime-affecting earnings). Fixed\n * compensations are split by whether their earning type is included in the\n * regular-rate-of-pay overtime calculation (`overtimeEarningNames`): included\n * earnings become each job's additional earnings, the rest become the flat,\n * employee-level `overtimeExcludedEarnings` section. Time off comes from the paid-time-off list,\n * final payout is added only for dismissal payrolls, and the payment-method\n * selector appears only when direct deposit is set up.\n *\n * @param options - The prepared compensation, normalized workweeks, payroll category, direct-deposit flag, overtime earning names, eligibility, the `withOvertime` flag, job titles, time-off accrual balances and entered values, and error copy.\n * @returns The populated field collections.\n * @internal\n */\nexport function createPayrollEditEmployeeFields({\n employeeCompensation,\n fixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n}: CreatePayrollEditEmployeeFieldsOptions): PayrollEditEmployeeFields {\n const hourlyCompensations = employeeCompensation?.hourlyCompensations ?? []\n const overtimeAffecting = fixedCompensations.filter(\n compensation => compensation.name != null && overtimeEarningNames.has(compensation.name),\n )\n const nonOvertime = fixedCompensations.filter(\n compensation => compensation.name == null || !overtimeEarningNames.has(compensation.name),\n )\n\n // A job appears if it has hourly lines or overtime-affecting earnings, in first\n // appearance order across those two sources.\n const jobUuids: string[] = []\n for (const compensation of [...hourlyCompensations, ...overtimeAffecting]) {\n if (compensation.jobUuid && !jobUuids.includes(compensation.jobUuid)) {\n jobUuids.push(compensation.jobUuid)\n }\n }\n\n const isOvertimeName = (name: string | null | undefined) =>\n name === COMPENSATION_NAME_OVERTIME || name === COMPENSATION_NAME_DOUBLE_OVERTIME\n\n const jobs: JobFields[] = jobUuids.map(jobUuid => {\n const jobHourlyCompensations = hourlyCompensations.filter(\n compensation => compensation.jobUuid === jobUuid,\n )\n // Overtime/Double-overtime rows stay out of `hours` entirely while\n // `withOvertime` is off — their underlying form values are untouched\n // (still whatever the prepared compensation carried), so hiding the row\n // can't lose or corrupt data. Driven by the single, employee-level flag —\n // no per-job hidden state.\n const visibleHourlyCompensations = withOvertime\n ? jobHourlyCompensations\n : jobHourlyCompensations.filter(compensation => !isOvertimeName(compensation.name))\n\n return {\n jobUuid,\n title: jobTitlesByUuid.get(jobUuid),\n hours: buildBreakdownSection(\n visibleHourlyCompensations,\n workweeks,\n 'hours',\n isOvertimeEligible,\n withOvertime,\n errorMessages,\n ),\n }\n })\n\n // Overtime-affecting earnings render as one employee-level section spanning\n // every job. Each entry keeps its per-job form path\n // (`overtimeIncludedEarnings.<jobUuid>.<name>`), so the flat section still binds and\n // submits per job.\n const overtimeIncludedEarnings = buildBreakdownSection(\n overtimeAffecting,\n workweeks,\n 'overtimeIncludedEarnings',\n isOvertimeEligible,\n withOvertime,\n errorMessages,\n )\n\n const overtimeExcludedEarnings: OtherEntry[] = nonOvertime\n .filter(\n (compensation): compensation is { jobUuid: string; name: string } =>\n Boolean(compensation.jobUuid) && Boolean(compensation.name),\n )\n .map(compensation => ({\n key: `${compensation.jobUuid}:${compensation.name}`,\n id: compensation.name,\n Field: createNumberField(\n `overtimeExcludedEarnings.${compensation.jobUuid}.${compensation.name}`,\n errorMessages,\n ),\n }))\n\n const timeOffRows = (employeeCompensation?.paidTimeOff ?? []).filter(entry => entry.name)\n const timeOff: TimeOffEntry[] = timeOffRows.map(entry => ({\n key: `timeOff:${entry.name!}`,\n name: entry.name!,\n Field: createNumberField(`timeOff.${entry.name!}`, errorMessages),\n // Seeded from the initial entered hours; the hook recomputes it live.\n remaining: computeTimeOffRemaining(timeOffAccrualByName.get(entry.name!), entry.hours),\n }))\n\n // Final-payout rows never show a remaining balance.\n const finalPayout =\n payrollCategory === PayrollCategory.Dismissal\n ? timeOffRows.map(entry => ({\n key: `finalPayout:${entry.name!}`,\n name: entry.name!,\n Field: createNumberField(`finalPayout.${entry.name!}`, errorMessages),\n remaining: null,\n }))\n : undefined\n\n return {\n jobs,\n overtimeIncludedEarnings,\n overtimeExcludedEarnings,\n timeOff,\n finalPayout,\n paymentMethod: hasDirectDepositSetup ? createPaymentMethodField() : undefined,\n }\n}\n"],"names":["isSplitByWorkweek","section","createNumberField","name","errorMessages","max","props","errorMessage","useFieldErrorMessage","jsx","TextInputField","stripLeadingZeros","createPaymentMethodField","RadioGroupHookField","createTextField","createReimbursementDraftFields","MAX_REIMBURSEMENT_AMOUNT","computeTimeOffRemaining","accrualBalance","enteredHours","buildBreakdownSection","compensations","workweeks","pathPrefix","isOvertimeEligible","withOvertime","rows","compensation","toEntry","row","weekStart","includeWorkweek","MAX_HOURS","byWeek","workweek","createPayrollEditEmployeeFields","employeeCompensation","fixedCompensations","payrollCategory","hasDirectDepositSetup","overtimeEarningNames","jobTitlesByUuid","timeOffAccrualByName","hourlyCompensations","overtimeAffecting","nonOvertime","jobUuids","isOvertimeName","COMPENSATION_NAME_OVERTIME","COMPENSATION_NAME_DOUBLE_OVERTIME","jobs","jobUuid","jobHourlyCompensations","visibleHourlyCompensations","overtimeIncludedEarnings","overtimeExcludedEarnings","timeOffRows","entry","timeOff","finalPayout","PayrollCategory"],"mappings":";;;;;;;;AAoSO,SAASA,EACdC,GACqC;AACrC,SAAO,CAAC,MAAM,QAAQA,CAAO;AAC/B;AAIA,SAASC,EACPC,GACAC,GACAC,GACmC;AACnC,SAAO,SAA0BC,GAAsC;AAMrE,UAAMC,IAAeC;AAAA,MACnBL;AAAA,MACAC;AAAA,IAAA;AAEF,WACE,gBAAAK;AAAA,MAACC;AAAA,MAAA;AAAA,QACE,GAAGJ;AAAA,QACJ,MAAAH;AAAA,QACA,MAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAAE;AAA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AAA,EACX,IACF;AAEN,SAAO;AAAA,IACL,MAAA8C;AAAA,IACA,0BAAAI;AAAA,IACA,0BAAAC;AAAA,IACA,SAAAG;AAAA,IACA,aAAAC;AAAA,IACA,eAAepB,IAAwB3B,MAA6B;AAAA,EAAA;AAExE;"}
1
+ {"version":3,"file":"fields.js","sources":["../../../../../../src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/fields.tsx"],"sourcesContent":["import type { ComponentType } from 'react'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollUpdatePaymentMethod } from '@gusto/embedded-api/models/components/payrollupdate'\nimport type { NormalizedWorkweek } from './payrollEditEmployeeHelpers'\nimport {\n MAX_HOURS,\n MAX_REIMBURSEMENT_AMOUNT,\n type PayrollEditEmployeeErrorCode,\n} from './payrollEditEmployeeSchema'\nimport { TextInputField } from '@/components/Common/Fields/TextInputField/TextInputField'\nimport { useFieldErrorMessage } from '@/partner-hook-utils/form/useFieldErrorMessage'\nimport { RadioGroupHookField } from '@/partner-hook-utils/form/fields'\nimport type { RadioGroupHookFieldProps } from '@/partner-hook-utils/form/fields/RadioGroupHookField'\nimport type { HookFieldProps, ValidationMessages } from '@/partner-hook-utils/types'\nimport type { TextInputProps } from '@/components/Common/UI/TextInput/TextInputTypes'\nimport { PayrollCategory } from '@/components/Payroll/payrollTypes'\nimport { COMPENSATION_NAME_DOUBLE_OVERTIME, COMPENSATION_NAME_OVERTIME } from '@/shared/constants'\nimport { stripLeadingZeros } from '@/helpers/formattedStrings'\n\n/**\n * Display copy for each validation error code a bound field can surface, so the\n * consumer supplies error text once (keyed by code) rather than reconstructing\n * form paths or hardcoding which rule each field can fail. Partial: a missing\n * code falls back to the raw error code.\n *\n * @public\n */\nexport type PayrollEditEmployeeErrorMessages = Partial<Record<PayrollEditEmployeeErrorCode, string>>\n\n/**\n * Presentation props accepted by a bound numeric field in the payroll editor.\n *\n * @remarks\n * The hook binds the react-hook-form `name`, forces `type=\"number\"`, and\n * resolves the field's own validation message internally; the UI supplies copy\n * and layout props (label, adornments, `shouldVisuallyHideLabel`, required\n * state, `description`).\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldProps = Omit<\n TextInputProps,\n 'name' | 'value' | 'onChange' | 'isInvalid' | 'type' | 'min' | 'errorMessage'\n>\n\n/**\n * A numeric field component pre-bound by the hook to a specific form path.\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldComponent = ComponentType<PayrollEditEmployeeFieldProps>\n\n/**\n * Presentation props accepted by the bound payment-method field.\n *\n * @remarks\n * The hook binds the `name` and publishes the option values on\n * `fieldsMetadata.paymentMethod`; the UI passes `getOptionLabel` to translate\n * each {@link PayrollUpdatePaymentMethod} value, rather than passing `options`.\n *\n * @public\n */\nexport type PayrollEditEmployeePaymentMethodFieldProps = HookFieldProps<\n RadioGroupHookFieldProps<never, PayrollUpdatePaymentMethod>\n>\n\n/**\n * The payment-method radio field component pre-bound by the hook.\n *\n * @public\n */\nexport type PayrollEditEmployeePaymentMethodField =\n ComponentType<PayrollEditEmployeePaymentMethodFieldProps>\n\n/**\n * One hours input within the hours section.\n *\n * @remarks\n * `key` is an opaque, stable React key. `jobUuid`, `name`, and (when the pay\n * period is multi-workweek) `workweekStart` are reach-in handles the UI uses to\n * group and label entries. When the section is a flat array, `workweekStart` is\n * omitted (single-workweek degenerate case); when it is a `Record` keyed by\n * workweek start, each entry carries its `workweekStart`.\n *\n * @public\n */\nexport interface HourEntry {\n /** Opaque, stable React key. */\n key: string\n /** The job this hours line belongs to. */\n jobUuid: string\n /** The compensation name (e.g. the API hours-compensation name). */\n name: string\n /** The workweek start date (`YYYY-MM-DD`) when the section is workweek-keyed. */\n workweekStart?: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * One earning input, used by the additional-earnings section.\n *\n * @remarks\n * Same shape as {@link HourEntry}. Whether an earning feeds the overtime\n * (regular rate of pay) calculation is decided by the hook, which sorts it into\n * the workweek-breakdown additional-earnings section or the flat other\n * section. The UI just renders whichever section an entry appears in.\n *\n * @public\n */\nexport type EarningEntry = HourEntry\n\n/**\n * One time-off or final-payout input.\n *\n * @remarks\n * Time off is never workweek-breakdown, so this section is always a flat array.\n *\n * @public\n */\nexport interface TimeOffEntry {\n /** Opaque, stable React key. */\n key: string\n /** The time-off policy compensation name. */\n name: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n /**\n * The policy's remaining balance after the entered hours are subtracted,\n * recomputed live as the user edits. `null` when the policy has no tracked\n * accrual balance (e.g. final-payout rows). Feed it into the field's own\n * `description` to render it as the input's help text.\n */\n remaining: number | null\n /** Read-only approved request hours for this pay period; absent on final-payout rows. */\n approvedRequestHours?: number\n}\n\n/**\n * One entry in the flat `overtimeExcludedEarnings` section.\n *\n * @remarks\n * Intentionally opaque: `overtimeExcludedEarnings` collects earnings that are not overtime-affecting\n * and whose input type the partner does not need to reason about. Render each\n * entry's `Field` keyed by `key`; use `id` as a reach-in handle for labeling.\n *\n * @public\n */\nexport interface OtherEntry {\n /** Opaque, stable React key. */\n key: string\n /** Reach-in handle identifying the underlying earning (its compensation name). */\n id: string\n /** Field component pre-bound to this entry's form path. */\n Field: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * A single job's hours section.\n *\n * @remarks\n * An employee can hold multiple jobs, each with its own hourly lines. `hours` is\n * either a flat `Entry[]` (single-workweek, or an overtime-ineligible employee)\n * OR a `Record<workweekStart, Entry[]>` (multi-workweek and overtime-eligible).\n * The value type is the signal — array is flat, object is split by workweek; use\n * {@link isSplitByWorkweek} to discriminate. `title` is the job's display title\n * (entity data, not copy) for rendering a per-job heading. Earnings are not\n * job-scoped: they live in the employee-level `overtimeIncludedEarnings` and\n * `overtimeExcludedEarnings` sections on {@link PayrollEditEmployeeFields}.\n *\n * @public\n */\nexport interface JobFields {\n /** The job identifier. */\n jobUuid: string\n /** The job's display title, when available, for a per-job heading. */\n title?: string\n /**\n * Hours inputs for this job. Excludes Overtime/Double-overtime rows while\n * `data.withOvertime` is `false`.\n */\n hours: HourEntry[] | Record<string, HourEntry[]>\n}\n\n/**\n * Presentation props accepted by a bound reimbursement description (text) field.\n *\n * @remarks\n * The hook binds the react-hook-form `name` internally; the UI supplies copy and\n * layout props (label, placeholder, `shouldVisuallyHideLabel`).\n *\n * @public\n */\nexport type ReimbursementDescriptionFieldProps = Omit<\n TextInputProps,\n 'name' | 'value' | 'onChange' | 'isInvalid' | 'type'\n>\n\n/**\n * The draft \"add reimbursement\" field group exposed on\n * `form.Fields.reimbursementDraft`.\n *\n * @remarks\n * A single in-progress row the UI reveals when the user starts adding a\n * reimbursement. `Description` and `Amount` bind to `reimbursementDraft.description`\n * / `reimbursementDraft.amount`. The UI shows them while `form.reimbursementDraft.isAdding`\n * is `true`, then calls `actions.saveReimbursement` (commits to the list) or\n * `actions.cancelReimbursement` (discards). Committed rows are rendered from\n * `data.reimbursements`, not from bound fields.\n *\n * @public\n */\nexport interface ReimbursementDraftFields {\n /** Description field pre-bound to the draft's form path. */\n Description: ComponentType<ReimbursementDescriptionFieldProps>\n /** Amount field pre-bound to the draft's form path. */\n Amount: PayrollEditEmployeeFieldComponent\n}\n\n/**\n * A committed reimbursement row for display in the consumer's table.\n *\n * @remarks\n * Exposed on `data.reimbursements`, seeded from the employee's existing\n * reimbursements and appended to as the user saves drafts. Display-only: the UI\n * renders `description`, `amount`, and the recurring/one-time `type`, plus a\n * remove control wired to `actions.removeReimbursement(index)`. `index` is the\n * row's position in the underlying form array (the removal handle); `uuid` is\n * present for rows that already exist server-side.\n *\n * @public\n */\nexport interface ReimbursementRow {\n /** Opaque, stable React key. */\n key: string\n /** The row's index in the reimbursements form array; pass to `removeReimbursement`. */\n index: number\n /** The reimbursement's server UUID, when it already exists. */\n uuid?: string\n /** The reimbursement description (may be blank; the UI supplies a fallback). */\n description: string\n /** The reimbursement amount as a decimal string. */\n amount: string\n /** Whether this reimbursement recurs. Recurring rows are managed outside payroll. */\n recurring: boolean\n}\n\n/**\n * The render-ready field collections exposed on `form.Fields`.\n *\n * @remarks\n * Hours are grouped under `jobs`, one entry per job, so multi-job employees\n * render correctly. All earnings and the remaining sections are employee-scoped\n * and stay top-level: `overtimeIncludedEarnings` (overtime-affecting) and\n * `overtimeExcludedEarnings` (non-overtime) each render as a single section spanning every\n * job, alongside time off, final payout, payment method, and reimbursements.\n *\n * @public\n */\nexport interface PayrollEditEmployeeFields {\n /** Per-job hours sections; one entry per job. */\n jobs: JobFields[]\n /**\n * Overtime-affecting earnings across all jobs, as a single employee-level\n * section. Flat `Entry[]` when unsplit, or `Record<workweekStart, Entry[]>`\n * when split by workweek; use {@link isSplitByWorkweek} to discriminate.\n */\n overtimeIncludedEarnings: EarningEntry[] | Record<string, EarningEntry[]>\n /** Non-overtime earnings (e.g. tips), always flat; opaque render entries. */\n overtimeExcludedEarnings: OtherEntry[]\n /** Time-off inputs (never workweek-breakdown). */\n timeOff: TimeOffEntry[]\n /** Final-payout inputs, present only for dismissal payrolls. */\n finalPayout?: TimeOffEntry[]\n /** Payment-method selector, present only when the employee has direct deposit set up. */\n paymentMethod?: PayrollEditEmployeePaymentMethodField\n /**\n * The draft \"add reimbursement\" field group, present only for itemized\n * (non-off-cycle) payrolls. Render while `form.reimbursementDraft.isAdding` is\n * `true`; committed rows come from `data.reimbursements`.\n */\n reimbursementDraft?: ReimbursementDraftFields\n}\n\n/**\n * Discriminates a workweek-breakdown section: `false` for the flat\n * (single-workweek) `Entry[]` form, `true` for the workweek-keyed\n * `Record<workweekStart, Entry[]>` form.\n *\n * @typeParam TEntry - The section's entry type.\n * @param section - A `form.Fields` section that may be flat or workweek-keyed.\n * @returns `true` when the section is keyed by workweek start date.\n * @public\n */\nexport function isSplitByWorkweek<TEntry>(\n section: TEntry[] | Record<string, TEntry[]>,\n): section is Record<string, TEntry[]> {\n return !Array.isArray(section)\n}\n\n// ── Bound field factories ──────────────────────────────────────────────\n\nfunction createNumberField(\n name: string,\n errorMessages?: PayrollEditEmployeeErrorMessages,\n max?: number,\n): PayrollEditEmployeeFieldComponent {\n return function BoundNumberField(props: PayrollEditEmployeeFieldProps) {\n // The field resolves its own validation copy from its bound path, so the\n // consumer supplies error copy once (keyed by code) and never reconstructs\n // form paths or guesses which rule a field can fail. name, type, min, max,\n // transform, and errorMessage are applied after the spread so callers can't\n // override the binding or the numeric contract via custom props.\n const errorMessage = useFieldErrorMessage(\n name,\n errorMessages as ValidationMessages<PayrollEditEmployeeErrorCode> | undefined,\n )\n return (\n <TextInputField\n {...props}\n name={name}\n type=\"number\"\n min={0}\n max={max}\n transform={stripLeadingZeros}\n errorMessage={errorMessage}\n />\n )\n }\n}\n\nfunction createPaymentMethodField(): PayrollEditEmployeePaymentMethodField {\n return function BoundPaymentMethodField(props: PayrollEditEmployeePaymentMethodFieldProps) {\n return (\n <RadioGroupHookField<never, PayrollUpdatePaymentMethod> {...props} name=\"paymentMethod\" />\n )\n }\n}\n\nfunction createTextField(name: string): ComponentType<ReimbursementDescriptionFieldProps> {\n return function BoundTextField(props: ReimbursementDescriptionFieldProps) {\n return <TextInputField {...props} name={name} />\n }\n}\n\n/**\n * Builds the draft \"add reimbursement\" field group, binding its Description and\n * Amount fields to the `reimbursementDraft` form path.\n *\n * @param errorMessages - Copy for each validation error code, baked into the amount field so it self-resolves.\n * @returns The pre-bound draft field group for `form.Fields.reimbursementDraft`.\n * @internal\n */\nexport function createReimbursementDraftFields(\n errorMessages?: PayrollEditEmployeeErrorMessages,\n): ReimbursementDraftFields {\n return {\n Description: createTextField('reimbursementDraft.description'),\n Amount: createNumberField('reimbursementDraft.amount', errorMessages, MAX_REIMBURSEMENT_AMOUNT),\n }\n}\n\n// ── Builders ───────────────────────────────────────────────────────────\n\n/** @internal */\nexport interface CreatePayrollEditEmployeeFieldsOptions {\n employeeCompensation: PayrollEmployeeCompensationsType | undefined\n /**\n * Fixed compensations to render, already merged with blank placeholders for\n * every company earning type (see `resolveEditableFixedCompensations`).\n */\n fixedCompensations: NonNullable<PayrollEmployeeCompensationsType['fixedCompensations']>\n workweeks: NormalizedWorkweek[]\n payrollCategory: PayrollCategory\n hasDirectDepositSetup: boolean\n /** Names of earning types included in the regular-rate-of-pay overtime calculation. */\n overtimeEarningNames: Set<string>\n /** Whether the employee is overtime-eligible (nonexempt family). Gates per-workweek splitting. */\n isOvertimeEligible: boolean\n /**\n * Gates per-workweek splitting\n * alongside `isOvertimeEligible`, and whether Overtime/Double-overtime rows\n * are included in `hours`.\n */\n withOvertime: boolean\n /** Job title lookup by job UUID, for per-job section headings. */\n jobTitlesByUuid: Map<string, string>\n /** Accrual balance by time-off policy name, for the remaining-balance display. */\n timeOffAccrualByName: Map<string, string>\n /** Copy for each validation error code, baked into every bound field so it self-resolves. */\n errorMessages?: PayrollEditEmployeeErrorMessages\n}\n\n/**\n * A time-off policy's remaining balance: its accrual balance minus the entered\n * hours. `null` when the policy has no tracked accrual balance (final-payout\n * rows). Shared by the field builder (seeding the initial value) and the hook\n * (recomputing it live as the user edits).\n *\n * @param accrualBalance - The policy's accrual balance, or `undefined` when untracked.\n * @param enteredHours - The currently entered hours for the policy.\n * @returns The remaining balance, or `null` when untracked.\n * @internal\n */\nexport function computeTimeOffRemaining(\n accrualBalance: string | undefined,\n enteredHours: string | null | undefined,\n): number | null {\n if (accrualBalance == null) return null\n return parseFloat(accrualBalance) - (parseFloat(enteredHours ?? '') || 0)\n}\n\nfunction buildBreakdownSection(\n compensations: Array<{ jobUuid?: string; name?: string }>,\n workweeks: NormalizedWorkweek[],\n pathPrefix: 'hours' | 'overtimeIncludedEarnings',\n isOvertimeEligible: boolean,\n withOvertime: boolean,\n errorMessages: PayrollEditEmployeeErrorMessages | undefined,\n): HourEntry[] | Record<string, HourEntry[]> {\n const rows = compensations.filter(\n (compensation): compensation is { jobUuid: string; name: string } =>\n Boolean(compensation.jobUuid) && Boolean(compensation.name),\n )\n\n const toEntry = (\n row: { jobUuid: string; name: string },\n weekStart: string,\n includeWorkweek: boolean,\n ): HourEntry => ({\n key: includeWorkweek ? `${row.jobUuid}:${row.name}:${weekStart}` : `${row.jobUuid}:${row.name}`,\n jobUuid: row.jobUuid,\n name: row.name,\n ...(includeWorkweek ? { workweekStart: weekStart } : {}),\n Field: createNumberField(\n `${pathPrefix}.${row.jobUuid}.${row.name}.${weekStart}`,\n errorMessages,\n pathPrefix === 'hours' ? MAX_HOURS : undefined,\n ),\n })\n\n // Split into per-workweek columns only for overtime-eligible employees while\n // `withOvertime` is on; workweek breakdowns exist solely to compute overtime\n // premiums, so an ineligible employee renders flat even on a multi-workweek\n // payroll, and an eligible one stays flat until `withOvertime` is set.\n if (workweeks.length > 1 && isOvertimeEligible && withOvertime) {\n const byWeek: Record<string, HourEntry[]> = {}\n for (const workweek of workweeks) {\n byWeek[workweek.startDate] = rows.map(row => toEntry(row, workweek.startDate, true))\n }\n return byWeek\n }\n\n const weekStart = workweeks[0]?.startDate ?? ''\n return rows.map(row => toEntry(row, weekStart, false))\n}\n\n/**\n * Builds the render-ready {@link PayrollEditEmployeeFields} from the prepared\n * compensation.\n *\n * @remarks\n * Hours and overtime-affecting earnings are grouped per job into `jobs` (a job\n * appears if it has hourly lines or overtime-affecting earnings). Fixed\n * compensations are split by whether their earning type is included in the\n * regular-rate-of-pay overtime calculation (`overtimeEarningNames`): included\n * earnings become each job's additional earnings, the rest become the flat,\n * employee-level `overtimeExcludedEarnings` section. Time off comes from the paid-time-off list,\n * final payout is added only for dismissal payrolls, and the payment-method\n * selector appears only when direct deposit is set up.\n *\n * @param options - The prepared compensation, normalized workweeks, payroll category, direct-deposit flag, overtime earning names, eligibility, the `withOvertime` flag, job titles, time-off accrual balances and entered values, and error copy.\n * @returns The populated field collections.\n * @internal\n */\nexport function createPayrollEditEmployeeFields({\n employeeCompensation,\n fixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n}: CreatePayrollEditEmployeeFieldsOptions): PayrollEditEmployeeFields {\n const hourlyCompensations = employeeCompensation?.hourlyCompensations ?? []\n const overtimeAffecting = fixedCompensations.filter(\n compensation => compensation.name != null && overtimeEarningNames.has(compensation.name),\n )\n const nonOvertime = fixedCompensations.filter(\n compensation => compensation.name == null || !overtimeEarningNames.has(compensation.name),\n )\n\n // A job appears if it has hourly lines or overtime-affecting earnings, in first\n // appearance order across those two sources.\n const jobUuids: string[] = []\n for (const compensation of [...hourlyCompensations, ...overtimeAffecting]) {\n if (compensation.jobUuid && !jobUuids.includes(compensation.jobUuid)) {\n jobUuids.push(compensation.jobUuid)\n }\n }\n\n const isOvertimeName = (name: string | null | undefined) =>\n name === COMPENSATION_NAME_OVERTIME || name === COMPENSATION_NAME_DOUBLE_OVERTIME\n\n const jobs: JobFields[] = jobUuids.map(jobUuid => {\n const jobHourlyCompensations = hourlyCompensations.filter(\n compensation => compensation.jobUuid === jobUuid,\n )\n // Overtime/Double-overtime rows stay out of `hours` entirely while\n // `withOvertime` is off — their underlying form values are untouched\n // (still whatever the prepared compensation carried), so hiding the row\n // can't lose or corrupt data. Driven by the single, employee-level flag —\n // no per-job hidden state.\n const visibleHourlyCompensations = withOvertime\n ? jobHourlyCompensations\n : jobHourlyCompensations.filter(compensation => !isOvertimeName(compensation.name))\n\n return {\n jobUuid,\n title: jobTitlesByUuid.get(jobUuid),\n hours: buildBreakdownSection(\n visibleHourlyCompensations,\n workweeks,\n 'hours',\n isOvertimeEligible,\n withOvertime,\n errorMessages,\n ),\n }\n })\n\n // Overtime-affecting earnings render as one employee-level section spanning\n // every job. Each entry keeps its per-job form path\n // (`overtimeIncludedEarnings.<jobUuid>.<name>`), so the flat section still binds and\n // submits per job.\n const overtimeIncludedEarnings = buildBreakdownSection(\n overtimeAffecting,\n workweeks,\n 'overtimeIncludedEarnings',\n isOvertimeEligible,\n withOvertime,\n errorMessages,\n )\n\n const overtimeExcludedEarnings: OtherEntry[] = nonOvertime\n .filter(\n (compensation): compensation is { jobUuid: string; name: string } =>\n Boolean(compensation.jobUuid) && Boolean(compensation.name),\n )\n .map(compensation => ({\n key: `${compensation.jobUuid}:${compensation.name}`,\n id: compensation.name,\n Field: createNumberField(\n `overtimeExcludedEarnings.${compensation.jobUuid}.${compensation.name}`,\n errorMessages,\n ),\n }))\n\n const timeOffRows = (employeeCompensation?.paidTimeOff ?? []).filter(entry => entry.name)\n const timeOff: TimeOffEntry[] = timeOffRows.map(entry => ({\n key: `timeOff:${entry.name!}`,\n name: entry.name!,\n Field: createNumberField(`timeOff.${entry.name!}`, errorMessages),\n // Seeded from the initial entered hours; the hook recomputes it live.\n remaining: computeTimeOffRemaining(timeOffAccrualByName.get(entry.name!), entry.hours),\n approvedRequestHours: Number(entry.approvedRequestHours || 0),\n }))\n\n // Final-payout rows never show a remaining balance.\n const finalPayout =\n payrollCategory === PayrollCategory.Dismissal\n ? timeOffRows.map(entry => ({\n key: `finalPayout:${entry.name!}`,\n name: entry.name!,\n Field: createNumberField(`finalPayout.${entry.name!}`, errorMessages),\n remaining: null,\n }))\n : undefined\n\n return {\n jobs,\n overtimeIncludedEarnings,\n overtimeExcludedEarnings,\n timeOff,\n finalPayout,\n paymentMethod: hasDirectDepositSetup ? createPaymentMethodField() : undefined,\n }\n}\n"],"names":["isSplitByWorkweek","section","createNumberField","name","errorMessages","max","props","errorMessage","useFieldErrorMessage","jsx","TextInputField","stripLeadingZeros","createPaymentMethodField","RadioGroupHookField","createTextField","createReimbursementDraftFields","MAX_REIMBURSEMENT_AMOUNT","computeTimeOffRemaining","accrualBalance","enteredHours","buildBreakdownSection","compensations","workweeks","pathPrefix","isOvertimeEligible","withOvertime","rows","compensation","toEntry","row","weekStart","includeWorkweek","MAX_HOURS","byWeek","workweek","createPayrollEditEmployeeFields","employeeCompensation","fixedCompensations","payrollCategory","hasDirectDepositSetup","overtimeEarningNames","jobTitlesByUuid","timeOffAccrualByName","hourlyCompensations","overtimeAffecting","nonOvertime","jobUuids","isOvertimeName","COMPENSATION_NAME_OVERTIME","COMPENSATION_NAME_DOUBLE_OVERTIME","jobs","jobUuid","jobHourlyCompensations","visibleHourlyCompensations","overtimeIncludedEarnings","overtimeExcludedEarnings","timeOffRows","entry","timeOff","finalPayout","PayrollCategory"],"mappings":";;;;;;;;AAsSO,SAASA,EACdC,GACqC;AACrC,SAAO,CAAC,MAAM,QAAQA,CAAO;AAC/B;AAIA,SAASC,EACPC,GACAC,GACAC,GACmC;AACnC,SAAO,SAA0BC,GAAsC;AAMrE,UAAMC,IAAeC;AAAA,MACnBL;AAAA,MACAC;AAAA,IAAA;AAEF,WACE,gBAAAK;AAAA,MAACC;AAAA,MAAA;AAAA,QACE,GAAGJ;AAAA,QACJ,MAAAH;AAAA,QACA,MAAK;AAAA,QACL,KAAK;AAAA,QACL,KAAAE;AAAA,QACA,WAAWM;AAAA,QACX,cAAAJ;AAAA,MAAA;AAAA,IAAA;AAAA,EAGN;AACF;AAEA,SAASK,IAAkE;AACzE,SAAO,SAAiCN,GAAmD;AACzF,WACE,gBAAAG,EAACI,GAAA,EAAwD,GAAGP,GAAO,MAAK,iBAAgB;AAAA,EAE5F;AACF;AAEA,SAASQ,EAAgBX,GAAiE;AACxF,SAAO,SAAwBG,GAA2C;AACxE,WAAO,gBAAAG,EAACC,GAAA,EAAgB,GAAGJ,GAAO,MAAAH,EAAA,CAAY;AAAA,EAChD;AACF;AAUO,SAASY,EACdX,GAC0B;AAC1B,SAAO;AAAA,IACL,aAAaU,EAAgB,gCAAgC;AAAA,IAC7D,QAAQZ,EAAkB,6BAA6BE,GAAeY,CAAwB;AAAA,EAAA;AAElG;AA4CO,SAASC,EACdC,GACAC,GACe;AACf,SAAID,KAAkB,OAAa,OAC5B,WAAWA,CAAc,KAAK,WAAWC,KAAgB,EAAE,KAAK;AACzE;AAEA,SAASC,EACPC,GACAC,GACAC,GACAC,GACAC,GACArB,GAC2C;AAC3C,QAAMsB,IAAOL,EAAc;AAAA,IACzB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,CAAA,GAAI,OAAO,CAAAqB,MAASA,EAAM,IAAI,GAClFC,IAA0BF,EAAY,IAAI,CAAAC,OAAU;AAAA,IACxD,KAAK,WAAWA,EAAM,IAAK;AAAA,IAC3B,MAAMA,EAAM;AAAA,IACZ,OAAOvD,EAAkB,WAAWuD,EAAM,IAAK,IAAIrD,CAAa;AAAA;AAAA,IAEhE,WAAWa,EAAwByB,EAAqB,IAAIe,EAAM,IAAK,GAAGA,EAAM,KAAK;AAAA,IACrF,sBAAsB,OAAOA,EAAM,wBAAwB,CAAC;AAAA,EAAA,EAC5D,GAGIE,IACJrB,MAAoBsB,EAAgB,YAChCJ,EAAY,IAAI,CAAAC,OAAU;AAAA,IACxB,KAAK,eAAeA,EAAM,IAAK;AAAA,IAC/B,MAAMA,EAAM;AAAA,IACZ,OAAOvD,EAAkB,eAAeuD,EAAM,IAAK,IAAIrD,CAAa;AAAA,IACpE,WAAW;AAAA,EAAA,EACX,IACF;AAEN,SAAO;AAAA,IACL,MAAA8C;AAAA,IACA,0BAAAI;AAAA,IACA,0BAAAC;AAAA,IACA,SAAAG;AAAA,IACA,aAAAC;AAAA,IACA,eAAepB,IAAwB3B,MAA6B;AAAA,EAAA;AAExE;"}
@@ -63,7 +63,7 @@ function Yt({
63
63
  const j = Ne(
64
64
  { companyId: l, payScheduleId: n?.payPeriod?.payScheduleUuid ?? "" },
65
65
  { enabled: !!n?.payPeriod?.payScheduleUuid }
66
- ), a = te.employee, s = n?.employeeCompensations?.find(
66
+ ), a = te.employeeShow, s = n?.employeeCompensations?.find(
67
67
  (e) => e.employeeUuid === u
68
68
  ), S = X(n ?? {}), d = (re.employeeBankAccounts?.length ?? 0) > 0, i = o(
69
69
  () => n ? Je(n.workweeks, n.payPeriod) : [],
@@ -1 +1 @@
1
- {"version":3,"file":"usePayrollEditEmployeeForm.js","sources":["../../../../../../src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { useFieldArray, useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeePaymentMethodsGetBankAccountsSuspense } from '@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts'\nimport { useEarningTypesListSuspense } from '@gusto/embedded-api/react-query/earningTypesList'\nimport { usePayrollsGetSuspense } from '@gusto/embedded-api/react-query/payrollsGet'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { usePayrollsUpdateMutation } from '@gusto/embedded-api/react-query/payrollsUpdate'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/payrollshow'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport {\n createPayrollEditEmployeeSchema,\n PAYMENT_METHOD_OPTIONS,\n PAYMENT_METHOD_VALUES,\n PayrollEditEmployeeErrorCodes,\n reimbursementDraftSchema,\n type PayrollEditEmployeeFormData,\n type PayrollEditEmployeeFormOutputs,\n} from './payrollEditEmployeeSchema'\nimport {\n buildPayrollUpdateEmployeeCompensation,\n collectOvertimeEarningNames,\n derivePayrollEditEmployeeDefaults,\n hasBreakdownsMatchingWorkweeks,\n hasExistingOvertimeHours,\n normalizeWorkweeks,\n resolveEditableFixedCompensations,\n zeroFillClearedWorkweekCells,\n type NormalizedWorkweek,\n} from './payrollEditEmployeeHelpers'\nimport {\n computeTimeOffRemaining,\n createPayrollEditEmployeeFields,\n createReimbursementDraftFields,\n type PayrollEditEmployeeErrorMessages,\n type PayrollEditEmployeeFields,\n type ReimbursementDraftFields,\n type ReimbursementRow,\n} from './fields'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport {\n derivePayrollCategory,\n isOffCyclePayroll,\n PayrollCategory,\n} from '@/components/Payroll/payrollTypes'\nimport { PREPARE_QUERY_KEY } from '@/components/Payroll/PayrollConfiguration/usePayrollConfigurationData'\nimport { isOvertimeEligibleFlsaStatus } from '@/components/Payroll/helpers'\nimport { retryAsync } from '@/helpers/retryAsync'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport {\n composeErrorHandler,\n type QueryWithRefetch,\n} from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldMetadataWithOptions,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\n\nconst PREPARE_MAX_ATTEMPTS = 4\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst isPayrollBeingProcessedError = (error: unknown): boolean =>\n error instanceof UnprocessableEntityError &&\n error.errors.some(issue => issue.category === 'invalid_operation')\n\n/**\n * Options accepted by {@link usePayrollEditEmployeeForm}.\n *\n * @public\n */\nexport interface UsePayrollEditEmployeeFormProps {\n /** The associated employee identifier. */\n employeeId: string\n /** The associated company identifier. */\n companyId: string\n /** The associated payroll identifier. */\n payrollId: string\n /**\n * Whether to expose reimbursement controls (`form.Fields.reimbursements`,\n * `actions.addReimbursement`/`removeReimbursement`, `form.reimbursements`).\n * Defaults to `true`. Controls are omitted for off-cycle payrolls regardless,\n * since those write reimbursements via the legacy fixed-compensation path.\n */\n withReimbursements?: boolean\n /** When validation runs. Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Defaults to `true`. Set to `false` when composing with other forms. */\n shouldFocusError?: boolean\n /**\n * Display copy for each validation error code, baked into every bound field so\n * it resolves and renders its own message. Supply it once, keyed by\n * {@link PayrollEditEmployeeErrorCodes}; a missing code falls back to the raw\n * code. Omit it to render raw codes.\n */\n errorMessages?: PayrollEditEmployeeErrorMessages\n}\n\n/**\n * Field metadata for {@link usePayrollEditEmployeeForm}, keyed by full form path.\n *\n * @remarks\n * Keys are minted from the prepared payroll's compensations at runtime\n * (`hours.${jobUuid}.${name}.${workweekStart}` and similar), so neither the key\n * set nor which entries carry options is known ahead of time.\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldsMetadata = Record<\n string,\n FieldMetadata | FieldMetadataWithOptions\n>\n\n/**\n * Ready-state return value of {@link usePayrollEditEmployeeForm} — the\n * `isLoading: false` branch of {@link UsePayrollEditEmployeeFormResult}.\n *\n * @public\n */\nexport interface UsePayrollEditEmployeeFormReady extends BaseFormHookReady<\n PayrollEditEmployeeFieldsMetadata,\n PayrollEditEmployeeFormData,\n PayrollEditEmployeeFields\n> {\n /** Loaded entities backing the editor. */\n data: {\n /** The employee being edited. */\n employee: Employee\n /** The employee's prepared compensation for this payroll, if present. */\n employeeCompensation?: PayrollEmployeeCompensationsType\n /** The prepared payroll (server-calculated totals and workweeks). */\n preparedPayroll: PayrollPrepared\n /** The pay schedule for the payroll, if loaded. */\n paySchedule?: PayScheduleShow\n /** Whether the pay period spans more than one workweek. Raw workweeks are on `preparedPayroll.workweeks`. */\n isMultipleWorkweeks: boolean\n /**\n * The pay period's normalized workweeks (`{ startDate, endDate }` strings),\n * in order — one entry, spanning the pay period, when it's a single\n * workweek. The per-workweek split fields are keyed by start date only, so\n * this is the source for each column's date range.\n */\n workweeks: NormalizedWorkweek[]\n /** Whether the employee is overtime-eligible (nonexempt family). Drives whether hours split by workweek. */\n isOvertimeEligible: boolean\n /**\n * The single, form-wide overtime-mode flag. `false` renders one flat\n * column per line with Overtime/Double-overtime rows hidden; `true`\n * splits hours and overtime-affecting earnings into per-workweek columns\n * (for overtime-eligible employees on a multi-workweek payroll) and\n * un-hides those rows. Starts `true` when the employee already has real\n * overtime hours or matching per-workweek breakdowns (see\n * `hasExistingOvertimeHours`, `hasBreakdownsMatchingWorkweeks`), or after\n * `actions.addOvertime` is called; otherwise starts `false`.\n */\n withOvertime: boolean\n /** Whether the employee has a direct-deposit bank account set up. */\n hasDirectDepositSetup: boolean\n /**\n * Committed reimbursement rows to render in a table, present only when\n * reimbursement controls are exposed. Seeded from the employee's existing\n * reimbursements and appended to as drafts are saved. Remove a row via\n * `actions.removeReimbursement(row.index)`.\n */\n reimbursements?: ReimbursementRow[]\n }\n /** Submission status. `mode` is always `'update'` since the payroll already exists. */\n status: { isPending: boolean; mode: 'update' }\n /** Form actions. */\n actions: {\n /** Validates and submits the form, resolving to the updated prepared payroll on success or `undefined` when validation blocked the submit. */\n onSubmit: () => Promise<HookSubmitResult<PayrollPrepared> | undefined>\n /**\n * Sets `data.withOvertime` to `true`, switching the whole form to the\n * workweek split: un-hides Overtime/Double-overtime rows and splits hours\n * and overtime-affecting earnings into per-workweek columns. Populates\n * only the first workweek cell of each line with that line's current\n * total, leaving every other cell blank — no auto distribution — so the\n * per-row validation then requires the user to fill in the rest. One\n * affordance for the whole employee, not one per job. One-directional —\n * there's no corresponding \"remove overtime\" action.\n */\n addOvertime: () => void\n /** Reveals the draft reimbursement row. Present only when reimbursement controls are exposed. */\n beginAddReimbursement?: () => void\n /** Validates the draft and commits it to the reimbursement list, or flags the draft amount if invalid. Present only when reimbursement controls are exposed. */\n saveReimbursement?: () => void\n /** Discards the draft reimbursement row. Present only when reimbursement controls are exposed. */\n cancelReimbursement?: () => void\n /** Removes the committed reimbursement row at `index` (zeroing existing rows so the update clears them). Present only when reimbursement controls are exposed. */\n removeReimbursement?: (index: number) => void\n }\n /** Form internals plus the reimbursement draft state. */\n form: BaseFormHookReady<\n PayrollEditEmployeeFieldsMetadata,\n PayrollEditEmployeeFormData,\n PayrollEditEmployeeFields\n >['form'] & {\n /** Draft reimbursement state, present only when reimbursement controls are exposed. */\n reimbursementDraft?: { isAdding: boolean }\n }\n}\n\n/**\n * Discriminated union returned by {@link usePayrollEditEmployeeForm}. Loading\n * branch carries only `errorHandling`; ready branch carries form data, fields,\n * status, and actions.\n *\n * @public\n */\nexport type UsePayrollEditEmployeeFormResult = HookLoadingResult | UsePayrollEditEmployeeFormReady\n\n/**\n * Headless form hook for editing a single employee's compensation within a\n * payroll run, built for regular-rate-of-pay (RRoP) support.\n *\n * @remarks\n * Prepares the payroll for the target employee, then exposes a workweek-keyed\n * form whose submit builds a `PayrollUpdate`. Single-workweek pay periods send\n * totals without `breakdowns`; multi-workweek pay periods send `breakdowns` per\n * line once that line's every workweek cell is filled. Overtime-eligible\n * (nonexempt) employees split hours and overtime-affecting earnings per\n * workweek while the single `data.withOvertime` flag is on (see\n * `actions.addOvertime`); everyone else, and every line while `withOvertime` is\n * off, edits flat totals.\n *\n * @param props - Hook options.\n * @returns A loading result while data is fetching, or a ready result with data,\n * fields, status, actions, and error handling.\n * @public\n */\nexport function usePayrollEditEmployeeForm({\n employeeId,\n companyId,\n payrollId,\n withReimbursements = true,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n errorMessages,\n}: UsePayrollEditEmployeeFormProps): UsePayrollEditEmployeeFormResult {\n const { data: employeeData } = useEmployeesGetSuspense({ employeeId })\n const { data: bankAccountsList } = useEmployeePaymentMethodsGetBankAccountsSuspense({\n employeeId,\n })\n const { data: earningTypesData } = useEarningTypesListSuspense({ companyId })\n const { data: payrollData } = usePayrollsGetSuspense({ companyId, payrollId })\n const isTransitionPayroll =\n derivePayrollCategory(payrollData.payrollShow ?? {}) === PayrollCategory.Transition\n\n const queryClient = useQueryClient()\n const { mutateAsync: preparePayroll } = usePayrollsPrepareMutation()\n const { mutateAsync: updatePayroll, isPending } = usePayrollsUpdateMutation()\n\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const [prepareError, setPrepareError] = useState<Error | null>(null)\n const hasFiredRef = useRef(false)\n\n const executePrepare = useCallback(async () => {\n setPrepareError(null)\n try {\n const result = await retryAsync(\n () =>\n preparePayroll({\n request: {\n companyId,\n payrollId,\n requestBody: { employeeUuids: isTransitionPayroll ? undefined : [employeeId] },\n },\n }),\n {\n maxAttempts: PREPARE_MAX_ATTEMPTS,\n delayMs: PREPARE_RETRY_DELAY_MS,\n shouldRetry: isPayrollBeingProcessedError,\n },\n )\n setPreparedPayroll(result.payrollPrepared)\n } catch (error) {\n setPrepareError(error as Error)\n }\n }, [companyId, payrollId, employeeId, preparePayroll, isTransitionPayroll])\n\n useEffect(() => {\n if (hasFiredRef.current) return\n hasFiredRef.current = true\n void executePrepare()\n }, [executePrepare])\n\n const payScheduleQuery = usePaySchedulesGet(\n { companyId, payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid ?? '' },\n { enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid },\n )\n\n const employee = employeeData.employee\n const employeeCompensation = preparedPayroll?.employeeCompensations?.find(\n comp => comp.employeeUuid === employeeId,\n )\n const payrollCategory = derivePayrollCategory(preparedPayroll ?? {})\n const hasDirectDepositSetup = (bankAccountsList.employeeBankAccounts?.length ?? 0) > 0\n\n // Only normalize once the payroll is prepared: normalizeWorkweeks throws on a\n // payroll with neither workweeks nor a pay period, and before prepare resolves\n // both are legitimately absent (still loading, not malformed).\n const workweeks = useMemo(\n () =>\n preparedPayroll\n ? normalizeWorkweeks(preparedPayroll.workweeks, preparedPayroll.payPeriod)\n : [],\n [preparedPayroll],\n )\n\n const overtimeEarningNames = useMemo(\n () => collectOvertimeEarningNames(earningTypesData.earningTypeList),\n [earningTypesData.earningTypeList],\n )\n\n // Source of truth for the employee's FLSA status: prefer the prepared\n // compensation's hourly lines (the same data the fields are built from, so the\n // gate and the rendered lines always agree), falling back to the employee's\n // primary-job compensation. Unknown status is treated as not overtime-eligible.\n const flsaStatus = useMemo(() => {\n const fromCompensation = employeeCompensation?.hourlyCompensations?.find(\n compensation => compensation.flsaStatus,\n )?.flsaStatus\n if (fromCompensation) return fromCompensation\n const primaryJob = employee?.jobs?.find(job => job.primary)\n return primaryJob?.compensations?.[0]?.flsaStatus\n }, [employeeCompensation, employee])\n const isOvertimeEligible = isOvertimeEligibleFlsaStatus(flsaStatus)\n\n // Starts on when the employee already has real overtime hours, or already has\n // per-workweek breakdowns matching the current pay period's workweeks (nothing\n // to hide either way), otherwise starts off until the user opts in via\n // `actions.addOvertime`. One-directional: there's no \"remove overtime\" action.\n const [withOvertimeSetByUser, setWithOvertimeSetByUser] = useState(false)\n const withOvertime =\n withOvertimeSetByUser ||\n hasExistingOvertimeHours(employeeCompensation?.hourlyCompensations) ||\n hasBreakdownsMatchingWorkweeks(employeeCompensation?.hourlyCompensations, workweeks)\n\n const primaryJobUuid = useMemo(() => employee?.jobs?.find(job => job.primary)?.uuid, [employee])\n\n // Seed a blank input for every payroll fixed-compensation type (like the stable\n // editor), then let the field/defaults builders split them into additional\n // earnings vs `overtimeExcludedEarnings` by overtime inclusion. Without this, an employee whose\n // prepared payroll carries no fixed compensations shows no earnings inputs.\n const resolvedFixedCompensations = useMemo(\n () =>\n resolveEditableFixedCompensations(\n employeeCompensation?.fixedCompensations,\n preparedPayroll?.fixedCompensationTypes,\n primaryJobUuid,\n flsaStatus,\n ),\n [employeeCompensation, preparedPayroll?.fixedCompensationTypes, primaryJobUuid, flsaStatus],\n )\n\n const jobTitlesByUuid = useMemo(() => {\n const titles = new Map<string, string>()\n for (const job of employee?.jobs ?? []) {\n if (job.uuid && job.title) titles.set(job.uuid, job.title)\n }\n return titles\n }, [employee])\n\n // Accrual balance per time-off policy, owned by the hook (rather than looked\n // up in the consumer) so the time-off field can render its own live remaining\n // balance.\n const timeOffAccrualByName = useMemo(() => {\n const balances = new Map<string, string>()\n for (const policy of employee?.eligiblePaidTimeOff ?? []) {\n if (policy.name && policy.accrualBalance != null) {\n balances.set(policy.name, policy.accrualBalance)\n }\n }\n return balances\n }, [employee])\n\n const schema = useMemo(() => createPayrollEditEmployeeSchema(), [])\n\n const resolvedDefaults = useMemo(\n () =>\n derivePayrollEditEmployeeDefaults(\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n resolvedFixedCompensations,\n ),\n [\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n resolvedFixedCompensations,\n ],\n )\n\n const formMethods = useForm<PayrollEditEmployeeFormData, unknown, PayrollEditEmployeeFormOutputs>(\n {\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n },\n )\n\n // Watched so each `Fields.timeOff[i].remaining` stays live as the user edits\n // hours. The whole form re-renders on keystroke regardless of who owns this\n // watch, so there's no cost to owning it here rather than in a per-row\n // subcomponent.\n const watchedTimeOff = useWatch({ control: formMethods.control, name: 'timeOff' })\n\n // Off-cycle payrolls write reimbursements via the legacy fixed-compensation path\n // (the itemized array is rejected server-side), so itemized reimbursement controls\n // are exposed only for regular payrolls and only when the partner opts in.\n const usesItemizedReimbursements = !isOffCyclePayroll(payrollCategory)\n const showReimbursements = withReimbursements && usesItemizedReimbursements\n\n const {\n fields: reimbursementArrayFields,\n append: appendReimbursement,\n remove: removeReimbursementRow,\n update: updateReimbursementRow,\n } = useFieldArray({\n control: formMethods.control,\n name: 'reimbursements',\n })\n\n const [isAddingReimbursement, setIsAddingReimbursement] = useState(false)\n\n const reimbursementDraftFields = useMemo<ReimbursementDraftFields>(\n () => createReimbursementDraftFields(errorMessages),\n [errorMessages],\n )\n\n // Committed rows for the consumer's table. A removed existing row (one with a\n // uuid) is zeroed rather than dropped so the update still clears it server-side;\n // those zero-amount rows are filtered out of the visible list but remain in the\n // form array for submit.\n const reimbursementRows = useMemo<ReimbursementRow[]>(\n () =>\n reimbursementArrayFields\n .map((field, index) => ({\n key: field.id,\n index,\n uuid: field.uuid ?? undefined,\n description: field.description,\n amount: field.amount,\n recurring: field.recurring ?? false,\n }))\n .filter(row => parseFloat(row.amount || '0') !== 0),\n [reimbursementArrayFields],\n )\n\n const beginAddReimbursement = useCallback(() => {\n setIsAddingReimbursement(true)\n }, [])\n\n const cancelReimbursement = useCallback(() => {\n formMethods.setValue('reimbursementDraft', { description: '', amount: '' })\n formMethods.clearErrors('reimbursementDraft')\n setIsAddingReimbursement(false)\n }, [formMethods])\n\n const saveReimbursement = useCallback(() => {\n const draft = formMethods.getValues('reimbursementDraft')\n const result = reimbursementDraftSchema.safeParse(draft)\n if (!result.success) {\n // The error code is a fallback; the field renders the consumer-supplied\n // `errorMessage` prop when present (see useField), so the copy is theirs to set.\n formMethods.setError('reimbursementDraft.amount', {\n message: PayrollEditEmployeeErrorCodes.REIMBURSEMENT_AMOUNT,\n })\n return\n }\n appendReimbursement({\n uuid: null,\n description: result.data.description.trim(),\n amount: parseFloat(result.data.amount).toFixed(2),\n recurring: false,\n })\n formMethods.setValue('reimbursementDraft', { description: '', amount: '' })\n formMethods.clearErrors('reimbursementDraft')\n setIsAddingReimbursement(false)\n }, [appendReimbursement, formMethods])\n\n const removeReimbursement = useCallback(\n (index: number) => {\n const field = reimbursementArrayFields[index]\n if (!field) return\n if (field.uuid) {\n updateReimbursementRow(index, { ...field, amount: '0' })\n } else {\n removeReimbursementRow(index)\n }\n },\n [reimbursementArrayFields, removeReimbursementRow, updateReimbursementRow],\n )\n\n const fields = useMemo(\n () =>\n createPayrollEditEmployeeFields({\n employeeCompensation,\n fixedCompensations: resolvedFixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n }),\n [\n employeeCompensation,\n resolvedFixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n ],\n )\n\n // Overlay the live remaining balance onto each time-off entry every render, so\n // it tracks the watched entered values without rebuilding (and remounting) the\n // bound field components the `fields` memo owns.\n const timeOffFields = useMemo(\n () =>\n fields.timeOff.map(entry => ({\n ...entry,\n remaining: computeTimeOffRemaining(\n timeOffAccrualByName.get(entry.name),\n watchedTimeOff[entry.name],\n ),\n })),\n [fields.timeOff, timeOffAccrualByName, watchedTimeOff],\n )\n\n // Re-derives with `withOvertime` forced `true` and pushes the result straight\n // into the form: every line's first workweek cell gets that line's current\n // total, every other cell is left blank (never auto-distributed — see\n // `derivePayrollEditEmployeeDefaults`/`buildWeekMap`). The per-row validation\n // then requires the user to fill in the rest before they can submit.\n // `setValue` (not `resetField`) is used so this overwrites even a value the\n // user already typed into the collapsed input. Plain function (not memoized):\n // it only runs on a user click, and its inputs are recomputed each render, so\n // a `useCallback` here would never actually hold a stable reference.\n const addOvertime = () => {\n setWithOvertimeSetByUser(true)\n const revealedDefaults = derivePayrollEditEmployeeDefaults(\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n true,\n resolvedFixedCompensations,\n )\n // Keep the user's edited collapsed value on the first workweek cell rather\n // than the seeded API total.\n const firstWeekStart = workweeks[0]?.startDate ?? ''\n const currentValues = formMethods.getValues()\n const overlayLiveFirstWeek = (\n revealed: PayrollEditEmployeeFormData['hours'],\n live: PayrollEditEmployeeFormData['hours'] | undefined,\n ) => {\n for (const [jobUuid, names] of Object.entries(revealed)) {\n for (const [name, weekMap] of Object.entries(names)) {\n const liveValue = live?.[jobUuid]?.[name]?.[firstWeekStart]\n if (liveValue !== undefined) weekMap[firstWeekStart] = liveValue\n }\n }\n return revealed\n }\n // `shouldDirty` so the form's `values`-prop reset (triggered by flipping\n // `withOvertimeSetByUser`) keeps these via `keepDirtyValues`.\n formMethods.setValue(\n 'hours',\n overlayLiveFirstWeek(revealedDefaults.hours, currentValues.hours),\n { shouldDirty: true },\n )\n formMethods.setValue(\n 'overtimeIncludedEarnings',\n overlayLiveFirstWeek(\n revealedDefaults.overtimeIncludedEarnings,\n currentValues.overtimeIncludedEarnings,\n ),\n { shouldDirty: true },\n )\n }\n const fieldsMetadata = useMemo<PayrollEditEmployeeFieldsMetadata>(\n () => ({\n paymentMethod: withOptions(\n { name: 'paymentMethod' },\n PAYMENT_METHOD_OPTIONS,\n PAYMENT_METHOD_VALUES,\n ),\n }),\n [],\n )\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('PayrollEditEmployeeForm')\n\n const prepareQuerySource: QueryWithRefetch = {\n error: prepareError,\n refetch: (() => executePrepare()) as unknown as QueryWithRefetch['refetch'],\n }\n\n const errorHandling = composeErrorHandler([prepareQuerySource, payScheduleQuery], {\n submitError,\n setSubmitError,\n })\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const onSubmit = async (): Promise<HookSubmitResult<PayrollPrepared> | undefined> => {\n let submitResult: HookSubmitResult<PayrollPrepared> | undefined\n\n // A workweek input that loaded with a value and was cleared by the user\n // submits an explicit `0` for that cell. Writing the `0` into form state\n // before validation lets the existing per-row check and submit builder run\n // unchanged: the cell is now filled rather than blank. Cells that were blank\n // at load stay blank (and keep validating as required in a touched row).\n const cleared = zeroFillClearedWorkweekCells(formMethods.getValues(), resolvedDefaults)\n if (cleared.hours) {\n formMethods.setValue('hours', cleared.hours, { shouldDirty: true })\n }\n if (cleared.overtimeIncludedEarnings) {\n formMethods.setValue('overtimeIncludedEarnings', cleared.overtimeIncludedEarnings, {\n shouldDirty: true,\n })\n }\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async data => {\n await baseSubmitHandler(data, async payload => {\n const compensation = buildPayrollUpdateEmployeeCompensation(\n payload,\n employeeCompensation,\n workweeks,\n payrollCategory,\n isOvertimeEligible,\n withOvertime,\n )\n\n const response = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: { employeeCompensations: [compensation] },\n },\n })\n\n const updated = response.payrollPrepared\n if (!updated) {\n throw new SDKInternalError('Payroll update did not return a prepared payroll')\n }\n\n setPreparedPayroll(updated)\n\n // The payroll configuration surface caches its prepared payroll under a hand-written\n // key, which the global SDK auto-invalidation (namespaced to @gusto/embedded-api\n // queries only) does not touch. Invalidate it explicitly so configuration reflects\n // this edit without a manual refresh.\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n\n submitResult = { mode: 'update', data: updated }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n if (!preparedPayroll || !employee) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n employee,\n employeeCompensation,\n preparedPayroll,\n paySchedule: payScheduleQuery.data?.payScheduleShow,\n isMultipleWorkweeks: workweeks.length > 1,\n workweeks,\n isOvertimeEligible,\n withOvertime,\n hasDirectDepositSetup,\n ...(showReimbursements ? { reimbursements: reimbursementRows } : {}),\n },\n status: { isPending, mode: 'update' as const },\n actions: {\n onSubmit,\n addOvertime,\n ...(showReimbursements\n ? {\n beginAddReimbursement,\n saveReimbursement,\n cancelReimbursement,\n removeReimbursement,\n }\n : {}),\n },\n errorHandling,\n form: {\n Fields: {\n ...fields,\n timeOff: timeOffFields,\n reimbursementDraft: showReimbursements ? reimbursementDraftFields : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n ...(showReimbursements ? { reimbursementDraft: { isAdding: isAddingReimbursement } } : {}),\n },\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityError","issue","usePayrollEditEmployeeForm","employeeId","companyId","payrollId","withReimbursements","validationMode","shouldFocusError","errorMessages","employeeData","useEmployeesGetSuspense","bankAccountsList","useEmployeePaymentMethodsGetBankAccountsSuspense","earningTypesData","useEarningTypesListSuspense","payrollData","usePayrollsGetSuspense","isTransitionPayroll","derivePayrollCategory","PayrollCategory","queryClient","useQueryClient","preparePayroll","usePayrollsPrepareMutation","updatePayroll","isPending","usePayrollsUpdateMutation","preparedPayroll","setPreparedPayroll","useState","prepareError","setPrepareError","hasFiredRef","useRef","executePrepare","useCallback","result","retryAsync","useEffect","payScheduleQuery","usePaySchedulesGet","employee","employeeCompensation","comp","payrollCategory","hasDirectDepositSetup","workweeks","useMemo","normalizeWorkweeks","overtimeEarningNames","collectOvertimeEarningNames","flsaStatus","fromCompensation","compensation","job","isOvertimeEligible","isOvertimeEligibleFlsaStatus","withOvertimeSetByUser","setWithOvertimeSetByUser","withOvertime","hasExistingOvertimeHours","hasBreakdownsMatchingWorkweeks","primaryJobUuid","resolvedFixedCompensations","resolveEditableFixedCompensations","jobTitlesByUuid","titles","timeOffAccrualByName","balances","policy","schema","createPayrollEditEmployeeSchema","resolvedDefaults","derivePayrollEditEmployeeDefaults","formMethods","useForm","zodResolver","watchedTimeOff","useWatch","usesItemizedReimbursements","isOffCyclePayroll","showReimbursements","reimbursementArrayFields","appendReimbursement","removeReimbursementRow","updateReimbursementRow","useFieldArray","isAddingReimbursement","setIsAddingReimbursement","reimbursementDraftFields","createReimbursementDraftFields","reimbursementRows","field","index","row","beginAddReimbursement","cancelReimbursement","saveReimbursement","draft","reimbursementDraftSchema","PayrollEditEmployeeErrorCodes","removeReimbursement","fields","createPayrollEditEmployeeFields","timeOffFields","entry","computeTimeOffRemaining","addOvertime","revealedDefaults","firstWeekStart","currentValues","overlayLiveFirstWeek","revealed","live","jobUuid","names","name","weekMap","liveValue","fieldsMetadata","withOptions","PAYMENT_METHOD_OPTIONS","PAYMENT_METHOD_VALUES","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","hookFormInternals","useHookFormInternals","onSubmit","submitResult","cleared","zeroFillClearedWorkweekCells","resolve","data","payload","buildPayrollUpdateEmployeeCompensation","updated","SDKInternalError","PREPARE_QUERY_KEY","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAMA,KAAuB,GACvBC,KAAyB,MAEzBC,KAA+B,CAACC,MACpCA,aAAiBC,MACjBD,EAAM,OAAO,KAAK,CAAAE,MAASA,EAAM,aAAa,mBAAmB;AAuK5D,SAASC,GAA2B;AAAA,EACzC,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,KAAmB;AAAA,EACnB,eAAAC;AACF,GAAsE;AACpE,QAAM,EAAE,MAAMC,GAAA,IAAiBC,GAAwB,EAAE,YAAAR,GAAY,GAC/D,EAAE,MAAMS,GAAA,IAAqBC,GAAiD;AAAA,IAClF,YAAAV;AAAA,EAAA,CACD,GACK,EAAE,MAAMW,EAAA,IAAqBC,GAA4B,EAAE,WAAAX,GAAW,GACtE,EAAE,MAAMY,GAAA,IAAgBC,GAAuB,EAAE,WAAAb,GAAW,WAAAC,GAAW,GACvEa,IACJC,EAAsBH,GAAY,eAAe,CAAA,CAAE,MAAMI,GAAgB,YAErEC,KAAcC,GAAA,GACd,EAAE,aAAaC,EAAA,IAAmBC,GAAA,GAClC,EAAE,aAAaC,IAAe,WAAAC,GAAA,IAAcC,GAAA,GAE5C,CAACC,GAAiBC,CAAkB,IAAIC,EAAA,GACxC,CAACC,IAAcC,CAAe,IAAIF,EAAuB,IAAI,GAC7DG,IAAcC,GAAO,EAAK,GAE1BC,IAAiBC,EAAY,YAAY;AAC7C,IAAAJ,EAAgB,IAAI;AACpB,QAAI;AACF,YAAMK,IAAS,MAAMC;AAAA,QACnB,MACEf,EAAe;AAAA,UACb,SAAS;AAAA,YACP,WAAAnB;AAAA,YACA,WAAAC;AAAA,YACA,aAAa,EAAE,eAAea,IAAsB,SA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js","sources":["../../../../../../src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { useFieldArray, useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeePaymentMethodsGetBankAccountsSuspense } from '@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts'\nimport { useEarningTypesListSuspense } from '@gusto/embedded-api/react-query/earningTypesList'\nimport { usePayrollsGetSuspense } from '@gusto/embedded-api/react-query/payrollsGet'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { usePayrollsUpdateMutation } from '@gusto/embedded-api/react-query/payrollsUpdate'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/unprocessedpayroll'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payschedulelistitem'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport {\n createPayrollEditEmployeeSchema,\n PAYMENT_METHOD_OPTIONS,\n PAYMENT_METHOD_VALUES,\n PayrollEditEmployeeErrorCodes,\n reimbursementDraftSchema,\n type PayrollEditEmployeeFormData,\n type PayrollEditEmployeeFormOutputs,\n} from './payrollEditEmployeeSchema'\nimport {\n buildPayrollUpdateEmployeeCompensation,\n collectOvertimeEarningNames,\n derivePayrollEditEmployeeDefaults,\n hasBreakdownsMatchingWorkweeks,\n hasExistingOvertimeHours,\n normalizeWorkweeks,\n resolveEditableFixedCompensations,\n zeroFillClearedWorkweekCells,\n type NormalizedWorkweek,\n} from './payrollEditEmployeeHelpers'\nimport {\n computeTimeOffRemaining,\n createPayrollEditEmployeeFields,\n createReimbursementDraftFields,\n type PayrollEditEmployeeErrorMessages,\n type PayrollEditEmployeeFields,\n type ReimbursementDraftFields,\n type ReimbursementRow,\n} from './fields'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport {\n derivePayrollCategory,\n isOffCyclePayroll,\n PayrollCategory,\n} from '@/components/Payroll/payrollTypes'\nimport { PREPARE_QUERY_KEY } from '@/components/Payroll/PayrollConfiguration/usePayrollConfigurationData'\nimport { isOvertimeEligibleFlsaStatus } from '@/components/Payroll/helpers'\nimport { retryAsync } from '@/helpers/retryAsync'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport {\n composeErrorHandler,\n type QueryWithRefetch,\n} from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldMetadataWithOptions,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\n\nconst PREPARE_MAX_ATTEMPTS = 4\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst isPayrollBeingProcessedError = (error: unknown): boolean =>\n error instanceof UnprocessableEntityError &&\n error.errors.some(issue => issue.category === 'invalid_operation')\n\n/**\n * Options accepted by {@link usePayrollEditEmployeeForm}.\n *\n * @public\n */\nexport interface UsePayrollEditEmployeeFormProps {\n /** The associated employee identifier. */\n employeeId: string\n /** The associated company identifier. */\n companyId: string\n /** The associated payroll identifier. */\n payrollId: string\n /**\n * Whether to expose reimbursement controls (`form.Fields.reimbursements`,\n * `actions.addReimbursement`/`removeReimbursement`, `form.reimbursements`).\n * Defaults to `true`. Controls are omitted for off-cycle payrolls regardless,\n * since those write reimbursements via the legacy fixed-compensation path.\n */\n withReimbursements?: boolean\n /** When validation runs. Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Defaults to `true`. Set to `false` when composing with other forms. */\n shouldFocusError?: boolean\n /**\n * Display copy for each validation error code, baked into every bound field so\n * it resolves and renders its own message. Supply it once, keyed by\n * {@link PayrollEditEmployeeErrorCodes}; a missing code falls back to the raw\n * code. Omit it to render raw codes.\n */\n errorMessages?: PayrollEditEmployeeErrorMessages\n}\n\n/**\n * Field metadata for {@link usePayrollEditEmployeeForm}, keyed by full form path.\n *\n * @remarks\n * Keys are minted from the prepared payroll's compensations at runtime\n * (`hours.${jobUuid}.${name}.${workweekStart}` and similar), so neither the key\n * set nor which entries carry options is known ahead of time.\n *\n * @public\n */\nexport type PayrollEditEmployeeFieldsMetadata = Record<\n string,\n FieldMetadata | FieldMetadataWithOptions\n>\n\n/**\n * Ready-state return value of {@link usePayrollEditEmployeeForm} — the\n * `isLoading: false` branch of {@link UsePayrollEditEmployeeFormResult}.\n *\n * @public\n */\nexport interface UsePayrollEditEmployeeFormReady extends BaseFormHookReady<\n PayrollEditEmployeeFieldsMetadata,\n PayrollEditEmployeeFormData,\n PayrollEditEmployeeFields\n> {\n /** Loaded entities backing the editor. */\n data: {\n /** The employee being edited. */\n employee: Employee\n /** The employee's prepared compensation for this payroll, if present. */\n employeeCompensation?: PayrollEmployeeCompensationsType\n /** The prepared payroll (server-calculated totals and workweeks). */\n preparedPayroll: PayrollPrepared\n /** The pay schedule for the payroll, if loaded. */\n paySchedule?: PayScheduleShow\n /** Whether the pay period spans more than one workweek. Raw workweeks are on `preparedPayroll.workweeks`. */\n isMultipleWorkweeks: boolean\n /**\n * The pay period's normalized workweeks (`{ startDate, endDate }` strings),\n * in order — one entry, spanning the pay period, when it's a single\n * workweek. The per-workweek split fields are keyed by start date only, so\n * this is the source for each column's date range.\n */\n workweeks: NormalizedWorkweek[]\n /** Whether the employee is overtime-eligible (nonexempt family). Drives whether hours split by workweek. */\n isOvertimeEligible: boolean\n /**\n * The single, form-wide overtime-mode flag. `false` renders one flat\n * column per line with Overtime/Double-overtime rows hidden; `true`\n * splits hours and overtime-affecting earnings into per-workweek columns\n * (for overtime-eligible employees on a multi-workweek payroll) and\n * un-hides those rows. Starts `true` when the employee already has real\n * overtime hours or matching per-workweek breakdowns (see\n * `hasExistingOvertimeHours`, `hasBreakdownsMatchingWorkweeks`), or after\n * `actions.addOvertime` is called; otherwise starts `false`.\n */\n withOvertime: boolean\n /** Whether the employee has a direct-deposit bank account set up. */\n hasDirectDepositSetup: boolean\n /**\n * Committed reimbursement rows to render in a table, present only when\n * reimbursement controls are exposed. Seeded from the employee's existing\n * reimbursements and appended to as drafts are saved. Remove a row via\n * `actions.removeReimbursement(row.index)`.\n */\n reimbursements?: ReimbursementRow[]\n }\n /** Submission status. `mode` is always `'update'` since the payroll already exists. */\n status: { isPending: boolean; mode: 'update' }\n /** Form actions. */\n actions: {\n /** Validates and submits the form, resolving to the updated prepared payroll on success or `undefined` when validation blocked the submit. */\n onSubmit: () => Promise<HookSubmitResult<PayrollPrepared> | undefined>\n /**\n * Sets `data.withOvertime` to `true`, switching the whole form to the\n * workweek split: un-hides Overtime/Double-overtime rows and splits hours\n * and overtime-affecting earnings into per-workweek columns. Populates\n * only the first workweek cell of each line with that line's current\n * total, leaving every other cell blank — no auto distribution — so the\n * per-row validation then requires the user to fill in the rest. One\n * affordance for the whole employee, not one per job. One-directional —\n * there's no corresponding \"remove overtime\" action.\n */\n addOvertime: () => void\n /** Reveals the draft reimbursement row. Present only when reimbursement controls are exposed. */\n beginAddReimbursement?: () => void\n /** Validates the draft and commits it to the reimbursement list, or flags the draft amount if invalid. Present only when reimbursement controls are exposed. */\n saveReimbursement?: () => void\n /** Discards the draft reimbursement row. Present only when reimbursement controls are exposed. */\n cancelReimbursement?: () => void\n /** Removes the committed reimbursement row at `index` (zeroing existing rows so the update clears them). Present only when reimbursement controls are exposed. */\n removeReimbursement?: (index: number) => void\n }\n /** Form internals plus the reimbursement draft state. */\n form: BaseFormHookReady<\n PayrollEditEmployeeFieldsMetadata,\n PayrollEditEmployeeFormData,\n PayrollEditEmployeeFields\n >['form'] & {\n /** Draft reimbursement state, present only when reimbursement controls are exposed. */\n reimbursementDraft?: { isAdding: boolean }\n }\n}\n\n/**\n * Discriminated union returned by {@link usePayrollEditEmployeeForm}. Loading\n * branch carries only `errorHandling`; ready branch carries form data, fields,\n * status, and actions.\n *\n * @public\n */\nexport type UsePayrollEditEmployeeFormResult = HookLoadingResult | UsePayrollEditEmployeeFormReady\n\n/**\n * Headless form hook for editing a single employee's compensation within a\n * payroll run, built for regular-rate-of-pay (RRoP) support.\n *\n * @remarks\n * Prepares the payroll for the target employee, then exposes a workweek-keyed\n * form whose submit builds a `PayrollUpdate`. Single-workweek pay periods send\n * totals without `breakdowns`; multi-workweek pay periods send `breakdowns` per\n * line once that line's every workweek cell is filled. Overtime-eligible\n * (nonexempt) employees split hours and overtime-affecting earnings per\n * workweek while the single `data.withOvertime` flag is on (see\n * `actions.addOvertime`); everyone else, and every line while `withOvertime` is\n * off, edits flat totals.\n *\n * @param props - Hook options.\n * @returns A loading result while data is fetching, or a ready result with data,\n * fields, status, actions, and error handling.\n * @public\n */\nexport function usePayrollEditEmployeeForm({\n employeeId,\n companyId,\n payrollId,\n withReimbursements = true,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n errorMessages,\n}: UsePayrollEditEmployeeFormProps): UsePayrollEditEmployeeFormResult {\n const { data: employeeData } = useEmployeesGetSuspense({ employeeId })\n const { data: bankAccountsList } = useEmployeePaymentMethodsGetBankAccountsSuspense({\n employeeId,\n })\n const { data: earningTypesData } = useEarningTypesListSuspense({ companyId })\n const { data: payrollData } = usePayrollsGetSuspense({ companyId, payrollId })\n const isTransitionPayroll =\n derivePayrollCategory(payrollData.payrollShow ?? {}) === PayrollCategory.Transition\n\n const queryClient = useQueryClient()\n const { mutateAsync: preparePayroll } = usePayrollsPrepareMutation()\n const { mutateAsync: updatePayroll, isPending } = usePayrollsUpdateMutation()\n\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const [prepareError, setPrepareError] = useState<Error | null>(null)\n const hasFiredRef = useRef(false)\n\n const executePrepare = useCallback(async () => {\n setPrepareError(null)\n try {\n const result = await retryAsync(\n () =>\n preparePayroll({\n request: {\n companyId,\n payrollId,\n requestBody: { employeeUuids: isTransitionPayroll ? undefined : [employeeId] },\n },\n }),\n {\n maxAttempts: PREPARE_MAX_ATTEMPTS,\n delayMs: PREPARE_RETRY_DELAY_MS,\n shouldRetry: isPayrollBeingProcessedError,\n },\n )\n setPreparedPayroll(result.payrollPrepared)\n } catch (error) {\n setPrepareError(error as Error)\n }\n }, [companyId, payrollId, employeeId, preparePayroll, isTransitionPayroll])\n\n useEffect(() => {\n if (hasFiredRef.current) return\n hasFiredRef.current = true\n void executePrepare()\n }, [executePrepare])\n\n const payScheduleQuery = usePaySchedulesGet(\n { companyId, payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid ?? '' },\n { enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid },\n )\n\n const employee = employeeData.employeeShow\n const employeeCompensation = preparedPayroll?.employeeCompensations?.find(\n comp => comp.employeeUuid === employeeId,\n )\n const payrollCategory = derivePayrollCategory(preparedPayroll ?? {})\n const hasDirectDepositSetup = (bankAccountsList.employeeBankAccounts?.length ?? 0) > 0\n\n // Only normalize once the payroll is prepared: normalizeWorkweeks throws on a\n // payroll with neither workweeks nor a pay period, and before prepare resolves\n // both are legitimately absent (still loading, not malformed).\n const workweeks = useMemo(\n () =>\n preparedPayroll\n ? normalizeWorkweeks(preparedPayroll.workweeks, preparedPayroll.payPeriod)\n : [],\n [preparedPayroll],\n )\n\n const overtimeEarningNames = useMemo(\n () => collectOvertimeEarningNames(earningTypesData.earningTypeList),\n [earningTypesData.earningTypeList],\n )\n\n // Source of truth for the employee's FLSA status: prefer the prepared\n // compensation's hourly lines (the same data the fields are built from, so the\n // gate and the rendered lines always agree), falling back to the employee's\n // primary-job compensation. Unknown status is treated as not overtime-eligible.\n const flsaStatus = useMemo(() => {\n const fromCompensation = employeeCompensation?.hourlyCompensations?.find(\n compensation => compensation.flsaStatus,\n )?.flsaStatus\n if (fromCompensation) return fromCompensation\n const primaryJob = employee?.jobs?.find(job => job.primary)\n return primaryJob?.compensations?.[0]?.flsaStatus\n }, [employeeCompensation, employee])\n const isOvertimeEligible = isOvertimeEligibleFlsaStatus(flsaStatus)\n\n // Starts on when the employee already has real overtime hours, or already has\n // per-workweek breakdowns matching the current pay period's workweeks (nothing\n // to hide either way), otherwise starts off until the user opts in via\n // `actions.addOvertime`. One-directional: there's no \"remove overtime\" action.\n const [withOvertimeSetByUser, setWithOvertimeSetByUser] = useState(false)\n const withOvertime =\n withOvertimeSetByUser ||\n hasExistingOvertimeHours(employeeCompensation?.hourlyCompensations) ||\n hasBreakdownsMatchingWorkweeks(employeeCompensation?.hourlyCompensations, workweeks)\n\n const primaryJobUuid = useMemo(() => employee?.jobs?.find(job => job.primary)?.uuid, [employee])\n\n // Seed a blank input for every payroll fixed-compensation type (like the stable\n // editor), then let the field/defaults builders split them into additional\n // earnings vs `overtimeExcludedEarnings` by overtime inclusion. Without this, an employee whose\n // prepared payroll carries no fixed compensations shows no earnings inputs.\n const resolvedFixedCompensations = useMemo(\n () =>\n resolveEditableFixedCompensations(\n employeeCompensation?.fixedCompensations,\n preparedPayroll?.fixedCompensationTypes,\n primaryJobUuid,\n flsaStatus,\n ),\n [employeeCompensation, preparedPayroll?.fixedCompensationTypes, primaryJobUuid, flsaStatus],\n )\n\n const jobTitlesByUuid = useMemo(() => {\n const titles = new Map<string, string>()\n for (const job of employee?.jobs ?? []) {\n if (job.uuid && job.title) titles.set(job.uuid, job.title)\n }\n return titles\n }, [employee])\n\n // Accrual balance per time-off policy, owned by the hook (rather than looked\n // up in the consumer) so the time-off field can render its own live remaining\n // balance.\n const timeOffAccrualByName = useMemo(() => {\n const balances = new Map<string, string>()\n for (const policy of employee?.eligiblePaidTimeOff ?? []) {\n if (policy.name && policy.accrualBalance != null) {\n balances.set(policy.name, policy.accrualBalance)\n }\n }\n return balances\n }, [employee])\n\n const schema = useMemo(() => createPayrollEditEmployeeSchema(), [])\n\n const resolvedDefaults = useMemo(\n () =>\n derivePayrollEditEmployeeDefaults(\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n resolvedFixedCompensations,\n ),\n [\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n resolvedFixedCompensations,\n ],\n )\n\n const formMethods = useForm<PayrollEditEmployeeFormData, unknown, PayrollEditEmployeeFormOutputs>(\n {\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n },\n )\n\n // Watched so each `Fields.timeOff[i].remaining` stays live as the user edits\n // hours. The whole form re-renders on keystroke regardless of who owns this\n // watch, so there's no cost to owning it here rather than in a per-row\n // subcomponent.\n const watchedTimeOff = useWatch({ control: formMethods.control, name: 'timeOff' })\n\n // Off-cycle payrolls write reimbursements via the legacy fixed-compensation path\n // (the itemized array is rejected server-side), so itemized reimbursement controls\n // are exposed only for regular payrolls and only when the partner opts in.\n const usesItemizedReimbursements = !isOffCyclePayroll(payrollCategory)\n const showReimbursements = withReimbursements && usesItemizedReimbursements\n\n const {\n fields: reimbursementArrayFields,\n append: appendReimbursement,\n remove: removeReimbursementRow,\n update: updateReimbursementRow,\n } = useFieldArray({\n control: formMethods.control,\n name: 'reimbursements',\n })\n\n const [isAddingReimbursement, setIsAddingReimbursement] = useState(false)\n\n const reimbursementDraftFields = useMemo<ReimbursementDraftFields>(\n () => createReimbursementDraftFields(errorMessages),\n [errorMessages],\n )\n\n // Committed rows for the consumer's table. A removed existing row (one with a\n // uuid) is zeroed rather than dropped so the update still clears it server-side;\n // those zero-amount rows are filtered out of the visible list but remain in the\n // form array for submit.\n const reimbursementRows = useMemo<ReimbursementRow[]>(\n () =>\n reimbursementArrayFields\n .map((field, index) => ({\n key: field.id,\n index,\n uuid: field.uuid ?? undefined,\n description: field.description,\n amount: field.amount,\n recurring: field.recurring ?? false,\n }))\n .filter(row => parseFloat(row.amount || '0') !== 0),\n [reimbursementArrayFields],\n )\n\n const beginAddReimbursement = useCallback(() => {\n setIsAddingReimbursement(true)\n }, [])\n\n const cancelReimbursement = useCallback(() => {\n formMethods.setValue('reimbursementDraft', { description: '', amount: '' })\n formMethods.clearErrors('reimbursementDraft')\n setIsAddingReimbursement(false)\n }, [formMethods])\n\n const saveReimbursement = useCallback(() => {\n const draft = formMethods.getValues('reimbursementDraft')\n const result = reimbursementDraftSchema.safeParse(draft)\n if (!result.success) {\n // The error code is a fallback; the field renders the consumer-supplied\n // `errorMessage` prop when present (see useField), so the copy is theirs to set.\n formMethods.setError('reimbursementDraft.amount', {\n message: PayrollEditEmployeeErrorCodes.REIMBURSEMENT_AMOUNT,\n })\n return\n }\n appendReimbursement({\n uuid: null,\n description: result.data.description.trim(),\n amount: parseFloat(result.data.amount).toFixed(2),\n recurring: false,\n })\n formMethods.setValue('reimbursementDraft', { description: '', amount: '' })\n formMethods.clearErrors('reimbursementDraft')\n setIsAddingReimbursement(false)\n }, [appendReimbursement, formMethods])\n\n const removeReimbursement = useCallback(\n (index: number) => {\n const field = reimbursementArrayFields[index]\n if (!field) return\n if (field.uuid) {\n updateReimbursementRow(index, { ...field, amount: '0' })\n } else {\n removeReimbursementRow(index)\n }\n },\n [reimbursementArrayFields, removeReimbursementRow, updateReimbursementRow],\n )\n\n const fields = useMemo(\n () =>\n createPayrollEditEmployeeFields({\n employeeCompensation,\n fixedCompensations: resolvedFixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n }),\n [\n employeeCompensation,\n resolvedFixedCompensations,\n workweeks,\n payrollCategory,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n withOvertime,\n jobTitlesByUuid,\n timeOffAccrualByName,\n errorMessages,\n ],\n )\n\n // Overlay the live remaining balance onto each time-off entry every render, so\n // it tracks the watched entered values without rebuilding (and remounting) the\n // bound field components the `fields` memo owns.\n const timeOffFields = useMemo(\n () =>\n fields.timeOff.map(entry => ({\n ...entry,\n remaining: computeTimeOffRemaining(\n timeOffAccrualByName.get(entry.name),\n watchedTimeOff[entry.name],\n ),\n })),\n [fields.timeOff, timeOffAccrualByName, watchedTimeOff],\n )\n\n // Re-derives with `withOvertime` forced `true` and pushes the result straight\n // into the form: every line's first workweek cell gets that line's current\n // total, every other cell is left blank (never auto-distributed — see\n // `derivePayrollEditEmployeeDefaults`/`buildWeekMap`). The per-row validation\n // then requires the user to fill in the rest before they can submit.\n // `setValue` (not `resetField`) is used so this overwrites even a value the\n // user already typed into the collapsed input. Plain function (not memoized):\n // it only runs on a user click, and its inputs are recomputed each render, so\n // a `useCallback` here would never actually hold a stable reference.\n const addOvertime = () => {\n setWithOvertimeSetByUser(true)\n const revealedDefaults = derivePayrollEditEmployeeDefaults(\n employeeCompensation,\n workweeks,\n hasDirectDepositSetup,\n overtimeEarningNames,\n isOvertimeEligible,\n true,\n resolvedFixedCompensations,\n )\n // Keep the user's edited collapsed value on the first workweek cell rather\n // than the seeded API total.\n const firstWeekStart = workweeks[0]?.startDate ?? ''\n const currentValues = formMethods.getValues()\n const overlayLiveFirstWeek = (\n revealed: PayrollEditEmployeeFormData['hours'],\n live: PayrollEditEmployeeFormData['hours'] | undefined,\n ) => {\n for (const [jobUuid, names] of Object.entries(revealed)) {\n for (const [name, weekMap] of Object.entries(names)) {\n const liveValue = live?.[jobUuid]?.[name]?.[firstWeekStart]\n if (liveValue !== undefined) weekMap[firstWeekStart] = liveValue\n }\n }\n return revealed\n }\n // `shouldDirty` so the form's `values`-prop reset (triggered by flipping\n // `withOvertimeSetByUser`) keeps these via `keepDirtyValues`.\n formMethods.setValue(\n 'hours',\n overlayLiveFirstWeek(revealedDefaults.hours, currentValues.hours),\n { shouldDirty: true },\n )\n formMethods.setValue(\n 'overtimeIncludedEarnings',\n overlayLiveFirstWeek(\n revealedDefaults.overtimeIncludedEarnings,\n currentValues.overtimeIncludedEarnings,\n ),\n { shouldDirty: true },\n )\n }\n const fieldsMetadata = useMemo<PayrollEditEmployeeFieldsMetadata>(\n () => ({\n paymentMethod: withOptions(\n { name: 'paymentMethod' },\n PAYMENT_METHOD_OPTIONS,\n PAYMENT_METHOD_VALUES,\n ),\n }),\n [],\n )\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('PayrollEditEmployeeForm')\n\n const prepareQuerySource: QueryWithRefetch = {\n error: prepareError,\n refetch: (() => executePrepare()) as unknown as QueryWithRefetch['refetch'],\n }\n\n const errorHandling = composeErrorHandler([prepareQuerySource, payScheduleQuery], {\n submitError,\n setSubmitError,\n })\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const onSubmit = async (): Promise<HookSubmitResult<PayrollPrepared> | undefined> => {\n let submitResult: HookSubmitResult<PayrollPrepared> | undefined\n\n // A workweek input that loaded with a value and was cleared by the user\n // submits an explicit `0` for that cell. Writing the `0` into form state\n // before validation lets the existing per-row check and submit builder run\n // unchanged: the cell is now filled rather than blank. Cells that were blank\n // at load stay blank (and keep validating as required in a touched row).\n const cleared = zeroFillClearedWorkweekCells(formMethods.getValues(), resolvedDefaults)\n if (cleared.hours) {\n formMethods.setValue('hours', cleared.hours, { shouldDirty: true })\n }\n if (cleared.overtimeIncludedEarnings) {\n formMethods.setValue('overtimeIncludedEarnings', cleared.overtimeIncludedEarnings, {\n shouldDirty: true,\n })\n }\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async data => {\n await baseSubmitHandler(data, async payload => {\n const compensation = buildPayrollUpdateEmployeeCompensation(\n payload,\n employeeCompensation,\n workweeks,\n payrollCategory,\n isOvertimeEligible,\n withOvertime,\n )\n\n const response = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: { employeeCompensations: [compensation] },\n },\n })\n\n const updated = response.payrollPrepared\n if (!updated) {\n throw new SDKInternalError('Payroll update did not return a prepared payroll')\n }\n\n setPreparedPayroll(updated)\n\n // The payroll configuration surface caches its prepared payroll under a hand-written\n // key, which the global SDK auto-invalidation (namespaced to @gusto/embedded-api\n // queries only) does not touch. Invalidate it explicitly so configuration reflects\n // this edit without a manual refresh.\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n\n submitResult = { mode: 'update', data: updated }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n if (!preparedPayroll || !employee) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n employee,\n employeeCompensation,\n preparedPayroll,\n paySchedule: payScheduleQuery.data?.payScheduleShow,\n isMultipleWorkweeks: workweeks.length > 1,\n workweeks,\n isOvertimeEligible,\n withOvertime,\n hasDirectDepositSetup,\n ...(showReimbursements ? { reimbursements: reimbursementRows } : {}),\n },\n status: { isPending, mode: 'update' as const },\n actions: {\n onSubmit,\n addOvertime,\n ...(showReimbursements\n ? {\n beginAddReimbursement,\n saveReimbursement,\n cancelReimbursement,\n removeReimbursement,\n }\n : {}),\n },\n errorHandling,\n form: {\n Fields: {\n ...fields,\n timeOff: timeOffFields,\n reimbursementDraft: showReimbursements ? reimbursementDraftFields : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n ...(showReimbursements ? { reimbursementDraft: { isAdding: isAddingReimbursement } } : {}),\n },\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityError","issue","usePayrollEditEmployeeForm","employeeId","companyId","payrollId","withReimbursements","validationMode","shouldFocusError","errorMessages","employeeData","useEmployeesGetSuspense","bankAccountsList","useEmployeePaymentMethodsGetBankAccountsSuspense","earningTypesData","useEarningTypesListSuspense","payrollData","usePayrollsGetSuspense","isTransitionPayroll","derivePayrollCategory","PayrollCategory","queryClient","useQueryClient","preparePayroll","usePayrollsPrepareMutation","updatePayroll","isPending","usePayrollsUpdateMutation","preparedPayroll","setPreparedPayroll","useState","prepareError","setPrepareError","hasFiredRef","useRef","executePrepare","useCallback","result","retryAsync","useEffect","payScheduleQuery","usePaySchedulesGet","employee","employeeCompensation","comp","payrollCategory","hasDirectDepositSetup","workweeks","useMemo","normalizeWorkweeks","overtimeEarningNames","collectOvertimeEarningNames","flsaStatus","fromCompensation","compensation","job","isOvertimeEligible","isOvertimeEligibleFlsaStatus","withOvertimeSetByUser","setWithOvertimeSetByUser","withOvertime","hasExistingOvertimeHours","hasBreakdownsMatchingWorkweeks","primaryJobUuid","resolvedFixedCompensations","resolveEditableFixedCompensations","jobTitlesByUuid","titles","timeOffAccrualByName","balances","policy","schema","createPayrollEditEmployeeSchema","resolvedDefaults","derivePayrollEditEmployeeDefaults","formMethods","useForm","zodResolver","watchedTimeOff","useWatch","usesItemizedReimbursements","isOffCyclePayroll","showReimbursements","reimbursementArrayFields","appendReimbursement","removeReimbursementRow","updateReimbursementRow","useFieldArray","isAddingReimbursement","setIsAddingReimbursement","reimbursementDraftFields","createReimbursementDraftFields","reimbursementRows","field","index","row","beginAddReimbursement","cancelReimbursement","saveReimbursement","draft","reimbursementDraftSchema","PayrollEditEmployeeErrorCodes","removeReimbursement","fields","createPayrollEditEmployeeFields","timeOffFields","entry","computeTimeOffRemaining","addOvertime","revealedDefaults","firstWeekStart","currentValues","overlayLiveFirstWeek","revealed","live","jobUuid","names","name","weekMap","liveValue","fieldsMetadata","withOptions","PAYMENT_METHOD_OPTIONS","PAYMENT_METHOD_VALUES","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","hookFormInternals","useHookFormInternals","onSubmit","submitResult","cleared","zeroFillClearedWorkweekCells","resolve","data","payload","buildPayrollUpdateEmployeeCompensation","updated","SDKInternalError","PREPARE_QUERY_KEY","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAuEA,MAAMA,KAAuB,GACvBC,KAAyB,MAEzBC,KAA+B,CAACC,MACpCA,aAAiBC,MACjBD,EAAM,OAAO,KAAK,CAAAE,MAASA,EAAM,aAAa,mBAAmB;AAuK5D,SAASC,GAA2B;AAAA,EACzC,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,KAAmB;AAAA,EACnB,eAAAC;AACF,GAAsE;AACpE,QAAM,EAAE,MAAMC,GAAA,IAAiBC,GAAwB,EAAE,YAAAR,GAAY,GAC/D,EAAE,MAAMS,GAAA,IAAqBC,GAAiD;AAAA,IAClF,YAAAV;AAAA,EAAA,CACD,GACK,EAAE,MAAMW,EAAA,IAAqBC,GAA4B,EAAE,WAAAX,GAAW,GACtE,EAAE,MAAMY,GAAA,IAAgBC,GAAuB,EAAE,WAAAb,GAAW,WAAAC,GAAW,GACvEa,IACJC,EAAsBH,GAAY,eAAe,CAAA,CAAE,MAAMI,GAAgB,YAErEC,KAAcC,GAAA,GACd,EAAE,aAAaC,EAAA,IAAmBC,GAAA,GAClC,EAAE,aAAaC,IAAe,WAAAC,GAAA,IAAcC,GAAA,GAE5C,CAACC,GAAiBC,CAAkB,IAAIC,EAAA,GACxC,CAACC,IAAcC,CAAe,IAAIF,EAAuB,IAAI,GAC7DG,IAAcC,GAAO,EAAK,GAE1BC,IAAiBC,EAAY,YAAY;AAC7C,IAAAJ,EAAgB,IAAI;AACpB,QAAI;AACF,YAAMK,IAAS,MAAMC;AAAA,QAC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