@gusto/embedded-react-sdk 0.52.0 → 0.52.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +32 -0
- package/dist/components/Base/Base.d.ts +2 -0
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Common/PaginationControl/PaginationControlTypes.d.ts +4 -1
- package/dist/components/Common/UI/Breadcrumbs/BreadcrumbsTypes.d.ts +1 -1
- package/dist/components/Common/UI/Breadcrumbs/BreadcrumbsTypes.js.map +1 -1
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroupTypes.d.ts +1 -1
- package/dist/components/Common/UI/CheckboxGroup/CheckboxGroupTypes.js.map +1 -1
- package/dist/components/Common/UI/ComboBox/ComboBoxTypes.d.ts +2 -2
- package/dist/components/Common/UI/DateRangePicker/DateRangePickerTypes.d.ts +3 -2
- package/dist/components/Common/UI/DescriptionList/DescriptionListTypes.d.ts +1 -1
- package/dist/components/Common/UI/DescriptionList/DescriptionListTypes.js.map +1 -1
- package/dist/components/Common/UI/Menu/MenuTypes.d.ts +3 -3
- package/dist/components/Common/UI/Menu/MenuTypes.js.map +1 -1
- package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBoxTypes.d.ts +2 -2
- package/dist/components/Common/UI/RadioGroup/RadioGroupTypes.d.ts +2 -2
- package/dist/components/Common/UI/RadioGroup/RadioGroupTypes.js.map +1 -1
- package/dist/components/Common/UI/Select/SelectTypes.d.ts +2 -2
- package/dist/components/Common/UI/Table/TableTypes.d.ts +4 -4
- package/dist/components/Common/UI/Table/TableTypes.js.map +1 -1
- package/dist/components/Common/UI/Tabs/TabsTypes.d.ts +2 -2
- package/dist/components/Company/DocumentSigner/shared/useSignCompanyForm/fields.js +4 -4
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js +5 -5
- package/dist/components/Company/StateTaxes/stateTaxesStateMachine.d.ts +0 -1
- package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js +12 -14
- package/dist/components/Company/StateTaxes/stateTaxesStateMachine.js.map +1 -1
- package/dist/components/Contractor/Address/Address.js +83 -75
- package/dist/components/Contractor/Address/Address.js.map +1 -1
- package/dist/components/Contractor/ContractorList/index.d.ts +2 -1
- package/dist/components/Contractor/ContractorList/index.js +112 -99
- package/dist/components/Contractor/ContractorList/index.js.map +1 -1
- package/dist/components/Contractor/Documents/SignatureForm/SignatureForm.js +170 -123
- package/dist/components/Contractor/Documents/SignatureForm/SignatureForm.js.map +1 -1
- package/dist/components/Contractor/Documents/SignatureForm/SignatureForm.module.scss.js +12 -0
- package/dist/components/Contractor/Documents/SignatureForm/SignatureForm.module.scss.js.map +1 -0
- package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/fields.js +44 -43
- package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/fields.js.map +1 -1
- package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/useContractorSignatureForm.js +91 -88
- package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/useContractorSignatureForm.js.map +1 -1
- package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/w9Fields.d.ts +0 -33
- package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/w9Fields.js +77 -86
- package/dist/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/w9Fields.js.map +1 -1
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlow.d.ts +1 -1
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlow.js.map +1 -1
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlowComponents.d.ts +2 -0
- package/dist/components/Contractor/OnboardingFlow/OnboardingFlowComponents.js.map +1 -1
- package/dist/components/Contractor/OnboardingFlow/onboardingStateMachine.js +150 -80
- package/dist/components/Contractor/OnboardingFlow/onboardingStateMachine.js.map +1 -1
- package/dist/components/Contractor/OnboardingFlow/onboardingStateMachine.test.d.ts +1 -0
- package/dist/components/Contractor/PaymentMethod/shared/useContractorBankAccountForm/fields.js +1 -1
- package/dist/components/Contractor/Profile/BusinessSelfOnboardingProfile.js +19 -18
- package/dist/components/Contractor/Profile/BusinessSelfOnboardingProfile.js.map +1 -1
- package/dist/components/Contractor/Profile/ContractorProfile.d.ts +1 -1
- package/dist/components/Contractor/Profile/ContractorProfile.js +121 -111
- package/dist/components/Contractor/Profile/ContractorProfile.js.map +1 -1
- package/dist/components/Contractor/Profile/IndividualSelfOnboardingProfile.js +27 -26
- package/dist/components/Contractor/Profile/IndividualSelfOnboardingProfile.js.map +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/fields.js +16 -16
- package/dist/components/Contractor/Submit/Submit.js +127 -67
- package/dist/components/Contractor/Submit/Submit.js.map +1 -1
- package/dist/components/Contractor/shared/useContractorHasSignedW9.d.ts +8 -0
- package/dist/components/Contractor/shared/useContractorHasSignedW9.js +10 -0
- package/dist/components/Contractor/shared/useContractorHasSignedW9.js.map +1 -0
- package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js +4 -4
- package/dist/components/Employee/Compensation/shared/useJobForm/fields.js +6 -6
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/fields.js +8 -8
- package/dist/components/Employee/Deductions/shared/useDeductionForm/fields.js +4 -4
- package/dist/components/Employee/Documents/shared/useSignEmployeeForm/fields.js +1 -1
- package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/fields.js +4 -4
- package/dist/components/Employee/PaymentMethod/shared/useBankForm/fields.js +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js +4 -4
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/fields.js +8 -8
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/fields.js +5 -5
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/useCurrentHomeAddressForm.d.ts +1 -0
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/useCurrentHomeAddressForm.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/fields.js +4 -4
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/useCurrentWorkAddressForm.d.ts +1 -0
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/useCurrentWorkAddressForm.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +8 -8
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fields.d.ts +2 -2
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fields.js.map +1 -1
- package/dist/components/index.d.ts +40 -0
- package/dist/contexts/ComponentAdapter/useComponentContext.d.ts +1 -1
- package/dist/contexts/ComponentAdapter/useComponentContext.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProvider.d.ts +1 -0
- package/dist/contexts/GustoProvider/GustoProvider.js.map +1 -1
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +1 -0
- package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
- package/dist/contexts/ThemeProvider/types.d.ts +2 -2
- package/dist/i18n/en/Contractor.Address.json.js +22 -20
- package/dist/i18n/en/Contractor.Address.json.js.map +1 -1
- package/dist/i18n/en/Contractor.ContractorList.json.js +22 -20
- package/dist/i18n/en/Contractor.ContractorList.json.js.map +1 -1
- package/dist/i18n/en/Contractor.Profile.json.js +13 -11
- package/dist/i18n/en/Contractor.Profile.json.js.map +1 -1
- package/dist/i18n/en/Contractor.SignatureForm.json.js +5 -5
- package/dist/i18n/en/Contractor.Submit.json.js +11 -11
- package/dist/i18n/types.d.ts +29 -9
- package/dist/index.d.ts +6 -3
- package/dist/models/WA_RISK_CODES.d.ts +1 -0
- package/dist/models/WA_RISK_CODES.js.map +1 -1
- package/dist/partner-hook-utils/composeErrorHandler.d.ts +4 -0
- package/dist/partner-hook-utils/composeErrorHandler.js.map +1 -1
- package/dist/partner-hook-utils/form/SDKFormProvider.d.ts +1 -0
- package/dist/partner-hook-utils/form/SDKFormProvider.js.map +1 -1
- package/dist/partner-hook-utils/form/composeSubmitHandler.d.ts +4 -0
- package/dist/partner-hook-utils/form/composeSubmitHandler.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/CheckboxHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/CheckboxHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/DatePickerHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/DatePickerHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/NumberInputHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/NumberInputHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/RadioGroupHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/RadioGroupHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/SelectHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/SelectHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/SwitchHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/SwitchHookField.js.map +1 -1
- package/dist/partner-hook-utils/form/fields/TextInputHookField.d.ts +1 -0
- package/dist/partner-hook-utils/form/fields/TextInputHookField.js.map +1 -1
- package/dist/partner-hook-utils/types.d.ts +9 -0
- package/dist/shared/constants.d.ts +10 -0
- package/dist/shared/constants.js +7 -6
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/Helpers.d.ts +2 -0
- package/dist/types/hooks.d.ts +1 -0
- package/dist/types/observability.d.ts +1 -0
- package/docs/guides/endpoint-inventory.json +17 -28
- package/package.json +16 -16
|
@@ -1,120 +1,130 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useMemo as
|
|
3
|
-
import { useTranslation as
|
|
4
|
-
import { useWatch as
|
|
5
|
-
import
|
|
6
|
-
import { useContractorDetailsForm as
|
|
7
|
-
import { ContractorType as
|
|
8
|
-
import { SelfOnboardingContractorProfile as
|
|
9
|
-
import
|
|
10
|
-
import { BaseBoundaries as
|
|
1
|
+
import { jsx as t, jsxs as d, Fragment as E } from "react/jsx-runtime";
|
|
2
|
+
import { useMemo as N, useState as v, useEffect as O } from "react";
|
|
3
|
+
import { useTranslation as I } from "react-i18next";
|
|
4
|
+
import { useWatch as S } from "react-hook-form";
|
|
5
|
+
import y from "classnames";
|
|
6
|
+
import { useContractorDetailsForm as A } from "./shared/useContractorDetailsForm/useContractorDetailsForm.js";
|
|
7
|
+
import { ContractorType as F } from "./shared/useContractorDetailsForm/contractorDetailsSchema.js";
|
|
8
|
+
import { SelfOnboardingContractorProfile as T } from "./SelfOnboardingContractorProfile.js";
|
|
9
|
+
import M from "./ContractorProfile.module.scss.js";
|
|
10
|
+
import { BaseBoundaries as P, BaseLayout as h } from "../../Base/Base.js";
|
|
11
11
|
import "../../Base/useBase.js";
|
|
12
|
-
import { SDKFormProvider as
|
|
13
|
-
import { Form as
|
|
14
|
-
import { Flex as
|
|
15
|
-
import { Grid as
|
|
16
|
-
import { useComponentContext as
|
|
17
|
-
import { useComponentDictionary as
|
|
18
|
-
import {
|
|
19
|
-
|
|
20
|
-
|
|
12
|
+
import { SDKFormProvider as L } from "../../../partner-hook-utils/form/SDKFormProvider.js";
|
|
13
|
+
import { Form as _ } from "../../Common/Form/Form.js";
|
|
14
|
+
import { Flex as c } from "../../Common/Flex/Flex.js";
|
|
15
|
+
import { Grid as R } from "../../Common/Grid/Grid.js";
|
|
16
|
+
import { useComponentContext as D } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
17
|
+
import { useComponentDictionary as x, useI18n as B } from "../../../i18n/I18n.js";
|
|
18
|
+
import { ContractorOnboardingStatus as b, componentEvents as g } from "../../../shared/constants.js";
|
|
19
|
+
import { useContractorHasSignedW9 as W } from "../shared/useContractorHasSignedW9.js";
|
|
20
|
+
function w(a) {
|
|
21
|
+
return a?.onboarded === !0 || a?.onboardingStatus === b.ONBOARDING_COMPLETED || a?.onboardingStatus === b.SELF_ONBOARDING_REVIEW || a?.onboardingStatus === b.ADMIN_ONBOARDING_REVIEW;
|
|
22
|
+
}
|
|
23
|
+
function U(a) {
|
|
24
|
+
const n = {
|
|
21
25
|
create: [],
|
|
22
26
|
update: ["firstName", "lastName", "businessName", "hourlyRate", "workState"]
|
|
23
27
|
};
|
|
24
|
-
return
|
|
25
|
-
create: [...
|
|
26
|
-
update: [...
|
|
28
|
+
return a ? n : {
|
|
29
|
+
create: [...n.create ?? [], "ssn", "ein"],
|
|
30
|
+
update: [...n.update ?? [], "ssn", "ein"]
|
|
27
31
|
};
|
|
28
32
|
}
|
|
29
|
-
function
|
|
30
|
-
return
|
|
31
|
-
|
|
33
|
+
function le(a) {
|
|
34
|
+
return x("Contractor.Profile", a.dictionary), /* @__PURE__ */ t(P, { componentName: "Contractor.Profile", FallbackComponent: a.FallbackComponent, children: a.isAdmin === !1 ? /* @__PURE__ */ t(
|
|
35
|
+
T,
|
|
32
36
|
{
|
|
33
|
-
contractorId:
|
|
34
|
-
onEvent:
|
|
35
|
-
className:
|
|
37
|
+
contractorId: a.contractorId,
|
|
38
|
+
onEvent: a.onEvent,
|
|
39
|
+
className: a.className
|
|
36
40
|
}
|
|
37
|
-
) : /* @__PURE__ */
|
|
41
|
+
) : /* @__PURE__ */ t(Q, { ...a }) });
|
|
42
|
+
}
|
|
43
|
+
function V({ contractorId: a }) {
|
|
44
|
+
const n = W(a), { t: r } = I("Contractor.Profile"), s = D();
|
|
45
|
+
return n ? /* @__PURE__ */ t(s.Alert, { status: "warning", disableScrollIntoView: !0, label: r("w9EditWarning.label"), children: /* @__PURE__ */ t(s.Text, { children: r("w9EditWarning.body") }) }) : null;
|
|
38
46
|
}
|
|
39
|
-
function
|
|
40
|
-
companyId:
|
|
41
|
-
contractorId:
|
|
42
|
-
defaultValues:
|
|
43
|
-
className:
|
|
47
|
+
function Q({
|
|
48
|
+
companyId: a,
|
|
49
|
+
contractorId: n,
|
|
50
|
+
defaultValues: r,
|
|
51
|
+
className: s,
|
|
44
52
|
onEvent: e
|
|
45
53
|
}) {
|
|
46
|
-
|
|
47
|
-
const
|
|
48
|
-
() => ({ type:
|
|
49
|
-
[
|
|
50
|
-
), [
|
|
51
|
-
!
|
|
52
|
-
),
|
|
53
|
-
() =>
|
|
54
|
-
[
|
|
55
|
-
),
|
|
56
|
-
|
|
57
|
-
companyId:
|
|
58
|
-
contractorId:
|
|
59
|
-
defaultValues:
|
|
60
|
-
optionalFieldsToRequire:
|
|
54
|
+
B("Contractor.Profile");
|
|
55
|
+
const o = N(
|
|
56
|
+
() => ({ type: F.Business, ...r }),
|
|
57
|
+
[r]
|
|
58
|
+
), [l, i] = v(
|
|
59
|
+
!n && (o.selfOnboarding ?? !1)
|
|
60
|
+
), m = N(
|
|
61
|
+
() => U(l),
|
|
62
|
+
[l]
|
|
63
|
+
), u = A(
|
|
64
|
+
n ? {
|
|
65
|
+
companyId: a,
|
|
66
|
+
contractorId: n,
|
|
67
|
+
defaultValues: o,
|
|
68
|
+
optionalFieldsToRequire: m
|
|
61
69
|
} : {
|
|
62
|
-
companyId:
|
|
63
|
-
defaultValues:
|
|
64
|
-
optionalFieldsToRequire:
|
|
70
|
+
companyId: a,
|
|
71
|
+
defaultValues: o,
|
|
72
|
+
optionalFieldsToRequire: m
|
|
65
73
|
}
|
|
66
74
|
);
|
|
67
|
-
return
|
|
68
|
-
|
|
75
|
+
return u.isLoading ? /* @__PURE__ */ t(h, { isLoading: !0, error: u.errorHandling.errors }) : /* @__PURE__ */ t(
|
|
76
|
+
H,
|
|
69
77
|
{
|
|
70
|
-
contractor:
|
|
78
|
+
contractor: u,
|
|
71
79
|
onEvent: e,
|
|
72
|
-
className:
|
|
73
|
-
setSelfOnboardingActive:
|
|
80
|
+
className: s,
|
|
81
|
+
setSelfOnboardingActive: i
|
|
74
82
|
}
|
|
75
83
|
);
|
|
76
84
|
}
|
|
77
|
-
function
|
|
78
|
-
contractor:
|
|
79
|
-
onEvent:
|
|
80
|
-
className:
|
|
81
|
-
setSelfOnboardingActive:
|
|
85
|
+
function H({
|
|
86
|
+
contractor: a,
|
|
87
|
+
onEvent: n,
|
|
88
|
+
className: r,
|
|
89
|
+
setSelfOnboardingActive: s
|
|
82
90
|
}) {
|
|
83
|
-
const { t: e } =
|
|
84
|
-
control:
|
|
91
|
+
const { t: e } = I("Contractor.Profile"), o = D(), l = S({
|
|
92
|
+
control: a.form.hookFormInternals.formMethods.control,
|
|
85
93
|
name: "selfOnboarding"
|
|
86
94
|
});
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}, [
|
|
90
|
-
const { Fields:
|
|
91
|
-
const
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
),
|
|
96
|
-
contractorId:
|
|
97
|
-
|
|
95
|
+
O(() => {
|
|
96
|
+
s(l);
|
|
97
|
+
}, [l, s]);
|
|
98
|
+
const { Fields: i } = a.form, m = a.status.mode, u = w(a.data.contractor), p = !l || u, C = async () => {
|
|
99
|
+
const f = await a.actions.onSubmit();
|
|
100
|
+
f && (n(
|
|
101
|
+
f.mode === "create" ? g.CONTRACTOR_CREATED : g.CONTRACTOR_UPDATED,
|
|
102
|
+
f.data
|
|
103
|
+
), n(g.CONTRACTOR_PROFILE_DONE, {
|
|
104
|
+
contractorId: f.data.uuid,
|
|
105
|
+
onboardingStatus: f.data.onboardingStatus,
|
|
106
|
+
selfOnboarding: l && !u
|
|
98
107
|
}));
|
|
99
108
|
};
|
|
100
|
-
return /* @__PURE__ */
|
|
101
|
-
|
|
109
|
+
return /* @__PURE__ */ t("section", { className: y(M.root, r), children: /* @__PURE__ */ t(h, { error: a.errorHandling.errors, children: /* @__PURE__ */ t(L, { formHookResult: a, children: /* @__PURE__ */ d(_, { onSubmit: () => {
|
|
110
|
+
C();
|
|
102
111
|
}, children: [
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/* @__PURE__ */
|
|
112
|
+
/* @__PURE__ */ d(c, { flexDirection: "column", gap: 20, alignItems: "stretch", children: [
|
|
113
|
+
m === "update" && a.data.contractor?.uuid && /* @__PURE__ */ t(V, { contractorId: a.data.contractor.uuid }),
|
|
114
|
+
/* @__PURE__ */ t("header", { children: /* @__PURE__ */ d(c, { flexDirection: "column", gap: 4, children: [
|
|
115
|
+
/* @__PURE__ */ t(o.Heading, { as: "h2", children: e("title") }),
|
|
116
|
+
/* @__PURE__ */ t(o.Text, { variant: "supporting", children: e("subtitle") })
|
|
107
117
|
] }) }),
|
|
108
|
-
(
|
|
109
|
-
|
|
110
|
-
|
|
118
|
+
(i.SelfOnboarding || i.Email) && /* @__PURE__ */ t(o.Box, { children: /* @__PURE__ */ d(R, { gap: 16, children: [
|
|
119
|
+
i.SelfOnboarding && /* @__PURE__ */ t(
|
|
120
|
+
i.SelfOnboarding,
|
|
111
121
|
{
|
|
112
122
|
label: e("fields.selfOnboarding.label"),
|
|
113
123
|
description: e("fields.selfOnboarding.description")
|
|
114
124
|
}
|
|
115
125
|
),
|
|
116
|
-
|
|
117
|
-
|
|
126
|
+
i.Email && /* @__PURE__ */ t(
|
|
127
|
+
i.Email,
|
|
118
128
|
{
|
|
119
129
|
label: e("fields.email.label"),
|
|
120
130
|
validationMessages: {
|
|
@@ -124,11 +134,11 @@ function Q({
|
|
|
124
134
|
}
|
|
125
135
|
)
|
|
126
136
|
] }) }),
|
|
127
|
-
/* @__PURE__ */
|
|
128
|
-
|
|
129
|
-
/* @__PURE__ */
|
|
130
|
-
/* @__PURE__ */
|
|
131
|
-
|
|
137
|
+
/* @__PURE__ */ t(i.Type, { label: e("fields.contractorType.label") }),
|
|
138
|
+
i.FirstName && i.LastName && /* @__PURE__ */ d(E, { children: [
|
|
139
|
+
/* @__PURE__ */ d(R, { gridTemplateColumns: { base: "1fr", medium: "1fr 1fr" }, gap: 16, children: [
|
|
140
|
+
/* @__PURE__ */ t(
|
|
141
|
+
i.FirstName,
|
|
132
142
|
{
|
|
133
143
|
label: e("fields.firstName.label"),
|
|
134
144
|
validationMessages: {
|
|
@@ -137,10 +147,10 @@ function Q({
|
|
|
137
147
|
}
|
|
138
148
|
}
|
|
139
149
|
),
|
|
140
|
-
|
|
150
|
+
i.MiddleInitial && /* @__PURE__ */ t(i.MiddleInitial, { label: e("fields.middleInitial.label") })
|
|
141
151
|
] }),
|
|
142
|
-
/* @__PURE__ */
|
|
143
|
-
|
|
152
|
+
/* @__PURE__ */ t(
|
|
153
|
+
i.LastName,
|
|
144
154
|
{
|
|
145
155
|
label: e("fields.lastName.label"),
|
|
146
156
|
validationMessages: {
|
|
@@ -149,8 +159,8 @@ function Q({
|
|
|
149
159
|
}
|
|
150
160
|
}
|
|
151
161
|
),
|
|
152
|
-
|
|
153
|
-
|
|
162
|
+
i.Ssn && p && /* @__PURE__ */ t(
|
|
163
|
+
i.Ssn,
|
|
154
164
|
{
|
|
155
165
|
label: e("fields.ssn.label"),
|
|
156
166
|
validationMessages: {
|
|
@@ -160,16 +170,16 @@ function Q({
|
|
|
160
170
|
}
|
|
161
171
|
)
|
|
162
172
|
] }),
|
|
163
|
-
|
|
164
|
-
/* @__PURE__ */
|
|
165
|
-
|
|
173
|
+
i.BusinessName && /* @__PURE__ */ d(E, { children: [
|
|
174
|
+
/* @__PURE__ */ t(
|
|
175
|
+
i.BusinessName,
|
|
166
176
|
{
|
|
167
177
|
label: e("fields.businessName.label"),
|
|
168
178
|
validationMessages: { REQUIRED: e("validations.businessName") }
|
|
169
179
|
}
|
|
170
180
|
),
|
|
171
|
-
|
|
172
|
-
|
|
181
|
+
i.Ein && p && /* @__PURE__ */ t(
|
|
182
|
+
i.Ein,
|
|
173
183
|
{
|
|
174
184
|
label: e("fields.ein.label"),
|
|
175
185
|
validationMessages: {
|
|
@@ -179,9 +189,9 @@ function Q({
|
|
|
179
189
|
}
|
|
180
190
|
)
|
|
181
191
|
] }),
|
|
182
|
-
/* @__PURE__ */
|
|
183
|
-
|
|
184
|
-
|
|
192
|
+
/* @__PURE__ */ t(i.WageType, { label: e("fields.wageType.label") }),
|
|
193
|
+
i.HourlyRate && /* @__PURE__ */ t(
|
|
194
|
+
i.HourlyRate,
|
|
185
195
|
{
|
|
186
196
|
label: e("fields.hourlyRate.label"),
|
|
187
197
|
min: 0,
|
|
@@ -189,8 +199,8 @@ function Q({
|
|
|
189
199
|
validationMessages: { REQUIRED: e("validations.hourlyRate") }
|
|
190
200
|
}
|
|
191
201
|
),
|
|
192
|
-
/* @__PURE__ */
|
|
193
|
-
|
|
202
|
+
/* @__PURE__ */ t(
|
|
203
|
+
i.StartDate,
|
|
194
204
|
{
|
|
195
205
|
label: e("fields.startDate.label"),
|
|
196
206
|
description: e("fields.startDate.description"),
|
|
@@ -198,18 +208,18 @@ function Q({
|
|
|
198
208
|
}
|
|
199
209
|
)
|
|
200
210
|
] }),
|
|
201
|
-
/* @__PURE__ */
|
|
202
|
-
|
|
211
|
+
/* @__PURE__ */ t(c, { gap: 12, justifyContent: "flex-end", children: /* @__PURE__ */ t(
|
|
212
|
+
o.Button,
|
|
203
213
|
{
|
|
204
214
|
type: "submit",
|
|
205
215
|
variant: "primary",
|
|
206
|
-
isDisabled:
|
|
207
|
-
children:
|
|
216
|
+
isDisabled: a.status.isPending,
|
|
217
|
+
children: a.status.isPending ? e(m === "create" ? "buttons.creating" : "buttons.updating") : e(m === "create" ? "buttons.create" : "buttons.update")
|
|
208
218
|
}
|
|
209
219
|
) })
|
|
210
220
|
] }) }) }) });
|
|
211
221
|
}
|
|
212
222
|
export {
|
|
213
|
-
|
|
223
|
+
le as ContractorProfile
|
|
214
224
|
};
|
|
215
225
|
//# sourceMappingURL=ContractorProfile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractorProfile.js","sources":["../../../../src/components/Contractor/Profile/ContractorProfile.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useWatch } from 'react-hook-form'\nimport classNames from 'classnames'\nimport {\n useContractorDetailsForm,\n ContractorType,\n type ContractorDetailsFormData,\n type ContractorDetailsOptionalFieldsToRequire,\n type UseContractorDetailsFormReady,\n} from './shared/useContractorDetailsForm'\nimport { SelfOnboardingContractorProfile } from './SelfOnboardingContractorProfile'\nimport styles from './ContractorProfile.module.scss'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseBoundaries, BaseLayout } from '@/components/Base'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport { Form } from '@/components/Common/Form'\nimport { Flex, Grid } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { componentEvents, ContractorOnboardingStatus } from '@/shared/constants'\n\n// The admin form restores the contractor profile's product requiredness on top\n// of the hook's API-aligned baseline (which leaves ssn/ein optional and\n// create-only fields optional on update). When the admin invites the contractor\n// to self-onboard, SSN/EIN are hidden and the contractor supplies them later, so\n// they are dropped from the required set. An SSN/EIN already on file is still\n// waived via redaction, so promoting them when not inviting is safe.\nfunction computeRequiredFields(\n selfOnboardingActive: boolean,\n): ContractorDetailsOptionalFieldsToRequire {\n const base: ContractorDetailsOptionalFieldsToRequire = {\n create: [],\n update: ['firstName', 'lastName', 'businessName', 'hourlyRate', 'workState'],\n }\n if (selfOnboardingActive) return base\n return {\n create: [...(base.create ?? []), 'ssn', 'ein'],\n update: [...(base.update ?? []), 'ssn', 'ein'],\n }\n}\n\n/**\n * Props for {@link ContractorProfile} in admin mode.\n *\n * @remarks\n * Renders the admin create/edit form. When `contractorId` is omitted, the form\n * creates a new contractor under `companyId`. When provided, it fetches and\n * updates the existing contractor.\n *\n * @public\n */\nexport interface ContractorProfileAdminProps extends BaseComponentInterface<'Contractor.Profile'> {\n /** UUID of the company the contractor belongs to. */\n companyId: string\n /** Initial values for the contractor profile form fields. */\n defaultValues?: Partial<ContractorDetailsFormData>\n /** When `true` (the default), renders the admin create/edit form. */\n isAdmin?: true\n /** UUID of an existing contractor to edit. When omitted, the form creates a new contractor. */\n contractorId?: string\n}\n\n/**\n * Props for {@link ContractorProfile} in self-onboarding mode.\n *\n * @remarks\n * Renders the contractor self-onboarding profile. The contractor must already\n * exist so its type (individual vs. business) can be resolved to determine\n * which fields to display.\n *\n * @public\n */\nexport interface ContractorProfileSelfOnboardingProps extends BaseComponentInterface<'Contractor.Profile'> {\n /** UUID of the company the contractor belongs to. */\n companyId: string\n /** Initial values for the contractor profile form fields. */\n defaultValues?: Partial<ContractorDetailsFormData>\n /** When `false`, renders the contractor self-onboarding profile. */\n isAdmin: false\n /** UUID of the existing contractor completing self-onboarding. Required in self-onboarding mode. */\n contractorId: string\n}\n\n/**\n * Props for {@link ContractorProfile}.\n *\n * @remarks\n * Discriminated by `isAdmin`. See {@link ContractorProfileAdminProps} and\n * {@link ContractorProfileSelfOnboardingProps} for the specific prop shapes.\n *\n * @public\n */\nexport type ContractorProfileProps =\n ContractorProfileAdminProps | ContractorProfileSelfOnboardingProps\n\n/**\n * Form for creating or editing a contractor profile, supporting both individual and business contractor types.\n *\n * @remarks\n * In admin mode (the default), renders different field sets depending on the contractor type (individual\n * vs. business) and wage type (hourly vs. fixed), and exposes a self-onboarding toggle that invites the\n * contractor to complete their own setup. When `contractorId` is provided, the form fetches the existing\n * contractor and updates it on submit; otherwise it creates a new contractor under `companyId`.\n *\n * When `isAdmin` is `false`, renders the contractor self-onboarding profile instead: it resolves the\n * existing contractor's type and presents the individual (name + SSN) or business (business name + EIN)\n * fields for the contractor to complete.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/created` | A new contractor was created successfully. | The created contractor entity |\n * | `contractor/updated` | An existing contractor was updated successfully. | The updated contractor entity |\n * | `contractor/profile/done` | The contractor profile step finished. | `{ contractorId: string, selfOnboarding: boolean }` |\n *\n * @param props - See {@link ContractorProfileProps}.\n * @returns The rendered contractor profile form.\n * @public\n */\nexport function ContractorProfile(props: ContractorProfileProps) {\n useComponentDictionary('Contractor.Profile', props.dictionary)\n return (\n <BaseBoundaries componentName=\"Contractor.Profile\" FallbackComponent={props.FallbackComponent}>\n {props.isAdmin === false ? (\n <SelfOnboardingContractorProfile\n contractorId={props.contractorId}\n onEvent={props.onEvent}\n className={props.className}\n />\n ) : (\n <ContractorProfileRoot {...props} />\n )}\n </BaseBoundaries>\n )\n}\n\nfunction ContractorProfileRoot({\n companyId,\n contractorId,\n defaultValues,\n className,\n onEvent,\n}: ContractorProfileProps) {\n useI18n('Contractor.Profile')\n\n const resolvedDefaults = useMemo<Partial<ContractorDetailsFormData>>(\n () => ({ type: ContractorType.Business, ...defaultValues }),\n [defaultValues],\n )\n\n // Mirrors the Employee AdminProfile loop: SSN/EIN requiredness depends on the\n // self-onboarding toggle, which lives in the form the hook creates. Seed from\n // the create-mode default, then sync from the watched value (see the ready child).\n const [selfOnboardingActive, setSelfOnboardingActive] = useState(\n !contractorId && (resolvedDefaults.selfOnboarding ?? false),\n )\n\n const optionalFieldsToRequire = useMemo(\n () => computeRequiredFields(selfOnboardingActive),\n [selfOnboardingActive],\n )\n\n const contractor = useContractorDetailsForm(\n contractorId\n ? {\n companyId,\n contractorId,\n defaultValues: resolvedDefaults,\n optionalFieldsToRequire,\n }\n : {\n companyId,\n defaultValues: resolvedDefaults,\n optionalFieldsToRequire,\n },\n )\n\n if (contractor.isLoading) {\n return <BaseLayout isLoading error={contractor.errorHandling.errors} />\n }\n\n return (\n <ContractorProfileReady\n contractor={contractor}\n onEvent={onEvent}\n className={className}\n setSelfOnboardingActive={setSelfOnboardingActive}\n />\n )\n}\n\ninterface ContractorProfileReadyProps {\n contractor: UseContractorDetailsFormReady\n onEvent: ContractorProfileProps['onEvent']\n className?: string\n setSelfOnboardingActive: (value: boolean) => void\n}\n\nfunction ContractorProfileReady({\n contractor,\n onEvent,\n className,\n setSelfOnboardingActive,\n}: ContractorProfileReadyProps) {\n const { t } = useTranslation('Contractor.Profile')\n const Components = useComponentContext()\n\n const watchedSelfOnboarding = useWatch({\n control: contractor.form.hookFormInternals.formMethods.control,\n name: 'selfOnboarding',\n })\n\n useEffect(() => {\n setSelfOnboardingActive(watchedSelfOnboarding)\n }, [watchedSelfOnboarding, setSelfOnboardingActive])\n\n const { Fields } = contractor.form\n const mode = contractor.status.mode\n\n const handleSubmit = async () => {\n const onboardingStatus = contractor.data.contractor?.onboardingStatus\n const result = await contractor.actions.onSubmit()\n if (!result) return\n\n onEvent(\n result.mode === 'create'\n ? componentEvents.CONTRACTOR_CREATED\n : componentEvents.CONTRACTOR_UPDATED,\n result.data,\n )\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n contractorId: result.data.uuid,\n selfOnboarding:\n watchedSelfOnboarding &&\n onboardingStatus !== ContractorOnboardingStatus.ADMIN_ONBOARDING_REVIEW,\n })\n }\n\n return (\n <section className={classNames(styles.root, className)}>\n <BaseLayout error={contractor.errorHandling.errors}>\n <SDKFormProvider formHookResult={contractor}>\n <Form onSubmit={() => void handleSubmit()}>\n <Flex flexDirection=\"column\" gap={20} alignItems=\"stretch\">\n <header>\n <Flex flexDirection=\"column\" gap={4}>\n <Components.Heading as=\"h2\">{t('title')}</Components.Heading>\n <Components.Text variant=\"supporting\">{t('subtitle')}</Components.Text>\n </Flex>\n </header>\n\n {(Fields.SelfOnboarding || Fields.Email) && (\n <Components.Box>\n <Grid gap={16}>\n {Fields.SelfOnboarding && (\n <Fields.SelfOnboarding\n label={t('fields.selfOnboarding.label')}\n description={t('fields.selfOnboarding.description')}\n />\n )}\n\n {Fields.Email && (\n <Fields.Email\n label={t('fields.email.label')}\n validationMessages={{\n REQUIRED: t('validations.email'),\n INVALID_EMAIL: t('validations.emailFormat'),\n }}\n />\n )}\n </Grid>\n </Components.Box>\n )}\n\n <Fields.Type label={t('fields.contractorType.label')} />\n\n {Fields.FirstName && Fields.LastName && (\n <>\n <Grid gridTemplateColumns={{ base: '1fr', medium: '1fr 1fr' }} gap={16}>\n <Fields.FirstName\n label={t('fields.firstName.label')}\n validationMessages={{\n REQUIRED: t('validations.firstName'),\n INVALID_NAME: t('validations.firstNameFormat'),\n }}\n />\n {Fields.MiddleInitial && (\n <Fields.MiddleInitial label={t('fields.middleInitial.label')} />\n )}\n </Grid>\n <Fields.LastName\n label={t('fields.lastName.label')}\n validationMessages={{\n REQUIRED: t('validations.lastName'),\n INVALID_NAME: t('validations.lastNameFormat'),\n }}\n />\n {Fields.Ssn && !watchedSelfOnboarding && (\n <Fields.Ssn\n label={t('fields.ssn.label')}\n validationMessages={{\n INVALID_SSN: t('validations.ssnFormat'),\n REQUIRED: t('validations.ssn'),\n }}\n />\n )}\n </>\n )}\n\n {Fields.BusinessName && (\n <>\n <Fields.BusinessName\n label={t('fields.businessName.label')}\n validationMessages={{ REQUIRED: t('validations.businessName') }}\n />\n {Fields.Ein && !watchedSelfOnboarding && (\n <Fields.Ein\n label={t('fields.ein.label')}\n validationMessages={{\n INVALID_EIN: t('validations.einFormat'),\n REQUIRED: t('validations.ein'),\n }}\n />\n )}\n </>\n )}\n\n <Fields.WageType label={t('fields.wageType.label')} />\n\n {Fields.HourlyRate && (\n <Fields.HourlyRate\n label={t('fields.hourlyRate.label')}\n min={0}\n format=\"currency\"\n validationMessages={{ REQUIRED: t('validations.hourlyRate') }}\n />\n )}\n\n <Fields.StartDate\n label={t('fields.startDate.label')}\n description={t('fields.startDate.description')}\n validationMessages={{ REQUIRED: t('validations.startDate') }}\n />\n </Flex>\n\n <Flex gap={12} justifyContent=\"flex-end\">\n <Components.Button\n type=\"submit\"\n variant=\"primary\"\n isDisabled={contractor.status.isPending}\n >\n {contractor.status.isPending\n ? mode === 'create'\n ? t('buttons.creating')\n : t('buttons.updating')\n : mode === 'create'\n ? t('buttons.create')\n : t('buttons.update')}\n </Components.Button>\n </Flex>\n </Form>\n </SDKFormProvider>\n </BaseLayout>\n </section>\n )\n}\n"],"names":["computeRequiredFields","selfOnboardingActive","base","ContractorProfile","props","useComponentDictionary","jsx","BaseBoundaries","SelfOnboardingContractorProfile","ContractorProfileRoot","companyId","contractorId","defaultValues","className","onEvent","useI18n","resolvedDefaults","useMemo","ContractorType","setSelfOnboardingActive","useState","optionalFieldsToRequire","contractor","useContractorDetailsForm","BaseLayout","ContractorProfileReady","t","useTranslation","Components","useComponentContext","watchedSelfOnboarding","useWatch","useEffect","Fields","mode","handleSubmit","onboardingStatus","result","componentEvents","ContractorOnboardingStatus","classNames","styles","SDKFormProvider","jsxs","Form","Flex","Grid","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;AA6BA,SAASA,EACPC,GAC0C;AAC1C,QAAMC,IAAiD;AAAA,IACrD,QAAQ,CAAA;AAAA,IACR,QAAQ,CAAC,aAAa,YAAY,gBAAgB,cAAc,WAAW;AAAA,EAAA;AAE7E,SAAID,IAA6BC,IAC1B;AAAA,IACL,QAAQ,CAAC,GAAIA,EAAK,UAAU,CAAA,GAAK,OAAO,KAAK;AAAA,IAC7C,QAAQ,CAAC,GAAIA,EAAK,UAAU,CAAA,GAAK,OAAO,KAAK;AAAA,EAAA;AAEjD;AAgFO,SAASC,GAAkBC,GAA+B;AAC/D,SAAAC,EAAuB,sBAAsBD,EAAM,UAAU,GAE3D,gBAAAE,EAACC,KAAe,eAAc,sBAAqB,mBAAmBH,EAAM,mBACzE,UAAAA,EAAM,YAAY,KACjB,gBAAAE;AAAA,IAACE;AAAA,IAAA;AAAA,MACC,cAAcJ,EAAM;AAAA,MACpB,SAASA,EAAM;AAAA,MACf,WAAWA,EAAM;AAAA,IAAA;AAAA,EAAA,IAGnB,gBAAAE,EAACG,GAAA,EAAuB,GAAGL,GAAO,EAAA,CAEtC;AAEJ;AAEA,SAASK,EAAsB;AAAA,EAC7B,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,eAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AACF,GAA2B;AACzB,EAAAC,EAAQ,oBAAoB;AAE5B,QAAMC,IAAmBC;AAAA,IACvB,OAAO,EAAE,MAAMC,EAAe,UAAU,GAAGN,EAAA;AAAA,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A;AAAA,IAAA,EAC1B,CACF;AAAA,EAAA,GACF,EAAA,CACF,GACF,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"ContractorProfile.js","sources":["../../../../src/components/Contractor/Profile/ContractorProfile.tsx"],"sourcesContent":["import { useEffect, useMemo, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useWatch } from 'react-hook-form'\nimport { type Contractor } from '@gusto/embedded-api/models/components/contractor'\nimport classNames from 'classnames'\nimport {\n useContractorDetailsForm,\n ContractorType,\n type ContractorDetailsFormData,\n type ContractorDetailsOptionalFieldsToRequire,\n type UseContractorDetailsFormReady,\n} from './shared/useContractorDetailsForm'\nimport { SelfOnboardingContractorProfile } from './SelfOnboardingContractorProfile'\nimport styles from './ContractorProfile.module.scss'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseBoundaries, BaseLayout } from '@/components/Base'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport { Form } from '@/components/Common/Form'\nimport { Flex, Grid } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { componentEvents, ContractorOnboardingStatus } from '@/shared/constants'\nimport { useContractorHasSignedW9 } from '@/components/Contractor/shared/useContractorHasSignedW9'\n\n// Once the contractor has finished self-onboarding (or the record is otherwise\n// under admin review / completed), the admin needs to view and edit SSN/EIN even\n// though the self-onboarding toggle stays on. Mirrors the Employee AdminProfile\n// `checkHasCompletedSelfOnboarding` override.\nfunction hasCompletedSelfOnboarding(contractor?: Contractor | null): boolean {\n return (\n contractor?.onboarded === true ||\n contractor?.onboardingStatus === ContractorOnboardingStatus.ONBOARDING_COMPLETED ||\n contractor?.onboardingStatus === ContractorOnboardingStatus.SELF_ONBOARDING_REVIEW ||\n contractor?.onboardingStatus === ContractorOnboardingStatus.ADMIN_ONBOARDING_REVIEW\n )\n}\n\n// The admin form restores the contractor profile's product requiredness on top\n// of the hook's API-aligned baseline (which leaves ssn/ein optional and\n// create-only fields optional on update). When the admin invites the contractor\n// to self-onboard, SSN/EIN are hidden and the contractor supplies them later, so\n// they are dropped from the required set. An SSN/EIN already on file is still\n// waived via redaction, so promoting them when not inviting is safe.\nfunction computeRequiredFields(\n selfOnboardingActive: boolean,\n): ContractorDetailsOptionalFieldsToRequire {\n const base: ContractorDetailsOptionalFieldsToRequire = {\n create: [],\n update: ['firstName', 'lastName', 'businessName', 'hourlyRate', 'workState'],\n }\n if (selfOnboardingActive) return base\n return {\n create: [...(base.create ?? []), 'ssn', 'ein'],\n update: [...(base.update ?? []), 'ssn', 'ein'],\n }\n}\n\n/**\n * Props for {@link ContractorProfile} in admin mode.\n *\n * @remarks\n * Renders the admin create/edit form. When `contractorId` is omitted, the form\n * creates a new contractor under `companyId`. When provided, it fetches and\n * updates the existing contractor.\n *\n * @public\n */\nexport interface ContractorProfileAdminProps extends BaseComponentInterface<'Contractor.Profile'> {\n /** UUID of the company the contractor belongs to. */\n companyId: string\n /** Initial values for the contractor profile form fields. */\n defaultValues?: Partial<ContractorDetailsFormData>\n /** When `true` (the default), renders the admin create/edit form. */\n isAdmin?: true\n /** UUID of an existing contractor to edit. When omitted, the form creates a new contractor. */\n contractorId?: string\n}\n\n/**\n * Props for {@link ContractorProfile} in self-onboarding mode.\n *\n * @remarks\n * Renders the contractor self-onboarding profile. The contractor must already\n * exist so its type (individual vs. business) can be resolved to determine\n * which fields to display.\n *\n * @public\n */\nexport interface ContractorProfileSelfOnboardingProps extends BaseComponentInterface<'Contractor.Profile'> {\n /** UUID of the company the contractor belongs to. */\n companyId: string\n /** Initial values for the contractor profile form fields. */\n defaultValues?: Partial<ContractorDetailsFormData>\n /** When `false`, renders the contractor self-onboarding profile. */\n isAdmin: false\n /** UUID of the existing contractor completing self-onboarding. Required in self-onboarding mode. */\n contractorId: string\n}\n\n/**\n * Props for {@link ContractorProfile}.\n *\n * @remarks\n * Discriminated by `isAdmin`. See {@link ContractorProfileAdminProps} and\n * {@link ContractorProfileSelfOnboardingProps} for the specific prop shapes.\n *\n * @public\n */\nexport type ContractorProfileProps =\n ContractorProfileAdminProps | ContractorProfileSelfOnboardingProps\n\n/**\n * Form for creating or editing a contractor profile, supporting both individual and business contractor types.\n *\n * @remarks\n * In admin mode (the default), renders different field sets depending on the contractor type (individual\n * vs. business) and wage type (hourly vs. fixed), and exposes a self-onboarding toggle that invites the\n * contractor to complete their own setup. When `contractorId` is provided, the form fetches the existing\n * contractor and updates it on submit; otherwise it creates a new contractor under `companyId`.\n *\n * When `isAdmin` is `false`, renders the contractor self-onboarding profile instead: it resolves the\n * existing contractor's type and presents the individual (name + SSN) or business (business name + EIN)\n * fields for the contractor to complete.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/created` | A new contractor was created successfully. | The created contractor entity |\n * | `contractor/updated` | An existing contractor was updated successfully. | The updated contractor entity |\n * | `contractor/profile/done` | The contractor profile step finished. | `{ contractorId: string, onboardingStatus?: string, selfOnboarding: boolean }` |\n *\n * @param props - See {@link ContractorProfileProps}.\n * @returns The rendered contractor profile form.\n * @public\n */\nexport function ContractorProfile(props: ContractorProfileProps) {\n useComponentDictionary('Contractor.Profile', props.dictionary)\n return (\n <BaseBoundaries componentName=\"Contractor.Profile\" FallbackComponent={props.FallbackComponent}>\n {props.isAdmin === false ? (\n <SelfOnboardingContractorProfile\n contractorId={props.contractorId}\n onEvent={props.onEvent}\n className={props.className}\n />\n ) : (\n <ContractorProfileRoot {...props} />\n )}\n </BaseBoundaries>\n )\n}\n\nfunction ContractorProfileW9Warning({ contractorId }: { contractorId: string }) {\n const hasSignedW9 = useContractorHasSignedW9(contractorId)\n const { t } = useTranslation('Contractor.Profile')\n const Components = useComponentContext()\n if (!hasSignedW9) return null\n return (\n <Components.Alert status=\"warning\" disableScrollIntoView label={t('w9EditWarning.label')}>\n <Components.Text>{t('w9EditWarning.body')}</Components.Text>\n </Components.Alert>\n )\n}\n\nfunction ContractorProfileRoot({\n companyId,\n contractorId,\n defaultValues,\n className,\n onEvent,\n}: ContractorProfileProps) {\n useI18n('Contractor.Profile')\n\n const resolvedDefaults = useMemo<Partial<ContractorDetailsFormData>>(\n () => ({ type: ContractorType.Business, ...defaultValues }),\n [defaultValues],\n )\n\n // Mirrors the Employee AdminProfile loop: SSN/EIN requiredness depends on the\n // self-onboarding toggle, which lives in the form the hook creates. Seed from\n // the create-mode default, then sync from the watched value (see the ready child).\n const [selfOnboardingActive, setSelfOnboardingActive] = useState(\n !contractorId && (resolvedDefaults.selfOnboarding ?? false),\n )\n\n const optionalFieldsToRequire = useMemo(\n () => computeRequiredFields(selfOnboardingActive),\n [selfOnboardingActive],\n )\n\n const contractor = useContractorDetailsForm(\n contractorId\n ? {\n companyId,\n contractorId,\n defaultValues: resolvedDefaults,\n optionalFieldsToRequire,\n }\n : {\n companyId,\n defaultValues: resolvedDefaults,\n optionalFieldsToRequire,\n },\n )\n\n if (contractor.isLoading) {\n return <BaseLayout isLoading error={contractor.errorHandling.errors} />\n }\n\n return (\n <ContractorProfileReady\n contractor={contractor}\n onEvent={onEvent}\n className={className}\n setSelfOnboardingActive={setSelfOnboardingActive}\n />\n )\n}\n\ninterface ContractorProfileReadyProps {\n contractor: UseContractorDetailsFormReady\n onEvent: ContractorProfileProps['onEvent']\n className?: string\n setSelfOnboardingActive: (value: boolean) => void\n}\n\nfunction ContractorProfileReady({\n contractor,\n onEvent,\n className,\n setSelfOnboardingActive,\n}: ContractorProfileReadyProps) {\n const { t } = useTranslation('Contractor.Profile')\n const Components = useComponentContext()\n\n const watchedSelfOnboarding = useWatch({\n control: contractor.form.hookFormInternals.formMethods.control,\n name: 'selfOnboarding',\n })\n\n useEffect(() => {\n setSelfOnboardingActive(watchedSelfOnboarding)\n }, [watchedSelfOnboarding, setSelfOnboardingActive])\n\n const { Fields } = contractor.form\n const mode = contractor.status.mode\n\n // SSN/EIN are hidden while collection is delegated to the contractor, but must\n // reappear once they've finished so the admin can review/edit them.\n const completedSelfOnboarding = hasCompletedSelfOnboarding(contractor.data.contractor)\n const showTaxId = !watchedSelfOnboarding || completedSelfOnboarding\n\n const handleSubmit = async () => {\n const result = await contractor.actions.onSubmit()\n if (!result) return\n\n onEvent(\n result.mode === 'create'\n ? componentEvents.CONTRACTOR_CREATED\n : componentEvents.CONTRACTOR_UPDATED,\n result.data,\n )\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n contractorId: result.data.uuid,\n onboardingStatus: result.data.onboardingStatus,\n selfOnboarding: watchedSelfOnboarding && !completedSelfOnboarding,\n })\n }\n\n return (\n <section className={classNames(styles.root, className)}>\n <BaseLayout error={contractor.errorHandling.errors}>\n <SDKFormProvider formHookResult={contractor}>\n <Form onSubmit={() => void handleSubmit()}>\n <Flex flexDirection=\"column\" gap={20} alignItems=\"stretch\">\n {mode === 'update' && contractor.data.contractor?.uuid && (\n <ContractorProfileW9Warning contractorId={contractor.data.contractor.uuid} />\n )}\n <header>\n <Flex flexDirection=\"column\" gap={4}>\n <Components.Heading as=\"h2\">{t('title')}</Components.Heading>\n <Components.Text variant=\"supporting\">{t('subtitle')}</Components.Text>\n </Flex>\n </header>\n\n {(Fields.SelfOnboarding || Fields.Email) && (\n <Components.Box>\n <Grid gap={16}>\n {Fields.SelfOnboarding && (\n <Fields.SelfOnboarding\n label={t('fields.selfOnboarding.label')}\n description={t('fields.selfOnboarding.description')}\n />\n )}\n\n {Fields.Email && (\n <Fields.Email\n label={t('fields.email.label')}\n validationMessages={{\n REQUIRED: t('validations.email'),\n INVALID_EMAIL: t('validations.emailFormat'),\n }}\n />\n )}\n </Grid>\n </Components.Box>\n )}\n\n <Fields.Type label={t('fields.contractorType.label')} />\n\n {Fields.FirstName && Fields.LastName && (\n <>\n <Grid gridTemplateColumns={{ base: '1fr', medium: '1fr 1fr' }} gap={16}>\n <Fields.FirstName\n label={t('fields.firstName.label')}\n validationMessages={{\n REQUIRED: t('validations.firstName'),\n INVALID_NAME: t('validations.firstNameFormat'),\n }}\n />\n {Fields.MiddleInitial && (\n <Fields.MiddleInitial label={t('fields.middleInitial.label')} />\n )}\n </Grid>\n <Fields.LastName\n label={t('fields.lastName.label')}\n validationMessages={{\n REQUIRED: t('validations.lastName'),\n INVALID_NAME: t('validations.lastNameFormat'),\n }}\n />\n {Fields.Ssn && showTaxId && (\n <Fields.Ssn\n label={t('fields.ssn.label')}\n validationMessages={{\n INVALID_SSN: t('validations.ssnFormat'),\n REQUIRED: t('validations.ssn'),\n }}\n />\n )}\n </>\n )}\n\n {Fields.BusinessName && (\n <>\n <Fields.BusinessName\n label={t('fields.businessName.label')}\n validationMessages={{ REQUIRED: t('validations.businessName') }}\n />\n {Fields.Ein && showTaxId && (\n <Fields.Ein\n label={t('fields.ein.label')}\n validationMessages={{\n INVALID_EIN: t('validations.einFormat'),\n REQUIRED: t('validations.ein'),\n }}\n />\n )}\n </>\n )}\n\n <Fields.WageType label={t('fields.wageType.label')} />\n\n {Fields.HourlyRate && (\n <Fields.HourlyRate\n label={t('fields.hourlyRate.label')}\n min={0}\n format=\"currency\"\n validationMessages={{ REQUIRED: t('validations.hourlyRate') }}\n />\n )}\n\n <Fields.StartDate\n label={t('fields.startDate.label')}\n description={t('fields.startDate.description')}\n validationMessages={{ REQUIRED: t('validations.startDate') }}\n />\n </Flex>\n\n <Flex gap={12} justifyContent=\"flex-end\">\n <Components.Button\n type=\"submit\"\n variant=\"primary\"\n isDisabled={contractor.status.isPending}\n >\n {contractor.status.isPending\n ? mode === 'create'\n ? t('buttons.creating')\n : t('buttons.updating')\n : mode === 'create'\n ? t('buttons.create')\n : t('buttons.update')}\n </Components.Button>\n </Flex>\n </Form>\n </SDKFormProvider>\n </BaseLayout>\n </section>\n )\n}\n"],"names":["hasCompletedSelfOnboarding","contractor","ContractorOnboardingStatus","computeRequiredFields","selfOnboardingActive","base","ContractorProfile","props","useComponentDictionary","jsx","BaseBoundaries","SelfOnboardingContractorProfile","ContractorProfileRoot","ContractorProfileW9Warning","contractorId","hasSignedW9","useContractorHasSignedW9","t","useTranslation","Components","useComponentContext","companyId","defaultValues","className","onEvent","useI18n","resolvedDefaults","useMemo","ContractorType","setSelfOnboardingActive","useState","optionalFieldsToRequire","useContractorDetailsForm","BaseLayout","ContractorProfileReady","watchedSelfOnboarding","useWatch","useEffect","Fields","mode","completedSelfOnboarding","showTaxId","handleSubmit","result","componentEvents","classNames","styles","SDKFormProvider","jsxs","Form","Flex","Grid","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;;AA6BA,SAASA,EAA2BC,GAAyC;AAC3E,SACEA,GAAY,cAAc,MAC1BA,GAAY,qBAAqBC,EAA2B,wBAC5DD,GAAY,qBAAqBC,EAA2B,0BAC5DD,GAAY,qBAAqBC,EAA2B;AAEhE;AAQA,SAASC,EACPC,GAC0C;AAC1C,QAAMC,IAAiD;AAAA,IACrD,QAAQ,CAAA;AAAA,IACR,QAAQ,CAAC,aAAa,YAAY,gBAAgB,cAAc,WAAW;AAAA,EAAA;AAE7E,SAAID,IAA6BC,IAC1B;AAAA,IACL,QAAQ,CAAC,GAAIA,EAAK,UAAU,CAAA,GAAK,OAAO,KAAK;AAAA,IAC7C,QAAQ,CAAC,GAAIA,EAAK,UAAU,CAAA,GAAK,OAAO,KAAK;AAAA,EAAA;AAEjD;AAgFO,SAASC,GAAkBC,GAA+B;AAC/D,SAAAC,EAAuB,sBAAsBD,EAAM,UAAU,GAE3D,gBAAAE,EAACC,KAAe,eAAc,sBAAqB,mBAAmBH,EAAM,mBACzE,UAAAA,EAAM,YAAY,KACjB,gBAAAE;AAAA,IAACE;AAAA,IAAA;AAAA,MACC,cAAcJ,EAAM;AAAA,MACpB,SAASA,EAAM;AAAA,MACf,WAAWA,EAAM;AAAA,IAAA;AAAA,EAAA,IAGnB,gBAAAE,EAACG,GAAA,EAAuB,GAAGL,GAAO,EAAA,CAEtC;AAEJ;AAEA,SAASM,EAA2B,EAAE,cAAAC,KAA0C;AAC9E,QAAMC,I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AAO,cACN,gBAAA7B;AAAA,QAAC6B,EAAO;AAAA,QAAP;AAAA,UACC,OAAOrB,EAAE,yBAAyB;AAAA,UAClC,KAAK;AAAA,UACL,QAAO;AAAA,UACP,oBAAoB,EAAE,UAAUA,EAAE,wBAAwB,EAAA;AAAA,QAAE;AAAA,MAAA;AAAA,MAIhE,gBAAAR;AAAA,QAAC6B,EAAO;AAAA,QAAP;AAAA,UACC,OAAOrB,EAAE,wBAAwB;AAAA,UACjC,aAAaA,EAAE,8BAA8B;AAAA,UAC7C,oBAAoB,EAAE,UAAUA,EAAE,uBAAuB,EAAA;AAAA,QAAE;AAAA,MAAA;AAAA,IAC7D,GACF;AAAA,IAEA,gBAAAR,EAACyC,GAAA,EAAK,KAAK,IAAI,gBAAe,YAC5B,UAAA,gBAAAzC;AAAA,MAACU,EAAW;AAAA,MAAX;AAAA,QACC,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,YAAYlB,EAAW,OAAO;AAAA,QAE7B,YAAW,OAAO,YAEbgB,EADFsB,MAAS,WACL,qBACA,kBADkB,IAGpBtB,EADFsB,MAAS,WACL,mBACA,gBADgB;AAAA,MACA;AAAA,IAAA,EAC1B,CACF;AAAA,EAAA,GACF,EAAA,CACF,GACF,GACF;AAEJ;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { jsx as
|
|
1
|
+
import { jsx as r, jsxs as a, Fragment as p } from "react/jsx-runtime";
|
|
2
2
|
import { useTranslation as g } from "react-i18next";
|
|
3
|
-
import
|
|
4
|
-
import { useContractorDetailsForm as
|
|
3
|
+
import b from "classnames";
|
|
4
|
+
import { useContractorDetailsForm as N } from "./shared/useContractorDetailsForm/useContractorDetailsForm.js";
|
|
5
5
|
import I from "./ContractorProfile.module.scss.js";
|
|
6
6
|
import { BaseLayout as d } from "../../Base/Base.js";
|
|
7
7
|
import "../../Base/useBase.js";
|
|
@@ -20,33 +20,34 @@ function H({
|
|
|
20
20
|
onEvent: l,
|
|
21
21
|
className: c
|
|
22
22
|
}) {
|
|
23
|
-
const { t: i } = g("Contractor.Profile"),
|
|
23
|
+
const { t: i } = g("Contractor.Profile"), o = F(), t = N({
|
|
24
24
|
contractorId: f,
|
|
25
25
|
withSelfOnboardingField: !1,
|
|
26
26
|
defaultValues: { selfOnboarding: !0 },
|
|
27
27
|
optionalFieldsToRequire: R
|
|
28
28
|
});
|
|
29
|
-
if (
|
|
30
|
-
return /* @__PURE__ */
|
|
31
|
-
const { Fields:
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
contractorId:
|
|
29
|
+
if (t.isLoading)
|
|
30
|
+
return /* @__PURE__ */ r(d, { isLoading: !0, error: t.errorHandling.errors });
|
|
31
|
+
const { Fields: e } = t.form, u = async () => {
|
|
32
|
+
const n = await t.actions.onSubmit();
|
|
33
|
+
n && (l(m.CONTRACTOR_UPDATED, n.data), l(m.CONTRACTOR_PROFILE_DONE, {
|
|
34
|
+
contractorId: n.data.uuid,
|
|
35
|
+
onboardingStatus: n.data.onboardingStatus,
|
|
35
36
|
selfOnboarding: !0
|
|
36
37
|
}));
|
|
37
38
|
};
|
|
38
|
-
return /* @__PURE__ */
|
|
39
|
+
return /* @__PURE__ */ r("section", { className: b(I.root, c), children: /* @__PURE__ */ r(d, { error: t.errorHandling.errors, children: /* @__PURE__ */ r(D, { formHookResult: t, children: /* @__PURE__ */ a(h, { onSubmit: () => {
|
|
39
40
|
u();
|
|
40
41
|
}, children: [
|
|
41
42
|
/* @__PURE__ */ a(s, { flexDirection: "column", gap: 20, alignItems: "stretch", children: [
|
|
42
|
-
/* @__PURE__ */
|
|
43
|
-
/* @__PURE__ */
|
|
44
|
-
/* @__PURE__ */
|
|
43
|
+
/* @__PURE__ */ r("header", { children: /* @__PURE__ */ a(s, { flexDirection: "column", gap: 4, children: [
|
|
44
|
+
/* @__PURE__ */ r(o.Heading, { as: "h2", children: i("selfOnboarding.title") }),
|
|
45
|
+
/* @__PURE__ */ r(o.Text, { variant: "supporting", children: i("selfOnboarding.individualDescription") })
|
|
45
46
|
] }) }),
|
|
46
|
-
|
|
47
|
+
e.FirstName && e.LastName && /* @__PURE__ */ a(p, { children: [
|
|
47
48
|
/* @__PURE__ */ a(v, { gridTemplateColumns: { base: "1fr", medium: "1fr 1fr" }, gap: 16, children: [
|
|
48
|
-
/* @__PURE__ */
|
|
49
|
-
|
|
49
|
+
/* @__PURE__ */ r(
|
|
50
|
+
e.FirstName,
|
|
50
51
|
{
|
|
51
52
|
label: i("fields.firstName.label"),
|
|
52
53
|
validationMessages: {
|
|
@@ -55,10 +56,10 @@ function H({
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
),
|
|
58
|
-
|
|
59
|
+
e.MiddleInitial && /* @__PURE__ */ r(e.MiddleInitial, { label: i("fields.middleInitial.label") })
|
|
59
60
|
] }),
|
|
60
|
-
/* @__PURE__ */
|
|
61
|
-
|
|
61
|
+
/* @__PURE__ */ r(
|
|
62
|
+
e.LastName,
|
|
62
63
|
{
|
|
63
64
|
label: i("fields.lastName.label"),
|
|
64
65
|
validationMessages: {
|
|
@@ -67,8 +68,8 @@ function H({
|
|
|
67
68
|
}
|
|
68
69
|
}
|
|
69
70
|
),
|
|
70
|
-
|
|
71
|
-
|
|
71
|
+
e.Ssn && /* @__PURE__ */ r(
|
|
72
|
+
e.Ssn,
|
|
72
73
|
{
|
|
73
74
|
label: i("fields.ssn.label"),
|
|
74
75
|
validationMessages: {
|
|
@@ -79,13 +80,13 @@ function H({
|
|
|
79
80
|
)
|
|
80
81
|
] })
|
|
81
82
|
] }),
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
-
|
|
83
|
+
/* @__PURE__ */ r(s, { gap: 12, justifyContent: "flex-end", children: /* @__PURE__ */ r(
|
|
84
|
+
o.Button,
|
|
84
85
|
{
|
|
85
86
|
type: "submit",
|
|
86
87
|
variant: "primary",
|
|
87
|
-
isDisabled:
|
|
88
|
-
children:
|
|
88
|
+
isDisabled: t.status.isPending,
|
|
89
|
+
children: t.status.isPending ? i("selfOnboarding.submitting") : i("selfOnboarding.continue")
|
|
89
90
|
}
|
|
90
91
|
) })
|
|
91
92
|
] }) }) }) });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IndividualSelfOnboardingProfile.js","sources":["../../../../src/components/Contractor/Profile/IndividualSelfOnboardingProfile.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport classNames from 'classnames'\nimport {\n useContractorDetailsForm,\n type ContractorDetailsOptionalFieldsToRequire,\n} from './shared/useContractorDetailsForm'\nimport type { ContractorSelfOnboardingProfileProps } from './SelfOnboardingContractorProfile'\nimport styles from './ContractorProfile.module.scss'\nimport { BaseLayout } from '@/components/Base'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport { Form } from '@/components/Common/Form'\nimport { Flex, Grid } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { componentEvents } from '@/shared/constants'\n\nconst INDIVIDUAL_REQUIRED_FIELDS: ContractorDetailsOptionalFieldsToRequire = {\n update: ['firstName', 'lastName', 'ssn'],\n}\n\n/**\n * Self-onboarding profile for an individual contractor — collects legal name\n * and SSN.\n *\n * @internal\n */\nexport function IndividualSelfOnboardingProfile({\n contractorId,\n onEvent,\n className,\n}: ContractorSelfOnboardingProfileProps) {\n const { t } = useTranslation('Contractor.Profile')\n const Components = useComponentContext()\n\n const contractor = useContractorDetailsForm({\n contractorId,\n withSelfOnboardingField: false,\n defaultValues: { selfOnboarding: true },\n optionalFieldsToRequire: INDIVIDUAL_REQUIRED_FIELDS,\n })\n\n if (contractor.isLoading) {\n return <BaseLayout isLoading error={contractor.errorHandling.errors} />\n }\n\n const { Fields } = contractor.form\n\n const handleSubmit = async () => {\n const result = await contractor.actions.onSubmit()\n if (!result) return\n\n onEvent(componentEvents.CONTRACTOR_UPDATED, result.data)\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n contractorId: result.data.uuid,\n selfOnboarding: true,\n })\n }\n\n return (\n <section className={classNames(styles.root, className)}>\n <BaseLayout error={contractor.errorHandling.errors}>\n <SDKFormProvider formHookResult={contractor}>\n <Form onSubmit={() => void handleSubmit()}>\n <Flex flexDirection=\"column\" gap={20} alignItems=\"stretch\">\n <header>\n <Flex flexDirection=\"column\" gap={4}>\n <Components.Heading as=\"h2\">{t('selfOnboarding.title')}</Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('selfOnboarding.individualDescription')}\n </Components.Text>\n </Flex>\n </header>\n\n {Fields.FirstName && Fields.LastName && (\n <>\n <Grid gridTemplateColumns={{ base: '1fr', medium: '1fr 1fr' }} gap={16}>\n <Fields.FirstName\n label={t('fields.firstName.label')}\n validationMessages={{\n REQUIRED: t('validations.firstName'),\n INVALID_NAME: t('validations.firstNameFormat'),\n }}\n />\n {Fields.MiddleInitial && (\n <Fields.MiddleInitial label={t('fields.middleInitial.label')} />\n )}\n </Grid>\n <Fields.LastName\n label={t('fields.lastName.label')}\n validationMessages={{\n REQUIRED: t('validations.lastName'),\n INVALID_NAME: t('validations.lastNameFormat'),\n }}\n />\n {Fields.Ssn && (\n <Fields.Ssn\n label={t('fields.ssn.label')}\n validationMessages={{\n INVALID_SSN: t('validations.ssnFormat'),\n REQUIRED: t('validations.ssn'),\n }}\n />\n )}\n </>\n )}\n </Flex>\n\n <Flex gap={12} justifyContent=\"flex-end\">\n <Components.Button\n type=\"submit\"\n variant=\"primary\"\n isDisabled={contractor.status.isPending}\n >\n {contractor.status.isPending\n ? t('selfOnboarding.submitting')\n : t('selfOnboarding.continue')}\n </Components.Button>\n </Flex>\n </Form>\n </SDKFormProvider>\n </BaseLayout>\n </section>\n )\n}\n"],"names":["INDIVIDUAL_REQUIRED_FIELDS","IndividualSelfOnboardingProfile","contractorId","onEvent","className","t","useTranslation","Components","useComponentContext","contractor","useContractorDetailsForm","BaseLayout","Fields","handleSubmit","result","componentEvents","jsx","classNames","styles","SDKFormProvider","jsxs","Form","Flex","Fragment","Grid"],"mappings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AAA,MAAX;AAAA,QACC,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,YAAYE,EAAW,OAAO;AAAA,QAE7B,YAAW,OAAO,YACfJ,EAAE,2BAA2B,IAC7BA,EAAE,yBAAyB;AAAA,MAAA;AAAA,IAAA,EACjC,CACF;AAAA,EAAA,GACF,EAAA,CACF,GACF,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"IndividualSelfOnboardingProfile.js","sources":["../../../../src/components/Contractor/Profile/IndividualSelfOnboardingProfile.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport classNames from 'classnames'\nimport {\n useContractorDetailsForm,\n type ContractorDetailsOptionalFieldsToRequire,\n} from './shared/useContractorDetailsForm'\nimport type { ContractorSelfOnboardingProfileProps } from './SelfOnboardingContractorProfile'\nimport styles from './ContractorProfile.module.scss'\nimport { BaseLayout } from '@/components/Base'\nimport { SDKFormProvider } from '@/partner-hook-utils/form/SDKFormProvider'\nimport { Form } from '@/components/Common/Form'\nimport { Flex, Grid } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { componentEvents } from '@/shared/constants'\n\nconst INDIVIDUAL_REQUIRED_FIELDS: ContractorDetailsOptionalFieldsToRequire = {\n update: ['firstName', 'lastName', 'ssn'],\n}\n\n/**\n * Self-onboarding profile for an individual contractor — collects legal name\n * and SSN.\n *\n * @internal\n */\nexport function IndividualSelfOnboardingProfile({\n contractorId,\n onEvent,\n className,\n}: ContractorSelfOnboardingProfileProps) {\n const { t } = useTranslation('Contractor.Profile')\n const Components = useComponentContext()\n\n const contractor = useContractorDetailsForm({\n contractorId,\n withSelfOnboardingField: false,\n defaultValues: { selfOnboarding: true },\n optionalFieldsToRequire: INDIVIDUAL_REQUIRED_FIELDS,\n })\n\n if (contractor.isLoading) {\n return <BaseLayout isLoading error={contractor.errorHandling.errors} />\n }\n\n const { Fields } = contractor.form\n\n const handleSubmit = async () => {\n const result = await contractor.actions.onSubmit()\n if (!result) return\n\n onEvent(componentEvents.CONTRACTOR_UPDATED, result.data)\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n contractorId: result.data.uuid,\n onboardingStatus: result.data.onboardingStatus,\n selfOnboarding: true,\n })\n }\n\n return (\n <section className={classNames(styles.root, className)}>\n <BaseLayout error={contractor.errorHandling.errors}>\n <SDKFormProvider formHookResult={contractor}>\n <Form onSubmit={() => void handleSubmit()}>\n <Flex flexDirection=\"column\" gap={20} alignItems=\"stretch\">\n <header>\n <Flex flexDirection=\"column\" gap={4}>\n <Components.Heading as=\"h2\">{t('selfOnboarding.title')}</Components.Heading>\n <Components.Text variant=\"supporting\">\n {t('selfOnboarding.individualDescription')}\n </Components.Text>\n </Flex>\n </header>\n\n {Fields.FirstName && Fields.LastName && (\n <>\n <Grid gridTemplateColumns={{ base: '1fr', medium: '1fr 1fr' }} gap={16}>\n <Fields.FirstName\n label={t('fields.firstName.label')}\n validationMessages={{\n REQUIRED: t('validations.firstName'),\n INVALID_NAME: t('validations.firstNameFormat'),\n }}\n />\n {Fields.MiddleInitial && (\n <Fields.MiddleInitial label={t('fields.middleInitial.label')} />\n )}\n </Grid>\n <Fields.LastName\n label={t('fields.lastName.label')}\n validationMessages={{\n REQUIRED: t('validations.lastName'),\n INVALID_NAME: t('validations.lastNameFormat'),\n }}\n />\n {Fields.Ssn && (\n <Fields.Ssn\n label={t('fields.ssn.label')}\n validationMessages={{\n INVALID_SSN: t('validations.ssnFormat'),\n REQUIRED: t('validations.ssn'),\n }}\n />\n )}\n </>\n )}\n </Flex>\n\n <Flex gap={12} justifyContent=\"flex-end\">\n <Components.Button\n type=\"submit\"\n variant=\"primary\"\n isDisabled={contractor.status.isPending}\n >\n {contractor.status.isPending\n ? t('selfOnboarding.submitting')\n : t('selfOnboarding.continue')}\n </Components.Button>\n </Flex>\n </Form>\n </SDKFormProvider>\n </BaseLayout>\n </section>\n )\n}\n"],"names":["INDIVIDUAL_REQUIRED_FIELDS","IndividualSelfOnboardingProfile","contractorId","onEvent","className","t","useTranslation","Components","useComponentContext","contractor","useContractorDetailsForm","BaseLayout","Fields","handleSubmit","result","componentEvents","jsx","classNames","styles","SDKFormProvider","jsxs","Form","Flex","Fragment","Grid"],"mappings":";;;;;;;;;;;;;;AAeA,MAAMA,IAAuE;AAAA,EAC3E,QAAQ,CAAC,aAAa,YAAY,KAAK;AACzC;AAQO,SAASC,EAAgC;AAAA,EAC9C,cAAAC;AAAA,EACA,SAAAC;AAAA,EACA,WAAAC;AACF,GAAyC;AACvC,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,oBAAoB,GAC3CC,IAAaC,EAAA,GAEbC,IAAaC,EAAyB;AAAA,IAC1C,cAAAR;AAAA,IACA,yBAAyB;AAAA,IACzB,eAAe,EAAE,gBAAgB,GAAA;AAAA,IACjC,yBAAyBF;AAAA,EAAA,CAC1B;AAED,MAAIS,EAAW;AACb,6BAAQE,GAAA,EAAW,WAAS,IAAC,OAAOF,EAAW,cAAc,QAAQ;AAGvE,QAAM,EAAE,QAAAG,MAAWH,EAAW,MAExBI,IAAe,YAAY;AAC/B,UAAMC,IAAS,MAAML,EAAW,QAAQ,SAAA;AACxC,IAAKK,MAELX,EAAQY,EAAgB,oBAAoBD,EAAO,IAAI,GACvDX,EAAQY,EAAgB,yBAAyB;AAAA,MAC/C,cAAcD,EAAO,KAAK;AAAA,MAC1B,kBAAkBA,EAAO,KAAK;AAAA,MAC9B,gBAAgB;AAAA,IAAA,CACjB;AAAA,EACH;AAEA,SACE,gBAAAE,EAAC,WAAA,EAAQ,WAAWC,EAAWC,EAAO,MAAMd,CAAS,GACnD,UAAA,gBAAAY,EAACL,GAAA,EAAW,OAAOF,EAAW,cAAc,QAC1C,UAAA,gBAAAO,EAACG,GAAA,EAAgB,gBAAgBV,GAC/B,UAAA,gBAAAW,EAACC,KAAK,UAAU,MAAA;AAAM,IAAKR,EAAA;AAAA,KACzB,UAAA;AAAA,IAAA,gBAAAO,EAACE,KAAK,eAAc,UAAS,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