@gusto/embedded-react-sdk 0.46.0 → 0.46.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/CHANGELOG.md +50 -0
  2. package/dist/components/Common/DataView/DataCards/DataCards.d.ts +2 -1
  3. package/dist/components/Common/DataView/DataCards/DataCards.js +14 -13
  4. package/dist/components/Common/DataView/DataCards/DataCards.js.map +1 -1
  5. package/dist/components/Common/DataView/DataTable/DataTable.d.ts +2 -1
  6. package/dist/components/Common/DataView/DataTable/DataTable.js +51 -50
  7. package/dist/components/Common/DataView/DataTable/DataTable.js.map +1 -1
  8. package/dist/components/Common/DataView/DataView.d.ts +1 -0
  9. package/dist/components/Common/DataView/DataView.js.map +1 -1
  10. package/dist/components/Common/DataView/useDataView.d.ts +8 -1
  11. package/dist/components/Common/DataView/useDataView.js +20 -17
  12. package/dist/components/Common/DataView/useDataView.js.map +1 -1
  13. package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.d.ts +9 -0
  14. package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.js +76 -0
  15. package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.js.map +1 -0
  16. package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.module.scss.js +8 -0
  17. package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.module.scss.js.map +1 -0
  18. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js +57 -202
  19. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js.map +1 -1
  20. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.d.ts +25 -0
  21. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js +81 -0
  22. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js.map +1 -0
  23. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.module.scss.js +8 -0
  24. package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.module.scss.js.map +1 -0
  25. package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.d.ts +18 -0
  26. package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js +171 -0
  27. package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js.map +1 -0
  28. package/dist/components/Employee/Compensation/management/index.d.ts +3 -0
  29. package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.d.ts +6 -1
  30. package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js +67 -209
  31. package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js.map +1 -1
  32. package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.d.ts +18 -0
  33. package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.js +169 -0
  34. package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.js.map +1 -0
  35. package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.d.ts +16 -0
  36. package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.js +36 -30
  37. package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.js.map +1 -1
  38. package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.d.ts +1 -1
  39. package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js.map +1 -1
  40. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +213 -191
  41. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
  42. package/dist/components/Employee/Dashboard/Dashboard.js +65 -53
  43. package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
  44. package/dist/components/Employee/Dashboard/DashboardComponents.d.ts +3 -3
  45. package/dist/components/Employee/Dashboard/DashboardComponents.js +138 -101
  46. package/dist/components/Employee/Dashboard/DashboardComponents.js.map +1 -1
  47. package/dist/components/Employee/Dashboard/JobAndPayView.js +340 -320
  48. package/dist/components/Employee/Dashboard/JobAndPayView.js.map +1 -1
  49. package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js +5 -3
  50. package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js.map +1 -1
  51. package/dist/components/Employee/Dashboard/dashboardStateMachine.js +147 -148
  52. package/dist/components/Employee/Dashboard/dashboardStateMachine.js.map +1 -1
  53. package/dist/components/Employee/Dashboard/getPendingCompensationChanges.d.ts +6 -0
  54. package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js +13 -12
  55. package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js.map +1 -1
  56. package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.d.ts +2 -2
  57. package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js +34 -35
  58. package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js.map +1 -1
  59. package/dist/components/Employee/EmployeeList/management/ManagementEmployeeList.js +37 -40
  60. package/dist/components/Employee/EmployeeList/management/ManagementEmployeeList.js.map +1 -1
  61. package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.d.ts +1 -2
  62. package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.js +64 -71
  63. package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.js.map +1 -1
  64. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.d.ts +2 -0
  65. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js +25 -0
  66. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js.map +1 -0
  67. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.d.ts +13 -0
  68. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.js +37 -0
  69. package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.js.map +1 -0
  70. package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.d.ts +6 -0
  71. package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js +69 -0
  72. package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js.map +1 -0
  73. package/dist/components/Employee/EmployeeListFlow/index.d.ts +3 -0
  74. package/dist/components/Employee/HomeAddress/management/HomeAddress.js +15 -12
  75. package/dist/components/Employee/HomeAddress/management/HomeAddress.js.map +1 -1
  76. package/dist/components/Employee/HomeAddress/management/HomeAddressView.d.ts +2 -1
  77. package/dist/components/Employee/HomeAddress/management/HomeAddressView.js +86 -83
  78. package/dist/components/Employee/HomeAddress/management/HomeAddressView.js.map +1 -1
  79. package/dist/components/Employee/WorkAddress/management/WorkAddress.js +14 -11
  80. package/dist/components/Employee/WorkAddress/management/WorkAddress.js.map +1 -1
  81. package/dist/components/Employee/WorkAddress/management/WorkAddressView.d.ts +2 -1
  82. package/dist/components/Employee/WorkAddress/management/WorkAddressView.js +92 -89
  83. package/dist/components/Employee/WorkAddress/management/WorkAddressView.js.map +1 -1
  84. package/dist/components/Employee/exports/employeeManagement.d.ts +2 -0
  85. package/dist/components/Employee/exports/employeeManagement.js +18 -16
  86. package/dist/components/Employee/exports/employeeManagement.js.map +1 -1
  87. package/dist/components/Employee/index.d.ts +2 -0
  88. package/dist/components/Employee/index.js +32 -30
  89. package/dist/components/Employee/index.js.map +1 -1
  90. package/dist/components/Flow/FlowHeader.js +34 -31
  91. package/dist/components/Flow/FlowHeader.js.map +1 -1
  92. package/dist/components/Flow/useFlow.d.ts +12 -0
  93. package/dist/components/Flow/useFlow.js.map +1 -1
  94. package/dist/components/TimeOff/PolicyList/PolicyList.js +92 -69
  95. package/dist/components/TimeOff/PolicyList/PolicyList.js.map +1 -1
  96. package/dist/components/TimeOff/PolicyList/PolicyListPresentation.js +23 -23
  97. package/dist/components/TimeOff/PolicyList/PolicyListPresentation.js.map +1 -1
  98. package/dist/components/TimeOff/TimeOffFlow/TimeOffFlowComponents.d.ts +1 -1
  99. package/dist/components/TimeOff/TimeOffFlow/TimeOffFlowComponents.js.map +1 -1
  100. package/dist/components/TimeOff/TimeOffFlow/timeOffStateMachine.js +73 -56
  101. package/dist/components/TimeOff/TimeOffFlow/timeOffStateMachine.js.map +1 -1
  102. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationForm.js +58 -58
  103. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationForm.js.map +1 -1
  104. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.d.ts +1 -1
  105. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.js +91 -87
  106. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.js.map +1 -1
  107. package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormTypes.d.ts +2 -0
  108. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js +91 -124
  109. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js.map +1 -1
  110. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.d.ts +1 -1
  111. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js +72 -87
  112. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js.map +1 -1
  113. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentationTypes.d.ts +1 -6
  114. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js +160 -220
  115. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js.map +1 -1
  116. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.d.ts +7 -3
  117. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js +77 -54
  118. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js.map +1 -1
  119. package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.test.d.ts +1 -0
  120. package/dist/components/TimeOff/TimeOffPolicyDetail/EditEmployeeBalanceModal.js +12 -11
  121. package/dist/components/TimeOff/TimeOffPolicyDetail/EditEmployeeBalanceModal.js.map +1 -1
  122. package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetail.js +177 -147
  123. package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetail.js.map +1 -1
  124. package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.d.ts +1 -1
  125. package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js +38 -36
  126. package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js.map +1 -1
  127. package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTableTypes.d.ts +2 -0
  128. package/dist/i18n/en/Company.TimeOff.SelectEmployees.json.js +10 -10
  129. package/dist/i18n/en/Company.TimeOff.TimeOffPolicies.json.js +17 -15
  130. package/dist/i18n/en/Company.TimeOff.TimeOffPolicies.json.js.map +1 -1
  131. package/dist/i18n/en/Company.TimeOff.TimeOffPolicyDetails.json.js +9 -9
  132. package/dist/i18n/en/Employee.Compensation.json.js +64 -56
  133. package/dist/i18n/en/Employee.Compensation.json.js.map +1 -1
  134. package/dist/i18n/en/Employee.Dashboard.json.js +26 -24
  135. package/dist/i18n/en/Employee.Dashboard.json.js.map +1 -1
  136. package/dist/i18n/en/Employee.HomeAddress.Management.json.js +12 -10
  137. package/dist/i18n/en/Employee.HomeAddress.Management.json.js.map +1 -1
  138. package/dist/i18n/en/Employee.ManagementEmployeeList.json.js +32 -30
  139. package/dist/i18n/en/Employee.ManagementEmployeeList.json.js.map +1 -1
  140. package/dist/i18n/en/Employee.WorkAddress.Management.json.js +16 -14
  141. package/dist/i18n/en/Employee.WorkAddress.Management.json.js.map +1 -1
  142. package/dist/i18n/en/common.json.d.ts +14 -0
  143. package/dist/partner-hook-utils/form/fields/DatePickerHookField.js +33 -32
  144. package/dist/partner-hook-utils/form/fields/DatePickerHookField.js.map +1 -1
  145. package/dist/partner-hook-utils/types.d.ts +4 -0
  146. package/dist/shared/constants.d.ts +2 -0
  147. package/dist/shared/constants.js +13 -12
  148. package/dist/shared/constants.js.map +1 -1
  149. package/dist/style.css +1 -1
  150. package/dist/types/i18next.d.ts +26 -12
  151. package/docs/reference/endpoint-inventory.json +24 -8
  152. package/package.json +1 -1
@@ -1,267 +1,289 @@
1
- import { useRef as X, useMemo as se, useEffect as V } from "react";
2
- import { useForm as De, useWatch as oe } from "react-hook-form";
3
- import { zodResolver as Ae } from "@hookform/resolvers/zod";
4
- import { useJobsAndCompensationsGetJobs as Ie } from "@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs";
5
- import { useJobsAndCompensationsCreateCompensationMutation as Ue } from "@gusto/embedded-api/react-query/jobsAndCompensationsCreateCompensation";
6
- import { useJobsAndCompensationsUpdateCompensationMutation as Re } from "@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation";
7
- import { useLocationsGetMinimumWages as Te } from "@gusto/embedded-api/react-query/locationsGetMinimumWages";
8
- import { useEmployeeAddressesGetWorkAddresses as je } from "@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses";
9
- import { useEmployeesGet as we } from "@gusto/embedded-api/react-query/employeesGet";
10
- import { createCompensationSchema as Le } from "./compensationSchema.js";
11
- import { EffectiveDateField as _e, MinimumWageIdField as Xe, AdjustForMinimumWageField as Ve, PaymentUnitField as Je, RateField as Ye, FlsaStatusField as ke, TitleField as qe } from "./fields.js";
12
- import { withOptions as J } from "../../../../../partner-hook-utils/form/withOptions.js";
13
- import { createGetFormSubmissionValues as He } from "../../../../../partner-hook-utils/form/getFormSubmissionValues.js";
14
- import { useDeriveFieldsMetadata as Be } from "../../../../../partner-hook-utils/form/useDeriveFieldsMetadata.js";
15
- import { useHookFormInternals as Ge } from "../../../../../partner-hook-utils/form/useHookFormInternals.js";
16
- import { composeErrorHandler as Ke } from "../../../../../partner-hook-utils/composeErrorHandler.js";
17
- import { FlsaStatus as n, PAY_PERIODS as l, TIP_CREDITS_UNSUPPORTED_STATES as Qe } from "../../../../../shared/constants.js";
18
- import { useBaseSubmit as $e } from "../../../../Base/useBaseSubmit.js";
19
- import { SDKInternalError as S } from "../../../../../types/sdkError.js";
20
- function xe(e, s, o) {
1
+ import { useRef as Y, useMemo as U, useEffect as q } from "react";
2
+ import { useForm as Ue, useWatch as ue } from "react-hook-form";
3
+ import { zodResolver as Ie } from "@hookform/resolvers/zod";
4
+ import { useJobsAndCompensationsGetJobs as Re } from "@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs";
5
+ import { GetV1EmployeesEmployeeIdJobsQueryParamInclude as Te } from "@gusto/embedded-api/models/operations/getv1employeesemployeeidjobs";
6
+ import { useJobsAndCompensationsCreateCompensationMutation as we } from "@gusto/embedded-api/react-query/jobsAndCompensationsCreateCompensation";
7
+ import { useJobsAndCompensationsUpdateCompensationMutation as je } from "@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation";
8
+ import { useLocationsGetMinimumWages as Le } from "@gusto/embedded-api/react-query/locationsGetMinimumWages";
9
+ import { useEmployeeAddressesGetWorkAddresses as _e } from "@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses";
10
+ import { useEmployeesGet as Je } from "@gusto/embedded-api/react-query/employeesGet";
11
+ import { createCompensationSchema as Ve } from "./compensationSchema.js";
12
+ import { EffectiveDateField as Xe, MinimumWageIdField as ke, AdjustForMinimumWageField as Ye, PaymentUnitField as qe, RateField as He, FlsaStatusField as Be, TitleField as Ge } from "./fields.js";
13
+ import { withOptions as H } from "../../../../../partner-hook-utils/form/withOptions.js";
14
+ import { createGetFormSubmissionValues as Qe } from "../../../../../partner-hook-utils/form/getFormSubmissionValues.js";
15
+ import { useDeriveFieldsMetadata as Ke } from "../../../../../partner-hook-utils/form/useDeriveFieldsMetadata.js";
16
+ import { useHookFormInternals as $e } from "../../../../../partner-hook-utils/form/useHookFormInternals.js";
17
+ import { composeErrorHandler as xe } from "../../../../../partner-hook-utils/composeErrorHandler.js";
18
+ import { FlsaStatus as i, PAY_PERIODS as p, TIP_CREDITS_UNSUPPORTED_STATES as ze } from "../../../../../shared/constants.js";
19
+ import { useBaseSubmit as Ze } from "../../../../Base/useBaseSubmit.js";
20
+ import { SDKInternalError as M } from "../../../../../types/sdkError.js";
21
+ import { formatDateToStringDate as et, addDays as tt } from "../../../../../helpers/dateFormatting.js";
22
+ function nt(e, o, n) {
21
23
  if (!e) return { compensation: null, job: null };
22
- if (s) {
23
- for (const i of e) {
24
- const r = i.compensations?.find((C) => C.uuid === s);
25
- if (r) return { compensation: r, job: i };
24
+ if (o) {
25
+ for (const a of e) {
26
+ const W = a.compensations?.find((I) => I.uuid === o);
27
+ if (W) return { compensation: W, job: a };
26
28
  }
27
- return { compensation: null, job: null };
29
+ return { compensation: null, job: n ? e.find((a) => a.uuid === n) ?? null : null };
28
30
  }
29
- return o ? { compensation: null, job: e.find((i) => i.uuid === o) ?? null } : { compensation: null, job: null };
31
+ return n ? { compensation: null, job: e.find((r) => r.uuid === n) ?? null } : { compensation: null, job: null };
30
32
  }
31
- function ze(e) {
33
+ function it(e) {
32
34
  if (!e) return null;
33
- for (const s of e) {
34
- if (!s.primary) continue;
35
- const o = s.compensations?.find((i) => i.uuid === s.currentCompensationUuid);
36
- if (o?.flsaStatus) return o.flsaStatus;
35
+ for (const o of e) {
36
+ if (!o.primary) continue;
37
+ const n = o.compensations?.find((r) => r.uuid === o.currentCompensationUuid);
38
+ if (n?.flsaStatus) return n.flsaStatus;
37
39
  }
38
40
  return null;
39
41
  }
40
- function Ze(e) {
42
+ function ot(e) {
41
43
  if (!e?.compensations) return [];
42
- const s = re();
43
- return e.compensations.filter((o) => o.effectiveDate !== void 0 && o.effectiveDate > s);
44
+ const o = ce();
45
+ return e.compensations.filter((n) => n.effectiveDate !== void 0 && n.effectiveDate > o);
44
46
  }
45
- function et(e) {
46
- return e.length === 0 ? null : e.reduce((s, o) => {
47
- const i = o.effectiveDate;
48
- return i && (!s || i < s) ? i : s;
47
+ function st(e) {
48
+ return e.length === 0 ? null : e.reduce((o, n) => {
49
+ const r = n.effectiveDate;
50
+ return r && (!o || r < o) ? r : o;
49
51
  }, null);
50
52
  }
51
- const ie = [
52
- n.EXEMPT,
53
- n.SALARIED_NONEXEMPT,
54
- n.NONEXEMPT,
55
- n.OWNER,
56
- n.COMMISSION_ONLY_EXEMPT,
57
- n.COMMISSION_ONLY_NONEXEMPT
58
- ], tt = ie.map((e) => ({ value: e, label: e })), ae = [
59
- l.HOUR,
60
- l.WEEK,
61
- l.MONTH,
62
- l.YEAR,
63
- l.PAYCHECK
64
- ], nt = ae.map((e) => ({ value: e, label: e }));
65
- function re() {
53
+ const me = [
54
+ i.EXEMPT,
55
+ i.SALARIED_NONEXEMPT,
56
+ i.NONEXEMPT,
57
+ i.OWNER,
58
+ i.COMMISSION_ONLY_EXEMPT,
59
+ i.COMMISSION_ONLY_NONEXEMPT
60
+ ], at = me.map((e) => ({ value: e, label: e })), le = [
61
+ p.HOUR,
62
+ p.WEEK,
63
+ p.MONTH,
64
+ p.YEAR,
65
+ p.PAYCHECK
66
+ ], rt = le.map((e) => ({ value: e, label: e }));
67
+ function ce() {
66
68
  return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
67
69
  }
68
- function Ct({
70
+ function Tt({
69
71
  employeeId: e,
70
- jobId: s,
71
- compensationId: o,
72
- optionalFieldsToRequire: i,
73
- defaultValues: r,
74
- validationMode: C = "onSubmit",
75
- shouldFocusError: ue = !0,
76
- withEffectiveDateField: y = !0
72
+ jobId: o,
73
+ compensationId: n,
74
+ optionalFieldsToRequire: r,
75
+ defaultValues: a,
76
+ validationMode: W = "onSubmit",
77
+ shouldFocusError: I = !0,
78
+ withEffectiveDateField: E = !0
77
79
  }) {
78
- const P = Ie(
79
- { employeeId: e ?? "" },
80
+ const R = Re(
81
+ {
82
+ employeeId: e ?? "",
83
+ // Fetch all effective-dated compensations when editing an existing one so
84
+ // resolveCompAndJob can find the target comp (future-dated comps are
85
+ // omitted from the default response, which only returns the current comp).
86
+ include: n ? Te.AllCompensations : void 0
87
+ },
80
88
  { enabled: !!e }
81
- ), D = je(
89
+ ), T = _e(
82
90
  { employeeId: e ?? "" },
83
91
  { enabled: !!e }
84
- ), A = we({ employeeId: e ?? "" }, { enabled: !!e }), f = P.data?.jobs, Y = D.data?.employeeWorkAddressesList?.find((t) => t.active), k = Y?.locationUuid, me = A.data?.employee, I = Te(
85
- { locationUuid: k ?? "" },
86
- { enabled: !!k }
87
- ), F = I.data?.minimumWageList ?? [], { compensation: u, job: a } = xe(
92
+ ), w = Je({ employeeId: e ?? "" }, { enabled: !!e }), f = R.data?.jobs, B = T.data?.employeeWorkAddressesList?.find((t) => t.active), G = B?.locationUuid, de = w.data?.employee, j = Le(
93
+ { locationUuid: G ?? "" },
94
+ { enabled: !!G }
95
+ ), C = j.data?.minimumWageList ?? [], { compensation: u, job: s } = nt(
88
96
  f,
89
- o,
90
- s
91
- ), ce = f && a ? f.filter((t) => t.uuid !== a.uuid).length : 0, U = X(null);
92
- U.current === null && f !== void 0 && (U.current = f.some((t) => t.primary));
93
- const W = U.current === !0 ? ze(f) : null, R = a?.hireDate ?? null, q = Ze(a), de = q.length > 0, le = et(q), p = !o, T = p ? "create" : "update", j = p && W === n.NONEXEMPT && a?.primary !== !0, [H, fe] = se(
94
- () => Le({
95
- mode: T,
96
- optionalFieldsToRequire: i,
97
- hireDate: R,
98
- withEffectiveDateField: y
97
+ n,
98
+ o
99
+ ), fe = f && s ? f.filter((t) => t.uuid !== s.uuid).length : 0, L = Y(null);
100
+ L.current === null && f !== void 0 && (L.current = f.some((t) => t.primary));
101
+ const N = L.current === !0 ? it(f) : null, F = s?.hireDate ?? // Secondary jobs being created (AddAnotherJob) have no hireDate until the
102
+ // job POST completes. Fall back to the primary job's hireDate so the schema
103
+ // can enforce EFFECTIVE_DATE_BEFORE_HIRE during that window.
104
+ f?.find((t) => t.primary)?.hireDate ?? null, Q = ot(s).filter(
105
+ (t) => t.uuid !== n
106
+ ), pe = Q.length > 0, K = st(Q), d = !n, _ = d ? "create" : "update", J = d && N === i.NONEXEMPT && s?.primary !== !0, h = U(() => {
107
+ if (E && !(!d && s?.primary === !0))
108
+ return et(tt(/* @__PURE__ */ new Date(), 1)) ?? void 0;
109
+ }, [d, s?.primary, E]), [$, ve] = U(
110
+ () => Ve({
111
+ mode: _,
112
+ optionalFieldsToRequire: r,
113
+ hireDate: F,
114
+ minEffectiveDate: h,
115
+ withEffectiveDateField: E
99
116
  }),
100
- [T, i, R, y]
101
- ), B = Y?.state, N = se(
117
+ [_, r, F, h, E]
118
+ ), x = B?.state, P = U(
102
119
  () => ({
103
- title: u?.title ?? a?.title ?? r?.title ?? "",
120
+ title: u?.title ?? s?.title ?? a?.title ?? "",
104
121
  // When adding a secondary, the FLSA must match the primary's — force it
105
122
  // here (overriding any partner default) so the form submits the right
106
123
  // value even though `Fields.FlsaStatus` is hidden.
107
- flsaStatus: j ? W : u?.flsaStatus ?? r?.flsaStatus ?? W ?? void 0,
108
- rate: Number(u?.rate ?? r?.rate ?? 0),
109
- adjustForMinimumWage: u?.adjustForMinimumWage ?? r?.adjustForMinimumWage ?? !1,
110
- minimumWageId: u?.minimumWages?.[0]?.uuid ?? r?.minimumWageId ?? "",
111
- paymentUnit: u?.paymentUnit ?? r?.paymentUnit ?? l.HOUR,
112
- effectiveDate: u?.effectiveDate ?? r?.effectiveDate ?? null
124
+ flsaStatus: J ? N : u?.flsaStatus ?? a?.flsaStatus ?? N ?? void 0,
125
+ rate: Number(u?.rate ?? a?.rate ?? 0),
126
+ adjustForMinimumWage: u?.adjustForMinimumWage ?? a?.adjustForMinimumWage ?? !1,
127
+ minimumWageId: u?.minimumWages?.[0]?.uuid ?? a?.minimumWageId ?? "",
128
+ paymentUnit: u?.paymentUnit ?? a?.paymentUnit ?? p.HOUR,
129
+ effectiveDate: u?.effectiveDate ?? a?.effectiveDate ?? null
113
130
  }),
114
- [u, a, r, W, j]
115
- ), M = De({
116
- resolver: Ae(H),
117
- mode: C,
118
- shouldFocusError: ue,
119
- defaultValues: N,
120
- values: N,
131
+ [u, s, a, N, J]
132
+ ), S = Ue({
133
+ resolver: Ie($),
134
+ mode: W,
135
+ shouldFocusError: I,
136
+ defaultValues: P,
137
+ values: P,
121
138
  resetOptions: { keepDirtyValues: !0 }
122
- }), { control: G, getValues: v, setValue: m } = M, c = oe({ control: G, name: "flsaStatus" }), pe = oe({
123
- control: G,
139
+ }), { control: z, getValues: g, setValue: m } = S, l = ue({ control: z, name: "flsaStatus" }), Ee = ue({
140
+ control: z,
124
141
  name: "adjustForMinimumWage"
125
142
  });
126
- V(() => {
127
- c === n.OWNER ? m("paymentUnit", l.PAYCHECK) : c === n.COMMISSION_ONLY_NONEXEMPT || c === n.COMMISSION_ONLY_EXEMPT ? (m("paymentUnit", l.YEAR), m("rate", 0)) : m("paymentUnit", N.paymentUnit);
128
- }, [c, m, N.paymentUnit]);
129
- const Ee = a ? a.compensations?.find((t) => t.uuid === a.currentCompensationUuid) : void 0, g = (u?.flsaStatus ?? Ee?.flsaStatus ?? null) === n.NONEXEMPT && c !== void 0 && c !== n.NONEXEMPT && ce > 0, h = X(!1), w = X(null);
130
- V(() => {
131
- !p && g && !h.current ? (w.current = v("effectiveDate") ?? null, m("effectiveDate", re(), { shouldDirty: !0, shouldValidate: !1 }), h.current = !0) : !p && !g && h.current && (m("effectiveDate", w.current ?? null, {
143
+ q(() => {
144
+ l === i.OWNER ? m("paymentUnit", p.PAYCHECK) : l === i.COMMISSION_ONLY_NONEXEMPT || l === i.COMMISSION_ONLY_EXEMPT ? (m("paymentUnit", p.YEAR), m("rate", 0)) : m("paymentUnit", P.paymentUnit);
145
+ }, [l, m, P.paymentUnit]);
146
+ const Me = s ? s.compensations?.find((t) => t.uuid === s.currentCompensationUuid) : void 0, b = (u?.flsaStatus ?? Me?.flsaStatus ?? null) === i.NONEXEMPT && l !== void 0 && l !== i.NONEXEMPT && fe > 0, A = Y(!1), V = Y(null);
147
+ q(() => {
148
+ !d && b && !A.current ? (V.current = g("effectiveDate") ?? null, m("effectiveDate", ce(), { shouldDirty: !0, shouldValidate: !1 }), A.current = !0) : !d && !b && A.current && (m("effectiveDate", V.current ?? null, {
132
149
  shouldDirty: !0,
133
150
  shouldValidate: !1
134
- }), w.current = null, h.current = !1);
135
- }, [p, g, v, m]);
136
- const K = Re(), Q = Ue(), Se = K.isPending || Q.isPending, {
137
- baseSubmitHandler: Me,
138
- error: ve,
139
- setError: ge
140
- } = $e("CompensationForm"), $ = Ke(e ? [P, D, A, I] : [], { submitError: ve, setSubmitError: ge }), x = c === n.COMMISSION_ONLY_NONEXEMPT || c === n.COMMISSION_ONLY_EXEMPT, be = c === n.OWNER, Oe = !j && (c !== n.NONEXEMPT || a?.primary === !0 || p), b = c === n.NONEXEMPT && F.length > 0 && B !== void 0 && !Qe.includes(B);
141
- V(() => {
142
- b || (v("adjustForMinimumWage") && m("adjustForMinimumWage", !1, { shouldDirty: !0, shouldValidate: !1 }), v("minimumWageId") && m("minimumWageId", "", { shouldDirty: !0, shouldValidate: !1 }));
143
- }, [b, v, m]);
144
- const ye = F.map((t) => ({
151
+ }), V.current = null, A.current = !1);
152
+ }, [d, b, g, m]);
153
+ const Z = je(), ee = we(), Se = Z.isPending || ee.isPending, {
154
+ baseSubmitHandler: ge,
155
+ error: be,
156
+ setError: ye
157
+ } = Ze("CompensationForm"), te = xe(e ? [R, T, w, j] : [], { submitError: be, setSubmitError: ye }), ne = l === i.COMMISSION_ONLY_NONEXEMPT || l === i.COMMISSION_ONLY_EXEMPT, Oe = l === i.OWNER, De = !J && (l !== i.NONEXEMPT || s?.primary === !0 || d), y = l === i.NONEXEMPT && C.length > 0 && x !== void 0 && !ze.includes(x);
158
+ q(() => {
159
+ y || (g("adjustForMinimumWage") && m("adjustForMinimumWage", !1, { shouldDirty: !0, shouldValidate: !1 }), g("minimumWageId") && m("minimumWageId", "", { shouldDirty: !0, shouldValidate: !1 }));
160
+ }, [y, g, m]);
161
+ const We = C.map((t) => ({
145
162
  value: t.uuid,
146
163
  label: `${t.wage} - ${t.authority}: ${t.notes ?? ""}`
147
- })), E = Be(fe, M.control), Fe = {
148
- title: E.title,
164
+ })), v = Ke(ve, S.control), ie = U(
165
+ () => [h, F].filter((t) => !!t).reduce((t, O) => !t || O > t ? O : t, null),
166
+ [h, F]
167
+ ), Ce = {
168
+ title: v.title,
149
169
  effectiveDate: {
150
- ...E.effectiveDate,
151
- isDisabled: g && !p
170
+ ...v.effectiveDate,
171
+ isDisabled: b && !d,
172
+ minDate: ie,
173
+ maxDate: K
152
174
  },
153
- flsaStatus: J(
154
- E.flsaStatus,
155
- tt,
156
- ie
175
+ flsaStatus: H(
176
+ v.flsaStatus,
177
+ at,
178
+ me
157
179
  ),
158
- rate: { ...E.rate, isDisabled: x },
159
- paymentUnit: J(
160
- { ...E.paymentUnit, isDisabled: be || x },
161
- nt,
162
- ae
180
+ rate: { ...v.rate, isDisabled: ne },
181
+ paymentUnit: H(
182
+ { ...v.paymentUnit, isDisabled: Oe || ne },
183
+ rt,
184
+ le
163
185
  ),
164
186
  adjustForMinimumWage: {
165
- ...E.adjustForMinimumWage,
166
- isDisabled: !b
187
+ ...v.adjustForMinimumWage,
188
+ isDisabled: !y
167
189
  },
168
- minimumWageId: J(
169
- E.minimumWageId,
170
- ye,
171
- F
190
+ minimumWageId: H(
191
+ v.minimumWageId,
192
+ We,
193
+ C
172
194
  )
173
- }, We = async (t) => {
174
- let z;
175
- return await new Promise((Z) => {
176
- M.handleSubmit(
177
- async (Ce) => {
178
- await Me(Ce, async (d) => {
179
- const ee = t?.jobId ?? s, L = t?.compensationId ?? o, te = L ? "update" : "create", Pe = y ? t?.effectiveDate ?? d.effectiveDate ?? void 0 : t?.effectiveDate ?? void 0, ne = {
180
- rate: String(d.rate),
181
- paymentUnit: d.paymentUnit,
182
- flsaStatus: d.flsaStatus,
183
- effectiveDate: Pe,
184
- title: d.title || void 0,
185
- adjustForMinimumWage: d.adjustForMinimumWage,
186
- minimumWages: d.adjustForMinimumWage ? [{ uuid: d.minimumWageId }] : []
195
+ }, Ne = async (t) => {
196
+ let O;
197
+ return await new Promise((oe) => {
198
+ S.handleSubmit(
199
+ async (Pe) => {
200
+ await ge(Pe, async (c) => {
201
+ const se = t?.jobId ?? o, X = t?.compensationId ?? n, ae = X ? "update" : "create", Ae = E ? t?.effectiveDate ?? c.effectiveDate ?? void 0 : t?.effectiveDate ?? void 0, re = {
202
+ rate: String(c.rate),
203
+ paymentUnit: c.paymentUnit,
204
+ flsaStatus: c.flsaStatus,
205
+ effectiveDate: Ae,
206
+ title: c.title || void 0,
207
+ adjustForMinimumWage: c.adjustForMinimumWage,
208
+ minimumWages: c.adjustForMinimumWage ? [{ uuid: c.minimumWageId }] : []
187
209
  };
188
- let O;
189
- if (te === "create") {
190
- if (!ee)
191
- throw new S(
210
+ let D;
211
+ if (ae === "create") {
212
+ if (!se)
213
+ throw new M(
192
214
  "jobId is required to create a compensation. Pass it as a hook prop or via submit options."
193
215
  );
194
- if (!d.flsaStatus)
195
- throw new S("flsaStatus is required to create a compensation.");
196
- if (O = (await Q.mutateAsync({
216
+ if (!c.flsaStatus)
217
+ throw new M("flsaStatus is required to create a compensation.");
218
+ if (D = (await ee.mutateAsync({
197
219
  request: {
198
- jobId: ee,
199
- compensationsRequestBody: { ...ne, flsaStatus: d.flsaStatus }
220
+ jobId: se,
221
+ compensationsRequestBody: { ...re, flsaStatus: c.flsaStatus }
200
222
  }
201
- })).compensation, !O) throw new S("Compensation creation failed");
223
+ })).compensation, !D) throw new M("Compensation creation failed");
202
224
  } else {
203
- if (!L)
204
- throw new S(
225
+ if (!X)
226
+ throw new M(
205
227
  "compensationId is required to update a compensation. Pass it as a hook prop or via submit options."
206
228
  );
207
- const _ = t?.compensationVersion ?? u?.version;
208
- if (!_)
209
- throw new S(
229
+ const k = t?.compensationVersion ?? u?.version;
230
+ if (!k)
231
+ throw new M(
210
232
  "compensation version is required to update a compensation. Pass it via submit options when threading post-create, or ensure the compensation is loaded."
211
233
  );
212
- if (O = (await K.mutateAsync({
234
+ if (D = (await Z.mutateAsync({
213
235
  request: {
214
- compensationId: L,
236
+ compensationId: X,
215
237
  compensationsUpdateRequestBody: {
216
- version: _,
217
- ...ne
238
+ version: k,
239
+ ...re
218
240
  }
219
241
  }
220
- })).compensation, !O) throw new S("Compensation update failed");
242
+ })).compensation, !D) throw new M("Compensation update failed");
221
243
  }
222
- z = { mode: te, data: O };
223
- }), Z();
244
+ O = { mode: ae, data: D };
245
+ }), oe();
224
246
  },
225
247
  () => {
226
- Z();
248
+ oe();
227
249
  }
228
250
  )();
229
- }), z;
230
- }, Ne = e ? P.isLoading || D.isLoading || A.isLoading || I.isLoading : !1, he = Ge(M);
231
- return Ne || e && (!f || !me) ? { isLoading: !0, errorHandling: $ } : {
251
+ }), O;
252
+ }, Fe = e ? R.isLoading || T.isLoading || w.isLoading || j.isLoading : !1, he = $e(S);
253
+ return Fe || e && (!f || !de) ? { isLoading: !0, errorHandling: te } : {
232
254
  isLoading: !1,
233
255
  data: {
234
256
  compensation: u,
235
- currentJob: a,
236
- minimumWages: F,
237
- minimumEffectiveDate: R,
238
- maximumEffectiveDate: le,
239
- hasPendingFutureCompensation: de
257
+ currentJob: s,
258
+ minimumWages: C,
259
+ minimumEffectiveDate: ie,
260
+ maximumEffectiveDate: K,
261
+ hasPendingFutureCompensation: pe
240
262
  },
241
263
  status: {
242
264
  isPending: Se,
243
- mode: T,
244
- willDeleteSecondaryJobs: g
265
+ mode: _,
266
+ willDeleteSecondaryJobs: b
245
267
  },
246
- actions: { onSubmit: We },
247
- errorHandling: $,
268
+ actions: { onSubmit: Ne },
269
+ errorHandling: te,
248
270
  form: {
249
271
  Fields: {
250
- Title: qe,
251
- FlsaStatus: Oe ? ke : void 0,
252
- Rate: Ye,
253
- PaymentUnit: Je,
254
- AdjustForMinimumWage: b ? Ve : void 0,
255
- MinimumWageId: b && pe ? Xe : void 0,
256
- EffectiveDate: y ? _e : void 0
272
+ Title: Ge,
273
+ FlsaStatus: De ? Be : void 0,
274
+ Rate: He,
275
+ PaymentUnit: qe,
276
+ AdjustForMinimumWage: y ? Ye : void 0,
277
+ MinimumWageId: y && Ee ? ke : void 0,
278
+ EffectiveDate: E ? Xe : void 0
257
279
  },
258
- fieldsMetadata: Fe,
280
+ fieldsMetadata: Ce,
259
281
  hookFormInternals: he,
260
- getFormSubmissionValues: He(M, H)
282
+ getFormSubmissionValues: Qe(S, $)
261
283
  }
262
284
  };
263
285
  }
264
286
  export {
265
- Ct as useCompensationForm
287
+ Tt as useCompensationForm
266
288
  };
267
289
  //# sourceMappingURL=useCompensationForm.js.map