@gusto/embedded-react-sdk 0.8.2 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/components/Common/DataView/DataCards/DataCards.js +21 -21
  3. package/dist/components/Common/DataView/DataCards/DataCards.js.map +1 -1
  4. package/dist/components/Common/UI/ComboBox/ComboBox.js +28 -27
  5. package/dist/components/Common/UI/ComboBox/ComboBox.js.map +1 -1
  6. package/dist/components/Common/UI/ComboBox/ComboBox.module.scss.js +6 -6
  7. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +5 -3
  8. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  9. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +5 -3
  10. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  11. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +7 -5
  12. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  13. package/dist/components/Company/BankAccount/BankAccountForm/context.js +5 -3
  14. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  15. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +5 -3
  16. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  17. package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +5 -3
  18. package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
  19. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +13 -11
  20. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  21. package/dist/components/Company/Industry/Context.js +8 -6
  22. package/dist/components/Company/Industry/Context.js.map +1 -1
  23. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +5 -3
  24. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  25. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +5 -3
  26. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  27. package/dist/components/Company/OnboardingOverview/context.js +5 -3
  28. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  29. package/dist/components/Company/PaySchedule/usePaySchedule.js +7 -5
  30. package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
  31. package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +10 -10
  32. package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js.map +1 -1
  33. package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js +1 -1
  34. package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js.map +1 -1
  35. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +29 -29
  36. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
  37. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +5 -3
  38. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  39. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +5 -3
  40. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  41. package/dist/components/Contractor/Address/Actions.d.ts +1 -0
  42. package/dist/components/Contractor/Address/Actions.js +13 -0
  43. package/dist/components/Contractor/Address/Actions.js.map +1 -0
  44. package/dist/components/Contractor/Address/Address.d.ts +16 -0
  45. package/dist/components/Contractor/Address/Address.js +74 -0
  46. package/dist/components/Contractor/Address/Address.js.map +1 -0
  47. package/dist/components/Contractor/Address/Form.d.ts +1 -0
  48. package/dist/components/Contractor/Address/Form.js +57 -0
  49. package/dist/components/Contractor/Address/Form.js.map +1 -0
  50. package/dist/components/Contractor/Address/Head.d.ts +1 -0
  51. package/dist/components/Contractor/Address/Head.js +15 -0
  52. package/dist/components/Contractor/Address/Head.js.map +1 -0
  53. package/dist/components/Contractor/Address/index.d.ts +2 -0
  54. package/dist/components/Contractor/Address/useAddress.d.ts +33 -0
  55. package/dist/components/Contractor/Address/useAddress.js +28 -0
  56. package/dist/components/Contractor/Address/useAddress.js.map +1 -0
  57. package/dist/components/Contractor/index.d.ts +2 -0
  58. package/dist/components/Contractor/index.js +5 -0
  59. package/dist/components/Contractor/index.js.map +1 -0
  60. package/dist/components/Employee/Compensation/Compensation.js +1 -1
  61. package/dist/components/Employee/Compensation/Compensation.js.map +1 -1
  62. package/dist/components/Employee/Deductions/useDeductions.js +8 -6
  63. package/dist/components/Employee/Deductions/useDeductions.js.map +1 -1
  64. package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +5 -3
  65. package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  66. package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +5 -3
  67. package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
  68. package/dist/components/Employee/EmployeeList/EmployeeList.js +1 -1
  69. package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
  70. package/dist/components/Employee/EmployeeList/List.js +9 -9
  71. package/dist/components/Employee/EmployeeList/List.js.map +1 -1
  72. package/dist/components/Employee/EmployeeList/useEmployeeList.d.ts +2 -1
  73. package/dist/components/Employee/EmployeeList/useEmployeeList.js +5 -3
  74. package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
  75. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +10 -8
  76. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
  77. package/dist/components/Employee/Profile/Profile.js +92 -88
  78. package/dist/components/Employee/Profile/Profile.js.map +1 -1
  79. package/dist/components/Employee/Profile/useProfile.js +5 -3
  80. package/dist/components/Employee/Profile/useProfile.js.map +1 -1
  81. package/dist/components/Employee/Taxes/StateForm.js +1 -1
  82. package/dist/components/Employee/Taxes/StateForm.js.map +1 -1
  83. package/dist/components/Employee/Taxes/Taxes.js +78 -75
  84. package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
  85. package/dist/components/Employee/Taxes/useTaxes.d.ts +2 -2
  86. package/dist/components/Employee/Taxes/useTaxes.js +5 -3
  87. package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
  88. package/dist/components/index.d.ts +1 -0
  89. package/dist/i18n/I18n.js +11 -11
  90. package/dist/i18n/I18n.js.map +1 -1
  91. package/dist/i18n/en/Contractor.Address.json.js +35 -0
  92. package/dist/i18n/en/Contractor.Address.json.js.map +1 -0
  93. package/dist/index.js +9 -7
  94. package/dist/index.js.map +1 -1
  95. package/dist/shared/constants.d.ts +6 -0
  96. package/dist/shared/constants.js +51 -45
  97. package/dist/shared/constants.js.map +1 -1
  98. package/dist/style.css +1 -1
  99. package/dist/types/i18next.d.ts +20 -1
  100. package/package.json +5 -2
@@ -1,27 +1,27 @@
1
- import { jsx as t, jsxs as pe, Fragment as ye } from "react/jsx-runtime";
2
- import { zodResolver as Ae } from "@hookform/resolvers/zod";
1
+ import { jsx as t, jsxs as ye, Fragment as Ae } from "react/jsx-runtime";
2
+ import { zodResolver as fe } from "@hookform/resolvers/zod";
3
3
  import { useRef as Ee } from "react";
4
- import { useForm as fe, useWatch as he, FormProvider as De } from "react-hook-form";
5
- import { useLocationsGetSuspense as Oe } from "@gusto/embedded-api/react-query/locationsGet";
6
- import { useEmployeesCreateMutation as Se } from "@gusto/embedded-api/react-query/employeesCreate";
7
- import { useEmployeesGetSuspense as Pe } from "@gusto/embedded-api/react-query/employeesGet";
8
- import { useEmployeeAddressesGetSuspense as ge } from "@gusto/embedded-api/react-query/employeeAddressesGet";
9
- import { useEmployeeAddressesCreateMutation as be } from "@gusto/embedded-api/react-query/employeeAddressesCreate";
10
- import { useEmployeeAddressesUpdateMutation as Ne } from "@gusto/embedded-api/react-query/employeeAddressesUpdate";
11
- import { useEmployeeAddressesUpdateWorkAddressMutation as Ie } from "@gusto/embedded-api/react-query/employeeAddressesUpdateWorkAddress";
12
- import { useEmployeesUpdateMutation as _e } from "@gusto/embedded-api/react-query/employeesUpdate";
13
- import { useEmployeeAddressesGetWorkAddressesSuspense as we } from "@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses";
14
- import { useEmployeeAddressesCreateWorkAddressMutation as ke } from "@gusto/embedded-api/react-query/employeeAddressesCreateWorkAddress";
15
- import { RFCDate as Me } from "@gusto/embedded-api/types/rfcdate";
16
- import { useEmployeesUpdateOnboardingStatusMutation as Re } from "@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus";
17
- import { invalidateEmployeesList as Le } from "@gusto/embedded-api/react-query/employeesList";
18
- import { useQueryClient as Be } from "@tanstack/react-query";
19
- import { AdminPersonalDetailsSchema as Ce, AdminPersonalDetails as L } from "./AdminPersonalDetails.js";
20
- import { SelfPersonalDetailsSchema as ve, SelfPersonalDetails as B } from "./SelfPersonalDetails.js";
4
+ import { useForm as he, useWatch as De, FormProvider as Oe } from "react-hook-form";
5
+ import { useLocationsGetSuspense as Se } from "@gusto/embedded-api/react-query/locationsGet";
6
+ import { useEmployeesCreateMutation as Pe } from "@gusto/embedded-api/react-query/employeesCreate";
7
+ import { useEmployeesGetSuspense as ge } from "@gusto/embedded-api/react-query/employeesGet";
8
+ import { useEmployeeAddressesGetSuspense as be } from "@gusto/embedded-api/react-query/employeeAddressesGet";
9
+ import { useEmployeeAddressesCreateMutation as Ne } from "@gusto/embedded-api/react-query/employeeAddressesCreate";
10
+ import { useEmployeeAddressesUpdateMutation as Ie } from "@gusto/embedded-api/react-query/employeeAddressesUpdate";
11
+ import { useEmployeeAddressesUpdateWorkAddressMutation as _e } from "@gusto/embedded-api/react-query/employeeAddressesUpdateWorkAddress";
12
+ import { useEmployeesUpdateMutation as we } from "@gusto/embedded-api/react-query/employeesUpdate";
13
+ import { useEmployeeAddressesGetWorkAddressesSuspense as ke } from "@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses";
14
+ import { useEmployeeAddressesCreateWorkAddressMutation as Me } from "@gusto/embedded-api/react-query/employeeAddressesCreateWorkAddress";
15
+ import { RFCDate as B } from "@gusto/embedded-api/types/rfcdate";
16
+ import { useEmployeesUpdateOnboardingStatusMutation as Be } from "@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus";
17
+ import { invalidateEmployeesList as Re } from "@gusto/embedded-api/react-query/employeesList";
18
+ import { useQueryClient as Le } from "@tanstack/react-query";
19
+ import { AdminPersonalDetailsSchema as ve, AdminPersonalDetails as L } from "./AdminPersonalDetails.js";
20
+ import { SelfPersonalDetailsSchema as Ce, SelfPersonalDetails as v } from "./SelfPersonalDetails.js";
21
21
  import { Head as C } from "./Head.js";
22
- import { Actions as v } from "./Actions.js";
23
- import { HomeAddressSchema as We, HomeAddress as W } from "./HomeAddress.js";
24
- import { WorkAddress as U } from "./WorkAddress.js";
22
+ import { Actions as W } from "./Actions.js";
23
+ import { HomeAddressSchema as We, HomeAddress as U } from "./HomeAddress.js";
24
+ import { WorkAddress as q } from "./WorkAddress.js";
25
25
  import { ProfileProvider as Ue } from "./useProfile.js";
26
26
  import { getEmployeeAddressForProfile as qe } from "./getEmployeeAddressForProfile.js";
27
27
  import { Form as Te } from "../../Common/Form/Form.js";
@@ -32,18 +32,18 @@ import { EmployeeOnboardingStatus as l, EmployeeSelfOnboardingStatuses as Ve, co
32
32
  import { useFlow as Ye } from "../../Flow/useFlow.js";
33
33
  import { ensureRequired as xe } from "../../../helpers/ensureRequired.js";
34
34
  function m(r) {
35
- return /* @__PURE__ */ t(He, { ...r, children: r.employeeId ? /* @__PURE__ */ t(ze, { ...r, employeeId: r.employeeId, children: r.children }) : /* @__PURE__ */ t(q, { ...r, children: r.children }) });
35
+ return /* @__PURE__ */ t(He, { ...r, children: r.employeeId ? /* @__PURE__ */ t(ze, { ...r, employeeId: r.employeeId, children: r.children }) : /* @__PURE__ */ t(T, { ...r, children: r.children }) });
36
36
  }
37
37
  function ze({ employeeId: r, ...a }) {
38
38
  const {
39
39
  data: { employee: u }
40
- } = Pe({ employeeId: r }), {
41
- data: { employeeAddressList: c }
42
40
  } = ge({ employeeId: r }), {
43
- data: { employeeWorkAddressList: i }
44
- } = we({ employeeId: r });
41
+ data: { employeeAddressList: c }
42
+ } = be({ employeeId: r }), {
43
+ data: { employeeWorkAddressesList: i }
44
+ } = ke({ employeeId: r });
45
45
  return /* @__PURE__ */ t(
46
- q,
46
+ T,
47
47
  {
48
48
  ...a,
49
49
  employee: u,
@@ -52,7 +52,7 @@ function ze({ employeeId: r, ...a }) {
52
52
  }
53
53
  );
54
54
  }
55
- const q = ({
55
+ const T = ({
56
56
  isAdmin: r = !1,
57
57
  isSelfOnboardingEnabled: a = !0,
58
58
  dictionary: u,
@@ -61,22 +61,22 @@ const q = ({
61
61
  R("Employee.Profile"), R("Employee.HomeAddress"), Fe("Employee.Profile", u);
62
62
  const {
63
63
  companyId: i,
64
- employee: f,
65
- homeAddresses: T,
66
- workAddresses: S,
67
- children: P,
68
- className: H = "",
64
+ employee: h,
65
+ homeAddresses: H,
66
+ workAddresses: P,
67
+ children: g,
68
+ className: G = "",
69
69
  defaultValues: s
70
- } = c, { onEvent: n, baseSubmitHandler: G } = Ge(), F = Be(), { data: V } = Oe({ companyId: i }), Y = V.locationList, { mutateAsync: x, isPending: z } = Se(), { mutateAsync: j, isPending: K } = _e(), { mutateAsync: Q, isPending: J } = ke(), { mutateAsync: X, isPending: Z } = Ie(), { mutateAsync: $, isPending: ee } = be(), { mutateAsync: re, isPending: te } = Ne(), {
71
- mutateAsync: oe,
72
- isPending: se
73
- } = Re({
74
- onSettled: () => Le(F, [i])
75
- }), g = { employee: f, workAddresses: S }, ne = qe(T), de = g.workAddresses?.find((O) => O.active), e = Ee({
76
- employee: g.employee,
77
- homeAddress: ne,
78
- workAddress: de
79
- }), h = {
70
+ } = c, { onEvent: n, baseSubmitHandler: F } = Ge(), V = Le(), { data: Y } = Se({ companyId: i }), x = Y.locationList, { mutateAsync: z, isPending: j } = Pe(), { mutateAsync: K, isPending: Q } = we(), { mutateAsync: J, isPending: X } = Me(), { mutateAsync: Z, isPending: $ } = _e(), { mutateAsync: ee, isPending: re } = Ne(), { mutateAsync: te, isPending: oe } = Ie(), {
71
+ mutateAsync: se,
72
+ isPending: ne
73
+ } = Be({
74
+ onSettled: () => Re(V, [i])
75
+ }), b = { employee: h, workAddresses: P }, de = qe(H), ie = b.workAddresses?.find((S) => S.active), e = Ee({
76
+ employee: b.employee,
77
+ homeAddress: de,
78
+ workAddress: ie
79
+ }), D = {
80
80
  firstName: e.current.employee?.firstName ?? s?.employee?.firstName ?? "",
81
81
  middleInitial: e.current.employee?.middleInitial ?? s?.employee?.middleInitial ?? "",
82
82
  lastName: e.current.employee?.lastName ?? s?.employee?.lastName ?? "",
@@ -91,33 +91,33 @@ const q = ({
91
91
  zip: e.current.homeAddress?.zip ?? s?.homeAddress?.zip ?? "",
92
92
  state: e.current.homeAddress?.state ?? s?.homeAddress?.state ?? "",
93
93
  courtesyWithholding: e.current.homeAddress?.courtesyWithholding ?? !1
94
- }, ie = e.current.employee?.onboarded || e.current.employee?.onboardingStatus === l.ONBOARDING_COMPLETED || e.current.employee?.onboardingStatus !== void 0 && e.current.employee.onboardingStatus !== l.ADMIN_ONBOARDING_INCOMPLETE ? { ...h, enableSsn: !1, selfOnboarding: !0 } : {
95
- ...h,
94
+ }, me = e.current.employee?.onboarded || e.current.employee?.onboardingStatus === l.ONBOARDING_COMPLETED || e.current.employee?.onboardingStatus !== void 0 && e.current.employee.onboardingStatus !== l.ADMIN_ONBOARDING_INCOMPLETE ? { ...D, enableSsn: !1, selfOnboarding: !0 } : {
95
+ ...D,
96
96
  selfOnboarding: a && e.current.employee?.onboardingStatus ? (
97
97
  // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses
98
98
  Ve.has(e.current.employee.onboarding_status)
99
99
  ) : !1,
100
100
  enableSsn: !e.current.employee?.hasSsn,
101
101
  ssn: ""
102
- }, me = {
103
- ...h,
102
+ }, ae = {
103
+ ...D,
104
104
  enableSsn: !e.current.employee?.hasSsn,
105
105
  ssn: ""
106
- }, D = fe({
107
- resolver: Ae(
108
- (r ? Ce : ve).and(We)
106
+ }, O = he({
107
+ resolver: fe(
108
+ (r ? ve : Ce).and(We)
109
109
  ),
110
- defaultValues: r ? ie : me
111
- }), { handleSubmit: ae } = D, b = he({ control: D.control, name: "selfOnboarding" }), le = async (O) => {
112
- await G(O, async (A) => {
113
- const { workAddress: N, startDate: ce, selfOnboarding: E, ...I } = A;
110
+ defaultValues: r ? me : ae
111
+ }), { handleSubmit: le } = O, N = De({ control: O.control, name: "selfOnboarding" }), ue = async (S) => {
112
+ await F(S, async (A) => {
113
+ const { workAddress: I, startDate: pe, selfOnboarding: f, ...E } = A;
114
114
  if (e.current.employee) {
115
- if (E && e.current.employee.onboardingStatus === l.ADMIN_ONBOARDING_INCOMPLETE || !E && e.current.employee.onboardingStatus === l.SELF_ONBOARDING_PENDING_INVITE) {
116
- const { employeeOnboardingStatus: p } = await oe({
115
+ if (f && e.current.employee.onboardingStatus === l.ADMIN_ONBOARDING_INCOMPLETE || !f && e.current.employee.onboardingStatus === l.SELF_ONBOARDING_PENDING_INVITE) {
116
+ const { employeeOnboardingStatus: p } = await se({
117
117
  request: {
118
118
  employeeId: e.current.employee.uuid,
119
119
  requestBody: {
120
- onboardingStatus: E ? l.SELF_ONBOARDING_PENDING_INVITE : l.ADMIN_ONBOARDING_INCOMPLETE
120
+ onboardingStatus: f ? l.SELF_ONBOARDING_PENDING_INVITE : l.ADMIN_ONBOARDING_INCOMPLETE
121
121
  }
122
122
  }
123
123
  });
@@ -126,28 +126,32 @@ const q = ({
126
126
  onboardingStatus: p.onboardingStatus
127
127
  }, n(d.EMPLOYEE_ONBOARDING_STATUS_UPDATED, p);
128
128
  }
129
- const { employee: o } = await j({
129
+ const { employee: o } = await K({
130
130
  request: {
131
131
  employeeId: e.current.employee.uuid,
132
- requestBody: { ...I, version: e.current.employee.version }
132
+ requestBody: { ...E, version: e.current.employee.version }
133
133
  }
134
134
  });
135
135
  e.current = { ...e.current, employee: o }, n(d.EMPLOYEE_UPDATED, o);
136
136
  } else {
137
- const { employee: o } = await x({
137
+ const { employee: o } = await z({
138
138
  request: {
139
139
  companyId: i,
140
- requestBody: { ...I, selfOnboarding: E }
140
+ requestBody: {
141
+ ...E,
142
+ selfOnboarding: f,
143
+ dateOfBirth: E.dateOfBirth ? new B(E.dateOfBirth) : void 0
144
+ }
141
145
  }
142
146
  });
143
147
  e.current = { ...e.current, employee: o }, n(d.EMPLOYEE_CREATED, o);
144
148
  }
145
149
  if (typeof e.current.employee?.uuid != "string")
146
150
  throw new Error("Employee id is not available");
147
- if ((!b || !r) && !A.selfOnboarding) {
151
+ if ((!N || !r) && !A.selfOnboarding) {
148
152
  const { street1: o, street2: p, city: _, state: w, zip: k, courtesyWithholding: M } = A;
149
153
  if (e.current.homeAddress) {
150
- const { employeeAddress: y } = await re({
154
+ const { employeeAddress: y } = await te({
151
155
  request: {
152
156
  homeAddressUuid: e.current.homeAddress.uuid,
153
157
  requestBody: {
@@ -163,7 +167,7 @@ const q = ({
163
167
  });
164
168
  e.current = { ...e.current, homeAddress: y }, n(d.EMPLOYEE_HOME_ADDRESS_UPDATED, y);
165
169
  } else {
166
- const { employeeAddress: y } = await $({
170
+ const { employeeAddress: y } = await ee({
167
171
  request: {
168
172
  employeeId: e.current.employee.uuid,
169
173
  requestBody: {
@@ -181,23 +185,23 @@ const q = ({
181
185
  }
182
186
  if (r)
183
187
  if (e.current.workAddress) {
184
- const { employeeWorkAddress: o } = await X({
188
+ const { employeeWorkAddress: o } = await Z({
185
189
  request: {
186
190
  workAddressUuid: e.current.workAddress.uuid,
187
191
  requestBody: {
188
192
  version: e.current.workAddress.version,
189
- locationUuid: N
193
+ locationUuid: I
190
194
  }
191
195
  }
192
196
  });
193
197
  e.current = { ...e.current, workAddress: o }, n(d.EMPLOYEE_WORK_ADDRESS_UPDATED, o);
194
198
  } else {
195
- const { employeeWorkAddress: o } = await Q({
199
+ const { employeeWorkAddress: o } = await J({
196
200
  request: {
197
201
  employeeId: e.current.employee?.uuid,
198
202
  requestBody: {
199
- locationUuid: N,
200
- effectiveDate: new Me(A.startDate || /* @__PURE__ */ new Date())
203
+ locationUuid: I,
204
+ effectiveDate: new B(A.startDate || /* @__PURE__ */ new Date())
201
205
  }
202
206
  }
203
207
  });
@@ -205,44 +209,44 @@ const q = ({
205
209
  }
206
210
  n(d.EMPLOYEE_PROFILE_DONE, {
207
211
  ...e.current.employee,
208
- startDate: ce
212
+ startDate: pe
209
213
  });
210
214
  });
211
- }, ue = () => {
215
+ }, ce = () => {
212
216
  n(d.CANCEL);
213
217
  };
214
- return /* @__PURE__ */ t("section", { className: H, children: /* @__PURE__ */ t(
218
+ return /* @__PURE__ */ t("section", { className: G, children: /* @__PURE__ */ t(
215
219
  Ue,
216
220
  {
217
221
  value: {
218
- companyLocations: Y,
219
- workAddresses: S,
222
+ companyLocations: x,
223
+ workAddresses: P,
220
224
  employee: e.current.employee ?? void 0,
221
- isSelfOnboardingIntended: b,
222
- handleCancel: ue,
225
+ isSelfOnboardingIntended: N,
226
+ handleCancel: ce,
223
227
  isAdmin: r,
224
228
  isSelfOnboardingEnabled: a,
225
- isPending: K || Z || ee || te || z || J || se
229
+ isPending: Q || $ || re || oe || j || X || ne
226
230
  },
227
- children: /* @__PURE__ */ t(De, { ...D, children: /* @__PURE__ */ t(Te, { onSubmit: ae(le), children: P || /* @__PURE__ */ pe(ye, { children: [
231
+ children: /* @__PURE__ */ t(Oe, { ...O, children: /* @__PURE__ */ t(Te, { onSubmit: le(ue), children: g || /* @__PURE__ */ ye(Ae, { children: [
228
232
  /* @__PURE__ */ t(C, {}),
229
233
  /* @__PURE__ */ t(L, {}),
230
- /* @__PURE__ */ t(B, {}),
231
- /* @__PURE__ */ t(W, {}),
234
+ /* @__PURE__ */ t(v, {}),
232
235
  /* @__PURE__ */ t(U, {}),
233
- /* @__PURE__ */ t(v, {})
236
+ /* @__PURE__ */ t(q, {}),
237
+ /* @__PURE__ */ t(W, {})
234
238
  ] }) }) })
235
239
  }
236
240
  ) });
237
241
  };
238
242
  m.Head = C;
239
- m.Actions = v;
243
+ m.Actions = W;
240
244
  m.AdminPersonalDetails = L;
241
- m.SelfPersonalDetails = B;
242
- m.HomeAddress = W;
243
- m.WorkAddress = U;
245
+ m.SelfPersonalDetails = v;
246
+ m.HomeAddress = U;
247
+ m.WorkAddress = q;
244
248
  const Ir = () => {
245
- const { companyId: r, employeeId: a, onEvent: u, isAdmin: c, defaultValues: i, isSelfOnboardingEnabled: f } = Ye();
249
+ const { companyId: r, employeeId: a, onEvent: u, isAdmin: c, defaultValues: i, isSelfOnboardingEnabled: h } = Ye();
246
250
  return /* @__PURE__ */ t(
247
251
  m,
248
252
  {
@@ -251,7 +255,7 @@ const Ir = () => {
251
255
  onEvent: u,
252
256
  isAdmin: c,
253
257
  defaultValues: i?.profile,
254
- isSelfOnboardingEnabled: f
258
+ isSelfOnboardingEnabled: h
255
259
  }
256
260
  );
257
261
  };
@@ -1 +1 @@
1
- {"version":3,"file":"Profile.js","sources":["../../../../src/components/Employee/Profile/Profile.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { useRef } from 'react'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm, useWatch } from 'react-hook-form'\nimport { useLocationsGetSuspense } from '@gusto/embedded-api/react-query/locationsGet'\nimport { useEmployeesCreateMutation } from '@gusto/embedded-api/react-query/employeesCreate'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { type Employee } from '@gusto/embedded-api/models/components/employee'\nimport { useEmployeeAddressesGetSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGet'\nimport { type EmployeeAddress } from '@gusto/embedded-api/models/components/employeeaddress'\nimport { useEmployeeAddressesCreateMutation } from '@gusto/embedded-api/react-query/employeeAddressesCreate'\nimport { useEmployeeAddressesUpdateMutation } from '@gusto/embedded-api/react-query/employeeAddressesUpdate'\nimport { useEmployeeAddressesUpdateWorkAddressMutation } from '@gusto/embedded-api/react-query/employeeAddressesUpdateWorkAddress'\nimport { useEmployeesUpdateMutation } from '@gusto/embedded-api/react-query/employeesUpdate'\nimport { useEmployeeAddressesGetWorkAddressesSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { useEmployeeAddressesCreateWorkAddressMutation } from '@gusto/embedded-api/react-query/employeeAddressesCreateWorkAddress'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport { useEmployeesUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus'\nimport { invalidateEmployeesList } from '@gusto/embedded-api/react-query/employeesList'\nimport { useQueryClient } from '@tanstack/react-query'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlow'\nimport { AdminPersonalDetails, AdminPersonalDetailsSchema } from './AdminPersonalDetails'\nimport { SelfPersonalDetails, SelfPersonalDetailsSchema } from './SelfPersonalDetails'\nimport { type PersonalDetailsPayload, type PersonalDetailsInputs } from './PersonalDetailsInputs'\nimport { Head } from './Head'\nimport { Actions } from './Actions'\nimport { HomeAddress, HomeAddressSchema, type HomeAddressInputs } from './HomeAddress'\nimport { WorkAddress } from './WorkAddress'\nimport { ProfileProvider } from './useProfile'\nimport { getEmployeeAddressForProfile } from './getEmployeeAddressForProfile'\nimport { Form } from '@/components/Common/Form'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n EmployeeOnboardingStatus,\n EmployeeSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport type { RequireAtLeastOne, WithRequired } from '@/types/Helpers'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { ensureRequired } from '@/helpers/ensureRequired'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\nexport type ProfileDefaultValues = RequireAtLeastOne<{\n employee?: RequireAtLeastOne<{\n firstName?: string\n middleInitial?: string\n lastName?: string\n email?: string\n dateOfBirth?: string\n }>\n homeAddress?: RequireAtLeastOne<{\n street1?: string\n street2?: string\n city?: string\n state?: string\n zip?: string\n }>\n}>\ninterface ProfileProps extends CommonComponentInterface<'Employee.Profile'> {\n employeeId?: string\n companyId: string\n defaultValues?: ProfileDefaultValues\n isAdmin?: boolean\n isSelfOnboardingEnabled?: boolean\n}\n\ninterface ProfileConditionalProps {\n employee?: Employee\n homeAddresses?: EmployeeAddress[]\n workAddresses?: EmployeeWorkAddress[]\n}\n\nexport function Profile(props: ProfileProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n {props.employeeId ? (\n <RootWithEmployee {...props} employeeId={props.employeeId}>\n {props.children}\n </RootWithEmployee>\n ) : (\n <Root {...props}>{props.children}</Root>\n )}\n </BaseComponent>\n )\n}\n\n/**Accounting for conditional logic where employee data needs to be fetched only if employeeId is present */\nfunction RootWithEmployee({ employeeId, ...props }: WithRequired<ProfileProps, 'employeeId'>) {\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n const {\n data: { employeeAddressList },\n } = useEmployeeAddressesGetSuspense({ employeeId })\n const {\n data: { employeeWorkAddressList },\n } = useEmployeeAddressesGetWorkAddressesSuspense({ employeeId })\n return (\n <Root\n {...props}\n employee={employee}\n homeAddresses={employeeAddressList}\n workAddresses={employeeWorkAddressList}\n />\n )\n}\n\nconst Root = ({\n isAdmin = false,\n isSelfOnboardingEnabled = true,\n dictionary,\n ...props\n}: ProfileProps & ProfileConditionalProps) => {\n useI18n('Employee.Profile')\n useI18n('Employee.HomeAddress')\n useComponentDictionary('Employee.Profile', dictionary)\n const {\n companyId,\n employee,\n homeAddresses,\n workAddresses,\n children,\n className = '',\n defaultValues,\n } = props\n const { onEvent, baseSubmitHandler } = useBase()\n const queryClient = useQueryClient()\n\n const { data } = useLocationsGetSuspense({ companyId })\n const companyLocations = data.locationList!\n\n const { mutateAsync: createEmployee, isPending: isPendingCreateEmployee } =\n useEmployeesCreateMutation()\n const { mutateAsync: mutateEmployee, isPending: isPendingEmployeeUpdate } =\n useEmployeesUpdateMutation()\n\n const { mutateAsync: createEmployeeWorkAddress, isPending: isPendingCreateWA } =\n useEmployeeAddressesCreateWorkAddressMutation()\n const { mutateAsync: mutateEmployeeWorkAddress, isPending: isPendingWorkAddressUpdate } =\n useEmployeeAddressesUpdateWorkAddressMutation()\n\n const { mutateAsync: createEmployeeHomeAddress, isPending: isPendingAddHA } =\n useEmployeeAddressesCreateMutation()\n const { mutateAsync: mutateEmployeeHomeAddress, isPending: isPendingUpdateHA } =\n useEmployeeAddressesUpdateMutation()\n\n const {\n mutateAsync: updateEmployeeOnboardingStatus,\n isPending: isPendingUpdateOnboardingStatus,\n } = useEmployeesUpdateOnboardingStatusMutation({\n onSettled: () => invalidateEmployeesList(queryClient, [companyId]),\n })\n\n const existingData = { employee, workAddresses, homeAddresses }\n\n const currentHomeAddress = getEmployeeAddressForProfile(homeAddresses)\n\n const currentWorkAddress = existingData.workAddresses?.find(address => address.active)\n const mergedData = useRef({\n employee: existingData.employee,\n homeAddress: currentHomeAddress,\n workAddress: currentWorkAddress,\n })\n const initialValues = {\n firstName: mergedData.current.employee?.firstName ?? defaultValues?.employee?.firstName ?? '',\n middleInitial:\n mergedData.current.employee?.middleInitial ?? defaultValues?.employee?.middleInitial ?? '',\n lastName: mergedData.current.employee?.lastName ?? defaultValues?.employee?.lastName ?? '',\n workAddress: mergedData.current.workAddress?.locationUuid,\n startDate: mergedData.current.employee?.jobs?.[0]?.hireDate\n ? new Date(mergedData.current.employee.jobs[0].hireDate)\n : null, // By default employee response contains only current job - therefore jobs[0]\n email: mergedData.current.employee?.email ?? defaultValues?.employee?.email ?? '',\n dateOfBirth: mergedData.current.employee?.dateOfBirth\n ? new Date(mergedData.current.employee.dateOfBirth)\n : defaultValues?.employee?.dateOfBirth\n ? new Date(defaultValues.employee.dateOfBirth)\n : null,\n\n street1: mergedData.current.homeAddress?.street1 ?? defaultValues?.homeAddress?.street1 ?? '',\n street2: mergedData.current.homeAddress?.street2 ?? defaultValues?.homeAddress?.street2 ?? '',\n city: mergedData.current.homeAddress?.city ?? defaultValues?.homeAddress?.city ?? '',\n zip: mergedData.current.homeAddress?.zip ?? defaultValues?.homeAddress?.zip ?? '',\n state: mergedData.current.homeAddress?.state ?? defaultValues?.homeAddress?.state ?? '',\n courtesyWithholding: mergedData.current.homeAddress?.courtesyWithholding ?? false,\n }\n\n const adminDefaultValues =\n mergedData.current.employee?.onboarded ||\n mergedData.current.employee?.onboardingStatus ===\n EmployeeOnboardingStatus.ONBOARDING_COMPLETED ||\n (mergedData.current.employee?.onboardingStatus !== undefined &&\n mergedData.current.employee.onboardingStatus !==\n EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE)\n ? { ...initialValues, enableSsn: false, selfOnboarding: true }\n : {\n ...initialValues,\n selfOnboarding: isSelfOnboardingEnabled\n ? mergedData.current.employee?.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n EmployeeSelfOnboardingStatuses.has(mergedData.current.employee.onboarding_status)\n : false\n : false,\n enableSsn: !mergedData.current.employee?.hasSsn,\n ssn: '',\n } // In edit mode ssn is submitted only if it has been modified\n\n const selfDetaultValues = {\n ...initialValues,\n enableSsn: !mergedData.current.employee?.hasSsn,\n ssn: '',\n }\n\n const formMethods = useForm<\n PersonalDetailsInputs & HomeAddressInputs,\n unknown,\n PersonalDetailsPayload & HomeAddressInputs\n >({\n resolver: zodResolver(\n (isAdmin ? AdminPersonalDetailsSchema : SelfPersonalDetailsSchema).and(HomeAddressSchema),\n ),\n defaultValues: isAdmin ? adminDefaultValues : selfDetaultValues,\n })\n\n const { handleSubmit } = formMethods\n const watchedSelfOnboarding = useWatch({ control: formMethods.control, name: 'selfOnboarding' })\n\n const onSubmit: SubmitHandler<PersonalDetailsPayload & HomeAddressInputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { workAddress, startDate, selfOnboarding, ...body } = payload\n //create or update employee\n if (!mergedData.current.employee) {\n const { employee: employeeData } = await createEmployee({\n request: {\n companyId,\n requestBody: { ...body, selfOnboarding },\n },\n })\n mergedData.current = { ...mergedData.current, employee: employeeData }\n onEvent(componentEvents.EMPLOYEE_CREATED, employeeData)\n } else {\n // Updating self-onboarding status\n if (\n (selfOnboarding &&\n mergedData.current.employee.onboardingStatus ===\n EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE) ||\n (!selfOnboarding &&\n mergedData.current.employee.onboardingStatus ===\n EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE)\n ) {\n const { employeeOnboardingStatus } = await updateEmployeeOnboardingStatus({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: {\n onboardingStatus: selfOnboarding\n ? EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE\n : EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE,\n },\n },\n })\n mergedData.current.employee = {\n ...mergedData.current.employee,\n onboardingStatus: employeeOnboardingStatus!\n .onboardingStatus as (typeof EmployeeOnboardingStatus)[keyof typeof EmployeeOnboardingStatus],\n }\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_STATUS_UPDATED, employeeOnboardingStatus)\n }\n const { employee: employeeData } = await mutateEmployee({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: { ...body, version: mergedData.current.employee.version as string },\n },\n })\n mergedData.current = { ...mergedData.current, employee: employeeData }\n onEvent(componentEvents.EMPLOYEE_UPDATED, employeeData)\n }\n if (typeof mergedData.current.employee?.uuid !== 'string') {\n throw new Error('Employee id is not available')\n }\n //create or update home address - only if not intended for self onboarding\n if (!watchedSelfOnboarding || !isAdmin) {\n //typeguard: in this scenario payload will contain address information\n if (!payload.selfOnboarding) {\n const { street1, street2, city, state, zip, courtesyWithholding } = payload\n if (!mergedData.current.homeAddress) {\n // Creating home address - for new employee effective_date is the same as work start date\n const { employeeAddress } = await createEmployeeHomeAddress({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: {\n street1,\n street2,\n city,\n state,\n zip,\n courtesyWithholding,\n },\n },\n })\n mergedData.current = { ...mergedData.current, homeAddress: employeeAddress }\n onEvent(componentEvents.EMPLOYEE_HOME_ADDRESS_CREATED, employeeAddress)\n } else {\n const { employeeAddress } = await mutateEmployeeHomeAddress({\n request: {\n homeAddressUuid: mergedData.current.homeAddress.uuid as string,\n requestBody: {\n version: mergedData.current.homeAddress.version as string,\n street1,\n street2,\n city,\n state,\n zip,\n courtesyWithholding,\n },\n },\n })\n mergedData.current = { ...mergedData.current, homeAddress: employeeAddress }\n onEvent(componentEvents.EMPLOYEE_HOME_ADDRESS_UPDATED, employeeAddress)\n }\n }\n }\n\n if (isAdmin) {\n //create or update workaddress\n if (!mergedData.current.workAddress) {\n const { employeeWorkAddress } = await createEmployeeWorkAddress({\n request: {\n employeeId: mergedData.current.employee?.uuid as string,\n requestBody: {\n locationUuid: workAddress,\n effectiveDate: new RFCDate(payload.startDate || new Date()),\n },\n },\n })\n\n mergedData.current = { ...mergedData.current, workAddress: employeeWorkAddress }\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS_CREATED, employeeWorkAddress)\n } else {\n //effective_date is excluded from update operation since it cannot be changed on initial work address\n const { employeeWorkAddress } = await mutateEmployeeWorkAddress({\n request: {\n workAddressUuid: mergedData.current.workAddress.uuid,\n requestBody: {\n version: mergedData.current.workAddress.version,\n locationUuid: workAddress,\n },\n },\n })\n mergedData.current = { ...mergedData.current, workAddress: employeeWorkAddress }\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS_UPDATED, employeeWorkAddress)\n }\n }\n\n onEvent(componentEvents.EMPLOYEE_PROFILE_DONE, {\n ...mergedData.current.employee,\n startDate,\n })\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n return (\n <section className={className}>\n <ProfileProvider\n value={{\n companyLocations,\n workAddresses,\n employee: mergedData.current.employee ?? undefined,\n isSelfOnboardingIntended: watchedSelfOnboarding,\n handleCancel,\n isAdmin,\n isSelfOnboardingEnabled,\n isPending:\n isPendingEmployeeUpdate ||\n isPendingWorkAddressUpdate ||\n isPendingAddHA ||\n isPendingUpdateHA ||\n isPendingCreateEmployee ||\n isPendingCreateWA ||\n isPendingUpdateOnboardingStatus,\n }}\n >\n <FormProvider {...formMethods}>\n <Form onSubmit={handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <AdminPersonalDetails />\n <SelfPersonalDetails />\n <HomeAddress />\n <WorkAddress />\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </ProfileProvider>\n </section>\n )\n}\n\nProfile.Head = Head\nProfile.Actions = Actions\nProfile.AdminPersonalDetails = AdminPersonalDetails\nProfile.SelfPersonalDetails = SelfPersonalDetails\nProfile.HomeAddress = HomeAddress\nProfile.WorkAddress = WorkAddress\n\nexport const ProfileContextual = () => {\n const { companyId, employeeId, onEvent, isAdmin, defaultValues, isSelfOnboardingEnabled } =\n useFlow<OnboardingContextInterface>()\n\n return (\n <Profile\n companyId={ensureRequired(companyId)}\n employeeId={employeeId}\n onEvent={onEvent}\n isAdmin={isAdmin}\n defaultValues={defaultValues?.profile}\n isSelfOnboardingEnabled={isSelfOnboardingEnabled}\n />\n )\n}\n"],"names":["Profile","props","jsx","BaseComponent","RootWithEmployee","Root","employeeId","employee","useEmployeesGetSuspense","employeeAddressList","useEmployeeAddressesGetSuspense","employeeWorkAddressList","useEmployeeAddressesGetWorkAddressesSuspense","isAdmin","isSelfOnboardingEnabled","dictionary","useI18n","useComponentDictionary","companyId","homeAddresses","workAddresses","children","className","defaultValues","onEvent","baseSubmitHandler","useBase","queryClient","useQueryClient","data","useLocationsGetSuspense","companyLocations","createEmployee","isPendingCreateEmployee","useEmployeesCreateMutation","mutateEmployee","isPendingEmployeeUpdate","useEmployeesUpdateMutation","createEmployeeWorkAddress","isPendingCreateWA","useEmployeeAddressesCreateWorkAddressMutation","mutateEmployeeWorkAddress","isPendingWorkAddressUpdate","useEmployeeAddressesUpdateWorkAddressMutation","createEmployeeHomeAddress","isPendingAddHA","useEmployeeAddressesCreateMutation","mutateEmployeeHomeAddress","isPendingUpdateHA","useEmployeeAddressesUpdateMutation","updateEmployeeOnboardingStatus","isPendingUpdateOnboardingStatus","useEmployeesUpdateOnboardingStatusMutation","invalidateEmployeesList","existingData","currentHomeAddress","getEmployeeAddressForProfile","currentWorkAddress","address","mergedData","useRef","initialValues","adminDefaultValues","EmployeeOnboardingStatus","EmployeeSelfOnboardingStatuses","selfDetaultValues","formMethods","useForm","zodResolver","AdminPersonalDetailsSchema","SelfPersonalDetailsSchema","HomeAddressSchema","handleSubmit","watchedSelfOnboarding","useWatch","onSubmit","payload","workAddress","startDate","selfOnboarding","body","employeeOnboardingStatus","componentEvents","employeeData","street1","street2","city","state","zip","courtesyWithholding","employeeAddress","employeeWorkAddress","RFCDate","handleCancel","ProfileProvider","FormProvider","Form","jsxs","Fragment","Head","AdminPersonalDetails","SelfPersonalDetails","HomeAddress","WorkAddress","Actions","ProfileContextual","useFlow","ensureRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EO,SAASA,EAAQC,GAA8C;AAElE,SAAA,gBAAAC,EAACC,MAAe,GAAGF,GAChB,YAAM,aACL,gBAAAC,EAACE,IAAkB,EAAA,GAAGH,GAAO,YAAYA,EAAM,YAC5C,UAAAA,EAAM,SACT,CAAA,IAEA,gBAAAC,EAACG,KAAM,GAAGJ,GAAQ,UAAMA,EAAA,SAAA,CAAS,EAErC,CAAA;AAEJ;AAGA,SAASG,GAAiB,EAAE,YAAAE,GAAY,GAAGL,KAAmD;AACtF,QAAA;AAAA,IACJ,MAAM,EAAE,UAAAM,EAAS;AAAA,EAAA,IACfC,GAAwB,EAAE,YAAAF,GAAY,GACpC;AAAA,IACJ,MAAM,EAAE,qBAAAG,EAAoB;AAAA,EAAA,IAC1BC,GAAgC,EAAE,YAAAJ,G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0BACZC,GAAQ,CAAA,CAAA;AAAA,MAAA,EACX,CAAA,EAEJ,CAAA,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAEAxG,EAAQ,OAAOmG;AACfnG,EAAQ,UAAUwG;AAClBxG,EAAQ,uBAAuBoG;AAC/BpG,EAAQ,sBAAsBqG;AAC9BrG,EAAQ,cAAcsG;AACtBtG,EAAQ,cAAcuG;AAEf,MAAME,KAAoB,MAAM;AAC/B,QAAA,EAAE,WAAAvF,GAAW,YAAAZ,GAAY,SAAAkB,GAAS,SAAAX,GAAS,eAAAU,GAAe,yBAAAT,MAC9D4F,GAAoC;AAGpC,SAAA,gBAAAxG;AAAA,IAACF;AAAA,IAAA;AAAA,MACC,WAAW2G,GAAezF,CAAS;AAAA,MACnC,YAAAZ;AAAA,MACA,SAAAkB;AAAA,MACA,SAAAX;AAAA,MACA,eAAeU,GAAe;AAAA,MAC9B,yBAAAT;AAAA,IAAA;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"Profile.js","sources":["../../../../src/components/Employee/Profile/Profile.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { useRef } from 'react'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm, useWatch } from 'react-hook-form'\nimport { useLocationsGetSuspense } from '@gusto/embedded-api/react-query/locationsGet'\nimport { useEmployeesCreateMutation } from '@gusto/embedded-api/react-query/employeesCreate'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport { type Employee } from '@gusto/embedded-api/models/components/employee'\nimport { useEmployeeAddressesGetSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGet'\nimport { type EmployeeAddress } from '@gusto/embedded-api/models/components/employeeaddress'\nimport { useEmployeeAddressesCreateMutation } from '@gusto/embedded-api/react-query/employeeAddressesCreate'\nimport { useEmployeeAddressesUpdateMutation } from '@gusto/embedded-api/react-query/employeeAddressesUpdate'\nimport { useEmployeeAddressesUpdateWorkAddressMutation } from '@gusto/embedded-api/react-query/employeeAddressesUpdateWorkAddress'\nimport { useEmployeesUpdateMutation } from '@gusto/embedded-api/react-query/employeesUpdate'\nimport { useEmployeeAddressesGetWorkAddressesSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { useEmployeeAddressesCreateWorkAddressMutation } from '@gusto/embedded-api/react-query/employeeAddressesCreateWorkAddress'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport { useEmployeesUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus'\nimport { invalidateEmployeesList } from '@gusto/embedded-api/react-query/employeesList'\nimport { useQueryClient } from '@tanstack/react-query'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlow'\nimport { AdminPersonalDetails, AdminPersonalDetailsSchema } from './AdminPersonalDetails'\nimport { SelfPersonalDetails, SelfPersonalDetailsSchema } from './SelfPersonalDetails'\nimport { type PersonalDetailsPayload, type PersonalDetailsInputs } from './PersonalDetailsInputs'\nimport { Head } from './Head'\nimport { Actions } from './Actions'\nimport { HomeAddress, HomeAddressSchema, type HomeAddressInputs } from './HomeAddress'\nimport { WorkAddress } from './WorkAddress'\nimport { ProfileProvider } from './useProfile'\nimport { getEmployeeAddressForProfile } from './getEmployeeAddressForProfile'\nimport { Form } from '@/components/Common/Form'\nimport {\n useBase,\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n EmployeeOnboardingStatus,\n EmployeeSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport type { RequireAtLeastOne, WithRequired } from '@/types/Helpers'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { ensureRequired } from '@/helpers/ensureRequired'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\nexport type ProfileDefaultValues = RequireAtLeastOne<{\n employee?: RequireAtLeastOne<{\n firstName?: string\n middleInitial?: string\n lastName?: string\n email?: string\n dateOfBirth?: string\n }>\n homeAddress?: RequireAtLeastOne<{\n street1?: string\n street2?: string\n city?: string\n state?: string\n zip?: string\n }>\n}>\ninterface ProfileProps extends CommonComponentInterface<'Employee.Profile'> {\n employeeId?: string\n companyId: string\n defaultValues?: ProfileDefaultValues\n isAdmin?: boolean\n isSelfOnboardingEnabled?: boolean\n}\n\ninterface ProfileConditionalProps {\n employee?: Employee\n homeAddresses?: EmployeeAddress[]\n workAddresses?: EmployeeWorkAddress[]\n}\n\nexport function Profile(props: ProfileProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n {props.employeeId ? (\n <RootWithEmployee {...props} employeeId={props.employeeId}>\n {props.children}\n </RootWithEmployee>\n ) : (\n <Root {...props}>{props.children}</Root>\n )}\n </BaseComponent>\n )\n}\n\n/**Accounting for conditional logic where employee data needs to be fetched only if employeeId is present */\nfunction RootWithEmployee({ employeeId, ...props }: WithRequired<ProfileProps, 'employeeId'>) {\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n const {\n data: { employeeAddressList },\n } = useEmployeeAddressesGetSuspense({ employeeId })\n const {\n data: { employeeWorkAddressesList },\n } = useEmployeeAddressesGetWorkAddressesSuspense({ employeeId })\n return (\n <Root\n {...props}\n employee={employee}\n homeAddresses={employeeAddressList}\n workAddresses={employeeWorkAddressesList}\n />\n )\n}\n\nconst Root = ({\n isAdmin = false,\n isSelfOnboardingEnabled = true,\n dictionary,\n ...props\n}: ProfileProps & ProfileConditionalProps) => {\n useI18n('Employee.Profile')\n useI18n('Employee.HomeAddress')\n useComponentDictionary('Employee.Profile', dictionary)\n const {\n companyId,\n employee,\n homeAddresses,\n workAddresses,\n children,\n className = '',\n defaultValues,\n } = props\n const { onEvent, baseSubmitHandler } = useBase()\n const queryClient = useQueryClient()\n\n const { data } = useLocationsGetSuspense({ companyId })\n const companyLocations = data.locationList!\n\n const { mutateAsync: createEmployee, isPending: isPendingCreateEmployee } =\n useEmployeesCreateMutation()\n const { mutateAsync: mutateEmployee, isPending: isPendingEmployeeUpdate } =\n useEmployeesUpdateMutation()\n\n const { mutateAsync: createEmployeeWorkAddress, isPending: isPendingCreateWA } =\n useEmployeeAddressesCreateWorkAddressMutation()\n const { mutateAsync: mutateEmployeeWorkAddress, isPending: isPendingWorkAddressUpdate } =\n useEmployeeAddressesUpdateWorkAddressMutation()\n\n const { mutateAsync: createEmployeeHomeAddress, isPending: isPendingAddHA } =\n useEmployeeAddressesCreateMutation()\n const { mutateAsync: mutateEmployeeHomeAddress, isPending: isPendingUpdateHA } =\n useEmployeeAddressesUpdateMutation()\n\n const {\n mutateAsync: updateEmployeeOnboardingStatus,\n isPending: isPendingUpdateOnboardingStatus,\n } = useEmployeesUpdateOnboardingStatusMutation({\n onSettled: () => invalidateEmployeesList(queryClient, [companyId]),\n })\n\n const existingData = { employee, workAddresses, homeAddresses }\n\n const currentHomeAddress = getEmployeeAddressForProfile(homeAddresses)\n\n const currentWorkAddress = existingData.workAddresses?.find(address => address.active)\n const mergedData = useRef({\n employee: existingData.employee,\n homeAddress: currentHomeAddress,\n workAddress: currentWorkAddress,\n })\n const initialValues = {\n firstName: mergedData.current.employee?.firstName ?? defaultValues?.employee?.firstName ?? '',\n middleInitial:\n mergedData.current.employee?.middleInitial ?? defaultValues?.employee?.middleInitial ?? '',\n lastName: mergedData.current.employee?.lastName ?? defaultValues?.employee?.lastName ?? '',\n workAddress: mergedData.current.workAddress?.locationUuid,\n startDate: mergedData.current.employee?.jobs?.[0]?.hireDate\n ? new Date(mergedData.current.employee.jobs[0].hireDate)\n : null, // By default employee response contains only current job - therefore jobs[0]\n email: mergedData.current.employee?.email ?? defaultValues?.employee?.email ?? '',\n dateOfBirth: mergedData.current.employee?.dateOfBirth\n ? new Date(mergedData.current.employee.dateOfBirth)\n : defaultValues?.employee?.dateOfBirth\n ? new Date(defaultValues.employee.dateOfBirth)\n : null,\n\n street1: mergedData.current.homeAddress?.street1 ?? defaultValues?.homeAddress?.street1 ?? '',\n street2: mergedData.current.homeAddress?.street2 ?? defaultValues?.homeAddress?.street2 ?? '',\n city: mergedData.current.homeAddress?.city ?? defaultValues?.homeAddress?.city ?? '',\n zip: mergedData.current.homeAddress?.zip ?? defaultValues?.homeAddress?.zip ?? '',\n state: mergedData.current.homeAddress?.state ?? defaultValues?.homeAddress?.state ?? '',\n courtesyWithholding: mergedData.current.homeAddress?.courtesyWithholding ?? false,\n }\n\n const adminDefaultValues =\n mergedData.current.employee?.onboarded ||\n mergedData.current.employee?.onboardingStatus ===\n EmployeeOnboardingStatus.ONBOARDING_COMPLETED ||\n (mergedData.current.employee?.onboardingStatus !== undefined &&\n mergedData.current.employee.onboardingStatus !==\n EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE)\n ? { ...initialValues, enableSsn: false, selfOnboarding: true }\n : {\n ...initialValues,\n selfOnboarding: isSelfOnboardingEnabled\n ? mergedData.current.employee?.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n EmployeeSelfOnboardingStatuses.has(mergedData.current.employee.onboarding_status)\n : false\n : false,\n enableSsn: !mergedData.current.employee?.hasSsn,\n ssn: '',\n } // In edit mode ssn is submitted only if it has been modified\n\n const selfDetaultValues = {\n ...initialValues,\n enableSsn: !mergedData.current.employee?.hasSsn,\n ssn: '',\n }\n\n const formMethods = useForm<\n PersonalDetailsInputs & HomeAddressInputs,\n unknown,\n PersonalDetailsPayload & HomeAddressInputs\n >({\n resolver: zodResolver(\n (isAdmin ? AdminPersonalDetailsSchema : SelfPersonalDetailsSchema).and(HomeAddressSchema),\n ),\n defaultValues: isAdmin ? adminDefaultValues : selfDetaultValues,\n })\n\n const { handleSubmit } = formMethods\n const watchedSelfOnboarding = useWatch({ control: formMethods.control, name: 'selfOnboarding' })\n\n const onSubmit: SubmitHandler<PersonalDetailsPayload & HomeAddressInputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { workAddress, startDate, selfOnboarding, ...body } = payload\n //create or update employee\n if (!mergedData.current.employee) {\n const { employee: employeeData } = await createEmployee({\n request: {\n companyId,\n requestBody: {\n ...body,\n selfOnboarding,\n dateOfBirth: body.dateOfBirth ? new RFCDate(body.dateOfBirth) : undefined,\n },\n },\n })\n mergedData.current = { ...mergedData.current, employee: employeeData }\n onEvent(componentEvents.EMPLOYEE_CREATED, employeeData)\n } else {\n // Updating self-onboarding status\n if (\n (selfOnboarding &&\n mergedData.current.employee.onboardingStatus ===\n EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE) ||\n (!selfOnboarding &&\n mergedData.current.employee.onboardingStatus ===\n EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE)\n ) {\n const { employeeOnboardingStatus } = await updateEmployeeOnboardingStatus({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: {\n onboardingStatus: selfOnboarding\n ? EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE\n : EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE,\n },\n },\n })\n mergedData.current.employee = {\n ...mergedData.current.employee,\n onboardingStatus: employeeOnboardingStatus!\n .onboardingStatus as (typeof EmployeeOnboardingStatus)[keyof typeof EmployeeOnboardingStatus],\n }\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_STATUS_UPDATED, employeeOnboardingStatus)\n }\n const { employee: employeeData } = await mutateEmployee({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: { ...body, version: mergedData.current.employee.version as string },\n },\n })\n mergedData.current = { ...mergedData.current, employee: employeeData }\n onEvent(componentEvents.EMPLOYEE_UPDATED, employeeData)\n }\n if (typeof mergedData.current.employee?.uuid !== 'string') {\n throw new Error('Employee id is not available')\n }\n //create or update home address - only if not intended for self onboarding\n if (!watchedSelfOnboarding || !isAdmin) {\n //typeguard: in this scenario payload will contain address information\n if (!payload.selfOnboarding) {\n const { street1, street2, city, state, zip, courtesyWithholding } = payload\n if (!mergedData.current.homeAddress) {\n // Creating home address - for new employee effective_date is the same as work start date\n const { employeeAddress } = await createEmployeeHomeAddress({\n request: {\n employeeId: mergedData.current.employee.uuid,\n requestBody: {\n street1,\n street2,\n city,\n state,\n zip,\n courtesyWithholding,\n },\n },\n })\n mergedData.current = { ...mergedData.current, homeAddress: employeeAddress }\n onEvent(componentEvents.EMPLOYEE_HOME_ADDRESS_CREATED, employeeAddress)\n } else {\n const { employeeAddress } = await mutateEmployeeHomeAddress({\n request: {\n homeAddressUuid: mergedData.current.homeAddress.uuid,\n requestBody: {\n version: mergedData.current.homeAddress.version,\n street1,\n street2,\n city,\n state,\n zip,\n courtesyWithholding,\n },\n },\n })\n mergedData.current = { ...mergedData.current, homeAddress: employeeAddress }\n onEvent(componentEvents.EMPLOYEE_HOME_ADDRESS_UPDATED, employeeAddress)\n }\n }\n }\n\n if (isAdmin) {\n //create or update workaddress\n if (!mergedData.current.workAddress) {\n const { employeeWorkAddress } = await createEmployeeWorkAddress({\n request: {\n employeeId: mergedData.current.employee?.uuid as string,\n requestBody: {\n locationUuid: workAddress,\n effectiveDate: new RFCDate(payload.startDate || new Date()),\n },\n },\n })\n\n mergedData.current = { ...mergedData.current, workAddress: employeeWorkAddress }\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS_CREATED, employeeWorkAddress)\n } else {\n //effective_date is excluded from update operation since it cannot be changed on initial work address\n const { employeeWorkAddress } = await mutateEmployeeWorkAddress({\n request: {\n workAddressUuid: mergedData.current.workAddress.uuid,\n requestBody: {\n version: mergedData.current.workAddress.version,\n locationUuid: workAddress,\n },\n },\n })\n mergedData.current = { ...mergedData.current, workAddress: employeeWorkAddress }\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS_UPDATED, employeeWorkAddress)\n }\n }\n\n onEvent(componentEvents.EMPLOYEE_PROFILE_DONE, {\n ...mergedData.current.employee,\n startDate,\n })\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n return (\n <section className={className}>\n <ProfileProvider\n value={{\n companyLocations,\n workAddresses,\n employee: mergedData.current.employee ?? undefined,\n isSelfOnboardingIntended: watchedSelfOnboarding,\n handleCancel,\n isAdmin,\n isSelfOnboardingEnabled,\n isPending:\n isPendingEmployeeUpdate ||\n isPendingWorkAddressUpdate ||\n isPendingAddHA ||\n isPendingUpdateHA ||\n isPendingCreateEmployee ||\n isPendingCreateWA ||\n isPendingUpdateOnboardingStatus,\n }}\n >\n <FormProvider {...formMethods}>\n <Form onSubmit={handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <AdminPersonalDetails />\n <SelfPersonalDetails />\n <HomeAddress />\n <WorkAddress />\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </ProfileProvider>\n </section>\n )\n}\n\nProfile.Head = Head\nProfile.Actions = Actions\nProfile.AdminPersonalDetails = AdminPersonalDetails\nProfile.SelfPersonalDetails = SelfPersonalDetails\nProfile.HomeAddress = HomeAddress\nProfile.WorkAddress = WorkAddress\n\nexport const ProfileContextual = () => {\n const { companyId, employeeId, onEvent, isAdmin, defaultValues, isSelfOnboardingEnabled } =\n useFlow<OnboardingContextInterface>()\n\n return (\n <Profile\n companyId={ensureRequired(companyId)}\n employeeId={employeeId}\n onEvent={onEvent}\n isAdmin={isAdmin}\n defaultValues={defaultValues?.profile}\n isSelfOnboardingEnabled={isSelfOnboardingEnabled}\n />\n )\n}\n"],"names":["Profile","props","jsx","BaseComponent","RootWithEmployee","Root","employeeId","employee","useEmployeesGetSuspense","employeeAddressList","useEmployeeAddressesGetSuspense","employeeWorkAddressesList","useEmployeeAddressesGetWorkAddressesSuspense","isAdmin","isSelfOnboardingEnabled","dictionary","useI18n","useComponentDictionary","companyId","homeAddresses","workAddresses","children","className","defaultValues","onEvent","baseSubmitHandler","useBase","queryClient","useQueryClient","data","useLocationsGetSuspense","companyLocations","createEmployee","isPendingCreateEmployee","useEmployeesCreateMutation","mutateEmployee","isPendingEmployeeUpdate","useEmployeesUpdateMutation","createEmployeeWorkAddress","isPendingCreateWA","useEmployeeAddressesCreateWorkAddressMutation","mutateEmployeeWorkAddress","isPendingWorkAddressUpdate","useEmployeeAddressesUpdateWorkAddressMutation","createEmployeeHomeAddress","isPendingAddHA","useEmployeeAddressesCreateMutation","mutateEmployeeHomeAddress","isPendingUpdateHA","useEmployeeAddressesUpdateMutation","updateEmployeeOnboardingStatus","isPendingUpdateOnboardingStatus","useEmployeesUpdateOnboardingStatusMutation","invalidateEmployeesList","existingData","currentHomeAddress","getEmployeeAddressForProfile","currentWorkAddress","address","mergedData","useRef","initialValues","adminDefaultValues","EmployeeOnboardingStatus","EmployeeSelfOnboardingStatuses","selfDetaultValues","formMethods","useForm","zodResolver","AdminPersonalDetailsSchema","SelfPersonalDetailsSchema","HomeAddressSchema","handleSubmit","watchedSelfOnboarding","useWatch","onSubmit","payload","workAddress","startDate","selfOnboarding","body","employeeOnboardingStatus","componentEvents","employeeData","RFCDate","street1","street2","city","state","zip","courtesyWithholding","employeeAddress","employeeWorkAddress","handleCancel","ProfileProvider","FormProvider","Form","jsxs","Fragment","Head","AdminPersonalDetails","SelfPersonalDetails","HomeAddress","WorkAddress","Actions","ProfileContextual","useFlow","ensureRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+EO,SAASA,EAAQC,GAA8C;AAElE,SAAA,gBAAAC,EAACC,MAAe,GAAGF,GAChB,YAAM,aACL,gBAAAC,EAACE,IAAkB,EAAA,GAAGH,GAAO,YAAYA,EAAM,YAC5C,UAAAA,EAAM,SACT,CAAA,IAEA,gBAAAC,EAACG,KAAM,GAAGJ,GAAQ,UAAMA,EAAA,SAAA,CAAS,EAErC,CAAA;AAEJ;AAGA,SAASG,GAAiB,EAAE,YAAAE,GAAY,GAAGL,KAAmD;AACtF,QAAA;AAAA,IACJ,MAAM,EAAE,UAAAM,EAAS;AAAA,EAAA,IACfC,GAAwB,EAAE,YAAAF,GAAY,GACpC;AAAA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AA,QAAA,gBAAAhG,EAACiG,GAAK,EAAA;AAAA,0BACLC,GAAqB,EAAA;AAAA,0BACrBC,GAAoB,EAAA;AAAA,0BACpBC,GAAY,EAAA;AAAA,0BACZC,GAAY,EAAA;AAAA,0BACZC,GAAQ,CAAA,CAAA;AAAA,MAAA,EACX,CAAA,EAEJ,CAAA,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAEAxG,EAAQ,OAAOmG;AACfnG,EAAQ,UAAUwG;AAClBxG,EAAQ,uBAAuBoG;AAC/BpG,EAAQ,sBAAsBqG;AAC9BrG,EAAQ,cAAcsG;AACtBtG,EAAQ,cAAcuG;AAEf,MAAME,KAAoB,MAAM;AAC/B,QAAA,EAAE,WAAAvF,GAAW,YAAAZ,GAAY,SAAAkB,GAAS,SAAAX,GAAS,eAAAU,GAAe,yBAAAT,MAC9D4F,GAAoC;AAGpC,SAAA,gBAAAxG;AAAA,IAACF;AAAA,IAAA;AAAA,MACC,WAAW2G,GAAezF,CAAS;AAAA,MACnC,YAAAZ;AAAA,MACA,SAAAkB;AAAA,MACA,SAAAX;AAAA,MACA,eAAeU,GAAe;AAAA,MAC9B,yBAAAT;AAAA,IAAA;AAAA,EACF;AAEJ;"}
@@ -6,11 +6,13 @@ import "@gusto/embedded-api/models/errors/apierror";
6
6
  import "@gusto/embedded-api/models/errors/sdkvalidationerror";
7
7
  import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
8
8
  import "../../Base/useBase.js";
9
+ import "../../../shared/constants.js";
9
10
  import "dompurify";
11
+ import "../../../contexts/ComponentAdapter/useComponentContext.js";
10
12
  import { createCompoundContext as o } from "../../Base/createCompoundContext.js";
11
- const [x, C] = o("ProfileContext");
13
+ const [c, d] = o("ProfileContext");
12
14
  export {
13
- C as ProfileProvider,
14
- x as useProfile
15
+ d as ProfileProvider,
16
+ c as useProfile
15
17
  };
16
18
  //# sourceMappingURL=useProfile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useProfile.js","sources":["../../../../src/components/Employee/Profile/useProfile.ts"],"sourcesContent":["import type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { type Location } from '@gusto/embedded-api/models/components/location'\nimport { createCompoundContext } from '@/components/Base'\n\n//Interface for context passed down to component slots\ntype ProfileContextType = {\n companyLocations: Location[]\n workAddresses?: EmployeeWorkAddress[]\n employee?: Employee\n isSelfOnboardingIntended?: boolean\n isPending: boolean\n isAdmin: boolean\n handleCancel: () => void\n isSelfOnboardingEnabled: boolean\n}\n\nconst [useProfile, ProfileProvider] = createCompoundContext<ProfileContextType>('ProfileContext')\nexport { useProfile, ProfileProvider }\n"],"names":["useProfile","ProfileProvider","createCompoundContext"],"mappings":";;;;;;;;;;AAiBA,MAAM,CAACA,GAAYC,CAAe,IAAIC,EAA0C,gBAAgB;"}
1
+ {"version":3,"file":"useProfile.js","sources":["../../../../src/components/Employee/Profile/useProfile.ts"],"sourcesContent":["import type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { type Location } from '@gusto/embedded-api/models/components/location'\nimport { createCompoundContext } from '@/components/Base'\n\n//Interface for context passed down to component slots\ntype ProfileContextType = {\n companyLocations: Location[]\n workAddresses?: EmployeeWorkAddress[]\n employee?: Employee\n isSelfOnboardingIntended?: boolean\n isPending: boolean\n isAdmin: boolean\n handleCancel: () => void\n isSelfOnboardingEnabled: boolean\n}\n\nconst [useProfile, ProfileProvider] = createCompoundContext<ProfileContextType>('ProfileContext')\nexport { useProfile, ProfileProvider }\n"],"names":["useProfile","ProfileProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;AAiBA,MAAM,CAACA,GAAYC,CAAe,IAAIC,EAA0C,gBAAgB;"}
@@ -11,7 +11,7 @@ const S = t.object({
11
11
  const n = d(), { employeeStateTaxes: m, isAdmin: a } = u(), { t: i } = s("Employee.Taxes"), { t: p } = s("common", { keyPrefix: "statesHash" });
12
12
  return m.map(({ state: o, questions: c }) => /* @__PURE__ */ l(f, { children: [
13
13
  /* @__PURE__ */ r(n.Heading, { as: "h2", children: i("stateTaxesTitle", { state: p(o) }) }),
14
- c.map((e) => e.isQuestionForAdminOnly && !a ? null : /* @__PURE__ */ r(
14
+ c?.map((e) => e.isQuestionForAdminOnly && !a ? null : /* @__PURE__ */ r(
15
15
  x,
16
16
  {
17
17
  question: {
@@ -1 +1 @@
1
- {"version":3,"file":"StateForm.js","sources":["../../../../src/components/Employee/Taxes/StateForm.tsx"],"sourcesContent":["import { Fragment } from 'react/jsx-runtime'\nimport { useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { useTaxes } from './useTaxes'\nimport type { STATES_ABBR } from '@/shared/constants'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\nimport { QuestionInput } from '@/components/Common/TaxInputs/TaxInputs'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const StateFormSchema = z.object({\n states: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),\n})\n\nexport type StateFormPayload = z.output<typeof StateFormSchema>\n\nexport const StateForm = () => {\n const Components = useComponentContext()\n const { employeeStateTaxes, isAdmin } = useTaxes()\n const { t } = useTranslation('Employee.Taxes')\n const { t: statesHash } = useTranslation('common', { keyPrefix: 'statesHash' })\n\n return employeeStateTaxes.map(({ state, questions }) => (\n <Fragment key={state}>\n <Components.Heading as=\"h2\">\n {t('stateTaxesTitle', { state: statesHash(state as (typeof STATES_ABBR)[number]) })}\n </Components.Heading>\n {questions.map(question => {\n // @ts-expect-error TODO: This is an issue with the schema, the isQuestionForAdminOnly field is not defined\n if (question.isQuestionForAdminOnly && !isAdmin) return null\n return (\n <QuestionInput\n question={{\n ...question,\n key: `states.${state}.${snakeCaseToCamelCase(question.key)}`, // Its important not to convert state as it must maintain two capital letters\n }}\n questionType={\n question.key === 'fileNewHireReport' ? 'Radio' : question.inputQuestionFormat.type\n }\n key={question.key}\n />\n )\n })}\n </Fragment>\n ))\n}\n"],"names":["StateFormSchema","z","StateForm","Components","useComponentContext","employeeStateTaxes","isAdmin","useTaxes","t","useTranslation","statesHash","state","questions","Fragment","jsx","question","QuestionInput","snakeCaseToCamelCase"],"mappings":";;;;;;;AASa,MAAAA,IAAkBC,EAAE,OAAO;AAAA,EACtC,QAAQA,EAAE,OAAOA,EAAE,UAAUA,EAAE,OAAOA,EAAE,OAAA,GAAUA,EAAE,QAAS,CAAA,CAAC,EAAE,SAAS;AAC3E,CAAC,GAIYC,IAAY,MAAM;AAC7B,QAAMC,IAAaC,EAAoB,GACjC,EAAE,oBAAAC,GAAoB,SAAAC,EAAQ,IAAIC,EAAS,GAC3C,EAAE,GAAAC,EAAA,IAAMC,EAAe,gBAAgB,GACvC,EAAE,GAAGC,MAAeD,EAAe,UAAU,EAAE,WAAW,cAAc;AAEvE,SAAAJ,EAAmB,IAAI,CAAC,EAAE,OAAAM,GAAO,WAAAC,EAAU,wBAC/CC,GACC,EAAA,UAAA;AAAA,IAAA,gBAAAC,EAACX,EAAW,SAAX,EAAmB,IAAG,MACpB,UAAAK,EAAE,mBAAmB,EAAE,OAAOE,EAAWC,CAAqC,EAAA,CAAG,EACpF,CAAA;AAAA,IACCC,EAAU,IAAI,CAAYG,MAErBA,EAAS,0BAA0B,CAACT,IAAgB,OAEtD,gBAAAQ;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,UAAU;AAAA,UACR,GAAGD;AAAA,UACH,KAAK,UAAUJ,CAAK,IAAIM,EAAqBF,EAAS,GAAG,CAAC;AAAA;AAAA,QAC5D;AAAA,QACA,cACEA,EAAS,QAAQ,sBAAsB,UAAUA,EAAS,oBAAoB;AAAA,MAAA;AAAA,MAE3EA,EAAS;AAAA,IAChB,CAEH;AAAA,EAAA,EAAA,GAnBYJ,CAoBf,CACD;AACH;"}
1
+ {"version":3,"file":"StateForm.js","sources":["../../../../src/components/Employee/Taxes/StateForm.tsx"],"sourcesContent":["import { Fragment } from 'react/jsx-runtime'\nimport { useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { useTaxes } from './useTaxes'\nimport type { STATES_ABBR } from '@/shared/constants'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\nimport { QuestionInput } from '@/components/Common/TaxInputs/TaxInputs'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const StateFormSchema = z.object({\n states: z.record(z.string(), z.record(z.string(), z.unknown())).optional(),\n})\n\nexport type StateFormPayload = z.output<typeof StateFormSchema>\n\nexport const StateForm = () => {\n const Components = useComponentContext()\n const { employeeStateTaxes, isAdmin } = useTaxes()\n const { t } = useTranslation('Employee.Taxes')\n const { t: statesHash } = useTranslation('common', { keyPrefix: 'statesHash' })\n\n return employeeStateTaxes.map(({ state, questions }) => (\n <Fragment key={state}>\n <Components.Heading as=\"h2\">\n {t('stateTaxesTitle', { state: statesHash(state as (typeof STATES_ABBR)[number]) })}\n </Components.Heading>\n {questions?.map(question => {\n if (question.isQuestionForAdminOnly && !isAdmin) return null\n return (\n <QuestionInput\n question={{\n ...question,\n key: `states.${state}.${snakeCaseToCamelCase(question.key)}`, // Its important not to convert state as it must maintain two capital letters\n }}\n questionType={\n question.key === 'fileNewHireReport' ? 'Radio' : question.inputQuestionFormat.type\n }\n key={question.key}\n />\n )\n })}\n </Fragment>\n ))\n}\n"],"names":["StateFormSchema","z","StateForm","Components","useComponentContext","employeeStateTaxes","isAdmin","useTaxes","t","useTranslation","statesHash","state","questions","Fragment","jsx","question","QuestionInput","snakeCaseToCamelCase"],"mappings":";;;;;;;AASa,MAAAA,IAAkBC,EAAE,OAAO;AAAA,EACtC,QAAQA,EAAE,OAAOA,EAAE,UAAUA,EAAE,OAAOA,EAAE,OAAA,GAAUA,EAAE,QAAS,CAAA,CAAC,EAAE,SAAS;AAC3E,CAAC,GAIYC,IAAY,MAAM;AAC7B,QAAMC,IAAaC,EAAoB,GACjC,EAAE,oBAAAC,GAAoB,SAAAC,EAAQ,IAAIC,EAAS,GAC3C,EAAE,GAAAC,EAAA,IAAMC,EAAe,gBAAgB,GACvC,EAAE,GAAGC,MAAeD,EAAe,UAAU,EAAE,WAAW,cAAc;AAEvE,SAAAJ,EAAmB,IAAI,CAAC,EAAE,OAAAM,GAAO,WAAAC,EAAU,wBAC/CC,GACC,EAAA,UAAA;AAAA,IAAA,gBAAAC,EAACX,EAAW,SAAX,EAAmB,IAAG,MACpB,UAAAK,EAAE,mBAAmB,EAAE,OAAOE,EAAWC,CAAqC,EAAA,CAAG,EACpF,CAAA;AAAA,IACCC,GAAW,IAAI,CAAYG,MACtBA,EAAS,0BAA0B,CAACT,IAAgB,OAEtD,gBAAAQ;AAAA,MAACE;AAAA,MAAA;AAAA,QACC,UAAU;AAAA,UACR,GAAGD;AAAA,UACH,KAAK,UAAUJ,CAAK,IAAIM,EAAqBF,EAAS,GAAG,CAAC;AAAA;AAAA,QAC5D;AAAA,QACA,cACEA,EAAS,QAAQ,sBAAsB,UAAUA,EAAS,oBAAoB;AAAA,MAAA;AAAA,MAE3EA,EAAS;AAAA,IAChB,CAEH;AAAA,EAAA,EAAA,GAlBYJ,CAmBf,CACD;AACH;"}