@gusto/embedded-react-sdk 0.10.2 → 0.10.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/dist/components/Base/Base.d.ts +3 -2
- package/dist/components/Base/Base.js +31 -31
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountComponents.js +16 -9
- package/dist/components/Company/BankAccount/BankAccountComponents.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js +22 -8
- package/dist/components/Company/BankAccount/BankAccountForm/Actions.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.d.ts +1 -0
- package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.js +23 -25
- package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.d.ts +4 -0
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountList/AccountView.js +14 -13
- package/dist/components/Company/BankAccount/BankAccountList/AccountView.js.map +1 -1
- package/dist/components/Company/BankAccount/stateMachine.d.ts +1 -1
- package/dist/components/Company/BankAccount/stateMachine.js +13 -5
- package/dist/components/Company/BankAccount/stateMachine.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js +41 -42
- package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Company/Industry/Industry.js +30 -31
- package/dist/components/Company/Industry/Industry.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/LocationForm.js +34 -37
- package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/List.js +4 -1
- package/dist/components/Company/Locations/LocationsList/List.js.map +1 -1
- package/dist/components/Company/PaySchedule/PaySchedule.js +70 -71
- package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
- package/dist/components/Contractor/Address/Address.js +37 -38
- package/dist/components/Contractor/Address/Address.js.map +1 -1
- package/dist/components/Contractor/NewHireReport/NewHireReport.js +57 -58
- package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
- package/dist/components/Employee/Compensation/Compensation.js +123 -132
- package/dist/components/Employee/Compensation/Compensation.js.map +1 -1
- package/dist/components/Employee/Deductions/Deductions.js +74 -79
- package/dist/components/Employee/Deductions/Deductions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js +36 -42
- package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/EmployeeList.js +57 -58
- package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/PaymentMethod.js +95 -97
- package/dist/components/Employee/PaymentMethod/PaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/Profile.js +118 -124
- package/dist/components/Employee/Profile/Profile.js.map +1 -1
- package/dist/components/Employee/Taxes/FederalForm.js +4 -4
- package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
- package/dist/components/Employee/Taxes/Taxes.js +59 -60
- package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
- package/dist/contexts/ApiProvider/ApiProvider.js +16 -14
- package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
- package/dist/contexts/ComponentAdapter/componentAdapterTypes.d.ts +5 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +2 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +19 -17
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/LoadingIndicatorProvider/LoadingIndicatorProvider.d.ts +7 -0
- package/dist/contexts/LoadingIndicatorProvider/LoadingIndicatorProvider.js +10 -0
- package/dist/contexts/LoadingIndicatorProvider/LoadingIndicatorProvider.js.map +1 -0
- package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.d.ts +6 -0
- package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.js +11 -0
- package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.js.map +1 -0
- package/dist/shared/constants.d.ts +2 -0
- package/dist/shared/constants.js +10 -9
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/package.json +5 -1
|
@@ -1,82 +1,78 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { zodResolver as
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useForm as
|
|
5
|
-
import { useLocationsGetSuspense as
|
|
6
|
-
import { useEmployeesCreateMutation as
|
|
7
|
-
import { useEmployeesGetSuspense as
|
|
8
|
-
import { useEmployeeAddressesGetSuspense as
|
|
9
|
-
import { useEmployeeAddressesCreateMutation as
|
|
10
|
-
import { useEmployeeAddressesUpdateMutation as
|
|
11
|
-
import { useEmployeeAddressesUpdateWorkAddressMutation as
|
|
12
|
-
import { useEmployeesUpdateMutation as
|
|
13
|
-
import { useEmployeeAddressesGetWorkAddressesSuspense as Le
|
|
14
|
-
import { useEmployeeAddressesCreateWorkAddressMutation as
|
|
15
|
-
import { RFCDate as
|
|
16
|
-
import { useEmployeesUpdateOnboardingStatusMutation as
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import { Actions as T } from "./Actions.js";
|
|
23
|
-
import { HomeAddressSchema as Fe, HomeAddress as G } from "./HomeAddress.js";
|
|
1
|
+
import { jsx as t, jsxs as fe, Fragment as Ee } from "react/jsx-runtime";
|
|
2
|
+
import { zodResolver as he } from "@hookform/resolvers/zod";
|
|
3
|
+
import { useState as De, useRef as Oe, useEffect as Se } from "react";
|
|
4
|
+
import { useForm as Pe, useWatch as ge, FormProvider as be } from "react-hook-form";
|
|
5
|
+
import { useLocationsGetSuspense as Ne } from "@gusto/embedded-api/react-query/locationsGet";
|
|
6
|
+
import { useEmployeesCreateMutation as Ie } from "@gusto/embedded-api/react-query/employeesCreate";
|
|
7
|
+
import { useEmployeesGetSuspense as _e } from "@gusto/embedded-api/react-query/employeesGet";
|
|
8
|
+
import { useEmployeeAddressesGetSuspense as we } from "@gusto/embedded-api/react-query/employeeAddressesGet";
|
|
9
|
+
import { useEmployeeAddressesCreateMutation as ke } from "@gusto/embedded-api/react-query/employeeAddressesCreate";
|
|
10
|
+
import { useEmployeeAddressesUpdateMutation as Me } from "@gusto/embedded-api/react-query/employeeAddressesUpdate";
|
|
11
|
+
import { useEmployeeAddressesUpdateWorkAddressMutation as Be } from "@gusto/embedded-api/react-query/employeeAddressesUpdateWorkAddress";
|
|
12
|
+
import { useEmployeesUpdateMutation as Re } from "@gusto/embedded-api/react-query/employeesUpdate";
|
|
13
|
+
import { useEmployeeAddressesGetWorkAddressesSuspense as Le } from "@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses";
|
|
14
|
+
import { useEmployeeAddressesCreateWorkAddressMutation as ve } from "@gusto/embedded-api/react-query/employeeAddressesCreateWorkAddress";
|
|
15
|
+
import { RFCDate as R } from "@gusto/embedded-api/types/rfcdate";
|
|
16
|
+
import { useEmployeesUpdateOnboardingStatusMutation as We } from "@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus";
|
|
17
|
+
import { AdminPersonalDetailsSchema as L, AdminSelfOnboardingPersonalDetailsSchema as Ce, AdminPersonalDetails as W } from "./AdminPersonalDetails.js";
|
|
18
|
+
import { SelfPersonalDetailsSchema as Ue, SelfPersonalDetails as C } from "./SelfPersonalDetails.js";
|
|
19
|
+
import { Head as U } from "./Head.js";
|
|
20
|
+
import { Actions as q } from "./Actions.js";
|
|
21
|
+
import { HomeAddressSchema as qe, HomeAddress as T } from "./HomeAddress.js";
|
|
24
22
|
import { WorkAddress as H } from "./WorkAddress.js";
|
|
25
|
-
import { ProfileProvider as
|
|
26
|
-
import { getEmployeeAddressForProfile as
|
|
27
|
-
import { Form as
|
|
28
|
-
import { BaseComponent as
|
|
29
|
-
import { useBase as
|
|
30
|
-
import { useI18n as
|
|
31
|
-
import { EmployeeOnboardingStatus as l, EmployeeSelfOnboardingStatuses as
|
|
32
|
-
import { useFlow as
|
|
33
|
-
import { ensureRequired as
|
|
34
|
-
function
|
|
35
|
-
return /* @__PURE__ */ t(
|
|
23
|
+
import { ProfileProvider as Te } from "./useProfile.js";
|
|
24
|
+
import { getEmployeeAddressForProfile as He } from "./getEmployeeAddressForProfile.js";
|
|
25
|
+
import { Form as Ge } from "../../Common/Form/Form.js";
|
|
26
|
+
import { BaseComponent as Fe } from "../../Base/Base.js";
|
|
27
|
+
import { useBase as Ve } from "../../Base/useBase.js";
|
|
28
|
+
import { useI18n as v, useComponentDictionary as Ye } from "../../../i18n/I18n.js";
|
|
29
|
+
import { EmployeeOnboardingStatus as l, EmployeeSelfOnboardingStatuses as xe, componentEvents as d } from "../../../shared/constants.js";
|
|
30
|
+
import { useFlow as ze } from "../../Flow/useFlow.js";
|
|
31
|
+
import { ensureRequired as je } from "../../../helpers/ensureRequired.js";
|
|
32
|
+
function i(r) {
|
|
33
|
+
return /* @__PURE__ */ t(Fe, { ...r, children: r.employeeId ? /* @__PURE__ */ t(Ke, { ...r, employeeId: r.employeeId, children: r.children }) : /* @__PURE__ */ t(G, { ...r, children: r.children }) });
|
|
36
34
|
}
|
|
37
|
-
function
|
|
35
|
+
function Ke({ employeeId: r, ...a }) {
|
|
38
36
|
const {
|
|
39
37
|
data: { employee: u }
|
|
40
|
-
} =
|
|
38
|
+
} = _e({ employeeId: r }), {
|
|
41
39
|
data: { employeeAddressList: c }
|
|
42
|
-
} =
|
|
43
|
-
data: { employeeWorkAddressesList:
|
|
40
|
+
} = we({ employeeId: r }), {
|
|
41
|
+
data: { employeeWorkAddressesList: m }
|
|
44
42
|
} = Le({ employeeId: r });
|
|
45
43
|
return /* @__PURE__ */ t(
|
|
46
|
-
|
|
44
|
+
G,
|
|
47
45
|
{
|
|
48
|
-
...
|
|
46
|
+
...a,
|
|
49
47
|
employee: u,
|
|
50
48
|
homeAddresses: c,
|
|
51
|
-
workAddresses:
|
|
49
|
+
workAddresses: m
|
|
52
50
|
}
|
|
53
51
|
);
|
|
54
52
|
}
|
|
55
|
-
const
|
|
53
|
+
const G = ({
|
|
56
54
|
isAdmin: r = !1,
|
|
57
|
-
isSelfOnboardingEnabled:
|
|
55
|
+
isSelfOnboardingEnabled: a = !0,
|
|
58
56
|
dictionary: u,
|
|
59
57
|
...c
|
|
60
58
|
}) => {
|
|
61
|
-
|
|
59
|
+
v("Employee.Profile"), v("Employee.HomeAddress"), Ye("Employee.Profile", u);
|
|
62
60
|
const {
|
|
63
|
-
companyId:
|
|
61
|
+
companyId: m,
|
|
64
62
|
employee: D,
|
|
65
|
-
homeAddresses:
|
|
63
|
+
homeAddresses: F,
|
|
66
64
|
workAddresses: g,
|
|
67
65
|
children: b,
|
|
68
|
-
className:
|
|
66
|
+
className: V = "",
|
|
69
67
|
defaultValues: s
|
|
70
|
-
} = c, { onEvent: n, baseSubmitHandler:
|
|
71
|
-
mutateAsync:
|
|
72
|
-
isPending:
|
|
73
|
-
} =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
workAddress: le
|
|
79
|
-
}), S = {
|
|
68
|
+
} = c, { onEvent: n, baseSubmitHandler: Y } = Ve(), [x, N] = De(L), { data: z } = Ne({ companyId: m }), j = z.locationList, { mutateAsync: K, isPending: J } = Ie(), { mutateAsync: Q, isPending: X } = Re(), { mutateAsync: Z, isPending: $ } = ve(), { mutateAsync: ee, isPending: re } = Be(), { mutateAsync: te, isPending: oe } = ke(), { mutateAsync: se, isPending: ne } = Me(), {
|
|
69
|
+
mutateAsync: de,
|
|
70
|
+
isPending: ie
|
|
71
|
+
} = We(), I = { employee: D, workAddresses: g }, ae = He(F), me = I.workAddresses?.find((P) => P.active), e = Oe({
|
|
72
|
+
employee: I.employee,
|
|
73
|
+
homeAddress: ae,
|
|
74
|
+
workAddress: me
|
|
75
|
+
}), O = {
|
|
80
76
|
firstName: e.current.employee?.firstName ?? s?.employee?.firstName ?? "",
|
|
81
77
|
middleInitial: e.current.employee?.middleInitial ?? s?.employee?.middleInitial ?? "",
|
|
82
78
|
lastName: e.current.employee?.lastName ?? s?.employee?.lastName ?? "",
|
|
@@ -91,33 +87,33 @@ const F = ({
|
|
|
91
87
|
zip: e.current.homeAddress?.zip ?? s?.homeAddress?.zip ?? "",
|
|
92
88
|
state: e.current.homeAddress?.state ?? s?.homeAddress?.state ?? "",
|
|
93
89
|
courtesyWithholding: e.current.homeAddress?.courtesyWithholding ?? !1
|
|
94
|
-
},
|
|
95
|
-
...
|
|
96
|
-
selfOnboarding:
|
|
90
|
+
}, le = 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 ? { ...O, enableSsn: !1, selfOnboarding: !0 } : {
|
|
91
|
+
...O,
|
|
92
|
+
selfOnboarding: a && e.current.employee?.onboardingStatus ? (
|
|
97
93
|
// @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses
|
|
98
|
-
|
|
94
|
+
xe.has(e.current.employee.onboarding_status)
|
|
99
95
|
) : !1,
|
|
100
96
|
enableSsn: !e.current.employee?.hasSsn,
|
|
101
97
|
ssn: ""
|
|
102
|
-
},
|
|
103
|
-
...
|
|
98
|
+
}, ue = {
|
|
99
|
+
...O,
|
|
104
100
|
enableSsn: !e.current.employee?.hasSsn,
|
|
105
101
|
ssn: ""
|
|
106
|
-
},
|
|
107
|
-
resolver:
|
|
108
|
-
(r ?
|
|
102
|
+
}, S = Pe({
|
|
103
|
+
resolver: he(
|
|
104
|
+
(r ? x : Ue).and(qe)
|
|
109
105
|
),
|
|
110
|
-
defaultValues: r ?
|
|
111
|
-
}), { handleSubmit:
|
|
112
|
-
|
|
113
|
-
r &&
|
|
106
|
+
defaultValues: r ? le : ue
|
|
107
|
+
}), { handleSubmit: ce } = S, A = ge({ control: S.control, name: "selfOnboarding" });
|
|
108
|
+
Se(() => {
|
|
109
|
+
r && N(A ? Ce : L);
|
|
114
110
|
}, [A, r]);
|
|
115
|
-
const
|
|
116
|
-
await
|
|
117
|
-
const { workAddress:
|
|
111
|
+
const pe = async (P) => {
|
|
112
|
+
await Y(P, async (f) => {
|
|
113
|
+
const { workAddress: _, startDate: Ae, selfOnboarding: E, ...h } = f;
|
|
118
114
|
if (e.current.employee) {
|
|
119
115
|
if (E && e.current.employee.onboardingStatus === l.ADMIN_ONBOARDING_INCOMPLETE || !E && e.current.employee.onboardingStatus === l.SELF_ONBOARDING_PENDING_INVITE) {
|
|
120
|
-
const { employeeOnboardingStatus: p } = await
|
|
116
|
+
const { employeeOnboardingStatus: p } = await de({
|
|
121
117
|
request: {
|
|
122
118
|
employeeId: e.current.employee.uuid,
|
|
123
119
|
requestBody: {
|
|
@@ -130,7 +126,7 @@ const F = ({
|
|
|
130
126
|
onboardingStatus: p.onboardingStatus
|
|
131
127
|
}, n(d.EMPLOYEE_ONBOARDING_STATUS_UPDATED, p);
|
|
132
128
|
}
|
|
133
|
-
const { employee: o } = await
|
|
129
|
+
const { employee: o } = await Q({
|
|
134
130
|
request: {
|
|
135
131
|
employeeId: e.current.employee.uuid,
|
|
136
132
|
requestBody: { ...h, version: e.current.employee.version }
|
|
@@ -138,13 +134,13 @@ const F = ({
|
|
|
138
134
|
});
|
|
139
135
|
e.current = { ...e.current, employee: o }, n(d.EMPLOYEE_UPDATED, o);
|
|
140
136
|
} else {
|
|
141
|
-
const { employee: o } = await
|
|
137
|
+
const { employee: o } = await K({
|
|
142
138
|
request: {
|
|
143
|
-
companyId:
|
|
139
|
+
companyId: m,
|
|
144
140
|
requestBody: {
|
|
145
141
|
...h,
|
|
146
142
|
selfOnboarding: E,
|
|
147
|
-
dateOfBirth: h.dateOfBirth ? new
|
|
143
|
+
dateOfBirth: h.dateOfBirth ? new R(h.dateOfBirth) : void 0
|
|
148
144
|
}
|
|
149
145
|
}
|
|
150
146
|
});
|
|
@@ -153,120 +149,118 @@ const F = ({
|
|
|
153
149
|
if (typeof e.current.employee?.uuid != "string")
|
|
154
150
|
throw new Error("Employee id is not available");
|
|
155
151
|
if ((!A || !r) && !f.selfOnboarding) {
|
|
156
|
-
const { street1: o, street2: p, city:
|
|
152
|
+
const { street1: o, street2: p, city: w, state: k, zip: M, courtesyWithholding: B } = f;
|
|
157
153
|
if (e.current.homeAddress) {
|
|
158
|
-
const { employeeAddress: y } = await
|
|
154
|
+
const { employeeAddress: y } = await se({
|
|
159
155
|
request: {
|
|
160
156
|
homeAddressUuid: e.current.homeAddress.uuid,
|
|
161
157
|
requestBody: {
|
|
162
158
|
version: e.current.homeAddress.version,
|
|
163
159
|
street1: o,
|
|
164
160
|
street2: p,
|
|
165
|
-
city:
|
|
166
|
-
state:
|
|
167
|
-
zip:
|
|
168
|
-
courtesyWithholding:
|
|
161
|
+
city: w,
|
|
162
|
+
state: k,
|
|
163
|
+
zip: M,
|
|
164
|
+
courtesyWithholding: B
|
|
169
165
|
}
|
|
170
166
|
}
|
|
171
167
|
});
|
|
172
168
|
e.current = { ...e.current, homeAddress: y }, n(d.EMPLOYEE_HOME_ADDRESS_UPDATED, y);
|
|
173
169
|
} else {
|
|
174
|
-
const { employeeAddress: y } = await
|
|
170
|
+
const { employeeAddress: y } = await te({
|
|
175
171
|
request: {
|
|
176
172
|
employeeId: e.current.employee.uuid,
|
|
177
173
|
requestBody: {
|
|
178
174
|
street1: o,
|
|
179
175
|
street2: p,
|
|
180
|
-
city:
|
|
181
|
-
state:
|
|
182
|
-
zip:
|
|
183
|
-
courtesyWithholding:
|
|
176
|
+
city: w,
|
|
177
|
+
state: k,
|
|
178
|
+
zip: M,
|
|
179
|
+
courtesyWithholding: B
|
|
184
180
|
}
|
|
185
181
|
}
|
|
186
182
|
});
|
|
187
183
|
e.current = { ...e.current, homeAddress: y }, n(d.EMPLOYEE_HOME_ADDRESS_CREATED, y);
|
|
188
184
|
}
|
|
189
185
|
}
|
|
190
|
-
if (r)
|
|
186
|
+
if (r)
|
|
191
187
|
if (e.current.workAddress) {
|
|
192
|
-
const { employeeWorkAddress: o } = await
|
|
188
|
+
const { employeeWorkAddress: o } = await ee({
|
|
193
189
|
request: {
|
|
194
190
|
workAddressUuid: e.current.workAddress.uuid,
|
|
195
191
|
requestBody: {
|
|
196
192
|
version: e.current.workAddress.version,
|
|
197
|
-
locationUuid:
|
|
193
|
+
locationUuid: _
|
|
198
194
|
}
|
|
199
195
|
}
|
|
200
196
|
});
|
|
201
197
|
e.current = { ...e.current, workAddress: o }, n(d.EMPLOYEE_WORK_ADDRESS_UPDATED, o);
|
|
202
198
|
} else {
|
|
203
|
-
const { employeeWorkAddress: o } = await
|
|
199
|
+
const { employeeWorkAddress: o } = await Z({
|
|
204
200
|
request: {
|
|
205
201
|
employeeId: e.current.employee?.uuid,
|
|
206
202
|
requestBody: {
|
|
207
|
-
locationUuid:
|
|
208
|
-
effectiveDate: new
|
|
203
|
+
locationUuid: _,
|
|
204
|
+
effectiveDate: new R(f.startDate || /* @__PURE__ */ new Date())
|
|
209
205
|
}
|
|
210
206
|
}
|
|
211
207
|
});
|
|
212
208
|
e.current = { ...e.current, workAddress: o }, n(d.EMPLOYEE_WORK_ADDRESS_CREATED, o);
|
|
213
209
|
}
|
|
214
|
-
await Ce(N);
|
|
215
|
-
}
|
|
216
210
|
n(d.EMPLOYEE_PROFILE_DONE, {
|
|
217
211
|
...e.current.employee,
|
|
218
|
-
startDate:
|
|
212
|
+
startDate: Ae
|
|
219
213
|
});
|
|
220
214
|
});
|
|
221
|
-
},
|
|
215
|
+
}, ye = () => {
|
|
222
216
|
n(d.CANCEL);
|
|
223
217
|
};
|
|
224
|
-
return /* @__PURE__ */ t("section", { className:
|
|
225
|
-
|
|
218
|
+
return /* @__PURE__ */ t("section", { className: V, children: /* @__PURE__ */ t(
|
|
219
|
+
Te,
|
|
226
220
|
{
|
|
227
221
|
value: {
|
|
228
|
-
companyLocations:
|
|
222
|
+
companyLocations: j,
|
|
229
223
|
workAddresses: g,
|
|
230
224
|
employee: e.current.employee ?? void 0,
|
|
231
225
|
isSelfOnboardingIntended: A,
|
|
232
|
-
handleCancel:
|
|
226
|
+
handleCancel: ye,
|
|
233
227
|
isAdmin: r,
|
|
234
|
-
isSelfOnboardingEnabled:
|
|
235
|
-
isPending:
|
|
228
|
+
isSelfOnboardingEnabled: a,
|
|
229
|
+
isPending: X || re || oe || ne || J || $ || ie
|
|
236
230
|
},
|
|
237
|
-
children: /* @__PURE__ */ t(
|
|
238
|
-
/* @__PURE__ */ t(q, {}),
|
|
239
|
-
/* @__PURE__ */ t(W, {}),
|
|
231
|
+
children: /* @__PURE__ */ t(be, { ...S, children: /* @__PURE__ */ t(Ge, { onSubmit: ce(pe), children: b || /* @__PURE__ */ fe(Ee, { children: [
|
|
240
232
|
/* @__PURE__ */ t(U, {}),
|
|
241
|
-
/* @__PURE__ */ t(
|
|
233
|
+
/* @__PURE__ */ t(W, {}),
|
|
234
|
+
/* @__PURE__ */ t(C, {}),
|
|
235
|
+
/* @__PURE__ */ t(T, {}),
|
|
242
236
|
/* @__PURE__ */ t(H, {}),
|
|
243
|
-
/* @__PURE__ */ t(
|
|
237
|
+
/* @__PURE__ */ t(q, {})
|
|
244
238
|
] }) }) })
|
|
245
239
|
}
|
|
246
240
|
) });
|
|
247
241
|
};
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
const
|
|
255
|
-
const { companyId: r, employeeId:
|
|
242
|
+
i.Head = U;
|
|
243
|
+
i.Actions = q;
|
|
244
|
+
i.AdminPersonalDetails = W;
|
|
245
|
+
i.SelfPersonalDetails = C;
|
|
246
|
+
i.HomeAddress = T;
|
|
247
|
+
i.WorkAddress = H;
|
|
248
|
+
const Ir = () => {
|
|
249
|
+
const { companyId: r, employeeId: a, onEvent: u, isAdmin: c, defaultValues: m, isSelfOnboardingEnabled: D } = ze();
|
|
256
250
|
return /* @__PURE__ */ t(
|
|
257
|
-
|
|
251
|
+
i,
|
|
258
252
|
{
|
|
259
|
-
companyId:
|
|
260
|
-
employeeId:
|
|
253
|
+
companyId: je(r),
|
|
254
|
+
employeeId: a,
|
|
261
255
|
onEvent: u,
|
|
262
256
|
isAdmin: c,
|
|
263
|
-
defaultValues:
|
|
257
|
+
defaultValues: m?.profile,
|
|
264
258
|
isSelfOnboardingEnabled: D
|
|
265
259
|
}
|
|
266
260
|
);
|
|
267
261
|
};
|
|
268
262
|
export {
|
|
269
|
-
|
|
270
|
-
|
|
263
|
+
i as Profile,
|
|
264
|
+
Ir as ProfileContextual
|
|
271
265
|
};
|
|
272
266
|
//# sourceMappingURL=Profile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Profile.js","sources":["../../../../src/components/Employee/Profile/Profile.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { useRef, useState, useEffect } 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 {\n invalidateAllEmployeeAddressesGetWorkAddresses,\n useEmployeeAddressesGetWorkAddressesSuspense,\n} 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 {\n AdminPersonalDetails,\n AdminPersonalDetailsSchema,\n AdminSelfOnboardingPersonalDetailsSchema,\n} 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 [AdminSchema, setAdminSchema] = useState<\n typeof AdminPersonalDetailsSchema | typeof AdminSelfOnboardingPersonalDetailsSchema\n >(AdminPersonalDetailsSchema)\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 ? AdminSchema : 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 useEffect(() => {\n if (isAdmin) {\n if (watchedSelfOnboarding) {\n setAdminSchema(AdminSelfOnboardingPersonalDetailsSchema)\n } else {\n setAdminSchema(AdminPersonalDetailsSchema)\n }\n }\n }, [watchedSelfOnboarding, isAdmin])\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 await invalidateAllEmployeeAddressesGetWorkAddresses(queryClient)\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","AdminSchema","setAdminSchema","useState","AdminPersonalDetailsSchema","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","SelfPersonalDetailsSchema","HomeAddressSchema","handleSubmit","watchedSelfOnboarding","useWatch","useEffect","AdminSelfOnboardingPersonalDetailsSchema","onSubmit","payload","workAddress","startDate","selfOnboarding","body","employeeOnboardingStatus","componentEvents","employeeData","RFCDate","street1","street2","city","state","zip","courtesyWithholding","employeeAddress","employeeWorkAddress","invalidateAllEmployeeAddressesGetWorkAddresses","handleCancel","ProfileProvider","FormProvider","Form","jsxs","Fragment","Head","AdminPersonalDetails","SelfPersonalDetails","HomeAddress","WorkAddress","Actions","ProfileContextual","useFlow","ensureRequired"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFO,SAASA,EAAQC,GAA8C;AAEl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e/F,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, useState, useEffect } 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 type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlow'\nimport {\n AdminPersonalDetails,\n AdminPersonalDetailsSchema,\n AdminSelfOnboardingPersonalDetailsSchema,\n} 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\n const [AdminSchema, setAdminSchema] = useState<\n typeof AdminPersonalDetailsSchema | typeof AdminSelfOnboardingPersonalDetailsSchema\n >(AdminPersonalDetailsSchema)\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\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 ? AdminSchema : 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 useEffect(() => {\n if (isAdmin) {\n if (watchedSelfOnboarding) {\n setAdminSchema(AdminSelfOnboardingPersonalDetailsSchema)\n } else {\n setAdminSchema(AdminPersonalDetailsSchema)\n }\n }\n }, [watchedSelfOnboarding, isAdmin])\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","AdminSchema","setAdminSchema","useState","AdminPersonalDetailsSchema","data","useLocationsGetSuspense","companyLocations","createEmployee","isPendingCreateEmployee","useEmployeesCreateMutation","mutateEmployee","isPendingEmployeeUpdate","useEmployeesUpdateMutation","createEmployeeWorkAddress","isPendingCreateWA","useEmployeeAddressesCreateWorkAddressMutation","mutateEmployeeWorkAddress","isPendingWorkAddressUpdate","useEmployeeAddressesUpdateWorkAddressMutation","createEmployeeHomeAddress","isPendingAddHA","useEmployeeAddressesCreateMutation","mutateEmployeeHomeAddress","isPendingUpdateHA","useEmployeeAddressesUpdateMutation","updateEmployeeOnboardingStatus","isPendingUpdateOnboardingStatus","useEmployeesUpdateOnboardingStatusMutation","existingData","currentHomeAddress","getEmployeeAddressForProfile","currentWorkAddress","address","mergedData","useRef","initialValues","adminDefaultValues","EmployeeOnboardingStatus","EmployeeSelfOnboardingStatuses","selfDetaultValues","formMethods","useForm","zodResolver","SelfPersonalDetailsSchema","HomeAddressSchema","handleSubmit","watchedSelfOnboarding","useWatch","useEffect","AdminSelfOnboardingPersonalDetailsSchema","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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiFO,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,GAAY,GAC5C;AAAA,IACJ,MAAM,EAAE,2BAAAK,EAA0B;AAAA,EAAA,IAChCC,GAA6C,EAAE,YAAAN,GAAY;AAE7D,SAAA,gBAAAJ;AAAA,IAACG;AAAA,IAAA;AAAA,MACE,GAAGJ;AAAA,MACJ,UAAAM;AAAA,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,MAAA,EACX,CAAA,EAEJ,CAAA,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAEA1G,EAAQ,OAAOqG;AACfrG,EAAQ,UAAU0G;AAClB1G,EAAQ,uBAAuBsG;AAC/BtG,EAAQ,sBAAsBuG;AAC9BvG,EAAQ,cAAcwG;AACtBxG,EAAQ,cAAcyG;AAEf,MAAME,KAAoB,MAAM;AAC/B,QAAA,EAAE,WAAAzF,GAAW,YAAAZ,GAAY,SAAAkB,GAAS,SAAAX,GAAS,eAAAU,GAAe,yBAAAT,MAC9D8F,GAAoC;AAGpC,SAAA,gBAAA1G;AAAA,IAACF;AAAA,IAAA;AAAA,MACC,WAAW6G,GAAe3F,CAAS;AAAA,MACnC,YAAAZ;AAAA,MACA,SAAAkB;AAAA,MACA,SAAAX;AAAA,MACA,eAAeU,GAAe;AAAA,MAC9B,yBAAAT;AAAA,IAAA;AAAA,EACF;AAEJ;"}
|
|
@@ -5,7 +5,7 @@ import { useComponentContext as u } from "../../../contexts/ComponentAdapter/use
|
|
|
5
5
|
import { SelectField as d } from "../../Common/Fields/SelectField/SelectField.js";
|
|
6
6
|
import { RadioGroupField as f } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
|
|
7
7
|
import { NumberInputField as i } from "../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
8
|
-
const
|
|
8
|
+
const F = t.object({
|
|
9
9
|
filingStatus: t.string().min(1),
|
|
10
10
|
twoJobs: t.string().min(1),
|
|
11
11
|
dependentsAmount: t.number().transform(String),
|
|
@@ -39,7 +39,7 @@ function R() {
|
|
|
39
39
|
name: "twoJobs",
|
|
40
40
|
label: e("multipleJobs2c"),
|
|
41
41
|
errorMessage: e("validations.federalTwoJobs"),
|
|
42
|
-
description: /* @__PURE__ */ r(
|
|
42
|
+
description: /* @__PURE__ */ r(o.Text, { children: /* @__PURE__ */ r(
|
|
43
43
|
m,
|
|
44
44
|
{
|
|
45
45
|
i18nKey: "includesSpouseExplanation",
|
|
@@ -48,7 +48,7 @@ function R() {
|
|
|
48
48
|
irs_link: /* @__PURE__ */ r(o.Link, {})
|
|
49
49
|
}
|
|
50
50
|
}
|
|
51
|
-
),
|
|
51
|
+
) }),
|
|
52
52
|
options: [
|
|
53
53
|
{ value: "true", label: e("twoJobYesLabel") },
|
|
54
54
|
{ value: "false", label: e("twoJobNoLabel") }
|
|
@@ -101,6 +101,6 @@ function R() {
|
|
|
101
101
|
}
|
|
102
102
|
export {
|
|
103
103
|
R as FederalForm,
|
|
104
|
-
|
|
104
|
+
F as FederalFormSchema
|
|
105
105
|
};
|
|
106
106
|
//# sourceMappingURL=FederalForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FederalForm.js","sources":["../../../../src/components/Employee/Taxes/FederalForm.tsx"],"sourcesContent":["import { Trans, useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { NumberInputField, RadioGroupField, SelectField } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const FederalFormSchema = z.object({\n filingStatus: z.string().min(1),\n twoJobs: z.string().min(1),\n dependentsAmount: z.number().transform(String),\n otherIncome: z.number().transform(String),\n deductions: z.number().transform(String),\n extraWithholding: z.number().transform(String),\n w4DataType: z.enum(['pre_2020_w4', 'rev_2020_w4']),\n})\n\nexport type FederalFormInputs = z.input<typeof FederalFormSchema>\nexport type FederalFormPayload = z.output<typeof FederalFormSchema>\n\nexport function FederalForm() {\n const { t } = useTranslation('Employee.Taxes')\n const Components = useComponentContext()\n\n const filingStatusCategories = [\n { value: 'Single', label: t('filingStatusSingle') },\n { value: 'Married', label: t('filingStatusMarried') },\n { value: 'Head of Household', label: t('filingStatusHeadOfHousehold') },\n { value: 'Exempt from withholding', label: t('filingStatusExemptFromWithholding') },\n ]\n\n return (\n <>\n <SelectField\n name=\"filingStatus\"\n label={t('federalFilingStatus1c')}\n placeholder={t('federalFillingStatusPlaceholder')}\n options={filingStatusCategories}\n isRequired\n errorMessage={t('validations.federalFilingStatus')}\n />\n <RadioGroupField\n name=\"twoJobs\"\n label={t('multipleJobs2c')}\n errorMessage={t('validations.federalTwoJobs')}\n description={\n <Trans\n
|
|
1
|
+
{"version":3,"file":"FederalForm.js","sources":["../../../../src/components/Employee/Taxes/FederalForm.tsx"],"sourcesContent":["import { Trans, useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { NumberInputField, RadioGroupField, SelectField } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport const FederalFormSchema = z.object({\n filingStatus: z.string().min(1),\n twoJobs: z.string().min(1),\n dependentsAmount: z.number().transform(String),\n otherIncome: z.number().transform(String),\n deductions: z.number().transform(String),\n extraWithholding: z.number().transform(String),\n w4DataType: z.enum(['pre_2020_w4', 'rev_2020_w4']),\n})\n\nexport type FederalFormInputs = z.input<typeof FederalFormSchema>\nexport type FederalFormPayload = z.output<typeof FederalFormSchema>\n\nexport function FederalForm() {\n const { t } = useTranslation('Employee.Taxes')\n const Components = useComponentContext()\n\n const filingStatusCategories = [\n { value: 'Single', label: t('filingStatusSingle') },\n { value: 'Married', label: t('filingStatusMarried') },\n { value: 'Head of Household', label: t('filingStatusHeadOfHousehold') },\n { value: 'Exempt from withholding', label: t('filingStatusExemptFromWithholding') },\n ]\n\n return (\n <>\n <SelectField\n name=\"filingStatus\"\n label={t('federalFilingStatus1c')}\n placeholder={t('federalFillingStatusPlaceholder')}\n options={filingStatusCategories}\n isRequired\n errorMessage={t('validations.federalFilingStatus')}\n />\n <RadioGroupField\n name=\"twoJobs\"\n label={t('multipleJobs2c')}\n errorMessage={t('validations.federalTwoJobs')}\n description={\n <Components.Text>\n <Trans\n i18nKey={'includesSpouseExplanation'}\n t={t}\n components={{\n irs_link: <Components.Link />,\n }}\n />\n </Components.Text>\n }\n options={[\n { value: 'true', label: t('twoJobYesLabel') },\n { value: 'false', label: t('twoJobNoLabel') },\n ]}\n />\n <NumberInputField\n name=\"dependentsAmount\"\n isRequired\n label={t('dependentsTotalIfApplicable')}\n errorMessage={t('fieldIsRequired')}\n />\n <NumberInputField\n name=\"otherIncome\"\n isRequired\n label={t('otherIncome')}\n format=\"currency\"\n min={0}\n errorMessage={t('fieldIsRequired')}\n />\n <NumberInputField\n name=\"deductions\"\n isRequired\n label={t('deductions')}\n format=\"currency\"\n min={0}\n errorMessage={t('fieldIsRequired')}\n />\n <NumberInputField\n name=\"extraWithholding\"\n isRequired\n label={t('extraWithholding')}\n format=\"currency\"\n min={0}\n errorMessage={t('fieldIsRequired')}\n />\n </>\n )\n}\n"],"names":["FederalFormSchema","z","FederalForm","t","useTranslation","Components","useComponentContext","filingStatusCategories","jsxs","Fragment","jsx","SelectField","RadioGroupField","Trans","NumberInputField"],"mappings":";;;;;;;AAKa,MAAAA,IAAoBC,EAAE,OAAO;AAAA,EACxC,cAAcA,EAAE,SAAS,IAAI,CAAC;AAAA,EAC9B,SAASA,EAAE,SAAS,IAAI,CAAC;AAAA,EACzB,kBAAkBA,EAAE,SAAS,UAAU,MAAM;AAAA,EAC7C,aAAaA,EAAE,SAAS,UAAU,MAAM;AAAA,EACxC,YAAYA,EAAE,SAAS,UAAU,MAAM;AAAA,EACvC,kBAAkBA,EAAE,SAAS,UAAU,MAAM;AAAA,EAC7C,YAAYA,EAAE,KAAK,CAAC,eAAe,aAAa,CAAC;AACnD,CAAC;AAKM,SAASC,IAAc;AAC5B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,gBAAgB,GACvCC,IAAaC,EAAoB,GAEjCC,IAAyB;AAAA,IAC7B,EAAE,OAAO,UAAU,OAAOJ,EAAE,oBAAoB,EAAE;AAAA,IAClD,EAAE,OAAO,WAAW,OAAOA,EAAE,qBAAqB,EAAE;AAAA,IACpD,EAAE,OAAO,qBAAqB,OAAOA,EAAE,6BAA6B,EAAE;AAAA,IACtE,EAAE,OAAO,2BAA2B,OAAOA,EAAE,mCAAmC,EAAE;AAAA,EACpF;AAEA,SAE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