@gusto/embedded-react-sdk 0.57.2 → 0.57.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/components/Common/DateRangeFilter/DateRangeFilter.js +32 -32
  3. package/dist/components/Common/DateRangeFilter/DateRangeFilter.js.map +1 -1
  4. package/dist/components/Common/OnboardingStatusBadge/index.js.map +1 -1
  5. package/dist/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.js.map +1 -1
  6. package/dist/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.js.map +1 -1
  7. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js +34 -14
  8. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js.map +1 -1
  9. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.js +106 -0
  10. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.js.map +1 -0
  11. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.js +136 -0
  12. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.js.map +1 -0
  13. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js +38 -20
  14. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js.map +1 -1
  15. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js +78 -44
  16. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js.map +1 -1
  17. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js +45 -37
  18. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js.map +1 -1
  19. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js +244 -95
  20. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js.map +1 -1
  21. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js +22 -0
  22. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js.map +1 -0
  23. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.js +13 -0
  24. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.js.map +1 -0
  25. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js +48 -43
  26. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js.map +1 -1
  27. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.js.map +1 -1
  28. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.js +57 -0
  29. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.js.map +1 -0
  30. package/dist/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.js.map +1 -1
  31. package/dist/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.js +83 -0
  32. package/dist/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.js.map +1 -0
  33. package/dist/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.js +84 -0
  34. package/dist/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.js.map +1 -0
  35. package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js.map +1 -1
  36. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js +109 -39
  37. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js.map +1 -1
  38. package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js.map +1 -1
  39. package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js.map +1 -1
  40. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.js.map +1 -1
  41. package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js +5 -5
  42. package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js.map +1 -1
  43. package/dist/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.js +1 -1
  44. package/dist/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.js.map +1 -1
  45. package/dist/components/Contractor/Compensation/shared/useContractorCompensationSummary/useContractorCompensationSummary.js +4 -4
  46. package/dist/components/Contractor/Compensation/shared/useContractorCompensationSummary/useContractorCompensationSummary.js.map +1 -1
  47. package/dist/components/Contractor/Compensation/shared/useContractorPayForm/useContractorPayForm.js +3 -3
  48. package/dist/components/Contractor/Compensation/shared/useContractorPayForm/useContractorPayForm.js.map +1 -1
  49. package/dist/components/Contractor/ContractorList/shared/useContractorList.js +6 -6
  50. package/dist/components/Contractor/ContractorList/shared/useContractorList.js.map +1 -1
  51. package/dist/components/Contractor/Dashboard/Dashboard.js +20 -20
  52. package/dist/components/Contractor/Dashboard/Dashboard.js.map +1 -1
  53. package/dist/components/Contractor/Dismissal/useDismissal/useDismissal.js +10 -10
  54. package/dist/components/Contractor/Dismissal/useDismissal/useDismissal.js.map +1 -1
  55. package/dist/components/Contractor/Landing/Landing.js +43 -39
  56. package/dist/components/Contractor/Landing/Landing.js.map +1 -1
  57. package/dist/components/Contractor/NewHireReport/NewHireReport.js +3 -3
  58. package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
  59. package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js +1 -1
  60. package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js.map +1 -1
  61. package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js +10 -10
  62. package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -1
  63. package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js +4 -4
  64. package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js.map +1 -1
  65. package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js +8 -8
  66. package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js.map +1 -1
  67. package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js +5 -5
  68. package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js.map +1 -1
  69. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js +3 -3
  70. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js.map +1 -1
  71. package/dist/components/Contractor/Profile/onboarding/SelfOnboardingContractorProfile.js +1 -1
  72. package/dist/components/Contractor/Profile/onboarding/SelfOnboardingContractorProfile.js.map +1 -1
  73. package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js +1 -1
  74. package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js.map +1 -1
  75. package/dist/components/Contractor/Profile/shared/useContractorProfileSummary/useContractorProfileSummary.js +1 -1
  76. package/dist/components/Contractor/Profile/shared/useContractorProfileSummary/useContractorProfileSummary.js.map +1 -1
  77. package/dist/components/Contractor/SelfOnboardingFlow/SelfOnboardingComponents.js +2 -9
  78. package/dist/components/Contractor/SelfOnboardingFlow/SelfOnboardingComponents.js.map +1 -1
  79. package/dist/components/Contractor/Submit/Submit.js +18 -18
  80. package/dist/components/Contractor/Submit/Submit.js.map +1 -1
  81. package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js +6 -6
  82. package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js.map +1 -1
  83. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +25 -25
  84. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
  85. package/dist/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.js +15 -15
  86. package/dist/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.js.map +1 -1
  87. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +1 -1
  88. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
  89. package/dist/components/Employee/Dashboard/Dashboard.js +25 -25
  90. package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
  91. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js +7 -7
  92. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js.map +1 -1
  93. package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js +1 -1
  94. package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js.map +1 -1
  95. package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js +6 -6
  96. package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js.map +1 -1
  97. package/dist/components/Employee/Landing/Landing.js +37 -33
  98. package/dist/components/Employee/Landing/Landing.js.map +1 -1
  99. package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js +27 -27
  100. package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js.map +1 -1
  101. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js +6 -6
  102. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js.map +1 -1
  103. package/dist/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.js +1 -1
  104. package/dist/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.js.map +1 -1
  105. package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.js +8 -15
  106. package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.js.map +1 -1
  107. package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js +11 -11
  108. package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js.map +1 -1
  109. package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js +12 -12
  110. package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js.map +1 -1
  111. package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js +26 -26
  112. package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js.map +1 -1
  113. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +66 -64
  114. package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
  115. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +1 -1
  116. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
  117. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js +6 -6
  118. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
  119. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
  120. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js +1 -1
  121. package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js.map +1 -1
  122. package/dist/components/Payroll/PayrollHistory/PayrollHistory.js.map +1 -1
  123. package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +6 -6
  124. package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
  125. package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
  126. package/dist/components/Payroll/PayrollList/PayrollListPresentation.js +9 -9
  127. package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
  128. package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
  129. package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js.map +1 -1
  130. package/dist/components/Payroll/helpers.js +1 -1
  131. package/dist/components/Payroll/helpers.js.map +1 -1
  132. package/dist/components/Payroll/payrollTypes.js +1 -1
  133. package/dist/components/Payroll/payrollTypes.js.map +1 -1
  134. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  135. package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js +1 -1
  136. package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js.map +1 -1
  137. package/dist/i18n/en/Company.Management.PaySchedule.json.js +31 -13
  138. package/dist/i18n/en/Company.Management.PaySchedule.json.js.map +1 -1
  139. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js +20 -12
  140. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js.map +1 -1
  141. package/dist/i18n/en/Payroll.PayrollHistory.json.js +1 -1
  142. package/dist/i18n/en/Payroll.PayrollList.json.js +5 -5
  143. package/dist/package.json.js +1 -1
  144. package/dist/shared/constants.js +5 -5
  145. package/dist/shared/constants.js.map +1 -1
  146. package/dist/src/components/Common/DateRangeFilter/DateRangeFilter.d.ts +2 -2
  147. package/dist/src/components/Common/OnboardingStatusBadge/index.d.ts +1 -1
  148. package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.d.ts +1 -1
  149. package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.d.ts +1 -1
  150. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.d.ts +10 -3
  151. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.d.ts +21 -0
  152. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.d.ts +34 -0
  153. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.d.ts +9 -3
  154. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.d.ts +5 -1
  155. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.d.ts +10 -10
  156. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.d.ts +12 -4
  157. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.d.ts +19 -0
  158. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.d.ts +17 -0
  159. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.d.ts +1 -1
  160. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.d.ts +34 -0
  161. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/usePayScheduleAssignment.d.ts +16 -3
  162. package/dist/src/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.d.ts +1 -1
  163. package/dist/src/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.d.ts +23 -0
  164. package/dist/src/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.d.ts +25 -0
  165. package/dist/src/components/Company/PaySchedule/management/PayScheduleManagementComponents.d.ts +1 -1
  166. package/dist/src/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.d.ts +1 -1
  167. package/dist/src/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.d.ts +1 -1
  168. package/dist/src/components/Contractor/Landing/Landing.d.ts +5 -2
  169. package/dist/src/components/Employee/Landing/Landing.d.ts +5 -2
  170. package/dist/src/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.d.ts +1 -1
  171. package/dist/src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.d.ts +1 -1
  172. package/dist/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.d.ts +1 -1
  173. package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.d.ts +2 -2
  174. package/dist/src/components/Payroll/PayrollHistory/PayrollHistoryPresentation.d.ts +1 -1
  175. package/dist/src/components/Payroll/PayrollList/PayrollListPresentation.d.ts +2 -2
  176. package/dist/src/components/Payroll/PayrollOverview/PayrollOverviewPresentation.d.ts +1 -1
  177. package/dist/src/components/Payroll/helpers.d.ts +2 -2
  178. package/dist/src/components/Payroll/usePreparedPayrollData.d.ts +2 -2
  179. package/dist/src/i18n/types.d.ts +82 -4
  180. package/dist/src/models/external.d.ts +63 -48
  181. package/dist/src/shared/constants.d.ts +1 -1
  182. package/docs/guides/endpoint-inventory.json +33 -13
  183. package/package.json +18 -18
@@ -1,13 +1,13 @@
1
- import { jsx as r, jsxs as o, Fragment as _ } from "react/jsx-runtime";
2
- import { useRef as z } from "react";
3
- import K from "classnames";
4
- import { useTranslation as W, Trans as X } from "react-i18next";
5
- import { useFormatEmployeePayRate as q, getRegularHours as J, getOvertimeHours as Q, formatHoursDisplay as R, getTotalPtoHours as Y, getAdditionalEarnings as Z, getReimbursements as $, calculateGrossPay as ee } from "../helpers.js";
6
- import { PayrollCategory as E } from "../payrollTypes.js";
1
+ import { jsx as r, jsxs as o, Fragment as z } from "react/jsx-runtime";
2
+ import { useRef as K } from "react";
3
+ import W from "classnames";
4
+ import { useTranslation as X, Trans as q } from "react-i18next";
5
+ import { useFormatEmployeePayRate as J, getRegularHours as Q, getOvertimeHours as Y, formatHoursDisplay as E, getTotalPtoHours as Z, getAdditionalEarnings as $, getReimbursements as b, calculateGrossPay as ee } from "../helpers.js";
6
+ import { PayrollCategory as j } from "../payrollTypes.js";
7
7
  import { PayrollBlockerAlerts as te } from "../PayrollBlocker/components/PayrollBlockerAlerts.js";
8
8
  import re from "./PayrollConfigurationPresentation.module.scss.js";
9
9
  import { useI18n as ne } from "../../../i18n/I18n.js";
10
- import { Flex as u, FlexItem as b } from "../../Common/Flex/Flex.js";
10
+ import { Flex as u, FlexItem as D } from "../../Common/Flex/Flex.js";
11
11
  import { Grid as oe } from "../../Common/Grid/Grid.js";
12
12
  import { HamburgerMenu as ie } from "../../Common/HamburgerMenu/HamburgerMenu.js";
13
13
  import { useComponentContext as le } from "../../../contexts/ComponentAdapter/useComponentContext.js";
@@ -24,32 +24,32 @@ import { DataView as ye } from "../../Common/DataView/DataView.js";
24
24
  const he = (l, f) => l?.startDate && l.endDate ? f.formatPayPeriod(l.startDate, l.endDate) : { startDate: "", endDate: "" }, Ve = ({
25
25
  className: l,
26
26
  employeeCompensations: f,
27
- employeeDetails: j,
27
+ employeeDetails: w,
28
28
  payPeriod: g,
29
- paySchedule: w,
30
- onEdit: H,
31
- onToggleExclude: M,
32
- onCalculatePayroll: D,
33
- onViewBlockers: N,
34
- payrollCategory: y = E.Regular,
35
- alerts: P,
29
+ paySchedule: H,
30
+ onEdit: M,
31
+ onToggleExclude: N,
32
+ onCalculatePayroll: P,
33
+ onViewBlockers: F,
34
+ payrollCategory: y = j.Regular,
35
+ alerts: C,
36
36
  payrollAlert: m,
37
37
  isPending: h,
38
38
  isCalculating: a,
39
- payrollBlockers: C = [],
40
- pagination: F,
41
- withReimbursements: U = !0,
42
- isCalculateDisabled: k = !1,
43
- grossUpEnabled: B = !1,
44
- onGrossUpSelect: G
39
+ payrollBlockers: k = [],
40
+ pagination: U,
41
+ withReimbursements: B = !0,
42
+ isCalculateDisabled: x = !1,
43
+ grossUpEnabled: G = !1,
44
+ onGrossUpSelect: I
45
45
  }) => {
46
- const { Button: x, Heading: T, Text: d, Badge: I, Alert: O } = le();
46
+ const { Button: T, Heading: v, Text: d, Badge: O, Alert: S } = le();
47
47
  ne("Payroll.PayrollConfiguration");
48
- const { t } = W("Payroll.PayrollConfiguration"), S = de(), A = q(), L = fe("payrollRegularRateOfPay"), v = z(null), s = pe({ ref: v }).includes("small"), c = new Map(j.map((e) => [e.uuid, e])), V = (e) => {
48
+ const { t } = X("Payroll.PayrollConfiguration"), A = de(), L = J(), V = fe("payrollRegularRateOfPay"), R = K(null), s = pe({ ref: R }).includes("small"), c = new Map(w.map((e) => [e.uuid, e])), _ = (e) => {
49
49
  const n = c.get(e);
50
50
  return (n ? ue({ first_name: n.firstName, last_name: n.lastName }) : "") || t("unknownEmployeeFallback");
51
51
  };
52
- return /* @__PURE__ */ r("div", { ref: v, className: K(re.container, l), children: /* @__PURE__ */ o(u, { flexDirection: "column", gap: 32, children: [
52
+ return /* @__PURE__ */ r("div", { ref: R, className: W(re.container, l), children: /* @__PURE__ */ o(u, { flexDirection: "column", gap: 32, children: [
53
53
  /* @__PURE__ */ o(
54
54
  u,
55
55
  {
@@ -58,44 +58,44 @@ const he = (l, f) => l?.startDate && l.endDate ? f.formatPayPeriod(l.startDate,
58
58
  alignItems: s ? "center" : "stretch",
59
59
  gap: s ? 0 : 16,
60
60
  children: [
61
- /* @__PURE__ */ o(b, { children: [
62
- /* @__PURE__ */ r(T, { as: "h1", children: t("pageTitle") }),
61
+ /* @__PURE__ */ o(D, { children: [
62
+ /* @__PURE__ */ r(v, { as: "h1", children: t("pageTitle") }),
63
63
  g && /* @__PURE__ */ r(d, { variant: "supporting", children: /* @__PURE__ */ r(
64
- X,
64
+ q,
65
65
  {
66
- i18nKey: y === E.Dismissal ? "descriptionDismissal" : "description",
66
+ i18nKey: y === j.Dismissal ? "descriptionDismissal" : "description",
67
67
  t,
68
68
  components: { dateWrapper: /* @__PURE__ */ r(d, { weight: "bold", as: "span" }) },
69
69
  values: {
70
- ...he(g, S),
70
+ ...he(g, A),
71
71
  payrollType: y
72
72
  }
73
73
  }
74
74
  ) })
75
75
  ] }),
76
- /* @__PURE__ */ r(b, { flexGrow: 0, children: s ? /* @__PURE__ */ r(
77
- x,
76
+ /* @__PURE__ */ r(D, { flexGrow: 0, children: s ? /* @__PURE__ */ r(
77
+ T,
78
78
  {
79
79
  title: t("calculatePayrollTitle"),
80
- onClick: D,
81
- isDisabled: k || h || a,
80
+ onClick: P,
81
+ isDisabled: x || h || a,
82
82
  children: t(a ? "calculatingPayroll" : "calculatePayroll")
83
83
  }
84
84
  ) : /* @__PURE__ */ r(u, { flexDirection: "column", justifyContent: "normal", alignItems: "stretch", gap: 12, children: /* @__PURE__ */ r(
85
- x,
85
+ T,
86
86
  {
87
87
  title: t("calculatePayrollTitle"),
88
- onClick: D,
89
- isDisabled: k || h || a,
88
+ onClick: P,
89
+ isDisabled: x || h || a,
90
90
  children: t(a ? "calculatingPayroll" : "calculatePayroll")
91
91
  }
92
92
  ) }) })
93
93
  ]
94
94
  }
95
95
  ),
96
- (P || m) && /* @__PURE__ */ o(oe, { gap: 16, gridTemplateColumns: "1fr", children: [
97
- m && /* @__PURE__ */ r(O, { label: m.label, status: m.variant, children: m.content }),
98
- P
96
+ (C || m) && /* @__PURE__ */ o(oe, { gap: 16, gridTemplateColumns: "1fr", children: [
97
+ m && /* @__PURE__ */ r(S, { label: m.label, status: m.variant, children: m.content }),
98
+ C
99
99
  ] }),
100
100
  h ? /* @__PURE__ */ r(
101
101
  ge,
@@ -103,17 +103,17 @@ const he = (l, f) => l?.startDate && l.endDate ? f.formatPayPeriod(l.startDate,
103
103
  title: t(a ? "calculatingTitle" : "loadingTitle"),
104
104
  description: t(a ? "calculatingDescription" : "loadingDescription")
105
105
  }
106
- ) : /* @__PURE__ */ o(_, { children: [
107
- C.length > 0 && /* @__PURE__ */ r(
106
+ ) : /* @__PURE__ */ o(z, { children: [
107
+ k.length > 0 && /* @__PURE__ */ r(
108
108
  te,
109
109
  {
110
- blockers: C,
111
- onViewBlockersClick: N
110
+ blockers: k,
111
+ onViewBlockersClick: F
112
112
  }
113
113
  ),
114
114
  /* @__PURE__ */ o(u, { flexDirection: "column", gap: 20, children: [
115
- /* @__PURE__ */ o(b, { children: [
116
- /* @__PURE__ */ r(T, { as: "h2", styledAs: "h3", children: t("hoursAndEarningsTitle") }),
115
+ /* @__PURE__ */ o(D, { children: [
116
+ /* @__PURE__ */ r(v, { as: "h2", styledAs: "h3", children: t("hoursAndEarningsTitle") }),
117
117
  /* @__PURE__ */ r(d, { variant: "supporting", children: t("hoursAndEarningsDescription") })
118
118
  ] }),
119
119
  /* @__PURE__ */ r(
@@ -124,11 +124,11 @@ const he = (l, f) => l?.startDate && l.endDate ? f.formatPayPeriod(l.startDate,
124
124
  {
125
125
  title: t("tableColumns.employees"),
126
126
  render: (e) => {
127
- const n = c.get(e.employeeUuid || ""), i = A(n);
127
+ const n = c.get(e.employeeUuid || ""), i = L(n);
128
128
  return /* @__PURE__ */ o(u, { flexDirection: "column", gap: 0, children: [
129
- V(e.employeeUuid || ""),
129
+ _(e.employeeUuid || ""),
130
130
  i && /* @__PURE__ */ r(d, { size: "xs", variant: "supporting", children: i }),
131
- e.excluded && /* @__PURE__ */ r(I, { status: "warning", children: t("skippedBadge") })
131
+ e.excluded && /* @__PURE__ */ r(O, { status: "warning", children: t("skippedBadge") })
132
132
  ] });
133
133
  }
134
134
  },
@@ -136,32 +136,32 @@ const he = (l, f) => l?.startDate && l.endDate ? f.formatPayPeriod(l.startDate,
136
136
  title: t("tableColumns.hours"),
137
137
  justify: "end",
138
138
  render: (e) => {
139
- const n = J(e), i = Q(e);
140
- return R(n + i);
139
+ const n = Q(e), i = Y(e);
140
+ return E(n + i);
141
141
  }
142
142
  },
143
143
  {
144
144
  title: t("tableColumns.timeOff"),
145
145
  justify: "end",
146
146
  render: (e) => {
147
- const n = Y(e);
148
- return R(n);
147
+ const n = Z(e);
148
+ return E(n);
149
149
  }
150
150
  },
151
151
  {
152
152
  title: t("tableColumns.additionalEarnings"),
153
153
  justify: "end",
154
154
  render: (e) => {
155
- const n = Z(e);
155
+ const n = $(e);
156
156
  return p(n);
157
157
  }
158
158
  },
159
- ...U ? [
159
+ ...B ? [
160
160
  {
161
161
  title: t("tableColumns.reimbursements"),
162
162
  justify: "end",
163
163
  render: (e) => {
164
- const n = $(e);
164
+ const n = b(e);
165
165
  return p(n);
166
166
  }
167
167
  }
@@ -170,16 +170,18 @@ const he = (l, f) => l?.startDate && l.endDate ? f.formatPayPeriod(l.startDate,
170
170
  title: t("tableColumns.totalPay"),
171
171
  justify: "end",
172
172
  render: (e) => {
173
- if (L)
174
- return p(Number(e.grossPay ?? 0));
173
+ if (V)
174
+ return p(
175
+ Number(e.grossPay ?? 0) + b(e)
176
+ );
175
177
  const n = c.get(e.employeeUuid || ""), i = n ? ee(
176
178
  e,
177
179
  n,
178
180
  g?.startDate ?? void 0,
179
- w,
181
+ H,
180
182
  y
181
183
  ) : 0;
182
- return p(i);
184
+ return p(i + b(e));
183
185
  }
184
186
  }
185
187
  ],
@@ -193,22 +195,22 @@ const he = (l, f) => l?.startDate && l.endDate ? f.formatPayPeriod(l.startDate,
193
195
  icon: /* @__PURE__ */ r(ae, { "aria-hidden": !0 }),
194
196
  onClick: () => {
195
197
  const n = c.get(e.employeeUuid || "");
196
- n && H(n);
198
+ n && M(n);
197
199
  }
198
200
  },
199
201
  {
200
202
  label: t(e.excluded ? "editMenu.unskip" : "editMenu.skip"),
201
203
  icon: e.excluded ? /* @__PURE__ */ r(me, { "aria-hidden": !0 }) : /* @__PURE__ */ r(se, { "aria-hidden": !0 }),
202
204
  onClick: () => {
203
- c.get(e.employeeUuid || "") && M(e);
205
+ c.get(e.employeeUuid || "") && N(e);
204
206
  }
205
207
  },
206
- ...B ? [
208
+ ...G ? [
207
209
  {
208
210
  label: t("editMenu.setNetEarnings"),
209
211
  icon: /* @__PURE__ */ r(ce, { "aria-hidden": !0 }),
210
212
  onClick: () => {
211
- e.employeeUuid && G?.(e.employeeUuid);
213
+ e.employeeUuid && I?.(e.employeeUuid);
212
214
  }
213
215
  }
214
216
  ] : []
@@ -216,7 +218,7 @@ const he = (l, f) => l?.startDate && l.endDate ? f.formatPayPeriod(l.startDate,
216
218
  triggerLabel: t("editMenu.edit")
217
219
  }
218
220
  ),
219
- pagination: F
221
+ pagination: U
220
222
  }
221
223
  )
222
224
  ] })
@@ -1 +1 @@
1
- {"version":3,"file":"PayrollConfigurationPresentation.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useRef } from 'react'\nimport classNames from 'classnames'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayScheduleShow as PayScheduleObject } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { Trans, useTranslation } from 'react-i18next'\nimport {\n useFormatEmployeePayRate,\n getRegularHours,\n getOvertimeHours,\n getTotalPtoHours,\n getAdditionalEarnings,\n getReimbursements,\n formatHoursDisplay,\n calculateGrossPay,\n} from '../helpers'\nimport { PayrollCategory } from '../payrollTypes'\nimport type { ApiPayrollBlocker } from '../PayrollBlocker/payrollHelpers'\nimport { PayrollBlockerAlerts } from '../PayrollBlocker/components/PayrollBlockerAlerts'\nimport styles from './PayrollConfigurationPresentation.module.scss'\nimport { useI18n } from '@/i18n'\nimport { DataView, Flex, FlexItem, Grid, PayrollLoading } from '@/components/Common'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport XCircle from '@/assets/icons/x-circle.svg?react'\nimport PlusCircle from '@/assets/icons/plus-circle.svg?react'\nimport CoinsHandSvg from '@/assets/icons/coins-hand.svg?react'\nimport { firstLastName, formatNumberAsCurrency } from '@/helpers/formattedStrings'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport useContainerBreakpoints from '@/hooks/useContainerBreakpoints/useContainerBreakpoints'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\n\ninterface PayrollConfigurationPresentationProps {\n /** CSS class name applied to the root element. */\n className?: string\n employeeCompensations: PayrollEmployeeCompensationsType[]\n employeeDetails: Employee[]\n payPeriod?: PayrollPayPeriodType\n paySchedule?: PayScheduleObject\n onCalculatePayroll: () => void\n onEdit: (employee: Employee) => void\n onToggleExclude: (employeeCompensation: PayrollEmployeeCompensationsType) => void\n onViewBlockers: () => void\n payrollCategory?: PayrollCategory\n alerts?: ReactNode\n payrollAlert?: {\n label: string\n content?: ReactNode\n variant: 'info' | 'warning'\n }\n isPending?: boolean\n isCalculating?: boolean\n payrollBlockers?: ApiPayrollBlocker[]\n pagination?: PaginationControlProps\n withReimbursements?: boolean\n isCalculateDisabled?: boolean\n grossUpEnabled?: boolean\n onGrossUpSelect?: (employeeUuid: string) => void\n}\n\nconst getPayrollConfigurationTitle = (\n payPeriod: PayrollPayPeriodType | undefined,\n dateFormatter: ReturnType<typeof useDateFormatter>,\n) => {\n if (payPeriod?.startDate && payPeriod.endDate) {\n return dateFormatter.formatPayPeriod(payPeriod.startDate, payPeriod.endDate)\n }\n return { startDate: '', endDate: '' }\n}\n\n/** @internal */\nexport const PayrollConfigurationPresentation = ({\n className,\n employeeCompensations,\n employeeDetails,\n payPeriod,\n paySchedule,\n onEdit,\n onToggleExclude,\n onCalculatePayroll,\n onViewBlockers,\n payrollCategory = PayrollCategory.Regular,\n alerts,\n payrollAlert,\n isPending,\n isCalculating,\n payrollBlockers = [],\n pagination,\n withReimbursements = true,\n isCalculateDisabled = false,\n grossUpEnabled = false,\n onGrossUpSelect,\n}: PayrollConfigurationPresentationProps) => {\n const { Button, Heading, Text, Badge, Alert } = useComponentContext()\n useI18n('Payroll.PayrollConfiguration')\n const { t } = useTranslation('Payroll.PayrollConfiguration')\n const dateFormatter = useDateFormatter()\n const formatEmployeePayRate = useFormatEmployeePayRate()\n const isRegularRateOfPayEnabled = useUnstableFeature('payrollRegularRateOfPay')\n const containerRef = useRef<HTMLDivElement>(null)\n const breakpoints = useContainerBreakpoints({ ref: containerRef })\n const isDesktop = breakpoints.includes('small')\n\n const employeeMap = new Map(employeeDetails.map(employee => [employee.uuid, employee]))\n\n const getEmployeeName = (employeeUuid: string) => {\n const employee = employeeMap.get(employeeUuid)\n const name = employee\n ? firstLastName({ first_name: employee.firstName, last_name: employee.lastName })\n : ''\n return name || t('unknownEmployeeFallback')\n }\n\n return (\n <div ref={containerRef} className={classNames(styles.container, className)}>\n <Flex flexDirection=\"column\" gap={32}>\n <Flex\n flexDirection={isDesktop ? 'row' : 'column'}\n justifyContent={isDesktop ? 'space-between' : 'normal'}\n alignItems={isDesktop ? 'center' : 'stretch'}\n gap={isDesktop ? 0 : 16}\n >\n <FlexItem>\n <Heading as=\"h1\">{t('pageTitle')}</Heading>\n {payPeriod && (\n <Text variant=\"supporting\">\n <Trans\n i18nKey={\n payrollCategory === PayrollCategory.Dismissal\n ? 'descriptionDismissal'\n : 'description'\n }\n t={t}\n components={{ dateWrapper: <Text weight=\"bold\" as=\"span\" /> }}\n values={{\n ...getPayrollConfigurationTitle(payPeriod, dateFormatter),\n payrollType: payrollCategory,\n }}\n />\n </Text>\n )}\n </FlexItem>\n <FlexItem flexGrow={isDesktop ? 0 : 0}>\n {isDesktop ? (\n <Button\n title={t('calculatePayrollTitle')}\n onClick={onCalculatePayroll}\n isDisabled={isCalculateDisabled || isPending || isCalculating}\n >\n {isCalculating ? t('calculatingPayroll') : t('calculatePayroll')}\n </Button>\n ) : (\n <Flex flexDirection=\"column\" justifyContent=\"normal\" alignItems=\"stretch\" gap={12}>\n <Button\n title={t('calculatePayrollTitle')}\n onClick={onCalculatePayroll}\n isDisabled={isCalculateDisabled || isPending || isCalculating}\n >\n {isCalculating ? t('calculatingPayroll') : t('calculatePayroll')}\n </Button>\n </Flex>\n )}\n </FlexItem>\n </Flex>\n\n {(alerts || payrollAlert) && (\n <Grid gap={16} gridTemplateColumns=\"1fr\">\n {payrollAlert && (\n <Alert label={payrollAlert.label} status={payrollAlert.variant}>\n {payrollAlert.content}\n </Alert>\n )}\n {alerts}\n </Grid>\n )}\n\n {isPending ? (\n <PayrollLoading\n title={isCalculating ? t('calculatingTitle') : t('loadingTitle')}\n description={isCalculating ? t('calculatingDescription') : t('loadingDescription')}\n />\n ) : (\n <>\n {payrollBlockers.length > 0 && (\n <PayrollBlockerAlerts\n blockers={payrollBlockers}\n onViewBlockersClick={onViewBlockers}\n />\n )}\n <Flex flexDirection=\"column\" gap={20}>\n <FlexItem>\n <Heading as=\"h2\" styledAs=\"h3\">\n {t('hoursAndEarningsTitle')}\n </Heading>\n <Text variant=\"supporting\">{t('hoursAndEarningsDescription')}</Text>\n </FlexItem>\n\n <DataView\n label={t('employeeCompensationsTitle')}\n columns={[\n {\n title: t('tableColumns.employees'),\n render: (item: PayrollEmployeeCompensationsType) => {\n const employee = employeeMap.get(item.employeeUuid || '')\n const payRateDisplay = formatEmployeePayRate(employee)\n return (\n <Flex flexDirection=\"column\" gap={0}>\n {getEmployeeName(item.employeeUuid || '')}\n {payRateDisplay && (\n <Text size=\"xs\" variant=\"supporting\">\n {payRateDisplay}\n </Text>\n )}\n {item.excluded && <Badge status=\"warning\">{t('skippedBadge')}</Badge>}\n </Flex>\n )\n },\n },\n {\n title: t('tableColumns.hours'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const hours = getRegularHours(item)\n const overtimeHours = getOvertimeHours(item)\n return formatHoursDisplay(hours + overtimeHours)\n },\n },\n {\n title: t('tableColumns.timeOff'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const ptoHours = getTotalPtoHours(item)\n return formatHoursDisplay(ptoHours)\n },\n },\n {\n title: t('tableColumns.additionalEarnings'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const earnings = getAdditionalEarnings(item)\n return formatNumberAsCurrency(earnings)\n },\n },\n ...(withReimbursements\n ? [\n {\n title: t('tableColumns.reimbursements'),\n justify: 'end' as const,\n render: (item: PayrollEmployeeCompensationsType) => {\n const reimbursements = getReimbursements(item)\n return formatNumberAsCurrency(reimbursements)\n },\n },\n ]\n : []),\n {\n title: t('tableColumns.totalPay'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n if (isRegularRateOfPayEnabled) {\n return formatNumberAsCurrency(Number(item.grossPay ?? 0))\n }\n const employee = employeeMap.get(item.employeeUuid || '')\n const calculatedGrossPay = employee\n ? calculateGrossPay(\n item,\n employee,\n payPeriod?.startDate ?? undefined,\n paySchedule,\n payrollCategory,\n )\n : 0\n return formatNumberAsCurrency(calculatedGrossPay)\n },\n },\n ]}\n data={employeeCompensations}\n itemMenu={(item: PayrollEmployeeCompensationsType) => (\n <HamburgerMenu\n items={[\n {\n label: t('editMenu.edit'),\n icon: <PencilSvg aria-hidden />,\n onClick: () => {\n const employee = employeeMap.get(item.employeeUuid || '')\n if (employee) {\n onEdit(employee)\n }\n },\n },\n {\n label: t(item.excluded ? 'editMenu.unskip' : 'editMenu.skip'),\n icon: item.excluded ? <PlusCircle aria-hidden /> : <XCircle aria-hidden />,\n onClick: () => {\n const employee = employeeMap.get(item.employeeUuid || '')\n if (employee) {\n onToggleExclude(item)\n }\n },\n },\n ...(grossUpEnabled\n ? [\n {\n label: t('editMenu.setNetEarnings'),\n icon: <CoinsHandSvg aria-hidden />,\n onClick: () => {\n if (item.employeeUuid) {\n onGrossUpSelect?.(item.employeeUuid)\n }\n },\n },\n ]\n : []),\n ]}\n triggerLabel={t('editMenu.edit')}\n />\n )}\n pagination={pagination}\n />\n </Flex>\n </>\n )}\n </Flex>\n </div>\n )\n}\n"],"names":["getPayrollConfigurationTitle","payPeriod","dateFormatter","PayrollConfigurationPresentation","className","employeeCompensations","employeeDetails","paySchedule","onEdit","onToggleExclude","onCalculatePayroll","onViewBlockers","payrollCategory","PayrollCategory","alerts","payrollAlert","isPending","isCalculating","payrollBlockers","pagination","withReimbursements","isCalculateDisabled","grossUpEnabled","onGrossUpSelect","Button","Heading","Text","Badge","Alert","useComponentContext","useI18n","useTranslation","useDateFormatter","formatEmployeePayRate","useFormatEmployeePayRate","isRegularRateOfPayEnabled","useUnstableFeature","containerRef","useRef","isDesktop","useContainerBreakpoints","employeeMap","employee","getEmployeeName","employeeUuid","firstLastName","jsx","classNames","styles","jsxs","Flex","FlexItem","Trans","Grid","PayrollLoading","Fragment","PayrollBlockerAlerts","DataView","item","payRateDisplay","hours","getRegularHours","overtimeHours","getOvertimeHours","formatHoursDisplay","ptoHours","getTotalPtoHours","earnings","getAdditionalEarnings","formatNumberAsCurrency","reimbursements","getReimbursements","calculatedGrossPay","calculateGrossPay","HamburgerMenu","PencilSvg","PlusCircle","XCircle","CoinsHandSvg"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgEA,MAAMA,KAA+B,CACnCC,GACAC,MAEID,GAAW,aAAaA,EAAU,UAC7BC,EAAc,gBAAgBD,EAAU,WAAWA,EAAU,OAAO,IAEtE,EAAE,WAAW,IAAI,SAAS,GAAA,GAItBE,KAAmC,CAAC;AAAA,EAC/C,WAAAC;AAAA,EACA,uBAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,WAAAL;AAAA,EACA,aAAAM;AAAA,EACA,QAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,iBAAAC,IAAkBC,EAAgB;AAAA,EAClC,QAAAC;AAAA,EACA,cAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,iBAAAC,IAAkB,CAAA;AAAA,EAClB,YAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,qBAAAC,IAAsB;AAAA,EACtB,gBAAAC,IAAiB;AAAA,EACjB,iBAAAC;AACF,MAA6C;AAC3C,QAAM,EAAE,QAAAC,GAAQ,SAAAC,GAAS,MAAAC,GAAM,OAAAC,GAAO,OAAAC,EAAA,IAAUC,GAAA;AAChD,EAAAC,GAAQ,8BAA8B;AACtC,QAAM,EAAE,EAAA,IAAMC,EAAe,8BAA8B,GACrD7B,IAAgB8B,GAAA,GAChBC,IAAwBC,EAAA,GACxBC,IAA4BC,GAAmB,yBAAyB,GACxEC,IAAeC,EAAuB,IAAI,GAE1CC,IADcC,GAAwB,EAAE,KAAKH,GAAc,EACnC,SAAS,OAAO,GAExCI,IAAc,IAAI,IAAInC,EAAgB,IAAI,CAAAoC,MA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AK,gBAAA9B,EAAC+B,IAAA,EAAQ,eAAW,GAAA,CAAC;AAAA,oBACxE,SAAS,MAAM;AAEb,sBADiBpC,EAAY,IAAIiB,EAAK,gBAAgB,EAAE,KAEtDjD,EAAgBiD,CAAI;AAAA,oBAExB;AAAA,kBAAA;AAAA,kBAEF,GAAIpC,IACA;AAAA,oBACE;AAAA,sBACE,OAAO,EAAE,yBAAyB;AAAA,sBAClC,MAAM,gBAAAwB,EAACgC,IAAA,EAAa,eAAW,GAAA,CAAC;AAAA,sBAChC,SAAS,MAAM;AACb,wBAAIpB,EAAK,gBACPnC,IAAkBmC,EAAK,YAAY;AAAA,sBAEvC;AAAA,oBAAA;AAAA,kBACF,IAEF,CAAA;AAAA,gBAAC;AAAA,gBAEP,cAAc,EAAE,eAAe;AAAA,cAAA;AAAA,YAAA;AAAA,YAGnC,YAAAvC;AAAA,UAAA;AAAA,QAAA;AAAA,MACF,EAAA,CACF;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,EAAA,CAEJ,EAAA,CACF;AAEJ;"}
1
+ {"version":3,"file":"PayrollConfigurationPresentation.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useRef } from 'react'\nimport classNames from 'classnames'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayScheduleShow as PayScheduleObject } from '@gusto/embedded-api/models/components/payschedulelistitem'\nimport { Trans, useTranslation } from 'react-i18next'\nimport {\n useFormatEmployeePayRate,\n getRegularHours,\n getOvertimeHours,\n getTotalPtoHours,\n getAdditionalEarnings,\n getReimbursements,\n formatHoursDisplay,\n calculateGrossPay,\n} from '../helpers'\nimport { PayrollCategory } from '../payrollTypes'\nimport type { ApiPayrollBlocker } from '../PayrollBlocker/payrollHelpers'\nimport { PayrollBlockerAlerts } from '../PayrollBlocker/components/PayrollBlockerAlerts'\nimport styles from './PayrollConfigurationPresentation.module.scss'\nimport { useI18n } from '@/i18n'\nimport { DataView, Flex, FlexItem, Grid, PayrollLoading } from '@/components/Common'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport XCircle from '@/assets/icons/x-circle.svg?react'\nimport PlusCircle from '@/assets/icons/plus-circle.svg?react'\nimport CoinsHandSvg from '@/assets/icons/coins-hand.svg?react'\nimport { firstLastName, formatNumberAsCurrency } from '@/helpers/formattedStrings'\nimport { useDateFormatter } from '@/hooks/useDateFormatter'\nimport useContainerBreakpoints from '@/hooks/useContainerBreakpoints/useContainerBreakpoints'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\n\ninterface PayrollConfigurationPresentationProps {\n /** CSS class name applied to the root element. */\n className?: string\n employeeCompensations: PayrollEmployeeCompensationsType[]\n employeeDetails: Employee[]\n payPeriod?: PayrollPayPeriodType\n paySchedule?: PayScheduleObject\n onCalculatePayroll: () => void\n onEdit: (employee: Employee) => void\n onToggleExclude: (employeeCompensation: PayrollEmployeeCompensationsType) => void\n onViewBlockers: () => void\n payrollCategory?: PayrollCategory\n alerts?: ReactNode\n payrollAlert?: {\n label: string\n content?: ReactNode\n variant: 'info' | 'warning'\n }\n isPending?: boolean\n isCalculating?: boolean\n payrollBlockers?: ApiPayrollBlocker[]\n pagination?: PaginationControlProps\n withReimbursements?: boolean\n isCalculateDisabled?: boolean\n grossUpEnabled?: boolean\n onGrossUpSelect?: (employeeUuid: string) => void\n}\n\nconst getPayrollConfigurationTitle = (\n payPeriod: PayrollPayPeriodType | undefined,\n dateFormatter: ReturnType<typeof useDateFormatter>,\n) => {\n if (payPeriod?.startDate && payPeriod.endDate) {\n return dateFormatter.formatPayPeriod(payPeriod.startDate, payPeriod.endDate)\n }\n return { startDate: '', endDate: '' }\n}\n\n/** @internal */\nexport const PayrollConfigurationPresentation = ({\n className,\n employeeCompensations,\n employeeDetails,\n payPeriod,\n paySchedule,\n onEdit,\n onToggleExclude,\n onCalculatePayroll,\n onViewBlockers,\n payrollCategory = PayrollCategory.Regular,\n alerts,\n payrollAlert,\n isPending,\n isCalculating,\n payrollBlockers = [],\n pagination,\n withReimbursements = true,\n isCalculateDisabled = false,\n grossUpEnabled = false,\n onGrossUpSelect,\n}: PayrollConfigurationPresentationProps) => {\n const { Button, Heading, Text, Badge, Alert } = useComponentContext()\n useI18n('Payroll.PayrollConfiguration')\n const { t } = useTranslation('Payroll.PayrollConfiguration')\n const dateFormatter = useDateFormatter()\n const formatEmployeePayRate = useFormatEmployeePayRate()\n const isRegularRateOfPayEnabled = useUnstableFeature('payrollRegularRateOfPay')\n const containerRef = useRef<HTMLDivElement>(null)\n const breakpoints = useContainerBreakpoints({ ref: containerRef })\n const isDesktop = breakpoints.includes('small')\n\n const employeeMap = new Map(employeeDetails.map(employee => [employee.uuid, employee]))\n\n const getEmployeeName = (employeeUuid: string) => {\n const employee = employeeMap.get(employeeUuid)\n const name = employee\n ? firstLastName({ first_name: employee.firstName, last_name: employee.lastName })\n : ''\n return name || t('unknownEmployeeFallback')\n }\n\n return (\n <div ref={containerRef} className={classNames(styles.container, className)}>\n <Flex flexDirection=\"column\" gap={32}>\n <Flex\n flexDirection={isDesktop ? 'row' : 'column'}\n justifyContent={isDesktop ? 'space-between' : 'normal'}\n alignItems={isDesktop ? 'center' : 'stretch'}\n gap={isDesktop ? 0 : 16}\n >\n <FlexItem>\n <Heading as=\"h1\">{t('pageTitle')}</Heading>\n {payPeriod && (\n <Text variant=\"supporting\">\n <Trans\n i18nKey={\n payrollCategory === PayrollCategory.Dismissal\n ? 'descriptionDismissal'\n : 'description'\n }\n t={t}\n components={{ dateWrapper: <Text weight=\"bold\" as=\"span\" /> }}\n values={{\n ...getPayrollConfigurationTitle(payPeriod, dateFormatter),\n payrollType: payrollCategory,\n }}\n />\n </Text>\n )}\n </FlexItem>\n <FlexItem flexGrow={isDesktop ? 0 : 0}>\n {isDesktop ? (\n <Button\n title={t('calculatePayrollTitle')}\n onClick={onCalculatePayroll}\n isDisabled={isCalculateDisabled || isPending || isCalculating}\n >\n {isCalculating ? t('calculatingPayroll') : t('calculatePayroll')}\n </Button>\n ) : (\n <Flex flexDirection=\"column\" justifyContent=\"normal\" alignItems=\"stretch\" gap={12}>\n <Button\n title={t('calculatePayrollTitle')}\n onClick={onCalculatePayroll}\n isDisabled={isCalculateDisabled || isPending || isCalculating}\n >\n {isCalculating ? t('calculatingPayroll') : t('calculatePayroll')}\n </Button>\n </Flex>\n )}\n </FlexItem>\n </Flex>\n\n {(alerts || payrollAlert) && (\n <Grid gap={16} gridTemplateColumns=\"1fr\">\n {payrollAlert && (\n <Alert label={payrollAlert.label} status={payrollAlert.variant}>\n {payrollAlert.content}\n </Alert>\n )}\n {alerts}\n </Grid>\n )}\n\n {isPending ? (\n <PayrollLoading\n title={isCalculating ? t('calculatingTitle') : t('loadingTitle')}\n description={isCalculating ? t('calculatingDescription') : t('loadingDescription')}\n />\n ) : (\n <>\n {payrollBlockers.length > 0 && (\n <PayrollBlockerAlerts\n blockers={payrollBlockers}\n onViewBlockersClick={onViewBlockers}\n />\n )}\n <Flex flexDirection=\"column\" gap={20}>\n <FlexItem>\n <Heading as=\"h2\" styledAs=\"h3\">\n {t('hoursAndEarningsTitle')}\n </Heading>\n <Text variant=\"supporting\">{t('hoursAndEarningsDescription')}</Text>\n </FlexItem>\n\n <DataView\n label={t('employeeCompensationsTitle')}\n columns={[\n {\n title: t('tableColumns.employees'),\n render: (item: PayrollEmployeeCompensationsType) => {\n const employee = employeeMap.get(item.employeeUuid || '')\n const payRateDisplay = formatEmployeePayRate(employee)\n return (\n <Flex flexDirection=\"column\" gap={0}>\n {getEmployeeName(item.employeeUuid || '')}\n {payRateDisplay && (\n <Text size=\"xs\" variant=\"supporting\">\n {payRateDisplay}\n </Text>\n )}\n {item.excluded && <Badge status=\"warning\">{t('skippedBadge')}</Badge>}\n </Flex>\n )\n },\n },\n {\n title: t('tableColumns.hours'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const hours = getRegularHours(item)\n const overtimeHours = getOvertimeHours(item)\n return formatHoursDisplay(hours + overtimeHours)\n },\n },\n {\n title: t('tableColumns.timeOff'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const ptoHours = getTotalPtoHours(item)\n return formatHoursDisplay(ptoHours)\n },\n },\n {\n title: t('tableColumns.additionalEarnings'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n const earnings = getAdditionalEarnings(item)\n return formatNumberAsCurrency(earnings)\n },\n },\n ...(withReimbursements\n ? [\n {\n title: t('tableColumns.reimbursements'),\n justify: 'end' as const,\n render: (item: PayrollEmployeeCompensationsType) => {\n const reimbursements = getReimbursements(item)\n return formatNumberAsCurrency(reimbursements)\n },\n },\n ]\n : []),\n {\n title: t('tableColumns.totalPay'),\n justify: 'end',\n render: (item: PayrollEmployeeCompensationsType) => {\n if (isRegularRateOfPayEnabled) {\n return formatNumberAsCurrency(\n Number(item.grossPay ?? 0) + getReimbursements(item),\n )\n }\n const employee = employeeMap.get(item.employeeUuid || '')\n const calculatedGrossPay = employee\n ? calculateGrossPay(\n item,\n employee,\n payPeriod?.startDate ?? undefined,\n paySchedule,\n payrollCategory,\n )\n : 0\n return formatNumberAsCurrency(calculatedGrossPay + getReimbursements(item))\n },\n },\n ]}\n data={employeeCompensations}\n itemMenu={(item: PayrollEmployeeCompensationsType) => (\n <HamburgerMenu\n items={[\n {\n label: t('editMenu.edit'),\n icon: <PencilSvg aria-hidden />,\n onClick: () => {\n const employee = employeeMap.get(item.employeeUuid || '')\n if (employee) {\n onEdit(employee)\n }\n },\n },\n {\n label: t(item.excluded ? 'editMenu.unskip' : 'editMenu.skip'),\n icon: item.excluded ? <PlusCircle aria-hidden /> : <XCircle aria-hidden />,\n onClick: () => {\n const employee = employeeMap.get(item.employeeUuid || '')\n if (employee) {\n onToggleExclude(item)\n }\n },\n },\n ...(grossUpEnabled\n ? [\n {\n label: t('editMenu.setNetEarnings'),\n icon: <CoinsHandSvg aria-hidden />,\n onClick: () => {\n if (item.employeeUuid) {\n onGrossUpSelect?.(item.employeeUuid)\n }\n },\n },\n ]\n : []),\n ]}\n triggerLabel={t('editMenu.edit')}\n />\n )}\n pagination={pagination}\n />\n </Flex>\n </>\n )}\n </Flex>\n </div>\n )\n}\n"],"names":["getPayrollConfigurationTitle","payPeriod","dateFormatter","PayrollConfigurationPresentation","className","employeeCompensations","employeeDetails","paySchedule","onEdit","onToggleExclude","onCalculatePayroll","onViewBlockers","payrollCategory","PayrollCategory","alerts","payrollAlert","isPending","isCalculating","payrollBlockers","pagination","withReimbursements","isCalculateDisabled","grossUpEnabled","onGrossUpSelect","Button","Heading","Text","Badge","Alert","useComponentContext","useI18n","useTranslation","useDateFormatter","formatEmployeePayRate","useFormatEmployeePayRate","isRegularRateOfPayEnabled","useUnstableFeature","containerRef","useRef","isDesktop","useContainerBreakpoints","employeeMap","employee","getEmployeeName","employeeUuid","firstLastName","jsx","classNames","styles","jsxs","Flex","FlexItem","Trans","Grid","PayrollLoading","Fragment","PayrollBlockerAlerts","DataView","item","payRateDisplay","hours","getRegularHours","overtimeHours","getOvertimeHours","formatHoursDisplay","ptoHours","getTotalPtoHours","earnings","getAdditionalEarnings","formatNumberAsCurrency","reimbursements","getReimbursements","calculatedGrossPay","calculateGrossPay","HamburgerMenu","PencilSvg","PlusCircle","XCircle","CoinsHandSvg"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAgEA,MAAMA,KAA+B,CACnCC,GACAC,MAEID,GAAW,aAAaA,EAAU,UAC7BC,EAAc,gBAAgBD,EAAU,WAAWA,EAAU,OAAO,IAEtE,E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,EAAa,eAAW,GAAA,CAAC;AAAA,sBAChC,SAAS,MAAM;AACb,wBAAIpB,EAAK,gBACPnC,IAAkBmC,EAAK,YAAY;AAAA,sBAEvC;AAAA,oBAAA;AAAA,kBACF,IAEF,CAAA;AAAA,gBAAC;AAAA,gBAEP,cAAc,EAAE,eAAe;AAAA,cAAA;AAAA,YAAA;AAAA,YAGnC,YAAAvC;AAAA,UAAA;AAAA,QAAA;AAAA,MACF,EAAA,CACF;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,EAAA,CAEJ,EAAA,CACF;AAEJ;"}
@@ -81,7 +81,7 @@ function De({
81
81
  ), t = e.find((s) => !s.ok);
82
82
  if (t)
83
83
  throw t.error;
84
- return e.filter((s) => s.ok).map((s) => s.value.employee).filter((s) => s != null);
84
+ return e.filter((s) => s.ok).map((s) => s.value.employeeShow).filter((s) => s != null);
85
85
  },
86
86
  enabled: u.length > 0 && !d,
87
87
  staleTime: A
@@ -1 +1 @@
1
- {"version":3,"file":"usePayrollConfigurationData.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { useEmployeesList } from '@gusto/embedded-api/react-query/employeesList'\nimport { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { useGustoEmbeddedContext } from '@gusto/embedded-api/react-query/_context'\nimport { payrollsPrepare } from '@gusto/embedded-api/funcs/payrollsPrepare'\nimport { employeesGet } from '@gusto/embedded-api/funcs/employeesGet'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport type { PayrollCategory } from '../payrollTypes'\nimport { derivePayrollCategory } from '../payrollTypes'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\n\ninterface UsePayrollConfigurationDataParams {\n companyId: string\n payrollId: string\n /** When true, don't call prepare and cancel any prepare already running. */\n disablePrepare?: boolean\n excludedEmployeeUuids?: string[]\n /**\n * When true, prepare is called without a roster. A transition payroll's roster is fixed by the\n * pay-schedule transition, so the API rejects any `employeeUuids` sent to prepare.\n */\n isTransitionPayroll?: boolean\n}\n\ninterface UsePayrollConfigurationDataReturn {\n employeeCompensations: PayrollEmployeeCompensationsType[]\n employeeDetails: Employee[]\n payPeriod: PayrollPayPeriodType | undefined\n paySchedule: PayScheduleShow | undefined\n payrollCategory: PayrollCategory\n pagination: PaginationControlProps\n isLoading: boolean\n isAlreadyProcessed: boolean\n refetch: () => Promise<void>\n}\n\n/** @internal */\nexport const PREPARE_QUERY_KEY = 'payroll-prepare'\nconst FIVE_MINUTES = 5 * 60 * 1000\nconst PREPARE_MAX_ATTEMPTS = 3\n\nconst isAlreadyProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\n/** @internal */\nexport function usePayrollConfigurationData({\n companyId,\n payrollId,\n disablePrepare = false,\n excludedEmployeeUuids = [],\n isTransitionPayroll = false,\n}: UsePayrollConfigurationDataParams): UsePayrollConfigurationDataReturn {\n const gustoClient = useGustoEmbeddedContext()\n const queryClient = useQueryClient()\n\n const { currentPage, itemsPerPage, getPaginationProps } = usePagination({\n defaultItemsPerPage: 25,\n })\n const [displayedEmployees, setDisplayedEmployees] = useState<Employee[]>([])\n const [isDataInSync, setIsDataInSync] = useState(false)\n const hasInitialDataRef = useRef(false)\n\n const { data: employeeData, isFetching: isFetchingEmployeeData } = useEmployeesList(\n {\n companyId,\n payrollUuid: payrollId,\n per: itemsPerPage,\n page: currentPage,\n sortBy: 'name',\n },\n { placeholderData: keepPreviousData, throwOnError: true },\n )\n\n const employeeDataRef = useRef(employeeData)\n employeeDataRef.current = employeeData\n\n const listedEmployeeUuids = useMemo(() => {\n return employeeData?.showEmployees?.map(e => e.uuid) || []\n }, [employeeData?.showEmployees])\n\n const missingExcludedUuids = useMemo(() => {\n const listedSet = new Set(listedEmployeeUuids)\n return excludedEmployeeUuids.filter(uuid => !listedSet.has(uuid))\n }, [excludedEmployeeUuids, listedEmployeeUuids])\n\n const employeeUuids = useMemo(() => {\n if (currentPage === 1) {\n return [...listedEmployeeUuids, ...missingExcludedUuids]\n }\n return listedEmployeeUuids\n }, [listedEmployeeUuids, missingExcludedUuids, currentPage])\n\n const employeeUuidsKey = useMemo(() => employeeUuids.join(','), [employeeUuids])\n\n const {\n data: prepareData,\n error: prepareError,\n isLoading: isPrepareLoading,\n isFetching: isPrepareFetching,\n } = useQuery({\n queryKey: [PREPARE_QUERY_KEY, payrollId, employeeUuidsKey],\n queryFn: async ({ signal }) => {\n const result = await payrollsPrepare(\n gustoClient,\n {\n companyId,\n payrollId,\n sortBy: 'last_name',\n requestBody: {\n employeeUuids: isTransitionPayroll ? undefined : employeeUuids,\n },\n },\n { signal },\n )\n\n if (!result.ok) {\n throw result.error\n }\n\n return result.value.payrollPrepared\n },\n enabled: employeeUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n placeholderData: keepPreviousData,\n throwOnError: error => !isAlreadyProcessedError(error),\n // An \"already processed\" prepare failure is terminal — retrying it wastes time. Other\n // errors (network blips, etc.) still get the standard retry treatment.\n retry: (failureCount, error) =>\n !isAlreadyProcessedError(error) && failureCount < PREPARE_MAX_ATTEMPTS,\n })\n\n const isAlreadyProcessed = isAlreadyProcessedError(prepareError)\n\n useEffect(() => {\n return () => {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [queryClient, payrollId])\n\n useEffect(() => {\n if (disablePrepare) {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [disablePrepare, queryClient, payrollId])\n\n const excludedUuidsKey = useMemo(() => missingExcludedUuids.join(','), [missingExcludedUuids])\n\n const { data: excludedEmployeeDetails } = useQuery({\n queryKey: ['excluded-employee-details', excludedUuidsKey],\n queryFn: async () => {\n const results = await Promise.all(\n missingExcludedUuids.map(uuid => employeesGet(gustoClient, { employeeId: uuid })),\n )\n const failedResult = results.find(result => !result.ok)\n if (failedResult) {\n throw failedResult.error\n }\n\n return results\n .filter(result => result.ok)\n .map(result => result.value.employee)\n .filter((e): e is Employee => e != null)\n },\n enabled: missingExcludedUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n })\n\n const syncData = useCallback(() => {\n const currentEmployeeData = employeeDataRef.current\n if (!currentEmployeeData?.showEmployees || !prepareData?.employeeCompensations) {\n setIsDataInSync(false)\n return\n }\n\n const currentUuids = currentEmployeeData.showEmployees.map(e => e.uuid)\n const preparedUuids = new Set(prepareData.employeeCompensations.map(c => c.employeeUuid))\n const allListedInSync =\n currentUuids.length > 0 && currentUuids.every(uuid => preparedUuids.has(uuid))\n\n if (allListedInSync) {\n const mergedEmployees = [...currentEmployeeData.showEmployees]\n if (currentPage === 1 && excludedEmployeeDetails?.length) {\n const listedSet = new Set(currentUuids)\n for (const employee of excludedEmployeeDetails) {\n if (!listedSet.has(employee.uuid)) {\n mergedEmployees.push(employee)\n }\n }\n }\n setDisplayedEmployees(mergedEmployees)\n setIsDataInSync(true)\n hasInitialDataRef.current = true\n } else {\n setIsDataInSync(false)\n }\n }, [prepareData?.employeeCompensations, excludedEmployeeDetails, currentPage])\n\n useEffect(() => {\n syncData()\n }, [syncData])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: prepareData?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!prepareData?.payPeriod?.payScheduleUuid,\n },\n )\n\n const handleRefetch = useCallback(async () => {\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }, [queryClient, payrollId])\n\n const isInitialLoading = isPrepareLoading && !hasInitialDataRef.current\n const isPaginating = isPrepareFetching && hasInitialDataRef.current\n const isPaginationFetching = isFetchingEmployeeData || isPaginating || !isDataInSync\n const isLoading =\n isInitialLoading || isPayScheduleLoading || (!employeeData && isFetchingEmployeeData)\n\n const headers = employeeData?.httpMeta.response.headers ?? new Headers()\n const pagination: PaginationControlProps = getPaginationProps(headers, isPaginationFetching)\n\n return {\n employeeCompensations: prepareData?.employeeCompensations ?? [],\n employeeDetails: displayedEmployees,\n payPeriod: prepareData?.payPeriod,\n paySchedule: payScheduleData?.payScheduleShow,\n payrollCategory: derivePayrollCategory(prepareData ?? {}),\n pagination,\n isLoading,\n isAlreadyProcessed,\n refetch: handleRefetch,\n }\n}\n"],"names":["PREPARE_QUERY_KEY","FIVE_MINUTES","PREPARE_MAX_ATTEMPTS","isAlreadyProcessedError","error","UnprocessableEntityError","e","usePayrollConfigurationData","companyId","payrollId","disablePrepare","excludedEmployeeUuids","isTransitionPayroll","gustoClient","useGustoEmbeddedContext","queryClient","useQueryClient","currentPage","itemsPerPage","getPaginationProps","usePagination","displayedEmployees","setDisplayedEmployees","useState","isDataInSync","setIsDataInSync","hasInitialDataRef","useRef","employeeData","isFetchingEmployeeData","useEmployeesList","keepPreviousData","employeeDataRef","listedEmployeeUuids","useMemo","missingExcludedUuids","listedSet","uuid","employeeUuids","employeeUuidsKey","prepareData","prepareError","isPrepareLoading","isPrepareFetching","useQuery","signal","result","payrollsPrepare","failureCount","isAlreadyProcessed","useEffect","excludedUuidsKey","excludedEmployeeDetails","results","employeesGet","failedResult","syncData","useCallback","currentEmployeeData","currentUuids","preparedUuids","c","mergedEmployees","employee","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","handleRefetch","isInitialLoading","isPaginating","isPaginationFetching","isLoading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ACA,oBAAAtB;AAAA,IACA,SAASkB;AAAA,EAAA;AAEb;"}
1
+ {"version":3,"file":"usePayrollConfigurationData.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { useEmployeesList } from '@gusto/embedded-api/react-query/employeesList'\nimport { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { useGustoEmbeddedContext } from '@gusto/embedded-api/react-query/_context'\nimport { payrollsPrepare } from '@gusto/embedded-api/funcs/payrollsPrepare'\nimport { employeesGet } from '@gusto/embedded-api/funcs/employeesGet'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payschedulelistitem'\nimport type { PayrollCategory } from '../payrollTypes'\nimport { derivePayrollCategory } from '../payrollTypes'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\n\ninterface UsePayrollConfigurationDataParams {\n companyId: string\n payrollId: string\n /** When true, don't call prepare and cancel any prepare already running. */\n disablePrepare?: boolean\n excludedEmployeeUuids?: string[]\n /**\n * When true, prepare is called without a roster. A transition payroll's roster is fixed by the\n * pay-schedule transition, so the API rejects any `employeeUuids` sent to prepare.\n */\n isTransitionPayroll?: boolean\n}\n\ninterface UsePayrollConfigurationDataReturn {\n employeeCompensations: PayrollEmployeeCompensationsType[]\n employeeDetails: Employee[]\n payPeriod: PayrollPayPeriodType | undefined\n paySchedule: PayScheduleShow | undefined\n payrollCategory: PayrollCategory\n pagination: PaginationControlProps\n isLoading: boolean\n isAlreadyProcessed: boolean\n refetch: () => Promise<void>\n}\n\n/** @internal */\nexport const PREPARE_QUERY_KEY = 'payroll-prepare'\nconst FIVE_MINUTES = 5 * 60 * 1000\nconst PREPARE_MAX_ATTEMPTS = 3\n\nconst isAlreadyProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\n/** @internal */\nexport function usePayrollConfigurationData({\n companyId,\n payrollId,\n disablePrepare = false,\n excludedEmployeeUuids = [],\n isTransitionPayroll = false,\n}: UsePayrollConfigurationDataParams): UsePayrollConfigurationDataReturn {\n const gustoClient = useGustoEmbeddedContext()\n const queryClient = useQueryClient()\n\n const { currentPage, itemsPerPage, getPaginationProps } = usePagination({\n defaultItemsPerPage: 25,\n })\n const [displayedEmployees, setDisplayedEmployees] = useState<Employee[]>([])\n const [isDataInSync, setIsDataInSync] = useState(false)\n const hasInitialDataRef = useRef(false)\n\n const { data: employeeData, isFetching: isFetchingEmployeeData } = useEmployeesList(\n {\n companyId,\n payrollUuid: payrollId,\n per: itemsPerPage,\n page: currentPage,\n sortBy: 'name',\n },\n { placeholderData: keepPreviousData, throwOnError: true },\n )\n\n const employeeDataRef = useRef(employeeData)\n employeeDataRef.current = employeeData\n\n const listedEmployeeUuids = useMemo(() => {\n return employeeData?.showEmployees?.map(e => e.uuid) || []\n }, [employeeData?.showEmployees])\n\n const missingExcludedUuids = useMemo(() => {\n const listedSet = new Set(listedEmployeeUuids)\n return excludedEmployeeUuids.filter(uuid => !listedSet.has(uuid))\n }, [excludedEmployeeUuids, listedEmployeeUuids])\n\n const employeeUuids = useMemo(() => {\n if (currentPage === 1) {\n return [...listedEmployeeUuids, ...missingExcludedUuids]\n }\n return listedEmployeeUuids\n }, [listedEmployeeUuids, missingExcludedUuids, currentPage])\n\n const employeeUuidsKey = useMemo(() => employeeUuids.join(','), [employeeUuids])\n\n const {\n data: prepareData,\n error: prepareError,\n isLoading: isPrepareLoading,\n isFetching: isPrepareFetching,\n } = useQuery({\n queryKey: [PREPARE_QUERY_KEY, payrollId, employeeUuidsKey],\n queryFn: async ({ signal }) => {\n const result = await payrollsPrepare(\n gustoClient,\n {\n companyId,\n payrollId,\n sortBy: 'last_name',\n requestBody: {\n employeeUuids: isTransitionPayroll ? undefined : employeeUuids,\n },\n },\n { signal },\n )\n\n if (!result.ok) {\n throw result.error\n }\n\n return result.value.payrollPrepared\n },\n enabled: employeeUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n placeholderData: keepPreviousData,\n throwOnError: error => !isAlreadyProcessedError(error),\n // An \"already processed\" prepare failure is terminal — retrying it wastes time. Other\n // errors (network blips, etc.) still get the standard retry treatment.\n retry: (failureCount, error) =>\n !isAlreadyProcessedError(error) && failureCount < PREPARE_MAX_ATTEMPTS,\n })\n\n const isAlreadyProcessed = isAlreadyProcessedError(prepareError)\n\n useEffect(() => {\n return () => {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [queryClient, payrollId])\n\n useEffect(() => {\n if (disablePrepare) {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [disablePrepare, queryClient, payrollId])\n\n const excludedUuidsKey = useMemo(() => missingExcludedUuids.join(','), [missingExcludedUuids])\n\n const { data: excludedEmployeeDetails } = useQuery({\n queryKey: ['excluded-employee-details', excludedUuidsKey],\n queryFn: async () => {\n const results = await Promise.all(\n missingExcludedUuids.map(uuid => employeesGet(gustoClient, { employeeId: uuid })),\n )\n const failedResult = results.find(result => !result.ok)\n if (failedResult) {\n throw failedResult.error\n }\n\n return results\n .filter(result => result.ok)\n .map(result => result.value.employeeShow)\n .filter((e): e is Employee => e != null)\n },\n enabled: missingExcludedUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n })\n\n const syncData = useCallback(() => {\n const currentEmployeeData = employeeDataRef.current\n if (!currentEmployeeData?.showEmployees || !prepareData?.employeeCompensations) {\n setIsDataInSync(false)\n return\n }\n\n const currentUuids = currentEmployeeData.showEmployees.map(e => e.uuid)\n const preparedUuids = new Set(prepareData.employeeCompensations.map(c => c.employeeUuid))\n const allListedInSync =\n currentUuids.length > 0 && currentUuids.every(uuid => preparedUuids.has(uuid))\n\n if (allListedInSync) {\n const mergedEmployees = [...currentEmployeeData.showEmployees]\n if (currentPage === 1 && excludedEmployeeDetails?.length) {\n const listedSet = new Set(currentUuids)\n for (const employee of excludedEmployeeDetails) {\n if (!listedSet.has(employee.uuid)) {\n mergedEmployees.push(employee)\n }\n }\n }\n setDisplayedEmployees(mergedEmployees)\n setIsDataInSync(true)\n hasInitialDataRef.current = true\n } else {\n setIsDataInSync(false)\n }\n }, [prepareData?.employeeCompensations, excludedEmployeeDetails, currentPage])\n\n useEffect(() => {\n syncData()\n }, [syncData])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: prepareData?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!prepareData?.payPeriod?.payScheduleUuid,\n },\n )\n\n const handleRefetch = useCallback(async () => {\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }, [queryClient, payrollId])\n\n const isInitialLoading = isPrepareLoading && !hasInitialDataRef.current\n const isPaginating = isPrepareFetching && hasInitialDataRef.current\n const isPaginationFetching = isFetchingEmployeeData || isPaginating || !isDataInSync\n const isLoading =\n isInitialLoading || isPayScheduleLoading || (!employeeData && isFetchingEmployeeData)\n\n const headers = employeeData?.httpMeta.response.headers ?? new Headers()\n const pagination: PaginationControlProps = getPaginationProps(headers, isPaginationFetching)\n\n return {\n employeeCompensations: prepareData?.employeeCompensations ?? [],\n employeeDetails: displayedEmployees,\n payPeriod: prepareData?.payPeriod,\n paySchedule: payScheduleData?.payScheduleShow,\n payrollCategory: derivePayrollCategory(prepareData ?? {}),\n pagination,\n isLoading,\n isAlreadyProcessed,\n refetch: handleRefetch,\n }\n}\n"],"names":["PREPARE_QUERY_KEY","FIVE_MINUTES","PREPARE_MAX_ATTEMPTS","isAlreadyProcessedError","error","UnprocessableEntityError","e","usePayrollConfigurationData","companyId","payrollId","disablePrepare","excludedEmployeeUuids","isTransitionPayroll","gustoClient","useGustoEmbeddedContext","queryClient","useQueryClient","currentPage","itemsPerPage","getPaginationProps","usePagination","displayedEmployees","setDisplayedEmployees","useState","isDataInSync","setIsDataInSync","hasInitialDataRef","useRef","employeeData","isFetchingEmployeeData","useEmployeesList","keepPreviousData","employeeDataRef","listedEmployeeUuids","useMemo","missingExcludedUuids","listedSet","uuid","employeeUuids","employeeUuidsKey","prepareData","prepareError","isPrepareLoading","isPrepareFetching","useQuery","signal","result","payrollsPrepare","failureCount","isAlreadyProcessed","useEffect","excludedUuidsKey","excludedEmployeeDetails","results","employeesGet","failedResult","syncData","useCallback","currentEmployeeData","currentUuids","preparedUuids","c","mergedEmployees","employee","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","handleRefetch","isInitialLoading","isPaginating","isPaginationFetching","isLoading","headers","pagination","derivePayrollCategory"],"mappings":";;;;;;;;;;AA2CO,MAAMA,IAAoB,mBAC3BC,IAAe,MAAS,KACxBC,KAAuB,GAEvBC,IAA0B,CAACC,MACzBA,aAAiBC,KAChBD,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADP;AAKpD,SAASC,GAA4B;AAAA,EAC1C,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,uBAAAC,IAAwB,CAAA;AAAA,EACxB,qBAAAC,IAAsB;AACxB,GAAyE;AACvE,QAAMC,IAAcC,GAAA,GACdC,IAAcC,GAAA,GAEd,EAAE,aAAAC,GAAa,cAAAC,GAAc,oBAAAC,EAAA,IAAuBC,GAAc;AAAA,IACtE,qBAAqB;AAAA,EAAA,CACtB,GACK,CAACC,GAAoBC,CAAqB,IA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S,CAAC,CAACA,GAAa,WAAW;AAAA,IAAA;AAAA,EACrC,GAGI2B,IAAgBV,EAAY,YAAY;AAC5C,UAAM1C,EAAY,kBAAkB;AAAA,MAClC,UAAU,CAACf,GAAmBS,CAAS;AAAA,IAAA,CACxC;AAAA,EACH,GAAG,CAACM,GAAaN,CAAS,CAAC,GAErB2D,IAAmB1B,KAAoB,CAAChB,EAAkB,SAC1D2C,IAAe1B,KAAqBjB,EAAkB,SACtD4C,IAAuBzC,KAA0BwC,KAAgB,CAAC7C,GAClE+C,IACJH,KAAoBH,KAAyB,CAACrC,KAAgBC,GAE1D2C,IAAU5C,GAAc,SAAS,SAAS,WAAW,IAAI,QAAA,GACzD6C,IAAqCtD,EAAmBqD,GAASF,CAAoB;AAE3F,SAAO;AAAA,IACL,uBAAuB9B,GAAa,yBAAyB,CAAA;AAAA,IAC7D,iBAAiBnB;AAAA,IACjB,WAAWmB,GAAa;AAAA,IACxB,aAAawB,GAAiB;AAAA,IAC9B,iBAAiBU,GAAsBlC,KAAe,EAAE;AAAA,IACxD,YAAAiC;AAAA,IACA,WAAAF;AAAA,IACA,oBAAAtB;AAAA,IACA,SAASkB;AAAA,EAAA;AAEb;"}
@@ -31,12 +31,12 @@ const oe = ({
31
31
  I("Payroll.PayrollEditEmployee", P);
32
32
  const R = W(), { LoadingIndicator: h, baseSubmitHandler: b } = ee(), { data: A } = q({ employeeId: e }), { data: L } = G({
33
33
  employeeId: e
34
- }), g = Q(() => [e], [e]), { data: S } = z({ companyId: r, payrollId: n }), D = d(S.payrollShow ?? {}) === j.Transition, { preparedPayroll: a, paySchedule: k, isLoading: U } = H({
34
+ }), S = Q(() => [e], [e]), { data: g } = z({ companyId: r, payrollId: n }), D = d(g.payrollShow ?? {}) === j.Transition, { preparedPayroll: a, paySchedule: k, isLoading: w } = H({
35
35
  companyId: r,
36
36
  payrollId: n,
37
- employeeUuids: g,
37
+ employeeUuids: S,
38
38
  isTransitionPayroll: D
39
- }), { mutateAsync: _, isPending: w } = M(), u = A.employee, O = a?.employeeCompensations?.find(
39
+ }), { mutateAsync: U, isPending: _ } = M(), u = A.employeeShow, O = a?.employeeCompensations?.find(
40
40
  (o) => o.employeeUuid === e
41
41
  ), x = (L.employeeBankAccounts || []).length > 0, y = d(a ?? {}), B = !F(y), Y = ({
42
42
  paymentMethod: o,
@@ -65,7 +65,7 @@ const oe = ({
65
65
  }), v = async (o) => {
66
66
  const s = Y(o);
67
67
  await b(null, async () => {
68
- const c = await _({
68
+ const c = await U({
69
69
  request: {
70
70
  companyId: r,
71
71
  payrollId: n,
@@ -84,14 +84,14 @@ const oe = ({
84
84
  }, T = () => {
85
85
  p(f.RUN_PAYROLL_EMPLOYEE_CANCELLED);
86
86
  };
87
- return U ? /* @__PURE__ */ t(h, {}) : /* @__PURE__ */ t(
87
+ return w ? /* @__PURE__ */ t(h, {}) : /* @__PURE__ */ t(
88
88
  X,
89
89
  {
90
90
  className: C,
91
91
  onSave: v,
92
92
  onCancel: T,
93
93
  employee: u,
94
- isPending: w,
94
+ isPending: _,
95
95
  employeeCompensation: O,
96
96
  fixedCompensationTypes: a?.fixedCompensationTypes || [],
97
97
  payPeriodStartDate: a?.payPeriod?.startDate ?? void 0,
@@ -1 +1 @@
1
- {"version":3,"file":"PayrollEditEmployee.js","sources":["../../../../src/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.tsx"],"sourcesContent":["import { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeePaymentMethodsGetBankAccountsSuspense } from '@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts'\nimport { usePayrollsUpdateMutation } from '@gusto/embedded-api/react-query/payrollsUpdate'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollUpdateEmployeeCompensations } from '@gusto/embedded-api/models/components/payrollupdate'\nimport { useMemo } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { usePayrollsGetSuspense } from '@gusto/embedded-api/react-query/payrollsGet'\nimport { usePreparedPayrollData } from '../usePreparedPayrollData'\nimport { PREPARE_QUERY_KEY } from '../PayrollConfiguration/usePayrollConfigurationData'\nimport { derivePayrollCategory, isOffCyclePayroll, PayrollCategory } from '../payrollTypes'\nimport { cleanupReimbursements } from '../helpers'\nimport { UNSTABLE_PayrollEditEmployee } from '../UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee'\nimport { PayrollEditEmployeePresentation } from './PayrollEditEmployeePresentation'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\nimport { componentEvents } from '@/shared/constants'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useComponentDictionary } from '@/i18n'\nimport { useBase } from '@/components/Base/useBase'\n\n/**\n * Props for {@link PayrollEditEmployee}.\n *\n * @public\n */\nexport interface PayrollEditEmployeeProps extends BaseComponentInterface<'Payroll.PayrollEditEmployee'> {\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 /** Whether to show reimbursement fields. Defaults to `true`. */\n withReimbursements?: boolean\n}\n\n/**\n * Editor for an individual employee's compensation within a payroll run.\n *\n * Allows modification of pay rates, hours, time off, additional earnings,\n * reimbursements, and payment method for a single employee on the specified payroll.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `runPayroll/employee/saved` | Fired when employee payroll compensation changes are saved | `{ payrollPrepared, employee }` |\n * | `runPayroll/employee/cancelled` | Fired when the user cancels editing employee payroll compensation | — |\n *\n * @param props - {@link PayrollEditEmployeeProps} plus base component props.\n * @returns The employee compensation editor.\n * @public\n *\n * @example\n * ```tsx\n * import { Payroll } from '@gusto/embedded-react-sdk'\n *\n * function MyComponent() {\n * return (\n * <Payroll.PayrollEditEmployee\n * employeeId=\"your-employee-id\"\n * companyId=\"your-company-id\"\n * payrollId=\"your-payroll-id\"\n * onEvent={() => {}}\n * />\n * )\n * }\n * ```\n */\nexport function PayrollEditEmployee(props: PayrollEditEmployeeProps) {\n const isRegularRateOfPayEnabled = useUnstableFeature('payrollRegularRateOfPay')\n\n if (isRegularRateOfPayEnabled) {\n return <UNSTABLE_PayrollEditEmployee {...props} />\n }\n\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({\n employeeId,\n companyId,\n payrollId,\n onEvent,\n dictionary,\n withReimbursements = true,\n className,\n}: PayrollEditEmployeeProps) => {\n useComponentDictionary('Payroll.PayrollEditEmployee', dictionary)\n\n const queryClient = useQueryClient()\n const { LoadingIndicator, baseSubmitHandler } = useBase()\n\n const { data: employeeData } = useEmployeesGetSuspense({ employeeId })\n const { data: bankAccountsList } = useEmployeePaymentMethodsGetBankAccountsSuspense({\n employeeId,\n })\n const memoizedEmployeeId = useMemo(() => [employeeId], [employeeId])\n const { data: payrollData } = usePayrollsGetSuspense({ companyId, payrollId })\n const isTransitionPayroll =\n derivePayrollCategory(payrollData.payrollShow ?? {}) === PayrollCategory.Transition\n const { preparedPayroll, paySchedule, isLoading } = usePreparedPayrollData({\n companyId,\n payrollId,\n employeeUuids: memoizedEmployeeId,\n isTransitionPayroll,\n })\n\n const { mutateAsync: updatePayroll, isPending } = usePayrollsUpdateMutation()\n\n const employee = employeeData.employee!\n const employeeCompensation = preparedPayroll?.employeeCompensations?.find(\n comp => comp.employeeUuid === employeeId,\n )\n const bankAccounts = bankAccountsList.employeeBankAccounts || []\n const hasDirectDepositSetup = bankAccounts.length > 0\n const payrollCategory = derivePayrollCategory(preparedPayroll ?? {})\n const usesItemizedReimbursements = !isOffCyclePayroll(payrollCategory)\n\n const transformEmployeeCompensation = ({\n paymentMethod,\n reimbursements,\n customWithholdings,\n ...compensation\n }: PayrollEmployeeCompensationsType): PayrollUpdateEmployeeCompensations => {\n return {\n ...compensation,\n // The legacy editor edits hours, not per-workweek breakdowns, so omit\n // breakdowns and let the API use the hours we send.\n hourlyCompensations: compensation.hourlyCompensations?.map(hourlyCompensation => {\n const { breakdowns, ...hourlyCompensationWithoutBreakdowns } = hourlyCompensation\n return hourlyCompensationWithoutBreakdowns\n }),\n fixedCompensations: compensation.fixedCompensations?.map(fixedCompensation => {\n const { breakdowns, ...fixedCompensationWithoutBreakdowns } = fixedCompensation\n return fixedCompensationWithoutBreakdowns\n }),\n ...(paymentMethod && paymentMethod !== 'Historical' ? { paymentMethod } : {}),\n memo: compensation.memo || undefined,\n // Off-cycle payrolls write reimbursements via the legacy fixed_compensations field; the\n // itemized array gets rejected by the `emb_off_cycle_disable_named_reimbursements` backend\n // flag (default-on globally, expected removal 2026-09-01).\n // TODO(post-2026-09-01): drop the branch once the flag is gone.\n ...(usesItemizedReimbursements && reimbursements\n ? { reimbursements: cleanupReimbursements(reimbursements) }\n : {}),\n }\n }\n\n const onSave = async (updatedCompensation: PayrollEmployeeCompensationsType) => {\n const transformedCompensation = transformEmployeeCompensation(updatedCompensation)\n await baseSubmitHandler(null, async () => {\n const result = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: {\n employeeCompensations: [transformedCompensation],\n },\n },\n })\n\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_SAVED, {\n payrollPrepared: result.payrollPrepared,\n employee,\n })\n })\n }\n\n const onCancel = () => {\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_CANCELLED)\n }\n\n if (isLoading) {\n return <LoadingIndicator />\n }\n\n return (\n <PayrollEditEmployeePresentation\n className={className}\n onSave={onSave}\n onCancel={onCancel}\n employee={employee}\n isPending={isPending}\n employeeCompensation={employeeCompensation}\n fixedCompensationTypes={preparedPayroll?.fixedCompensationTypes || []}\n payPeriodStartDate={preparedPayroll?.payPeriod?.startDate ?? undefined}\n paySchedule={paySchedule}\n payrollCategory={payrollCategory}\n withReimbursements={withReimbursements}\n hasDirectDepositSetup={hasDirectDepositSetup}\n />\n )\n}\n"],"names":["PayrollEditEmployee","props","useUnstableFeature","jsx","UNSTABLE_PayrollEditEmployee","BaseComponent","Root","employeeId","companyId","payrollId","onEvent","dictionary","withReimbursements","className","useComponentDictionary","queryClient","useQueryClient","LoadingIndicator","baseSubmitHandler","useBase","employeeData","useEmployeesGetSuspense","bankAccountsList","useEmployeePaymentMethodsGetBankAccountsSuspense","memoizedEmployeeId","useMemo","payrollData","usePayrollsGetSuspense","isTransitionPayroll","derivePayrollCategory","PayrollCategory","preparedPayroll","paySchedule","isLoading","usePreparedPayrollData","updatePayroll","isPending","usePayrollsUpdateMutation","employee","employeeCompensation","comp","hasDirectDepositSetup","payrollCategory","usesItemizedReimbursements","isOffCyclePayroll","transformEmployeeCompensation","paymentMethod","reimbursements","customWithholdings","compensation","hourlyCompensation","breakdowns","hourlyCompensationWithoutBreakdowns","fixedCompensation","fixedCompensationWithoutBreakdowns","cleanupReimbursements","onSave","updatedCompensation","transformedCompensation","result","PREPARE_QUERY_KEY","componentEvents","onCancel","PayrollEditEmployeePresentation"],"mappings":";;;;;;;;;;;;;;;;;;AAqEO,SAASA,GAAoBC,GAAiC;AAGnE,SAFkCC,EAAmB,yBAAyB,IAGrE,gBAAAC,EAACC,GAAA,EAA8B,GAAGH,EAAA,CAAO,IAIhD,gBAAAE,EAACE,GAAA,EAAe,GAAGJ,GACjB,UAAA,gBAAAE,EAACG,MAAM,GAAGL,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMK,KAAO,CAAC;AAAA,EACZ,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,YAAAC;AAAA,EACA,oBAAAC,IAAqB;AAAA,EACrB,WAAAC;AACF,MAAgC;AAC9B,EAAAC,EAAuB,+BAA+BH,CAAU;AAEhE,QAAMI,IAAcC,EAAA,GACd,EAAE,kBAAAC,GAAkB,m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/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.tsx"],"sourcesContent":["import { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useEmployeePaymentMethodsGetBankAccountsSuspense } from '@gusto/embedded-api/react-query/employeePaymentMethodsGetBankAccounts'\nimport { usePayrollsUpdateMutation } from '@gusto/embedded-api/react-query/payrollsUpdate'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { PayrollUpdateEmployeeCompensations } from '@gusto/embedded-api/models/components/payrollupdate'\nimport { useMemo } from 'react'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { usePayrollsGetSuspense } from '@gusto/embedded-api/react-query/payrollsGet'\nimport { usePreparedPayrollData } from '../usePreparedPayrollData'\nimport { PREPARE_QUERY_KEY } from '../PayrollConfiguration/usePayrollConfigurationData'\nimport { derivePayrollCategory, isOffCyclePayroll, PayrollCategory } from '../payrollTypes'\nimport { cleanupReimbursements } from '../helpers'\nimport { UNSTABLE_PayrollEditEmployee } from '../UNSTABLE_PayrollEditEmployee/UNSTABLE_PayrollEditEmployee'\nimport { PayrollEditEmployeePresentation } from './PayrollEditEmployeePresentation'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\nimport { componentEvents } from '@/shared/constants'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useComponentDictionary } from '@/i18n'\nimport { useBase } from '@/components/Base/useBase'\n\n/**\n * Props for {@link PayrollEditEmployee}.\n *\n * @public\n */\nexport interface PayrollEditEmployeeProps extends BaseComponentInterface<'Payroll.PayrollEditEmployee'> {\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 /** Whether to show reimbursement fields. Defaults to `true`. */\n withReimbursements?: boolean\n}\n\n/**\n * Editor for an individual employee's compensation within a payroll run.\n *\n * Allows modification of pay rates, hours, time off, additional earnings,\n * reimbursements, and payment method for a single employee on the specified payroll.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `runPayroll/employee/saved` | Fired when employee payroll compensation changes are saved | `{ payrollPrepared, employee }` |\n * | `runPayroll/employee/cancelled` | Fired when the user cancels editing employee payroll compensation | — |\n *\n * @param props - {@link PayrollEditEmployeeProps} plus base component props.\n * @returns The employee compensation editor.\n * @public\n *\n * @example\n * ```tsx\n * import { Payroll } from '@gusto/embedded-react-sdk'\n *\n * function MyComponent() {\n * return (\n * <Payroll.PayrollEditEmployee\n * employeeId=\"your-employee-id\"\n * companyId=\"your-company-id\"\n * payrollId=\"your-payroll-id\"\n * onEvent={() => {}}\n * />\n * )\n * }\n * ```\n */\nexport function PayrollEditEmployee(props: PayrollEditEmployeeProps) {\n const isRegularRateOfPayEnabled = useUnstableFeature('payrollRegularRateOfPay')\n\n if (isRegularRateOfPayEnabled) {\n return <UNSTABLE_PayrollEditEmployee {...props} />\n }\n\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({\n employeeId,\n companyId,\n payrollId,\n onEvent,\n dictionary,\n withReimbursements = true,\n className,\n}: PayrollEditEmployeeProps) => {\n useComponentDictionary('Payroll.PayrollEditEmployee', dictionary)\n\n const queryClient = useQueryClient()\n const { LoadingIndicator, baseSubmitHandler } = useBase()\n\n const { data: employeeData } = useEmployeesGetSuspense({ employeeId })\n const { data: bankAccountsList } = useEmployeePaymentMethodsGetBankAccountsSuspense({\n employeeId,\n })\n const memoizedEmployeeId = useMemo(() => [employeeId], [employeeId])\n const { data: payrollData } = usePayrollsGetSuspense({ companyId, payrollId })\n const isTransitionPayroll =\n derivePayrollCategory(payrollData.payrollShow ?? {}) === PayrollCategory.Transition\n const { preparedPayroll, paySchedule, isLoading } = usePreparedPayrollData({\n companyId,\n payrollId,\n employeeUuids: memoizedEmployeeId,\n isTransitionPayroll,\n })\n\n const { mutateAsync: updatePayroll, isPending } = usePayrollsUpdateMutation()\n\n const employee = employeeData.employeeShow!\n const employeeCompensation = preparedPayroll?.employeeCompensations?.find(\n comp => comp.employeeUuid === employeeId,\n )\n const bankAccounts = bankAccountsList.employeeBankAccounts || []\n const hasDirectDepositSetup = bankAccounts.length > 0\n const payrollCategory = derivePayrollCategory(preparedPayroll ?? {})\n const usesItemizedReimbursements = !isOffCyclePayroll(payrollCategory)\n\n const transformEmployeeCompensation = ({\n paymentMethod,\n reimbursements,\n customWithholdings,\n ...compensation\n }: PayrollEmployeeCompensationsType): PayrollUpdateEmployeeCompensations => {\n return {\n ...compensation,\n // The legacy editor edits hours, not per-workweek breakdowns, so omit\n // breakdowns and let the API use the hours we send.\n hourlyCompensations: compensation.hourlyCompensations?.map(hourlyCompensation => {\n const { breakdowns, ...hourlyCompensationWithoutBreakdowns } = hourlyCompensation\n return hourlyCompensationWithoutBreakdowns\n }),\n fixedCompensations: compensation.fixedCompensations?.map(fixedCompensation => {\n const { breakdowns, ...fixedCompensationWithoutBreakdowns } = fixedCompensation\n return fixedCompensationWithoutBreakdowns\n }),\n ...(paymentMethod && paymentMethod !== 'Historical' ? { paymentMethod } : {}),\n memo: compensation.memo || undefined,\n // Off-cycle payrolls write reimbursements via the legacy fixed_compensations field; the\n // itemized array gets rejected by the `emb_off_cycle_disable_named_reimbursements` backend\n // flag (default-on globally, expected removal 2026-09-01).\n // TODO(post-2026-09-01): drop the branch once the flag is gone.\n ...(usesItemizedReimbursements && reimbursements\n ? { reimbursements: cleanupReimbursements(reimbursements) }\n : {}),\n }\n }\n\n const onSave = async (updatedCompensation: PayrollEmployeeCompensationsType) => {\n const transformedCompensation = transformEmployeeCompensation(updatedCompensation)\n await baseSubmitHandler(null, async () => {\n const result = await updatePayroll({\n request: {\n companyId,\n payrollId,\n payrollUpdate: {\n employeeCompensations: [transformedCompensation],\n },\n },\n })\n\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_SAVED, {\n payrollPrepared: result.payrollPrepared,\n employee,\n })\n })\n }\n\n const onCancel = () => {\n onEvent(componentEvents.RUN_PAYROLL_EMPLOYEE_CANCELLED)\n }\n\n if (isLoading) {\n return <LoadingIndicator />\n }\n\n return (\n <PayrollEditEmployeePresentation\n className={className}\n onSave={onSave}\n onCancel={onCancel}\n employee={employee}\n isPending={isPending}\n employeeCompensation={employeeCompensation}\n fixedCompensationTypes={preparedPayroll?.fixedCompensationTypes || []}\n payPeriodStartDate={preparedPayroll?.payPeriod?.startDate ?? undefined}\n paySchedule={paySchedule}\n payrollCategory={payrollCategory}\n withReimbursements={withReimbursements}\n hasDirectDepositSetup={hasDirectDepositSetup}\n />\n )\n}\n"],"names":["PayrollEditEmployee","props","useUnstableFeature","jsx","UNSTABLE_PayrollEditEmployee","BaseComponent","Root","employeeId","companyId","payrollId","onEvent","dictionary","withReimbursements","className","useComponentDictionary","queryClient","useQueryClient","LoadingIndicator","baseSubmitHandler","useBase","employeeData","useEmployeesGetSuspense","bankAccountsList","useEmployeePaymentMethodsGetBankAccountsSuspense","memoizedEmployeeId","useMemo","payrollData","usePayrollsGetSuspense","isTransitionPayroll","derivePayrollCategory","PayrollCategory","preparedPayroll","paySchedule","isLoading","usePreparedPayrollData","updatePayroll","isPending","usePayrollsUpdateMutation","employee","employeeCompensation","comp","hasDirectDepositSetup","payrollCategory","usesItemizedReimbursements","isOffCyclePayroll","transformEmployeeCompensation","paymentMethod","reimbursements","customWithholdings","compensation","hourlyCompensation","breakdowns","hourlyCompensationWithoutBreakdowns","fixedCompensation","fixedCompensationWithoutBreakdowns","cleanupReimbursements","onSave","updatedCompensation","transformedCompensation","result","PREPARE_QUERY_KEY","componentEvents","onCancel","PayrollEditEmployeePresentation"],"mappings":";;;;;;;;;;;;;;;;;;AAqEO,SAASA,GAAoBC,GAAiC;AAGnE,SAFkCC,EAAmB,yBAAyB,IAGrE,gBAAAC,EAACC,GAAA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