@gusto/embedded-react-sdk 0.52.1 → 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 +16 -0
- package/dist/components/Base/Base.d.ts +2 -2
- package/dist/components/Base/Base.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -5
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -5
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -7
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -5
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -5
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/shared/useSignCompanyForm/fields.js +4 -4
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +8 -10
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +6 -8
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -5
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -5
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +3 -5
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js +5 -5
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -5
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -5
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- 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.js +52 -61
- 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/PaymentMethod/shared/useContractorBankAccountForm/fields.js +1 -1
- package/dist/components/Contractor/Profile/ContractorProfile.js +63 -57
- package/dist/components/Contractor/Profile/ContractorProfile.js.map +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/fields.js +16 -16
- package/dist/components/Contractor/Submit/Submit.js +118 -101
- 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/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -5
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- 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/Payroll/usePreparedPayrollData.js +8 -10
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/components/index.d.ts +40 -0
- 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.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/types.d.ts +22 -6
- package/dist/index.d.ts +6 -3
- package/dist/style.css +1 -1
- package/dist/types/Helpers.d.ts +1 -1
- package/docs/guides/endpoint-inventory.json +0 -27
- package/package.json +6 -6
|
@@ -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 { 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'\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 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 <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","companyId","contractorId","defaultValues","className","onEvent","useI18n","resolvedDefaults","useMemo","ContractorType","setSelfOnboardingActive","useState","optionalFieldsToRequire","useContractorDetailsForm","BaseLayout","ContractorProfileReady","t","useTranslation","Components","useComponentContext","watchedSelfOnboarding","useWatch","useEffect","Fields","mode","completedSelfOnboarding","showTaxId","handleSubmit","result","componentEvents","classNames","styles","SDKFormProvider","jsxs","Form","Flex","Grid","Fragment"],"mappings":";;;;;;;;;;;;;;;;;;AA4BA,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,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,MA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AO;AAAA,QAE7B,YAAW,OAAO,YAEb2B,EADFQ,MAAS,WACL,qBACA,kBADkB,IAGpBR,EADFQ,MAAS,WACL,mBACA,gBADgB;AAAA,MACA;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,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AC/B;AAAA,QAAA;AAAA,MACF,GAEJ;AAAA,wBAGDqB,EAAO,UAAP,EAAgB,OAAOrB,EAAE,uBAAuB,GAAG;AAAA,MAEnDqB,EAAO,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,24 +1,24 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { useFormFieldsMetadataContext as i } from "../../../../../partner-hook-utils/form/FormFieldsMetadataContext.js";
|
|
3
|
-
import { usePlaceholderSSN as d, normalizeSSN as u } from "../../../../../helpers/ssn.js";
|
|
4
|
-
import { usePlaceholderEin as f, normalizeEin as s } from "../../../../../helpers/federalEin.js";
|
|
5
|
-
import { SelectHookField as c } from "../../../../../partner-hook-utils/form/fields/SelectHookField.js";
|
|
6
2
|
import { TextInputHookField as n } from "../../../../../partner-hook-utils/form/fields/TextInputHookField.js";
|
|
3
|
+
import { SelectHookField as d } from "../../../../../partner-hook-utils/form/fields/SelectHookField.js";
|
|
4
|
+
import { NumberInputHookField as u } from "../../../../../partner-hook-utils/form/fields/NumberInputHookField.js";
|
|
5
|
+
import { DatePickerHookField as f } from "../../../../../partner-hook-utils/form/fields/DatePickerHookField.js";
|
|
6
|
+
import { RadioGroupHookField as i } from "../../../../../partner-hook-utils/form/fields/RadioGroupHookField.js";
|
|
7
7
|
import { SwitchHookField as m } from "../../../../../partner-hook-utils/form/fields/SwitchHookField.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
8
|
+
import { useFormFieldsMetadataContext as l } from "../../../../../partner-hook-utils/form/FormFieldsMetadataContext.js";
|
|
9
|
+
import { usePlaceholderSSN as s, normalizeSSN as c } from "../../../../../helpers/ssn.js";
|
|
10
|
+
import { usePlaceholderEin as F, normalizeEin as p } from "../../../../../helpers/federalEin.js";
|
|
11
11
|
function b(e) {
|
|
12
|
-
return /* @__PURE__ */ t(
|
|
12
|
+
return /* @__PURE__ */ t(i, { ...e, name: "type" });
|
|
13
13
|
}
|
|
14
14
|
function g(e) {
|
|
15
|
-
return /* @__PURE__ */ t(
|
|
15
|
+
return /* @__PURE__ */ t(i, { ...e, name: "wageType" });
|
|
16
16
|
}
|
|
17
17
|
function I(e) {
|
|
18
|
-
return /* @__PURE__ */ t(
|
|
18
|
+
return /* @__PURE__ */ t(f, { ...e, name: "startDate" });
|
|
19
19
|
}
|
|
20
20
|
function M(e) {
|
|
21
|
-
return /* @__PURE__ */ t(
|
|
21
|
+
return /* @__PURE__ */ t(u, { ...e, name: "hourlyRate" });
|
|
22
22
|
}
|
|
23
23
|
function T(e) {
|
|
24
24
|
return /* @__PURE__ */ t(m, { ...e, name: "selfOnboarding" });
|
|
@@ -42,31 +42,31 @@ function V(e) {
|
|
|
42
42
|
return /* @__PURE__ */ t(n, { ...e, name: "businessName" });
|
|
43
43
|
}
|
|
44
44
|
function W(e) {
|
|
45
|
-
const a =
|
|
45
|
+
const a = l(), o = e.formHookResult?.form.fieldsMetadata ?? a?.metadata ?? {}, r = s(o.ssn?.hasRedactedValue);
|
|
46
46
|
return /* @__PURE__ */ t(
|
|
47
47
|
n,
|
|
48
48
|
{
|
|
49
49
|
...e,
|
|
50
50
|
name: "ssn",
|
|
51
|
-
transform:
|
|
51
|
+
transform: c,
|
|
52
52
|
placeholder: r
|
|
53
53
|
}
|
|
54
54
|
);
|
|
55
55
|
}
|
|
56
56
|
function j(e) {
|
|
57
|
-
const a =
|
|
57
|
+
const a = l(), o = e.formHookResult?.form.fieldsMetadata ?? a?.metadata ?? {}, r = F(o.ein?.hasRedactedValue);
|
|
58
58
|
return /* @__PURE__ */ t(
|
|
59
59
|
n,
|
|
60
60
|
{
|
|
61
61
|
...e,
|
|
62
62
|
name: "ein",
|
|
63
|
-
transform:
|
|
63
|
+
transform: p,
|
|
64
64
|
placeholder: r
|
|
65
65
|
}
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
function B(e) {
|
|
69
|
-
return /* @__PURE__ */ t(
|
|
69
|
+
return /* @__PURE__ */ t(d, { ...e, name: "workState" });
|
|
70
70
|
}
|
|
71
71
|
export {
|
|
72
72
|
V as BusinessNameField,
|
|
@@ -1,144 +1,161 @@
|
|
|
1
1
|
import { jsx as t, jsxs as a } from "react/jsx-runtime";
|
|
2
|
-
import { useTranslation as
|
|
3
|
-
import { useContractorsUpdateOnboardingStatusMutation as
|
|
4
|
-
import { useContractorsGetOnboardingStatusSuspense as
|
|
5
|
-
import { useContractorsGetSuspense as
|
|
6
|
-
import { useContractorDocumentsGetAllSuspense as
|
|
7
|
-
import { useContractorDocumentsGetPdf as
|
|
8
|
-
import { SubmitDone as
|
|
9
|
-
import { Flex as
|
|
10
|
-
import { ActionsLayout as
|
|
11
|
-
import { useComponentContext as
|
|
2
|
+
import { useTranslation as S } from "react-i18next";
|
|
3
|
+
import { useContractorsUpdateOnboardingStatusMutation as L } from "@gusto/embedded-api/react-query/contractorsUpdateOnboardingStatus";
|
|
4
|
+
import { useContractorsGetOnboardingStatusSuspense as w } from "@gusto/embedded-api/react-query/contractorsGetOnboardingStatus";
|
|
5
|
+
import { useContractorsGetSuspense as N } from "@gusto/embedded-api/react-query/contractorsGet";
|
|
6
|
+
import { useContractorDocumentsGetAllSuspense as M } from "@gusto/embedded-api/react-query/contractorDocumentsGetAll";
|
|
7
|
+
import { useContractorDocumentsGetPdf as q } from "@gusto/embedded-api/react-query/contractorDocumentsGetPdf";
|
|
8
|
+
import { SubmitDone as G } from "./SubmitDone.js";
|
|
9
|
+
import { Flex as l, FlexItem as P } from "../../Common/Flex/Flex.js";
|
|
10
|
+
import { ActionsLayout as j } from "../../Common/ActionsLayout/ActionsLayout.js";
|
|
11
|
+
import { useComponentContext as h } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
12
12
|
import "react";
|
|
13
|
-
import { useI18n as
|
|
14
|
-
import { BaseComponent as
|
|
15
|
-
import { useBase as
|
|
16
|
-
import { ContractorOnboardingStatus as O, componentEvents as
|
|
17
|
-
import { firstLastName as
|
|
18
|
-
import { W9_DOCUMENT_NAME as
|
|
19
|
-
|
|
20
|
-
|
|
13
|
+
import { useI18n as k, useComponentDictionary as H } from "../../../i18n/I18n.js";
|
|
14
|
+
import { BaseComponent as W } from "../../Base/Base.js";
|
|
15
|
+
import { useBase as F } from "../../Base/useBase.js";
|
|
16
|
+
import { ContractorOnboardingStatus as O, componentEvents as C } from "../../../shared/constants.js";
|
|
17
|
+
import { firstLastName as V } from "../../../helpers/formattedStrings.js";
|
|
18
|
+
import { W9_DOCUMENT_NAME as T } from "../Documents/SignatureForm/useContractorSignatureForm/w9Fields.js";
|
|
19
|
+
import { useContractorHasSignedW9 as z } from "../shared/useContractorHasSignedW9.js";
|
|
20
|
+
function gt(n) {
|
|
21
|
+
return /* @__PURE__ */ t(W, { ...n, children: /* @__PURE__ */ t(J, { ...n, children: n.children }) });
|
|
21
22
|
}
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
const { Alert:
|
|
25
|
-
contractorUuid:
|
|
26
|
-
}),
|
|
27
|
-
contractorUuid:
|
|
28
|
-
}),
|
|
29
|
-
(
|
|
30
|
-
),
|
|
31
|
-
await
|
|
32
|
-
const
|
|
23
|
+
const J = ({ contractorId: n, selfOnboarding: c, dictionary: r }) => {
|
|
24
|
+
k("Contractor.Submit"), H("Contractor.Submit", r);
|
|
25
|
+
const { Alert: d, Button: u, Heading: i, UnorderedList: m } = h(), { t: e } = S("Contractor.Submit"), { onEvent: o, baseSubmitHandler: s } = F(), g = Object.values(e("warningItems", { returnObjects: !0 })), { data: b } = w({
|
|
26
|
+
contractorUuid: n
|
|
27
|
+
}), p = b.contractorOnboardingStatus?.onboardingStatus, { data: R } = N({ contractorUuid: n }), D = R.contractor, x = D?.type === "Individual" ? D.firstName : D?.businessName, { data: A } = M({
|
|
28
|
+
contractorUuid: n
|
|
29
|
+
}), _ = (A.documents ?? []).filter(
|
|
30
|
+
(f) => f.requiresSigning && !f.signedAt
|
|
31
|
+
), U = _.some((f) => f.name === T), { mutateAsync: B, isPending: E } = L(), v = async () => {
|
|
32
|
+
await s(null, async () => {
|
|
33
|
+
const f = await B({
|
|
33
34
|
request: {
|
|
34
|
-
contractorUuid:
|
|
35
|
+
contractorUuid: n,
|
|
35
36
|
contractorOnboardingStatusUpdateRequestBody: {
|
|
36
37
|
onboardingStatus: O.ONBOARDING_COMPLETED
|
|
37
38
|
}
|
|
38
39
|
}
|
|
39
40
|
});
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
),
|
|
41
|
+
o(
|
|
42
|
+
C.CONTRACTOR_ONBOARDING_STATUS_UPDATED,
|
|
43
|
+
f.contractorOnboardingStatus
|
|
44
|
+
), o(C.CONTRACTOR_SUBMIT_DONE, { message: e("submitDone.successMessage") });
|
|
44
45
|
});
|
|
45
|
-
},
|
|
46
|
-
|
|
47
|
-
message:
|
|
46
|
+
}, y = () => {
|
|
47
|
+
o(C.CONTRACTOR_INVITE_CONTRACTOR, { contractorId: n }), o(C.CONTRACTOR_SUBMIT_DONE, {
|
|
48
|
+
message: e("inviteContractor.successMessage")
|
|
48
49
|
});
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
onboardingStatus:
|
|
52
|
-
message:
|
|
50
|
+
}, I = () => {
|
|
51
|
+
o(C.CONTRACTOR_SUBMIT_DONE, {
|
|
52
|
+
onboardingStatus: p,
|
|
53
|
+
message: e("submitDone.successMessage")
|
|
53
54
|
});
|
|
54
55
|
};
|
|
55
|
-
return
|
|
56
|
-
/* @__PURE__ */ t(
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
return p === O.ONBOARDING_COMPLETED ? /* @__PURE__ */ t(G, { onDone: I }) : p === O.SELF_ONBOARDING_NOT_INVITED && c ? /* @__PURE__ */ t(X, { onSubmit: y, contractorId: n }) : /* @__PURE__ */ a(l, { flexDirection: "column", gap: 24, children: [
|
|
57
|
+
/* @__PURE__ */ t(P, { children: /* @__PURE__ */ t(i, { as: "h2", children: e("heading") }) }),
|
|
58
|
+
/* @__PURE__ */ t(
|
|
59
|
+
K,
|
|
59
60
|
{
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
description: n("documentRequirements.description", { contractorName: B })
|
|
65
|
-
}
|
|
66
|
-
),
|
|
67
|
-
children: /* @__PURE__ */ a(c, { flexDirection: "column", gap: 16, children: [
|
|
68
|
-
b.map((o) => {
|
|
69
|
-
const S = o.name === _, q = S ? n("documentRequirements.documents.taxpayer_identification_form_w_9.title") : o.title ?? "", G = S ? n("documentRequirements.documents.taxpayer_identification_form_w_9.description") : o.description ?? "";
|
|
70
|
-
return /* @__PURE__ */ t(
|
|
71
|
-
Z,
|
|
72
|
-
{
|
|
73
|
-
title: q,
|
|
74
|
-
description: G,
|
|
75
|
-
document: o,
|
|
76
|
-
downloadLabel: n("documentRequirements.downloadCta")
|
|
77
|
-
},
|
|
78
|
-
o.uuid
|
|
79
|
-
);
|
|
80
|
-
}),
|
|
81
|
-
v && /* @__PURE__ */ t(u, { status: "info", label: n("documentRequirements.alertLabel") })
|
|
82
|
-
] })
|
|
61
|
+
contractorId: n,
|
|
62
|
+
documentsToCollect: _,
|
|
63
|
+
contractorName: x,
|
|
64
|
+
hasW9: U
|
|
83
65
|
}
|
|
84
66
|
),
|
|
85
|
-
/* @__PURE__ */ a(
|
|
86
|
-
/* @__PURE__ */ t(
|
|
87
|
-
/* @__PURE__ */ t(
|
|
67
|
+
/* @__PURE__ */ a(l, { flexDirection: "column", gap: 8, children: [
|
|
68
|
+
/* @__PURE__ */ t(d, { status: "warning", label: e("title"), children: /* @__PURE__ */ t(m, { items: g }) }),
|
|
69
|
+
/* @__PURE__ */ t(j, { justifyContent: "end", children: /* @__PURE__ */ t(u, { title: e("submitCta"), onClick: v, isLoading: E, children: e("submitCta") }) })
|
|
88
70
|
] })
|
|
89
71
|
] });
|
|
90
|
-
},
|
|
91
|
-
|
|
92
|
-
|
|
72
|
+
}, K = ({
|
|
73
|
+
contractorId: n,
|
|
74
|
+
documentsToCollect: c,
|
|
75
|
+
contractorName: r,
|
|
76
|
+
hasW9: d
|
|
77
|
+
}) => {
|
|
78
|
+
const u = z(n), { Alert: i, Box: m, BoxHeader: e } = h(), { t: o } = S("Contractor.Submit");
|
|
79
|
+
return u || c.length === 0 ? null : /* @__PURE__ */ t(
|
|
80
|
+
m,
|
|
81
|
+
{
|
|
82
|
+
header: /* @__PURE__ */ t(
|
|
83
|
+
e,
|
|
84
|
+
{
|
|
85
|
+
title: o("documentRequirements.title"),
|
|
86
|
+
description: o("documentRequirements.description", { contractorName: r })
|
|
87
|
+
}
|
|
88
|
+
),
|
|
89
|
+
children: /* @__PURE__ */ a(l, { flexDirection: "column", gap: 16, children: [
|
|
90
|
+
c.map((s) => {
|
|
91
|
+
const g = s.name === T, b = g ? o("documentRequirements.documents.taxpayer_identification_form_w_9.title") : s.title ?? "", p = g ? o("documentRequirements.documents.taxpayer_identification_form_w_9.description") : s.description ?? "";
|
|
92
|
+
return /* @__PURE__ */ t(
|
|
93
|
+
Q,
|
|
94
|
+
{
|
|
95
|
+
title: b,
|
|
96
|
+
description: p,
|
|
97
|
+
document: s,
|
|
98
|
+
downloadLabel: o("documentRequirements.downloadCta")
|
|
99
|
+
},
|
|
100
|
+
s.uuid
|
|
101
|
+
);
|
|
102
|
+
}),
|
|
103
|
+
d && /* @__PURE__ */ t(i, { status: "info", label: o("documentRequirements.alertLabel") })
|
|
104
|
+
] })
|
|
105
|
+
}
|
|
106
|
+
);
|
|
107
|
+
}, Q = ({
|
|
108
|
+
title: n,
|
|
109
|
+
description: c,
|
|
93
110
|
document: r,
|
|
94
|
-
downloadLabel:
|
|
111
|
+
downloadLabel: d
|
|
95
112
|
}) => {
|
|
96
|
-
const { Text:
|
|
97
|
-
{ documentUuid:
|
|
98
|
-
{ enabled: !!
|
|
99
|
-
),
|
|
100
|
-
return /* @__PURE__ */ a(
|
|
101
|
-
/* @__PURE__ */ a(
|
|
102
|
-
/* @__PURE__ */ t(
|
|
103
|
-
/* @__PURE__ */ t(
|
|
113
|
+
const { Text: u, Button: i } = h(), m = r?.uuid, { data: e, isLoading: o } = q(
|
|
114
|
+
{ documentUuid: m ?? "" },
|
|
115
|
+
{ enabled: !!m }
|
|
116
|
+
), s = e?.documentPdf?.documentUrl ?? null;
|
|
117
|
+
return /* @__PURE__ */ a(l, { gap: 16, justifyContent: "space-between", alignItems: "center", children: [
|
|
118
|
+
/* @__PURE__ */ a(l, { flexDirection: "column", gap: 4, children: [
|
|
119
|
+
/* @__PURE__ */ t(u, { weight: "medium", children: n }),
|
|
120
|
+
/* @__PURE__ */ t(u, { variant: "supporting", children: c })
|
|
104
121
|
] }),
|
|
105
|
-
(
|
|
122
|
+
(o || s) && /* @__PURE__ */ t(
|
|
106
123
|
i,
|
|
107
124
|
{
|
|
108
125
|
variant: "secondary",
|
|
109
|
-
isLoading:
|
|
126
|
+
isLoading: o,
|
|
110
127
|
onClick: () => {
|
|
111
|
-
|
|
128
|
+
s && window.open(s, "_blank", "noopener,noreferrer");
|
|
112
129
|
},
|
|
113
|
-
children:
|
|
130
|
+
children: d
|
|
114
131
|
}
|
|
115
132
|
)
|
|
116
133
|
] });
|
|
117
|
-
},
|
|
118
|
-
onSubmit:
|
|
119
|
-
contractorId:
|
|
134
|
+
}, X = ({
|
|
135
|
+
onSubmit: n,
|
|
136
|
+
contractorId: c
|
|
120
137
|
}) => {
|
|
121
|
-
const { t: r } =
|
|
122
|
-
return /* @__PURE__ */ a(
|
|
123
|
-
/* @__PURE__ */ t(
|
|
138
|
+
const { t: r } = S("Contractor.Submit", { keyPrefix: "inviteContractor" }), { Button: d, Heading: u, Text: i } = h(), { data: m } = N({ contractorUuid: c }), e = m.contractor;
|
|
139
|
+
return /* @__PURE__ */ a(l, { flexDirection: "column", children: [
|
|
140
|
+
/* @__PURE__ */ t(u, { as: "h2", children: r("title") }),
|
|
124
141
|
/* @__PURE__ */ t(i, { children: r("description") }),
|
|
125
|
-
/* @__PURE__ */ a(
|
|
142
|
+
/* @__PURE__ */ a(l, { flexDirection: "column", children: [
|
|
126
143
|
/* @__PURE__ */ a("div", { children: [
|
|
127
|
-
/* @__PURE__ */ t(i, { children:
|
|
128
|
-
first_name:
|
|
129
|
-
last_name:
|
|
144
|
+
/* @__PURE__ */ t(i, { children: V({
|
|
145
|
+
first_name: e?.firstName,
|
|
146
|
+
last_name: e?.lastName
|
|
130
147
|
}) }),
|
|
131
|
-
/* @__PURE__ */ t(i, { children:
|
|
148
|
+
/* @__PURE__ */ t(i, { children: e?.email })
|
|
132
149
|
] }),
|
|
133
150
|
/* @__PURE__ */ a("div", { children: [
|
|
134
151
|
/* @__PURE__ */ t(i, { children: r("startDateLabel") }),
|
|
135
|
-
/* @__PURE__ */ t(i, { children:
|
|
152
|
+
/* @__PURE__ */ t(i, { children: e?.startDate })
|
|
136
153
|
] })
|
|
137
154
|
] }),
|
|
138
|
-
/* @__PURE__ */ t(
|
|
155
|
+
/* @__PURE__ */ t(d, { title: r("inviteCta"), onClick: n, children: r("inviteCta") })
|
|
139
156
|
] });
|
|
140
157
|
};
|
|
141
158
|
export {
|
|
142
|
-
|
|
159
|
+
gt as ContractorSubmit
|
|
143
160
|
};
|
|
144
161
|
//# sourceMappingURL=Submit.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Submit.js","sources":["../../../../src/components/Contractor/Submit/Submit.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useContractorsUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/contractorsUpdateOnboardingStatus'\nimport { useContractorsGetOnboardingStatusSuspense } from '@gusto/embedded-api/react-query/contractorsGetOnboardingStatus'\nimport { useContractorsGetSuspense } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorDocumentsGetAllSuspense } from '@gusto/embedded-api/react-query/contractorDocumentsGetAll'\nimport { useContractorDocumentsGetPdf } from '@gusto/embedded-api/react-query/contractorDocumentsGetPdf'\nimport type { Document } from '@gusto/embedded-api/models/components/document'\nimport { SubmitDone } from './SubmitDone'\nimport { ActionsLayout, Flex, FlexItem } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n, useComponentDictionary } from '@/i18n'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { componentEvents, ContractorOnboardingStatus } from '@/shared/constants'\nimport { firstLastName } from '@/helpers/formattedStrings'\nimport { W9_DOCUMENT_NAME } from '@/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/w9Fields'\n\n/**\n * Props for {@link ContractorSubmit}.\n *\n * @public\n */\nexport interface ContractorSubmitProps extends BaseComponentInterface<'Contractor.Submit'> {\n /** UUID of the contractor being submitted. */\n contractorId: string\n /** When true, adjusts the submission for the self-onboarding flow, surfacing the invite step before the contractor's onboarding status is finalized. */\n selfOnboarding?: boolean\n}\n\n/**\n * Finalizes contractor onboarding by updating the onboarding status, and in the self-onboarding flow can trigger an invitation to the contractor.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/onboardingStatus/updated` | The contractor's onboarding status was successfully updated. | The updated `contractorOnboardingStatus` returned by the API. |\n * | `contractor/invite/selfOnboarding` | The invite action was triggered for a self-onboarding contractor. | `{ contractorId: string }` |\n * | `contractor/submit/done` | The submission step finished — fired after a successful status update, after an invite, or when the contractor was already onboarded. | `{ message: string }`, optionally with `onboardingStatus` when the contractor was already completed. |\n *\n * @param props - See {@link ContractorSubmitProps}.\n * @returns The rendered submission step.\n * @public\n */\nexport function ContractorSubmit(props: ContractorSubmitProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ contractorId, selfOnboarding, dictionary }: ContractorSubmitProps) => {\n useI18n('Contractor.Submit')\n useComponentDictionary('Contractor.Submit', dictionary)\n const { Alert, Box, BoxHeader, Button, Heading, UnorderedList } = useComponentContext()\n const { t } = useTranslation('Contractor.Submit')\n const { onEvent, baseSubmitHandler } = useBase()\n const items = Object.values(t('warningItems', { returnObjects: true }))\n\n const { data } = useContractorsGetOnboardingStatusSuspense({\n contractorUuid: contractorId,\n })\n const onboardingStatus = data.contractorOnboardingStatus?.onboardingStatus\n\n const { data: contractorData } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const contractor = contractorData.contractor\n const contractorName =\n contractor?.type === 'Individual' ? contractor.firstName : contractor?.businessName\n\n const { data: documentsData } = useContractorDocumentsGetAllSuspense({\n contractorUuid: contractorId,\n })\n const documentsToCollect = (documentsData.documents ?? []).filter(\n d => d.requiresSigning && !d.signedAt,\n )\n const hasW9 = documentsToCollect.some(d => d.name === W9_DOCUMENT_NAME)\n\n const { mutateAsync, isPending } = useContractorsUpdateOnboardingStatusMutation()\n\n const onSubmit = async () => {\n await baseSubmitHandler(null, async () => {\n const response = await mutateAsync({\n request: {\n contractorUuid: contractorId,\n contractorOnboardingStatusUpdateRequestBody: {\n onboardingStatus: ContractorOnboardingStatus.ONBOARDING_COMPLETED,\n },\n },\n })\n onEvent(\n componentEvents.CONTRACTOR_ONBOARDING_STATUS_UPDATED,\n response.contractorOnboardingStatus,\n )\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, { message: t('submitDone.successMessage') })\n })\n }\n const handleInviteContractor = () => {\n onEvent(componentEvents.CONTRACTOR_INVITE_CONTRACTOR, { contractorId })\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, {\n message: t('inviteContractor.successMessage'),\n })\n }\n\n const handleSubmitDone = () => {\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, {\n onboardingStatus,\n message: t('submitDone.successMessage'),\n })\n }\n\n if (onboardingStatus === ContractorOnboardingStatus.ONBOARDING_COMPLETED) {\n return <SubmitDone onDone={handleSubmitDone} />\n }\n if (\n onboardingStatus === ContractorOnboardingStatus.SELF_ONBOARDING_NOT_INVITED &&\n selfOnboarding\n ) {\n return <InviteContractor onSubmit={handleInviteContractor} contractorId={contractorId} />\n }\n\n return (\n <Flex flexDirection=\"column\" gap={24}>\n <FlexItem>\n <Heading as=\"h2\">{t('heading')}</Heading>\n </FlexItem>\n\n {documentsToCollect.length > 0 && (\n <Box\n header={\n <BoxHeader\n title={t('documentRequirements.title')}\n description={t('documentRequirements.description', { contractorName })}\n />\n }\n >\n <Flex flexDirection=\"column\" gap={16}>\n {documentsToCollect.map(document => {\n const isW9 = document.name === W9_DOCUMENT_NAME\n const title = isW9\n ? t('documentRequirements.documents.taxpayer_identification_form_w_9.title')\n : (document.title ?? '')\n const description = isW9\n ? t('documentRequirements.documents.taxpayer_identification_form_w_9.description')\n : (document.description ?? '')\n return (\n <DocumentRequirementItem\n key={document.uuid}\n title={title}\n description={description}\n document={document}\n downloadLabel={t('documentRequirements.downloadCta')}\n />\n )\n })}\n {hasW9 && <Alert status=\"info\" label={t('documentRequirements.alertLabel')}></Alert>}\n </Flex>\n </Box>\n )}\n <Flex flexDirection=\"column\" gap={8}>\n <Alert status=\"warning\" label={t('title')}>\n <UnorderedList items={items} />\n </Alert>\n <ActionsLayout justifyContent=\"end\">\n <Button title={t('submitCta')} onClick={onSubmit} isLoading={isPending}>\n {t('submitCta')}\n </Button>\n </ActionsLayout>\n </Flex>\n </Flex>\n )\n}\n\nconst DocumentRequirementItem = ({\n title,\n description,\n document,\n downloadLabel,\n}: {\n title: string\n description: string\n document: Document | undefined\n downloadLabel: string\n}) => {\n const { Text, Button } = useComponentContext()\n const documentUuid = document?.uuid\n const { data: pdfData, isLoading: isPdfLoading } = useContractorDocumentsGetPdf(\n { documentUuid: documentUuid ?? '' },\n { enabled: Boolean(documentUuid) },\n )\n const pdfUrl = pdfData?.documentPdf?.documentUrl ?? null\n\n return (\n <Flex gap={16} justifyContent=\"space-between\" alignItems=\"center\">\n <Flex flexDirection=\"column\" gap={4}>\n <Text weight=\"medium\">{title}</Text>\n <Text variant=\"supporting\">{description}</Text>\n </Flex>\n {(isPdfLoading || pdfUrl) && (\n <Button\n variant=\"secondary\"\n isLoading={isPdfLoading}\n onClick={() => {\n if (pdfUrl) window.open(pdfUrl, '_blank', 'noopener,noreferrer')\n }}\n >\n {downloadLabel}\n </Button>\n )}\n </Flex>\n )\n}\n\nconst InviteContractor = ({\n onSubmit,\n contractorId,\n}: {\n onSubmit: () => void\n contractorId: string\n}) => {\n const { t } = useTranslation('Contractor.Submit', { keyPrefix: 'inviteContractor' })\n const { Button, Heading, Text } = useComponentContext()\n\n const { data: contractorData } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const contractor = contractorData.contractor\n\n return (\n <Flex flexDirection=\"column\">\n <Heading as=\"h2\">{t('title')}</Heading>\n <Text>{t('description')}</Text>\n <Flex flexDirection=\"column\">\n <div>\n <Text>\n {firstLastName({\n first_name: contractor?.firstName,\n last_name: contractor?.lastName,\n })}\n </Text>\n <Text>{contractor?.email}</Text>\n </div>\n <div>\n <Text>{t('startDateLabel')}</Text>\n <Text>{contractor?.startDate}</Text>\n </div>\n </Flex>\n <Button title={t('inviteCta')} onClick={onSubmit}>\n {t('inviteCta')}\n </Button>\n </Flex>\n )\n}\n"],"names":["ContractorSubmit","props","jsx","BaseComponent","Root","contractorId","selfOnboarding","dictionary","useI18n","useComponentDictionary","Alert","Box","BoxHeader","Button","Heading","UnorderedList","useComponentContext","t","useTranslation","onEvent","baseSubmitHandler","useBase","items","data","useContractorsGetOnboardingStatusSuspense","onboardingStatus","contractorData","useContractorsGetSuspense","contractor","contractorName","documentsData","useContractorDocumentsGetAllSuspense","documentsToCollect","d","hasW9","W9_DOCUMENT_NAME","mutateAsync","isPending","useContractorsUpdateOnboardingStatusMutation","onSubmit","response","ContractorOnboardingStatus","componentEvents","handleInviteContractor","handleSubmitDone","SubmitDone","InviteContractor","jsxs","Flex","FlexItem","document","isW9","title","description","DocumentRequirementItem","ActionsLayout","downloadLabel","Text","documentUuid","pdfData","isPdfLoading","useContractorDocumentsGetPdf","pdfUrl","firstLastName"],"mappings":";;;;;;;;;;;;;;;;;;AA0CO,SAASA,GAAiBC,GAA8B;AAC7D,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMG,IAAO,CAAC,EAAE,cAAAC,GAAc,gBAAAC,GAAgB,YAAAC,QAAwC;AACpF,EAAAC,EAAQ,mBAAmB,GAC3BC,EAAuB,qBAAqBF,CAAU;AACtD,QAAM,EAAE,OAAAG,GAAO,KAAAC,GAAK,WAAAC,GAAW,QAAAC,GAAQ,SAAAC,GAAS,eAAAC,EAAA,IAAkBC,EAAA,GAC5D,EAAE,GAAAC,EAAA,IAAMC,EAAe,mBAAmB,GAC1C,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,EAAA,GACjC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I,EAAE,WAAW,GAAG,SAASsB,GACrC,UAAAtB,EAAE,WAAW,EAAA,CAChB;AAAA,EAAA,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Submit.js","sources":["../../../../src/components/Contractor/Submit/Submit.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useContractorsUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/contractorsUpdateOnboardingStatus'\nimport { useContractorsGetOnboardingStatusSuspense } from '@gusto/embedded-api/react-query/contractorsGetOnboardingStatus'\nimport { useContractorsGetSuspense } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorDocumentsGetAllSuspense } from '@gusto/embedded-api/react-query/contractorDocumentsGetAll'\nimport { useContractorDocumentsGetPdf } from '@gusto/embedded-api/react-query/contractorDocumentsGetPdf'\nimport type { Document } from '@gusto/embedded-api/models/components/document'\nimport { SubmitDone } from './SubmitDone'\nimport { ActionsLayout, Flex, FlexItem } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n, useComponentDictionary } from '@/i18n'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport { componentEvents, ContractorOnboardingStatus } from '@/shared/constants'\nimport { firstLastName } from '@/helpers/formattedStrings'\nimport { W9_DOCUMENT_NAME } from '@/components/Contractor/Documents/SignatureForm/useContractorSignatureForm/w9Fields'\nimport { useContractorHasSignedW9 } from '@/components/Contractor/shared/useContractorHasSignedW9'\n\n/**\n * Props for {@link ContractorSubmit}.\n *\n * @public\n */\nexport interface ContractorSubmitProps extends BaseComponentInterface<'Contractor.Submit'> {\n /** UUID of the contractor being submitted. */\n contractorId: string\n /** When true, adjusts the submission for the self-onboarding flow, surfacing the invite step before the contractor's onboarding status is finalized. */\n selfOnboarding?: boolean\n}\n\n/**\n * Finalizes contractor onboarding by updating the onboarding status, and in the self-onboarding flow can trigger an invitation to the contractor.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `contractor/onboardingStatus/updated` | The contractor's onboarding status was successfully updated. | The updated `contractorOnboardingStatus` returned by the API. |\n * | `contractor/invite/selfOnboarding` | The invite action was triggered for a self-onboarding contractor. | `{ contractorId: string }` |\n * | `contractor/submit/done` | The submission step finished — fired after a successful status update, after an invite, or when the contractor was already onboarded. | `{ message: string }`, optionally with `onboardingStatus` when the contractor was already completed. |\n *\n * @param props - See {@link ContractorSubmitProps}.\n * @returns The rendered submission step.\n * @public\n */\nexport function ContractorSubmit(props: ContractorSubmitProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ contractorId, selfOnboarding, dictionary }: ContractorSubmitProps) => {\n useI18n('Contractor.Submit')\n useComponentDictionary('Contractor.Submit', dictionary)\n const { Alert, Button, Heading, UnorderedList } = useComponentContext()\n const { t } = useTranslation('Contractor.Submit')\n const { onEvent, baseSubmitHandler } = useBase()\n const items = Object.values(t('warningItems', { returnObjects: true }))\n\n const { data } = useContractorsGetOnboardingStatusSuspense({\n contractorUuid: contractorId,\n })\n const onboardingStatus = data.contractorOnboardingStatus?.onboardingStatus\n\n const { data: contractorData } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const contractor = contractorData.contractor\n const contractorName =\n contractor?.type === 'Individual' ? contractor.firstName : contractor?.businessName\n\n const { data: documentsData } = useContractorDocumentsGetAllSuspense({\n contractorUuid: contractorId,\n })\n const documentsToCollect = (documentsData.documents ?? []).filter(\n d => d.requiresSigning && !d.signedAt,\n )\n const hasW9 = documentsToCollect.some(d => d.name === W9_DOCUMENT_NAME)\n\n const { mutateAsync, isPending } = useContractorsUpdateOnboardingStatusMutation()\n\n const onSubmit = async () => {\n await baseSubmitHandler(null, async () => {\n const response = await mutateAsync({\n request: {\n contractorUuid: contractorId,\n contractorOnboardingStatusUpdateRequestBody: {\n onboardingStatus: ContractorOnboardingStatus.ONBOARDING_COMPLETED,\n },\n },\n })\n onEvent(\n componentEvents.CONTRACTOR_ONBOARDING_STATUS_UPDATED,\n response.contractorOnboardingStatus,\n )\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, { message: t('submitDone.successMessage') })\n })\n }\n const handleInviteContractor = () => {\n onEvent(componentEvents.CONTRACTOR_INVITE_CONTRACTOR, { contractorId })\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, {\n message: t('inviteContractor.successMessage'),\n })\n }\n\n const handleSubmitDone = () => {\n onEvent(componentEvents.CONTRACTOR_SUBMIT_DONE, {\n onboardingStatus,\n message: t('submitDone.successMessage'),\n })\n }\n\n if (onboardingStatus === ContractorOnboardingStatus.ONBOARDING_COMPLETED) {\n return <SubmitDone onDone={handleSubmitDone} />\n }\n if (\n onboardingStatus === ContractorOnboardingStatus.SELF_ONBOARDING_NOT_INVITED &&\n selfOnboarding\n ) {\n return <InviteContractor onSubmit={handleInviteContractor} contractorId={contractorId} />\n }\n\n return (\n <Flex flexDirection=\"column\" gap={24}>\n <FlexItem>\n <Heading as=\"h2\">{t('heading')}</Heading>\n </FlexItem>\n\n <ContractorSubmitDocuments\n contractorId={contractorId}\n documentsToCollect={documentsToCollect}\n contractorName={contractorName}\n hasW9={hasW9}\n />\n <Flex flexDirection=\"column\" gap={8}>\n <Alert status=\"warning\" label={t('title')}>\n <UnorderedList items={items} />\n </Alert>\n <ActionsLayout justifyContent=\"end\">\n <Button title={t('submitCta')} onClick={onSubmit} isLoading={isPending}>\n {t('submitCta')}\n </Button>\n </ActionsLayout>\n </Flex>\n </Flex>\n )\n}\n\nconst ContractorSubmitDocuments = ({\n contractorId,\n documentsToCollect,\n contractorName,\n hasW9,\n}: {\n contractorId: string\n documentsToCollect: Document[]\n contractorName: string | null | undefined\n hasW9: boolean\n}) => {\n const hasSignedW9 = useContractorHasSignedW9(contractorId)\n const { Alert, Box, BoxHeader } = useComponentContext()\n const { t } = useTranslation('Contractor.Submit')\n\n // If the contractor already signed a W-9 during self-onboarding, we don't\n // show manual collection instructions.\n if (hasSignedW9) {\n return null\n }\n\n if (documentsToCollect.length === 0) {\n return null\n }\n\n return (\n <Box\n header={\n <BoxHeader\n title={t('documentRequirements.title')}\n description={t('documentRequirements.description', { contractorName })}\n />\n }\n >\n <Flex flexDirection=\"column\" gap={16}>\n {documentsToCollect.map(document => {\n const isW9 = document.name === W9_DOCUMENT_NAME\n const title = isW9\n ? t('documentRequirements.documents.taxpayer_identification_form_w_9.title')\n : (document.title ?? '')\n const description = isW9\n ? t('documentRequirements.documents.taxpayer_identification_form_w_9.description')\n : (document.description ?? '')\n return (\n <DocumentRequirementItem\n key={document.uuid}\n title={title}\n description={description}\n document={document}\n downloadLabel={t('documentRequirements.downloadCta')}\n />\n )\n })}\n {hasW9 && <Alert status=\"info\" label={t('documentRequirements.alertLabel')}></Alert>}\n </Flex>\n </Box>\n )\n}\n\nconst DocumentRequirementItem = ({\n title,\n description,\n document,\n downloadLabel,\n}: {\n title: string\n description: string\n document: Document | undefined\n downloadLabel: string\n}) => {\n const { Text, Button } = useComponentContext()\n const documentUuid = document?.uuid\n const { data: pdfData, isLoading: isPdfLoading } = useContractorDocumentsGetPdf(\n { documentUuid: documentUuid ?? '' },\n { enabled: Boolean(documentUuid) },\n )\n const pdfUrl = pdfData?.documentPdf?.documentUrl ?? null\n\n return (\n <Flex gap={16} justifyContent=\"space-between\" alignItems=\"center\">\n <Flex flexDirection=\"column\" gap={4}>\n <Text weight=\"medium\">{title}</Text>\n <Text variant=\"supporting\">{description}</Text>\n </Flex>\n {(isPdfLoading || pdfUrl) && (\n <Button\n variant=\"secondary\"\n isLoading={isPdfLoading}\n onClick={() => {\n if (pdfUrl) window.open(pdfUrl, '_blank', 'noopener,noreferrer')\n }}\n >\n {downloadLabel}\n </Button>\n )}\n </Flex>\n )\n}\n\nconst InviteContractor = ({\n onSubmit,\n contractorId,\n}: {\n onSubmit: () => void\n contractorId: string\n}) => {\n const { t } = useTranslation('Contractor.Submit', { keyPrefix: 'inviteContractor' })\n const { Button, Heading, Text } = useComponentContext()\n\n const { data: contractorData } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const contractor = contractorData.contractor\n\n return (\n <Flex flexDirection=\"column\">\n <Heading as=\"h2\">{t('title')}</Heading>\n <Text>{t('description')}</Text>\n <Flex flexDirection=\"column\">\n <div>\n <Text>\n {firstLastName({\n first_name: contractor?.firstName,\n last_name: contractor?.lastName,\n })}\n </Text>\n <Text>{contractor?.email}</Text>\n </div>\n <div>\n <Text>{t('startDateLabel')}</Text>\n <Text>{contractor?.startDate}</Text>\n </div>\n </Flex>\n <Button title={t('inviteCta')} onClick={onSubmit}>\n {t('inviteCta')}\n </Button>\n </Flex>\n )\n}\n"],"names":["ContractorSubmit","props","jsx","BaseComponent","Root","contractorId","selfOnboarding","dictionary","useI18n","useComponentDictionary","Alert","Button","Heading","UnorderedList","useComponentContext","t","useTranslation","onEvent","baseSubmitHandler","useBase","items","data","useContractorsGetOnboardingStatusSuspense","onboardingStatus","contractorData","useContractorsGetSuspense","contractor","contractorName","documentsData","useContractorDocumentsGetAllSuspense","documentsToCollect","d","hasW9","W9_DOCUMENT_NAME","mutateAsync","isPending","useContractorsUpdateOnboardingStatusMutation","onSubmit","response","ContractorOnboardingStatus","componentEvents","handleInviteContractor","handleSubmitDone","SubmitDone","InviteContractor","jsxs","Flex","FlexItem","ContractorSubmitDocuments","ActionsLayout","hasSignedW9","useContractorHasSignedW9","Box","BoxHeader","document","isW9","title","description","DocumentRequirementItem","downloadLabel","Text","documentUuid","pdfData","isPdfLoading","useContractorDocumentsGetPdf","pdfUrl","firstLastName"],"mappings":";;;;;;;;;;;;;;;;;;;AA2CO,SAASA,GAAiBC,GAA8B;AAC7D,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMG,IAAO,CAAC,EAAE,cAAAC,GAAc,gBAAAC,GAAgB,YAAAC,Q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C,EAACU,GAAA,EAAQ,IAAG,MAAM,UAAAG,EAAE,OAAO,GAAE;AAAA,IAC7B,gBAAAb,EAAC0D,GAAA,EAAM,UAAA7C,EAAE,aAAa,EAAA,CAAE;AAAA,IACxB,gBAAA8B,EAACC,GAAA,EAAK,eAAc,UAClB,UAAA;AAAA,MAAA,gBAAAD,EAAC,OAAA,EACC,UAAA;AAAA,QAAA,gBAAA3C,EAAC0D,KACE,UAAAM,EAAc;AAAA,UACb,YAAYxC,GAAY;AAAA,UACxB,WAAWA,GAAY;AAAA,QAAA,CACxB,GACH;AAAA,QACA,gBAAAxB,EAAC0D,GAAA,EAAM,UAAAlC,GAAY,MAAA,CAAM;AAAA,MAAA,GAC3B;AAAA,wBACC,OAAA,EACC,UAAA;AAAA,QAAA,gBAAAxB,EAAC0D,GAAA,EAAM,UAAA7C,EAAE,gBAAgB,EAAA,CAAE;AAAA,QAC3B,gBAAAb,EAAC0D,GAAA,EAAM,UAAAlC,GAAY,UAAA,CAAU;AAAA,MAAA,EAAA,CAC/B;AAAA,IAAA,GACF;AAAA,IACA,gBAAAxB,EAACS,GAAA,EAAO,OAAOI,EAAE,WAAW,GAAG,SAASsB,GACrC,UAAAtB,EAAE,WAAW,EAAA,CAChB;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns `true` when the contractor has a W-9 with a `signedAt` timestamp on
|
|
3
|
+
* file. Fetches via Suspense — must be rendered inside a Suspense boundary
|
|
4
|
+
* (SDK `BaseBoundaries` supplies one).
|
|
5
|
+
*
|
|
6
|
+
* @internal
|
|
7
|
+
*/
|
|
8
|
+
export declare function useContractorHasSignedW9(contractorId: string): boolean;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { useContractorDocumentsGetAllSuspense as n } from "@gusto/embedded-api/react-query/contractorDocumentsGetAll";
|
|
2
|
+
import { isW9Document as r } from "../Documents/SignatureForm/useContractorSignatureForm/w9Fields.js";
|
|
3
|
+
function c(o) {
|
|
4
|
+
const { data: e } = n({ contractorUuid: o });
|
|
5
|
+
return (e.documents ?? []).some((t) => r(t) && !!t.signedAt);
|
|
6
|
+
}
|
|
7
|
+
export {
|
|
8
|
+
c as useContractorHasSignedW9
|
|
9
|
+
};
|
|
10
|
+
//# sourceMappingURL=useContractorHasSignedW9.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useContractorHasSignedW9.js","sources":["../../../../src/components/Contractor/shared/useContractorHasSignedW9.ts"],"sourcesContent":["import { useContractorDocumentsGetAllSuspense } from '@gusto/embedded-api/react-query/contractorDocumentsGetAll'\nimport { isW9Document } from '@/components/Contractor/Documents/SignatureForm/useContractorSignatureForm'\n\n/**\n * Returns `true` when the contractor has a W-9 with a `signedAt` timestamp on\n * file. Fetches via Suspense — must be rendered inside a Suspense boundary\n * (SDK `BaseBoundaries` supplies one).\n *\n * @internal\n */\nexport function useContractorHasSignedW9(contractorId: string): boolean {\n const { data } = useContractorDocumentsGetAllSuspense({ contractorUuid: contractorId })\n return (data.documents ?? []).some(doc => isW9Document(doc) && !!doc.signedAt)\n}\n"],"names":["useContractorHasSignedW9","contractorId","data","useContractorDocumentsGetAllSuspense","doc","isW9Document"],"mappings":";;AAUO,SAASA,EAAyBC,GAA+B;AACtE,QAAM,EAAE,MAAAC,EAAA,IAASC,EAAqC,EAAE,gBAAgBF,GAAc;AACtF,UAAQC,EAAK,aAAa,CAAA,GAAI,KAAK,CAAAE,MAAOC,EAAaD,CAAG,KAAK,CAAC,CAACA,EAAI,QAAQ;AAC/E;"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { TextInputHookField as n } from "../../../../../partner-hook-utils/form/fields/TextInputHookField.js";
|
|
3
3
|
import { SelectHookField as i } from "../../../../../partner-hook-utils/form/fields/SelectHookField.js";
|
|
4
4
|
import { CheckboxHookField as r } from "../../../../../partner-hook-utils/form/fields/CheckboxHookField.js";
|
|
5
5
|
import { NumberInputHookField as o } from "../../../../../partner-hook-utils/form/fields/NumberInputHookField.js";
|
|
6
|
-
import {
|
|
6
|
+
import { DatePickerHookField as m } from "../../../../../partner-hook-utils/form/fields/DatePickerHookField.js";
|
|
7
7
|
function c(e) {
|
|
8
|
-
return /* @__PURE__ */ t(
|
|
8
|
+
return /* @__PURE__ */ t(n, { ...e, name: "title" });
|
|
9
9
|
}
|
|
10
10
|
function p(e) {
|
|
11
11
|
return /* @__PURE__ */ t(i, { ...e, name: "flsaStatus" });
|
|
@@ -23,7 +23,7 @@ function g(e) {
|
|
|
23
23
|
return /* @__PURE__ */ t(i, { ...e, name: "minimumWageId" });
|
|
24
24
|
}
|
|
25
25
|
function x(e) {
|
|
26
|
-
return /* @__PURE__ */ t(
|
|
26
|
+
return /* @__PURE__ */ t(m, { ...e, name: "effectiveDate" });
|
|
27
27
|
}
|
|
28
28
|
export {
|
|
29
29
|
H as AdjustForMinimumWageField,
|