@gusto/embedded-react-sdk 0.46.2 → 0.46.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +67 -0
- package/dist/components/Common/DataView/DataTable/DataTable.js +76 -72
- package/dist/components/Common/DataView/DataTable/DataTable.js.map +1 -1
- package/dist/components/Common/DataView/DataTable/DataTable.module.scss.js +8 -0
- package/dist/components/Common/DataView/DataTable/DataTable.module.scss.js.map +1 -0
- package/dist/components/Common/DataView/useDataView.d.ts +2 -0
- package/dist/components/Common/DataView/useDataView.js.map +1 -1
- package/dist/components/Common/DocumentViewer/DocumentViewer.js +10 -10
- package/dist/components/Common/DocumentViewer/DocumentViewer.js.map +1 -1
- package/dist/components/Common/DocumentViewer/DocumentViewer.module.scss.js +9 -9
- package/dist/components/Common/PaginationControl/PaginationControl.js +11 -10
- package/dist/components/Common/PaginationControl/PaginationControl.js.map +1 -1
- package/dist/components/Common/PaginationControl/PaginationControlTypes.d.ts +1 -1
- package/dist/components/Common/UI/DescriptionList/DescriptionList.js +11 -10
- package/dist/components/Common/UI/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/components/Common/UI/DescriptionList/DescriptionList.module.scss.js +4 -4
- package/dist/components/Common/UI/Input/InputTypes.d.ts +1 -1
- package/dist/components/Common/UI/Input/InputTypes.js.map +1 -1
- package/dist/components/Common/UI/NumberInput/NumberInput.js +51 -48
- package/dist/components/Common/UI/NumberInput/NumberInput.js.map +1 -1
- package/dist/components/Common/VisuallyHidden/VisuallyHidden.d.ts +1 -1
- package/dist/components/Common/VisuallyHidden/VisuallyHidden.js.map +1 -1
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -6
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- 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 +5 -6
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +6 -7
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -4
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -4
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +3 -4
- 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 -4
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/useAddress.js +5 -6
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/Profile/useContractorProfile.js +33 -34
- package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
- package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js +14 -11
- package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js.map +1 -1
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js +0 -2
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js.map +1 -1
- package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js +18 -18
- package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js.map +1 -1
- package/dist/components/Employee/Compensation/onboarding/JobsList/JobsListPresentation.js +36 -36
- package/dist/components/Employee/Compensation/onboarding/JobsList/JobsListPresentation.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js +4 -4
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +140 -140
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useJobForm/fields.js +6 -6
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.d.ts +6 -5
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +162 -131
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
- package/dist/components/Employee/Dashboard/BasicDetailsView.js +74 -88
- package/dist/components/Employee/Dashboard/BasicDetailsView.js.map +1 -1
- package/dist/components/Employee/Dashboard/Dashboard.js +53 -51
- package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Employee/Dashboard/DocumentsView.js +17 -10
- package/dist/components/Employee/Dashboard/DocumentsView.js.map +1 -1
- package/dist/components/Employee/Dashboard/JobAndPayView.js +383 -357
- package/dist/components/Employee/Dashboard/JobAndPayView.js.map +1 -1
- package/dist/components/Employee/Dashboard/TaxesView.js +114 -101
- package/dist/components/Employee/Dashboard/TaxesView.js.map +1 -1
- package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js +36 -36
- package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js.map +1 -1
- package/dist/components/Employee/Deductions/DeductionsForm/StandardDeductionForm.js +57 -57
- package/dist/components/Employee/Deductions/DeductionsForm/StandardDeductionForm.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.d.ts +14 -5
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.js +55 -36
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/childSupportGarnishmentFormSchema.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/fields.js +8 -8
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/useChildSupportGarnishmentForm.js +18 -18
- package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/useChildSupportGarnishmentForm.js.map +1 -1
- package/dist/components/Employee/Deductions/shared/useDeductionForm/fields.js +4 -4
- package/dist/components/Employee/Deductions/shared/useDeductionForm/useDeductionForm.d.ts +3 -3
- package/dist/components/Employee/Deductions/shared/useDeductionForm/useDeductionForm.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- 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/HomeAddress/management/HomeAddressView.js +157 -147
- package/dist/components/Employee/HomeAddress/management/HomeAddressView.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js +56 -55
- package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js +20 -20
- package/dist/components/Employee/PaymentMethod/onboarding/BankForm.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useBankForm/fields.js +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.d.ts +1 -1
- package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js +4 -4
- package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js.map +1 -1
- 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/homeAddressSchema.d.ts +0 -1
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.js +11 -12
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/homeAddressSchema.test.d.ts +1 -0
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.d.ts +6 -1
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.js +95 -94
- package/dist/components/Employee/Profile/shared/useHomeAddressForm/useHomeAddressForm.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/fields.js +4 -4
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.d.ts +6 -1
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.js +87 -86
- package/dist/components/Employee/Profile/shared/useWorkAddressForm/useWorkAddressForm.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/EmployeeStateTaxesView.js +18 -18
- package/dist/components/Employee/StateTaxes/shared/EmployeeStateTaxesView.js.map +1 -1
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +8 -8
- package/dist/components/Employee/Taxes/useTaxes.js +3 -4
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.js +5 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js +61 -60
- package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js.map +1 -1
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +2 -3
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +2 -3
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js +6 -7
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.d.ts +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js +52 -68
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.module.scss.js +4 -4
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentationTypes.d.ts +0 -11
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js +137 -163
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js +36 -35
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js.map +1 -1
- package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetailPresentation.js +34 -34
- package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetailPresentation.js.map +1 -1
- package/dist/helpers/breadcrumbHelpers.d.ts +1 -1
- package/dist/helpers/breadcrumbHelpers.js.map +1 -1
- package/dist/helpers/federalEin.d.ts +1 -0
- package/dist/helpers/federalEin.js.map +1 -1
- package/dist/helpers/mask.d.ts +8 -4
- package/dist/helpers/mask.js.map +1 -1
- package/dist/helpers/rem.d.ts +2 -1
- package/dist/helpers/rem.js.map +1 -1
- package/dist/hooks/useAsyncError.d.ts +1 -0
- package/dist/hooks/useAsyncError.js.map +1 -1
- package/dist/hooks/useForkRef/useForkRef.d.ts +1 -0
- package/dist/hooks/useForkRef/useForkRef.js.map +1 -1
- package/dist/i18n/I18n.d.ts +9 -1
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Company.TimeOff.EmployeeTable.json.js +14 -14
- package/dist/i18n/en/Company.TimeOff.SelectEmployees.json.js +12 -18
- package/dist/i18n/en/Company.TimeOff.SelectEmployees.json.js.map +1 -1
- package/dist/i18n/en/Employee.Compensation.json.js +24 -24
- package/dist/i18n/en/Employee.Dashboard.json.js +22 -20
- package/dist/i18n/en/Employee.Dashboard.json.js.map +1 -1
- package/dist/i18n/en/Employee.PaymentMethod.json.js +25 -25
- package/dist/i18n/en/Employee.StateTaxes.json.js +12 -10
- package/dist/i18n/en/Employee.StateTaxes.json.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/hooks.d.ts +1 -1
- package/dist/types/i18next.d.ts +4 -17
- package/dist/types/observability.d.ts +1 -1
- package/package.json +30 -27
- package/dist/components/Employee/Dashboard/CompensationCard.d.ts +0 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useLocationsList.js","sources":["../../../../../src/components/Company/Locations/LocationsList/useLocationsList.ts"],"sourcesContent":["import { type Location } from '@gusto/embedded-api/models/components/location'\nimport { createCompoundContext } from '@/components/Base'\nimport type { PaginationItemsPerPage } from '@/components/Common/PaginationControl/PaginationControlTypes'\n\ntype LocationsListContextType = {\n locationList: Location[]\n totalPages: number\n totalCount: number\n currentPage: number\n itemsPerPage: PaginationItemsPerPage\n handleItemsPerPageChange: (n: PaginationItemsPerPage) => void\n handleFirstPage: () => void\n handlePreviousPage: () => void\n handleNextPage: () => void\n handleLastPage: () => void\n handleEditLocation: (uuid: string) => void\n handleAddLocation: () => void\n handleContinue: () => void\n}\n\nconst [useLocationsList, LocationsListProvider] = createCompoundContext<LocationsListContextType>(\n 'CompanyDocumentListContext',\n)\n\nexport { useLocationsList, LocationsListProvider }\n"],"names":["useLocationsList","LocationsListProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useLocationsList.js","sources":["../../../../../src/components/Company/Locations/LocationsList/useLocationsList.ts"],"sourcesContent":["import { type Location } from '@gusto/embedded-api/models/components/location'\nimport { createCompoundContext } from '@/components/Base'\nimport type { PaginationItemsPerPage } from '@/components/Common/PaginationControl/PaginationControlTypes'\n\ntype LocationsListContextType = {\n locationList: Location[]\n totalPages: number\n totalCount: number\n currentPage: number\n itemsPerPage: PaginationItemsPerPage\n handleItemsPerPageChange: (n: PaginationItemsPerPage) => void\n handleFirstPage: () => void\n handlePreviousPage: () => void\n handleNextPage: () => void\n handleLastPage: () => void\n handleEditLocation: (uuid: string) => void\n handleAddLocation: () => void\n handleContinue: () => void\n}\n\nconst [useLocationsList, LocationsListProvider] = createCompoundContext<LocationsListContextType>(\n 'CompanyDocumentListContext',\n)\n\nexport { useLocationsList, LocationsListProvider }\n"],"names":["useLocationsList","LocationsListProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;;;AAoBA,MAAM,CAACA,GAAkBC,CAAqB,IAAIC;AAAA,EAChD;AACF;"}
|
|
@@ -14,11 +14,10 @@ import "../../../contexts/LocaleProvider/useLocale.js";
|
|
|
14
14
|
import "../../../shared/constants.js";
|
|
15
15
|
import "classnames";
|
|
16
16
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
17
|
-
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
18
17
|
import { createCompoundContext as o } from "../../Base/createCompoundContext.js";
|
|
19
|
-
const [
|
|
18
|
+
const [s, u] = o("OnboardingOverviewContext");
|
|
20
19
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
u as OnboardingOverviewProvider,
|
|
21
|
+
s as useOnboardingOverview
|
|
23
22
|
};
|
|
24
23
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../../../../src/components/Company/OnboardingOverview/context.ts"],"sourcesContent":["import type { OnboardingStep } from '@gusto/embedded-api/models/components/companyonboardingstatus'\nimport { createCompoundContext } from '@/components/Base'\n\ntype OnboardingOverviewContextType = {\n onboardingCompleted?: boolean\n onboardingSteps?: OnboardingStep[]\n handleDone: () => void\n handleContinue: () => void\n}\n\nconst [useOnboardingOverview, OnboardingOverviewProvider] =\n createCompoundContext<OnboardingOverviewContextType>('OnboardingOverviewContext')\n\nexport { useOnboardingOverview, OnboardingOverviewProvider }\n"],"names":["useOnboardingOverview","OnboardingOverviewProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../../src/components/Company/OnboardingOverview/context.ts"],"sourcesContent":["import type { OnboardingStep } from '@gusto/embedded-api/models/components/companyonboardingstatus'\nimport { createCompoundContext } from '@/components/Base'\n\ntype OnboardingOverviewContextType = {\n onboardingCompleted?: boolean\n onboardingSteps?: OnboardingStep[]\n handleDone: () => void\n handleContinue: () => void\n}\n\nconst [useOnboardingOverview, OnboardingOverviewProvider] =\n createCompoundContext<OnboardingOverviewContextType>('OnboardingOverviewContext')\n\nexport { useOnboardingOverview, OnboardingOverviewProvider }\n"],"names":["useOnboardingOverview","OnboardingOverviewProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;;;AAUA,MAAM,CAACA,GAAuBC,CAA0B,IACtDC,EAAqD,2BAA2B;"}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { jsx as o } from "react/jsx-runtime";
|
|
2
|
-
import { TextInputHookField as t } from "../../../../../partner-hook-utils/form/fields/TextInputHookField.js";
|
|
3
|
-
import { SelectHookField as i } from "../../../../../partner-hook-utils/form/fields/SelectHookField.js";
|
|
4
2
|
import { NumberInputHookField as n } from "../../../../../partner-hook-utils/form/fields/NumberInputHookField.js";
|
|
5
3
|
import { DatePickerHookField as r } from "../../../../../partner-hook-utils/form/fields/DatePickerHookField.js";
|
|
6
|
-
import { RadioGroupHookField as
|
|
4
|
+
import { RadioGroupHookField as t } from "../../../../../partner-hook-utils/form/fields/RadioGroupHookField.js";
|
|
5
|
+
import { SelectHookField as i } from "../../../../../partner-hook-utils/form/fields/SelectHookField.js";
|
|
6
|
+
import { TextInputHookField as m } from "../../../../../partner-hook-utils/form/fields/TextInputHookField.js";
|
|
7
7
|
function F(e) {
|
|
8
|
-
return /* @__PURE__ */ o(
|
|
8
|
+
return /* @__PURE__ */ o(m, { ...e, name: "customName" });
|
|
9
9
|
}
|
|
10
10
|
function p(e) {
|
|
11
11
|
return /* @__PURE__ */ o(i, { ...e, name: "frequency" });
|
|
12
12
|
}
|
|
13
13
|
function y(e) {
|
|
14
|
-
return /* @__PURE__ */ o(
|
|
14
|
+
return /* @__PURE__ */ o(t, { ...e, name: "customTwicePerMonth" });
|
|
15
15
|
}
|
|
16
16
|
function P(e) {
|
|
17
17
|
return /* @__PURE__ */ o(r, { ...e, name: "anchorPayDate" });
|
|
@@ -14,11 +14,10 @@ import "../../../../contexts/LocaleProvider/useLocale.js";
|
|
|
14
14
|
import "../../../../shared/constants.js";
|
|
15
15
|
import "classnames";
|
|
16
16
|
import "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
17
|
-
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
18
17
|
import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
|
|
19
|
-
const [
|
|
18
|
+
const [f, v] = t("StateTaxesFormContext");
|
|
20
19
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
v as StateTaxesFormProvider,
|
|
21
|
+
f as useStateTaxesForm
|
|
23
22
|
};
|
|
24
23
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/context.ts"],"sourcesContent":["import type { TaxRequirementsState } from '@gusto/embedded-api/models/components/taxrequirementsstate'\nimport { createCompoundContext } from '@/components/Base'\n\ninterface StateTaxFormContext {\n isPending: boolean\n state: string\n stateTaxRequirements: TaxRequirementsState\n handleCancel: () => void\n}\n\nconst [useStateTaxesForm, StateTaxesFormProvider] =\n createCompoundContext<StateTaxFormContext>('StateTaxesFormContext')\n\nexport { useStateTaxesForm, StateTaxesFormProvider }\n"],"names":["useStateTaxesForm","StateTaxesFormProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/context.ts"],"sourcesContent":["import type { TaxRequirementsState } from '@gusto/embedded-api/models/components/taxrequirementsstate'\nimport { createCompoundContext } from '@/components/Base'\n\ninterface StateTaxFormContext {\n isPending: boolean\n state: string\n stateTaxRequirements: TaxRequirementsState\n handleCancel: () => void\n}\n\nconst [useStateTaxesForm, StateTaxesFormProvider] =\n createCompoundContext<StateTaxFormContext>('StateTaxesFormContext')\n\nexport { useStateTaxesForm, StateTaxesFormProvider }\n"],"names":["useStateTaxesForm","StateTaxesFormProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;;;AAUA,MAAM,CAACA,GAAmBC,CAAsB,IAC9CC,EAA2C,uBAAuB;"}
|
|
@@ -14,11 +14,10 @@ import "../../../../contexts/LocaleProvider/useLocale.js";
|
|
|
14
14
|
import "../../../../shared/constants.js";
|
|
15
15
|
import "classnames";
|
|
16
16
|
import "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
17
|
-
import "../../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
18
17
|
import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
|
|
19
|
-
const [
|
|
18
|
+
const [f, v] = t("StateTaxesListContext");
|
|
20
19
|
export {
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
v as StateTaxesListProvider,
|
|
21
|
+
f as useStateTaxesList
|
|
23
22
|
};
|
|
24
23
|
//# sourceMappingURL=context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesList/context.ts"],"sourcesContent":["import type { TaxRequirementStatesList } from '@gusto/embedded-api/models/components/taxrequirementstateslist'\nimport { createCompoundContext } from '@/components/Base'\n\ntype StateTaxesListContextType = {\n isPending: boolean\n stateTaxRequirements: TaxRequirementStatesList[]\n handleContinue: () => void\n handleChange: (state: string) => void\n}\n\nconst [useStateTaxesList, StateTaxesListProvider] =\n createCompoundContext<StateTaxesListContextType>('StateTaxesListContext')\n\nexport { useStateTaxesList, StateTaxesListProvider }\n"],"names":["useStateTaxesList","StateTaxesListProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"context.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesList/context.ts"],"sourcesContent":["import type { TaxRequirementStatesList } from '@gusto/embedded-api/models/components/taxrequirementstateslist'\nimport { createCompoundContext } from '@/components/Base'\n\ntype StateTaxesListContextType = {\n isPending: boolean\n stateTaxRequirements: TaxRequirementStatesList[]\n handleContinue: () => void\n handleChange: (state: string) => void\n}\n\nconst [useStateTaxesList, StateTaxesListProvider] =\n createCompoundContext<StateTaxesListContextType>('StateTaxesListContext')\n\nexport { useStateTaxesList, StateTaxesListProvider }\n"],"names":["useStateTaxesList","StateTaxesListProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;;;AAUA,MAAM,CAACA,GAAmBC,CAAsB,IAC9CC,EAAiD,uBAAuB;"}
|
|
@@ -15,20 +15,19 @@ import "../../../contexts/LocaleProvider/useLocale.js";
|
|
|
15
15
|
import "../../../shared/constants.js";
|
|
16
16
|
import "classnames";
|
|
17
17
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
18
|
-
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
19
18
|
import { createCompoundContext as r } from "../../Base/createCompoundContext.js";
|
|
20
|
-
const
|
|
19
|
+
const h = t.object({
|
|
21
20
|
street1: t.string().min(1),
|
|
22
21
|
street2: t.string().optional(),
|
|
23
22
|
city: t.string().min(1),
|
|
24
23
|
state: t.string().min(1),
|
|
25
24
|
zip: t.string().min(1)
|
|
26
|
-
}), [
|
|
25
|
+
}), [j, l] = r(
|
|
27
26
|
"ContractorAddressContext"
|
|
28
27
|
);
|
|
29
28
|
export {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
h as AddressFormSchema,
|
|
30
|
+
l as AddressProvider,
|
|
31
|
+
j as useAddress
|
|
33
32
|
};
|
|
34
33
|
//# sourceMappingURL=useAddress.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useAddress.js","sources":["../../../../src/components/Contractor/Address/useAddress.ts"],"sourcesContent":["import type { Contractor, ContractorType } from '@gusto/embedded-api/models/components/contractor'\nimport type { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress'\nimport { z } from 'zod'\nimport { createCompoundContext } from '@/components/Base'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\n\nexport interface AddressContextType {\n contractor?: Contractor\n contractorType?: ContractorType\n address?: ContractorAddress\n isPending: boolean\n}\n\nexport type AddressDefaultValues = RequireAtLeastOne<\n Pick<ContractorAddress, 'street1' | 'street2' | 'city' | 'state' | 'zip'>\n>\n\nexport const AddressFormSchema = z.object({\n street1: z.string().min(1),\n street2: z.string().optional(),\n city: z.string().min(1),\n state: z.string().min(1),\n zip: z.string().min(1),\n})\n\nexport type AddressFormValues = z.infer<typeof AddressFormSchema>\n\nconst [useAddress, AddressProvider] = createCompoundContext<AddressContextType>(\n 'ContractorAddressContext',\n)\n\nexport { useAddress, AddressProvider }\n"],"names":["AddressFormSchema","z","useAddress","AddressProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useAddress.js","sources":["../../../../src/components/Contractor/Address/useAddress.ts"],"sourcesContent":["import type { Contractor, ContractorType } from '@gusto/embedded-api/models/components/contractor'\nimport type { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress'\nimport { z } from 'zod'\nimport { createCompoundContext } from '@/components/Base'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\n\nexport interface AddressContextType {\n contractor?: Contractor\n contractorType?: ContractorType\n address?: ContractorAddress\n isPending: boolean\n}\n\nexport type AddressDefaultValues = RequireAtLeastOne<\n Pick<ContractorAddress, 'street1' | 'street2' | 'city' | 'state' | 'zip'>\n>\n\nexport const AddressFormSchema = z.object({\n street1: z.string().min(1),\n street2: z.string().optional(),\n city: z.string().min(1),\n state: z.string().min(1),\n zip: z.string().min(1),\n})\n\nexport type AddressFormValues = z.infer<typeof AddressFormSchema>\n\nconst [useAddress, AddressProvider] = createCompoundContext<AddressContextType>(\n 'ContractorAddressContext',\n)\n\nexport { useAddress, AddressProvider }\n"],"names":["AddressFormSchema","z","useAddress","AddressProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;;;;AAiBO,MAAMA,IAAoBC,EAAE,OAAO;AAAA,EACxC,SAASA,EAAE,SAAS,IAAI,CAAC;AAAA,EACzB,SAASA,EAAE,OAAA,EAAS,SAAA;AAAA,EACpB,MAAMA,EAAE,SAAS,IAAI,CAAC;AAAA,EACtB,OAAOA,EAAE,SAAS,IAAI,CAAC;AAAA,EACvB,KAAKA,EAAE,OAAA,EAAS,IAAI,CAAC;AACvB,CAAC,GAIK,CAACC,GAAYC,CAAe,IAAIC;AAAA,EACpC;AACF;"}
|
|
@@ -18,19 +18,18 @@ import { SDKInternalError as Y } from "../../../types/sdkError.js";
|
|
|
18
18
|
import { ContractorSelfOnboardingStatuses as x, componentEvents as b, ContractorOnboardingStatus as ee } from "../../../shared/constants.js";
|
|
19
19
|
import "classnames";
|
|
20
20
|
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
21
|
-
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
22
21
|
import { useI18n as oe } from "../../../i18n/I18n.js";
|
|
23
22
|
import { SSN_REGEX as se, NAME_REGEX as T } from "../../../helpers/validations.js";
|
|
24
23
|
import { removeNonDigits as ae } from "../../../helpers/formattedStrings.js";
|
|
25
24
|
import { formatDateToStringDate as te } from "../../../helpers/dateFormatting.js";
|
|
26
|
-
import { normalizeEin as
|
|
27
|
-
const
|
|
25
|
+
import { normalizeEin as ne } from "../../../helpers/federalEin.js";
|
|
26
|
+
const i = L, a = J, ie = s.object({
|
|
28
27
|
// Self-onboarding toggle
|
|
29
28
|
selfOnboarding: s.boolean(),
|
|
30
29
|
email: s.string().email().optional(),
|
|
31
30
|
// Required contractor fields
|
|
32
31
|
contractorType: s.enum([a.Individual, a.Business]),
|
|
33
|
-
wageType: s.enum([
|
|
32
|
+
wageType: s.enum([i.Hourly, i.Fixed]),
|
|
34
33
|
startDate: s.date(),
|
|
35
34
|
// Individual contractor fields
|
|
36
35
|
firstName: s.string().min(1).regex(T).optional(),
|
|
@@ -42,79 +41,79 @@ const n = L, a = J, ne = s.object({
|
|
|
42
41
|
ein: s.string().optional(),
|
|
43
42
|
// Wage fields
|
|
44
43
|
hourlyRate: s.number().min(0).optional()
|
|
45
|
-
}), re = (t, f,
|
|
46
|
-
(e,
|
|
47
|
-
if (e.selfOnboarding && !e.email &&
|
|
44
|
+
}), re = (t, f, m) => ie.superRefine(
|
|
45
|
+
(e, n) => {
|
|
46
|
+
if (e.selfOnboarding && !e.email && n.addIssue({
|
|
48
47
|
code: s.ZodIssueCode.custom,
|
|
49
48
|
path: ["email"],
|
|
50
49
|
message: t("validations.email")
|
|
51
50
|
}), e.contractorType === a.Individual)
|
|
52
|
-
if (e.firstName ||
|
|
51
|
+
if (e.firstName || n.addIssue({
|
|
53
52
|
code: s.ZodIssueCode.custom,
|
|
54
53
|
path: ["firstName"],
|
|
55
54
|
message: t("validations.firstName")
|
|
56
|
-
}), e.lastName ||
|
|
55
|
+
}), e.lastName || n.addIssue({
|
|
57
56
|
code: s.ZodIssueCode.custom,
|
|
58
57
|
path: ["lastName"],
|
|
59
58
|
message: t("validations.lastName")
|
|
60
59
|
}), !e.ssn)
|
|
61
|
-
!f && !e.selfOnboarding &&
|
|
60
|
+
!f && !e.selfOnboarding && n.addIssue({
|
|
62
61
|
code: s.ZodIssueCode.custom,
|
|
63
62
|
path: ["ssn"],
|
|
64
63
|
message: t("validations.ssn")
|
|
65
64
|
});
|
|
66
65
|
else {
|
|
67
66
|
const l = ae(e.ssn);
|
|
68
|
-
se.test(l) ||
|
|
67
|
+
se.test(l) || n.addIssue({
|
|
69
68
|
code: s.ZodIssueCode.custom,
|
|
70
69
|
path: ["ssn"],
|
|
71
70
|
message: t("validations.ssnFormat")
|
|
72
71
|
});
|
|
73
72
|
}
|
|
74
73
|
if (e.contractorType === a.Business)
|
|
75
|
-
if (e.businessName ||
|
|
74
|
+
if (e.businessName || n.addIssue({
|
|
76
75
|
code: s.ZodIssueCode.custom,
|
|
77
76
|
path: ["businessName"],
|
|
78
77
|
message: t("validations.businessName")
|
|
79
78
|
}), !e.ein)
|
|
80
|
-
!
|
|
79
|
+
!m && !e.selfOnboarding && n.addIssue({
|
|
81
80
|
code: s.ZodIssueCode.custom,
|
|
82
81
|
path: ["ein"],
|
|
83
82
|
message: t("validations.ein")
|
|
84
83
|
});
|
|
85
84
|
else {
|
|
86
|
-
const l =
|
|
87
|
-
/^\d{2}-\d{7}$/.test(l) ||
|
|
85
|
+
const l = ne(e.ein);
|
|
86
|
+
/^\d{2}-\d{7}$/.test(l) || n.addIssue({
|
|
88
87
|
code: s.ZodIssueCode.custom,
|
|
89
88
|
path: ["ein"],
|
|
90
89
|
message: t("validations.einFormat")
|
|
91
90
|
});
|
|
92
91
|
}
|
|
93
|
-
e.wageType ===
|
|
92
|
+
e.wageType === i.Hourly && (e.hourlyRate === void 0 || e.hourlyRate < 0) && n.addIssue({
|
|
94
93
|
code: s.ZodIssueCode.custom,
|
|
95
94
|
path: ["hourlyRate"],
|
|
96
95
|
message: t("validations.hourlyRate")
|
|
97
96
|
});
|
|
98
97
|
}
|
|
99
98
|
);
|
|
100
|
-
function
|
|
99
|
+
function Ae({
|
|
101
100
|
companyId: t,
|
|
102
101
|
contractorId: f,
|
|
103
|
-
defaultValues:
|
|
102
|
+
defaultValues: m,
|
|
104
103
|
existingContractor: e
|
|
105
104
|
}) {
|
|
106
105
|
oe("Contractor.Profile");
|
|
107
|
-
const { t:
|
|
108
|
-
|
|
106
|
+
const { t: n } = X("Contractor.Profile"), { onEvent: l, baseSubmitHandler: g } = Q(), S = re(
|
|
107
|
+
n,
|
|
109
108
|
e?.hasSsn ?? !1,
|
|
110
109
|
e?.hasEin ?? !1
|
|
111
110
|
), { mutateAsync: R, isPending: w } = k(), { mutateAsync: O, isPending: D } = K(), I = G(
|
|
112
111
|
() => ({
|
|
113
112
|
selfOnboarding: !1,
|
|
114
113
|
contractorType: a.Business,
|
|
115
|
-
wageType:
|
|
114
|
+
wageType: i.Fixed,
|
|
116
115
|
startDate: /* @__PURE__ */ new Date(),
|
|
117
|
-
...
|
|
116
|
+
...m,
|
|
118
117
|
// Override with existing contractor data if available
|
|
119
118
|
...e && {
|
|
120
119
|
selfOnboarding: e.onboardingStatus ? (
|
|
@@ -122,7 +121,7 @@ function He({
|
|
|
122
121
|
x.has(e.onboardingStatus)
|
|
123
122
|
) : !1,
|
|
124
123
|
contractorType: e.type || a.Business,
|
|
125
|
-
wageType: e.wageType ||
|
|
124
|
+
wageType: e.wageType || i.Fixed,
|
|
126
125
|
startDate: e.startDate ? new Date(e.startDate) : /* @__PURE__ */ new Date(),
|
|
127
126
|
firstName: e.firstName || void 0,
|
|
128
127
|
middleInitial: e.middleInitial || void 0,
|
|
@@ -135,14 +134,14 @@ function He({
|
|
|
135
134
|
})() : void 0
|
|
136
135
|
}
|
|
137
136
|
}),
|
|
138
|
-
[e,
|
|
139
|
-
),
|
|
137
|
+
[e, m]
|
|
138
|
+
), d = j({
|
|
140
139
|
resolver: $(S),
|
|
141
140
|
defaultValues: I,
|
|
142
141
|
...e && { values: I },
|
|
143
142
|
resetOptions: { keepDirtyValues: !0 }
|
|
144
|
-
}), { handleSubmit: E, formState: F } =
|
|
145
|
-
control:
|
|
143
|
+
}), { handleSubmit: E, formState: F } = d, u = v({ control: d.control, name: "contractorType" }), P = v({ control: d.control, name: "wageType" }), y = v({
|
|
144
|
+
control: d.control,
|
|
146
145
|
name: "selfOnboarding"
|
|
147
146
|
}), N = (o) => {
|
|
148
147
|
const r = {
|
|
@@ -151,7 +150,7 @@ function He({
|
|
|
151
150
|
startDate: te(o.startDate) || "",
|
|
152
151
|
selfOnboarding: o.selfOnboarding,
|
|
153
152
|
email: o.selfOnboarding ? o.email : void 0,
|
|
154
|
-
hourlyRate: o.wageType ===
|
|
153
|
+
hourlyRate: o.wageType === i.Hourly ? String(o.hourlyRate) : void 0,
|
|
155
154
|
isActive: !0
|
|
156
155
|
};
|
|
157
156
|
return o.contractorType === a.Individual ? {
|
|
@@ -199,16 +198,16 @@ function He({
|
|
|
199
198
|
contractorId: c
|
|
200
199
|
});
|
|
201
200
|
});
|
|
202
|
-
}, A = !!y, H = u === a.Business, Z = u === a.Individual, _ = P ===
|
|
201
|
+
}, A = !!y, H = u === a.Business, Z = u === a.Individual, _ = P === i.Hourly, U = u === a.Individual && !y, M = u === a.Business && !y, q = [
|
|
203
202
|
{ label: "Individual", value: a.Individual },
|
|
204
203
|
{ label: "Business", value: a.Business }
|
|
205
204
|
], W = [
|
|
206
|
-
{ label: "Hourly", value:
|
|
207
|
-
{ label: "Fixed", value:
|
|
205
|
+
{ label: "Hourly", value: i.Hourly },
|
|
206
|
+
{ label: "Fixed", value: i.Fixed }
|
|
208
207
|
], z = w || D;
|
|
209
208
|
return {
|
|
210
209
|
// Form methods and submission
|
|
211
|
-
formMethods:
|
|
210
|
+
formMethods: d,
|
|
212
211
|
handleSubmit: E(B),
|
|
213
212
|
formState: {
|
|
214
213
|
...F,
|
|
@@ -230,8 +229,8 @@ function He({
|
|
|
230
229
|
}
|
|
231
230
|
export {
|
|
232
231
|
a as ContractorType,
|
|
233
|
-
|
|
232
|
+
i as WageType,
|
|
234
233
|
re as createContractorProfileValidationSchema,
|
|
235
|
-
|
|
234
|
+
Ae as useContractorProfile
|
|
236
235
|
};
|
|
237
236
|
//# sourceMappingURL=useContractorProfile.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContractorProfile.js","sources":["../../../../src/components/Contractor/Profile/useContractorProfile.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { useForm, useWatch } from 'react-hook-form'\nimport { z } from 'zod'\nimport { useContractorsCreateMutation } from '@gusto/embedded-api/react-query/contractorsCreate'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api/react-query/contractorsUpdate'\nimport type { ContractorCreateRequestBody } from '@gusto/embedded-api/models/components/contractorcreaterequestbody'\nimport type { ContractorUpdateRequestBody } from '@gusto/embedded-api/models/components/contractorupdaterequestbody'\nimport {\n ContractorWageType as ApiWageType,\n ContractorType as ApiContractorType,\n type Contractor,\n} from '@gusto/embedded-api/models/components/contractor'\nimport { useBase } from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n ContractorOnboardingStatus,\n ContractorSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport { SSN_REGEX, NAME_REGEX } from '@/helpers/validations'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { normalizeEin } from '@/helpers/federalEin'\nimport { SDKInternalError } from '@/types/sdkError'\n\n// Re-export the API types for convenience\nexport const WageType = ApiWageType\nexport const ContractorType = ApiContractorType\n\n// Form schema definition - exported for use in stories and tests\nconst ContractorProfileSchema = z.object({\n // Self-onboarding toggle\n selfOnboarding: z.boolean(),\n email: z.string().email().optional(),\n\n // Required contractor fields\n contractorType: z.enum([ContractorType.Individual, ContractorType.Business]),\n wageType: z.enum([WageType.Hourly, WageType.Fixed]),\n startDate: z.date(),\n\n // Individual contractor fields\n firstName: z.string().min(1).regex(NAME_REGEX).optional(),\n middleInitial: z.string().optional(),\n lastName: z.string().min(1).regex(NAME_REGEX).optional(),\n ssn: z.string().optional(),\n\n // Business contractor fields\n businessName: z.string().optional(),\n ein: z.string().optional(),\n\n // Wage fields\n hourlyRate: z.number().min(0).optional(),\n})\n\nexport type ContractorProfileFormData = z.infer<typeof ContractorProfileSchema>\n\n// Create validation schema - exported for stories\nexport const createContractorProfileValidationSchema = (\n t: (key: string) => string,\n hasSsn: boolean,\n hasEin: boolean,\n) => {\n return ContractorProfileSchema.superRefine(\n (data: ContractorProfileFormData, ctx: z.RefinementCtx) => {\n // Email validation for contractor invitation\n if (data.selfOnboarding && !data.email) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['email'],\n message: t('validations.email'),\n })\n }\n\n // Individual contractor validations\n if (data.contractorType === ContractorType.Individual) {\n if (!data.firstName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['firstName'],\n message: t('validations.firstName'),\n })\n }\n\n if (!data.lastName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['lastName'],\n message: t('validations.lastName'),\n })\n }\n\n if (!data.ssn) {\n if (!hasSsn && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssn'),\n })\n }\n } else {\n // Validate SSN format\n const cleanSSN = removeNonDigits(data.ssn)\n if (!SSN_REGEX.test(cleanSSN)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssnFormat'),\n })\n }\n }\n }\n\n // Business contractor validations\n if (data.contractorType === ContractorType.Business) {\n if (!data.businessName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['businessName'],\n message: t('validations.businessName'),\n })\n }\n\n if (!data.ein) {\n if (!hasEin && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.ein'),\n })\n }\n } else {\n // Validate EIN format after normalization (XX-XXXXXXX)\n const normalizedEin = normalizeEin(data.ein)\n if (!/^\\d{2}-\\d{7}$/.test(normalizedEin)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.einFormat'),\n })\n }\n }\n }\n\n // Hourly rate validation for hourly contractors\n if (data.wageType === WageType.Hourly) {\n if (data.hourlyRate === undefined || data.hourlyRate < 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['hourlyRate'],\n message: t('validations.hourlyRate'),\n })\n }\n }\n },\n )\n}\n\nexport interface UseContractorProfileProps {\n companyId: string\n contractorId?: string\n defaultValues?: Partial<ContractorProfileFormData>\n existingContractor?: Contractor\n}\n\nexport function useContractorProfile({\n companyId,\n contractorId,\n defaultValues,\n existingContractor,\n}: UseContractorProfileProps) {\n useI18n('Contractor.Profile')\n const { t } = useTranslation('Contractor.Profile')\n const { onEvent, baseSubmitHandler } = useBase()\n\n // Create validation schema with translations\n const validationSchema = createContractorProfileValidationSchema(\n t as (key: string) => string,\n existingContractor?.hasSsn ?? false,\n existingContractor?.hasEin ?? false,\n )\n\n // API mutations\n const { mutateAsync: createContractor, isPending: isCreating } = useContractorsCreateMutation()\n const { mutateAsync: updateContractor, isPending: isUpdating } = useContractorsUpdateMutation()\n\n // Prepare default values from existing contractor or provided defaults\n const formDefaultValues = useMemo(\n () => ({\n selfOnboarding: false,\n contractorType: ContractorType.Business,\n wageType: WageType.Fixed,\n startDate: new Date(),\n ...defaultValues,\n // Override with existing contractor data if available\n ...(existingContractor && {\n selfOnboarding: existingContractor.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n ContractorSelfOnboardingStatuses.has(existingContractor.onboardingStatus)\n : false,\n contractorType: existingContractor.type || ContractorType.Business,\n wageType: existingContractor.wageType || WageType.Fixed,\n startDate: existingContractor.startDate\n ? new Date(existingContractor.startDate)\n : new Date(),\n firstName: existingContractor.firstName || undefined,\n middleInitial: existingContractor.middleInitial || undefined,\n lastName: existingContractor.lastName || undefined,\n businessName: existingContractor.businessName || undefined,\n email: existingContractor.email || undefined,\n hourlyRate: existingContractor.hourlyRate\n ? (() => {\n const parsed = parseFloat(existingContractor.hourlyRate)\n return isNaN(parsed) ? undefined : parsed\n })()\n : undefined,\n }),\n }),\n [existingContractor, defaultValues],\n )\n\n // Form setup\n const formMethods = useForm<ContractorProfileFormData, unknown, ContractorProfileFormData>({\n resolver: zodResolver(validationSchema),\n defaultValues: formDefaultValues,\n ...(existingContractor && { values: formDefaultValues }),\n resetOptions: { keepDirtyValues: true },\n })\n\n const { handleSubmit, formState } = formMethods\n\n // Watch form values for conditional rendering\n const watchedType = useWatch({ control: formMethods.control, name: 'contractorType' })\n const watchedWageType = useWatch({ control: formMethods.control, name: 'wageType' })\n const watchedSelfOnboarding = useWatch({\n control: formMethods.control,\n name: 'selfOnboarding',\n })\n\n // Helper function to transform form data to API payload\n const transformFormDataToCreatePayload = (\n data: ContractorProfileFormData,\n ): ContractorCreateRequestBody => {\n const basePayload = {\n type: data.contractorType,\n wageType: data.wageType,\n startDate: formatDateToStringDate(data.startDate) || '',\n selfOnboarding: data.selfOnboarding,\n email: data.selfOnboarding ? data.email : undefined,\n hourlyRate: data.wageType === WageType.Hourly ? String(data.hourlyRate) : undefined,\n isActive: true,\n }\n\n if (data.contractorType === ContractorType.Individual) {\n return {\n ...basePayload,\n firstName: data.firstName,\n middleInitial: data.middleInitial || undefined,\n lastName: data.lastName,\n ssn: data.ssn,\n fileNewHireReport: false, // Default value\n }\n } else {\n return {\n ...basePayload,\n fileNewHireReport: false, // Default value\n businessName: data.businessName,\n ein: data.ein?.replace(/-/g, ''),\n }\n }\n }\n\n const transformFormDataToUpdatePayload = (\n data: ContractorProfileFormData,\n version: string,\n ): ContractorUpdateRequestBody => {\n const createPayload = transformFormDataToCreatePayload(data)\n return {\n ...createPayload,\n version,\n }\n }\n\n // Event handlers\n const onSubmit: SubmitHandler<ContractorProfileFormData> = async data => {\n await baseSubmitHandler(data, async payload => {\n let contractorId = existingContractor?.uuid\n if (existingContractor) {\n // Update existing contractor\n if (!existingContractor.version) {\n throw new SDKInternalError('Contractor version is required for updates')\n }\n const version = existingContractor.version\n const apiPayload = transformFormDataToUpdatePayload(payload, version)\n\n const updateResponse = await updateContractor({\n request: {\n contractorUuid: contractorId!,\n contractorUpdateRequestBody: apiPayload,\n },\n })\n\n onEvent(componentEvents.CONTRACTOR_UPDATED, updateResponse.contractor)\n } else {\n // Create new contractor\n const apiPayload = transformFormDataToCreatePayload(payload)\n\n const createResponse = await createContractor({\n request: {\n companyUuid: companyId,\n contractorCreateRequestBody: apiPayload,\n },\n })\n\n contractorId = createResponse.contractor?.uuid\n onEvent(componentEvents.CONTRACTOR_CREATED, createResponse.contractor)\n }\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n selfOnboarding:\n payload.selfOnboarding &&\n existingContractor?.onboardingStatus !==\n ContractorOnboardingStatus.ADMIN_ONBOARDING_REVIEW,\n contractorId,\n })\n })\n }\n\n // Conditional rendering helpers\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion\n const shouldShowEmailField = !!watchedSelfOnboarding\n const shouldShowBusinessFields = watchedType === ContractorType.Business\n const shouldShowIndividualFields = watchedType === ContractorType.Individual\n const shouldShowHourlyRate = watchedWageType === WageType.Hourly\n const shouldShowSsnField = watchedType === ContractorType.Individual && !watchedSelfOnboarding\n const shouldShowEinField = watchedType === ContractorType.Business && !watchedSelfOnboarding\n\n // Form field options\n const contractorTypeOptions = [\n { label: 'Individual', value: ContractorType.Individual },\n { label: 'Business', value: ContractorType.Business },\n ]\n\n const wageTypeOptions = [\n { label: 'Hourly', value: WageType.Hourly },\n { label: 'Fixed', value: WageType.Fixed },\n ]\n\n // Determine if we're currently submitting (creating or updating)\n const isSubmitting = isCreating || isUpdating\n // Return only what the component actually needs\n return {\n // Form methods and submission\n formMethods,\n handleSubmit: handleSubmit(onSubmit),\n formState: {\n ...formState,\n isSubmitting,\n },\n\n // Conditional rendering flags\n shouldShowEmailField,\n shouldShowBusinessFields,\n shouldShowIndividualFields,\n shouldShowHourlyRate,\n shouldShowSsnField,\n shouldShowEinField,\n\n // Form options\n contractorTypeOptions,\n wageTypeOptions,\n\n // Component state\n isEditing: !!contractorId,\n }\n}\n"],"names":["WageType","ApiWageType","ContractorType","ApiContractorType","ContractorProfileSchema","z","NAME_REGEX","createContractorProfileValidationSchema","hasSsn","hasEin","data","ctx","cleanSSN","removeNonDigits","SSN_REGEX","normalizedEin","normalizeEin","useContractorProfile","companyId","contractorId","defaultValues","existingContractor","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","validationSchema","createContractor","isCreating","useContractorsCreateMutation","updateContractor","isUpdating","useContractorsUpdateMutation","formDefaultValues","useMemo","ContractorSelfOnboardingStatuses","parsed","formMethods","useForm","zodResolver","handleSubmit","formState","watchedType","useWatch","watchedWageType","watchedSelfOnboarding","transformFormDataToCreatePayload","basePayload","formatDateToStringDate","transformFormDataToUpdatePayload","version","onSubmit","payload","SDKInternalError","apiPayload","updateResponse","componentEvents","createResponse","ContractorOnboardingStatus","shouldShowEmailField","shouldShowBusinessFields","shouldShowIndividualFields","shouldShowHourlyRate","shouldShowSsnField","shouldShowEinField","contractorTypeOptions","wageTypeOptions","isSubmitting"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,MAAMA,IAAWC,GACXC,IAAiBC,GAGxBC,KAA0BC,EAAE,OAAO;AAAA;AAAA,EAEvC,gBAAgBA,EAAE,QAAA;AAAA,EAClB,OAAOA,EAAE,OAAA,EAAS,MAAA,EAAQ,SAAA;AAAA;AAAA,EAG1B,gBAAgBA,EAAE,KAAK,CAACH,EAAe,YAAYA,EAAe,QAAQ,CAAC;AAAA,EAC3E,UAAUG,EAAE,KAAK,CAACL,EAAS,QAAQA,EAAS,KAAK,CAAC;AAAA,EAClD,WAAWK,EAAE,KAAA;AAAA;AAAA,EAGb,WAAWA,EAAE,OAAA,EAAS,IAAI,CAAC,EA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A,MACH,cAAA0B;AAAA,IAAA;AAAA;AAAA,IAIF,sBAAAR;AAAA,IACA,0BAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,oBAAAC;AAAA;AAAA,IAGA,uBAAAC;AAAA,IACA,iBAAAC;AAAA;AAAA,IAGA,WAAW,CAAC,CAACjD;AAAA,EAAA;AAEjB;"}
|
|
1
|
+
{"version":3,"file":"useContractorProfile.js","sources":["../../../../src/components/Contractor/Profile/useContractorProfile.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { useForm, useWatch } from 'react-hook-form'\nimport { z } from 'zod'\nimport { useContractorsCreateMutation } from '@gusto/embedded-api/react-query/contractorsCreate'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api/react-query/contractorsUpdate'\nimport type { ContractorCreateRequestBody } from '@gusto/embedded-api/models/components/contractorcreaterequestbody'\nimport type { ContractorUpdateRequestBody } from '@gusto/embedded-api/models/components/contractorupdaterequestbody'\nimport {\n ContractorWageType as ApiWageType,\n ContractorType as ApiContractorType,\n type Contractor,\n} from '@gusto/embedded-api/models/components/contractor'\nimport { useBase } from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n ContractorOnboardingStatus,\n ContractorSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport { SSN_REGEX, NAME_REGEX } from '@/helpers/validations'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { normalizeEin } from '@/helpers/federalEin'\nimport { SDKInternalError } from '@/types/sdkError'\n\n// Re-export the API types for convenience\nexport const WageType = ApiWageType\nexport const ContractorType = ApiContractorType\n\n// Form schema definition - exported for use in stories and tests\nconst ContractorProfileSchema = z.object({\n // Self-onboarding toggle\n selfOnboarding: z.boolean(),\n email: z.string().email().optional(),\n\n // Required contractor fields\n contractorType: z.enum([ContractorType.Individual, ContractorType.Business]),\n wageType: z.enum([WageType.Hourly, WageType.Fixed]),\n startDate: z.date(),\n\n // Individual contractor fields\n firstName: z.string().min(1).regex(NAME_REGEX).optional(),\n middleInitial: z.string().optional(),\n lastName: z.string().min(1).regex(NAME_REGEX).optional(),\n ssn: z.string().optional(),\n\n // Business contractor fields\n businessName: z.string().optional(),\n ein: z.string().optional(),\n\n // Wage fields\n hourlyRate: z.number().min(0).optional(),\n})\n\nexport type ContractorProfileFormData = z.infer<typeof ContractorProfileSchema>\n\n// Create validation schema - exported for stories\nexport const createContractorProfileValidationSchema = (\n t: (key: string) => string,\n hasSsn: boolean,\n hasEin: boolean,\n) => {\n return ContractorProfileSchema.superRefine(\n (data: ContractorProfileFormData, ctx: z.RefinementCtx) => {\n // Email validation for contractor invitation\n if (data.selfOnboarding && !data.email) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['email'],\n message: t('validations.email'),\n })\n }\n\n // Individual contractor validations\n if (data.contractorType === ContractorType.Individual) {\n if (!data.firstName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['firstName'],\n message: t('validations.firstName'),\n })\n }\n\n if (!data.lastName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['lastName'],\n message: t('validations.lastName'),\n })\n }\n\n if (!data.ssn) {\n if (!hasSsn && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssn'),\n })\n }\n } else {\n // Validate SSN format\n const cleanSSN = removeNonDigits(data.ssn)\n if (!SSN_REGEX.test(cleanSSN)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssnFormat'),\n })\n }\n }\n }\n\n // Business contractor validations\n if (data.contractorType === ContractorType.Business) {\n if (!data.businessName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['businessName'],\n message: t('validations.businessName'),\n })\n }\n\n if (!data.ein) {\n if (!hasEin && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.ein'),\n })\n }\n } else {\n // Validate EIN format after normalization (XX-XXXXXXX)\n const normalizedEin = normalizeEin(data.ein)\n if (!/^\\d{2}-\\d{7}$/.test(normalizedEin)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.einFormat'),\n })\n }\n }\n }\n\n // Hourly rate validation for hourly contractors\n if (data.wageType === WageType.Hourly) {\n if (data.hourlyRate === undefined || data.hourlyRate < 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['hourlyRate'],\n message: t('validations.hourlyRate'),\n })\n }\n }\n },\n )\n}\n\nexport interface UseContractorProfileProps {\n companyId: string\n contractorId?: string\n defaultValues?: Partial<ContractorProfileFormData>\n existingContractor?: Contractor\n}\n\nexport function useContractorProfile({\n companyId,\n contractorId,\n defaultValues,\n existingContractor,\n}: UseContractorProfileProps) {\n useI18n('Contractor.Profile')\n const { t } = useTranslation('Contractor.Profile')\n const { onEvent, baseSubmitHandler } = useBase()\n\n // Create validation schema with translations\n const validationSchema = createContractorProfileValidationSchema(\n t as (key: string) => string,\n existingContractor?.hasSsn ?? false,\n existingContractor?.hasEin ?? false,\n )\n\n // API mutations\n const { mutateAsync: createContractor, isPending: isCreating } = useContractorsCreateMutation()\n const { mutateAsync: updateContractor, isPending: isUpdating } = useContractorsUpdateMutation()\n\n // Prepare default values from existing contractor or provided defaults\n const formDefaultValues = useMemo(\n () => ({\n selfOnboarding: false,\n contractorType: ContractorType.Business,\n wageType: WageType.Fixed,\n startDate: new Date(),\n ...defaultValues,\n // Override with existing contractor data if available\n ...(existingContractor && {\n selfOnboarding: existingContractor.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n ContractorSelfOnboardingStatuses.has(existingContractor.onboardingStatus)\n : false,\n contractorType: existingContractor.type || ContractorType.Business,\n wageType: existingContractor.wageType || WageType.Fixed,\n startDate: existingContractor.startDate\n ? new Date(existingContractor.startDate)\n : new Date(),\n firstName: existingContractor.firstName || undefined,\n middleInitial: existingContractor.middleInitial || undefined,\n lastName: existingContractor.lastName || undefined,\n businessName: existingContractor.businessName || undefined,\n email: existingContractor.email || undefined,\n hourlyRate: existingContractor.hourlyRate\n ? (() => {\n const parsed = parseFloat(existingContractor.hourlyRate)\n return isNaN(parsed) ? undefined : parsed\n })()\n : undefined,\n }),\n }),\n [existingContractor, defaultValues],\n )\n\n // Form setup\n const formMethods = useForm<ContractorProfileFormData, unknown, ContractorProfileFormData>({\n resolver: zodResolver(validationSchema),\n defaultValues: formDefaultValues,\n ...(existingContractor && { values: formDefaultValues }),\n resetOptions: { keepDirtyValues: true },\n })\n\n const { handleSubmit, formState } = formMethods\n\n // Watch form values for conditional rendering\n const watchedType = useWatch({ control: formMethods.control, name: 'contractorType' })\n const watchedWageType = useWatch({ control: formMethods.control, name: 'wageType' })\n const watchedSelfOnboarding = useWatch({\n control: formMethods.control,\n name: 'selfOnboarding',\n })\n\n // Helper function to transform form data to API payload\n const transformFormDataToCreatePayload = (\n data: ContractorProfileFormData,\n ): ContractorCreateRequestBody => {\n const basePayload = {\n type: data.contractorType,\n wageType: data.wageType,\n startDate: formatDateToStringDate(data.startDate) || '',\n selfOnboarding: data.selfOnboarding,\n email: data.selfOnboarding ? data.email : undefined,\n hourlyRate: data.wageType === WageType.Hourly ? String(data.hourlyRate) : undefined,\n isActive: true,\n }\n\n if (data.contractorType === ContractorType.Individual) {\n return {\n ...basePayload,\n firstName: data.firstName,\n middleInitial: data.middleInitial || undefined,\n lastName: data.lastName,\n ssn: data.ssn,\n fileNewHireReport: false, // Default value\n }\n } else {\n return {\n ...basePayload,\n fileNewHireReport: false, // Default value\n businessName: data.businessName,\n ein: data.ein?.replace(/-/g, ''),\n }\n }\n }\n\n const transformFormDataToUpdatePayload = (\n data: ContractorProfileFormData,\n version: string,\n ): ContractorUpdateRequestBody => {\n const createPayload = transformFormDataToCreatePayload(data)\n return {\n ...createPayload,\n version,\n }\n }\n\n // Event handlers\n const onSubmit: SubmitHandler<ContractorProfileFormData> = async data => {\n await baseSubmitHandler(data, async payload => {\n let contractorId = existingContractor?.uuid\n if (existingContractor) {\n // Update existing contractor\n if (!existingContractor.version) {\n throw new SDKInternalError('Contractor version is required for updates')\n }\n const version = existingContractor.version\n const apiPayload = transformFormDataToUpdatePayload(payload, version)\n\n const updateResponse = await updateContractor({\n request: {\n contractorUuid: contractorId!,\n contractorUpdateRequestBody: apiPayload,\n },\n })\n\n onEvent(componentEvents.CONTRACTOR_UPDATED, updateResponse.contractor)\n } else {\n // Create new contractor\n const apiPayload = transformFormDataToCreatePayload(payload)\n\n const createResponse = await createContractor({\n request: {\n companyUuid: companyId,\n contractorCreateRequestBody: apiPayload,\n },\n })\n\n contractorId = createResponse.contractor?.uuid\n onEvent(componentEvents.CONTRACTOR_CREATED, createResponse.contractor)\n }\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n selfOnboarding:\n payload.selfOnboarding &&\n existingContractor?.onboardingStatus !==\n ContractorOnboardingStatus.ADMIN_ONBOARDING_REVIEW,\n contractorId,\n })\n })\n }\n\n // Conditional rendering helpers\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion\n const shouldShowEmailField = !!watchedSelfOnboarding\n const shouldShowBusinessFields = watchedType === ContractorType.Business\n const shouldShowIndividualFields = watchedType === ContractorType.Individual\n const shouldShowHourlyRate = watchedWageType === WageType.Hourly\n const shouldShowSsnField = watchedType === ContractorType.Individual && !watchedSelfOnboarding\n const shouldShowEinField = watchedType === ContractorType.Business && !watchedSelfOnboarding\n\n // Form field options\n const contractorTypeOptions = [\n { label: 'Individual', value: ContractorType.Individual },\n { label: 'Business', value: ContractorType.Business },\n ]\n\n const wageTypeOptions = [\n { label: 'Hourly', value: WageType.Hourly },\n { label: 'Fixed', value: WageType.Fixed },\n ]\n\n // Determine if we're currently submitting (creating or updating)\n const isSubmitting = isCreating || isUpdating\n // Return only what the component actually needs\n return {\n // Form methods and submission\n formMethods,\n handleSubmit: handleSubmit(onSubmit),\n formState: {\n ...formState,\n isSubmitting,\n },\n\n // Conditional rendering flags\n shouldShowEmailField,\n shouldShowBusinessFields,\n shouldShowIndividualFields,\n shouldShowHourlyRate,\n shouldShowSsnField,\n shouldShowEinField,\n\n // Form options\n contractorTypeOptions,\n wageTypeOptions,\n\n // Component state\n isEditing: !!contractorId,\n }\n}\n"],"names":["WageType","ApiWageType","ContractorType","ApiContractorType","ContractorProfileSchema","z","NAME_REGEX","createContractorProfileValidationSchema","hasSsn","hasEin","data","ctx","cleanSSN","removeNonDigits","SSN_REGEX","normalizedEin","normalizeEin","useContractorProfile","companyId","contractorId","defaultValues","existingContractor","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","validationSchema","createContractor","isCreating","useContractorsCreateMutation","updateContractor","isUpdating","useContractorsUpdateMutation","formDefaultValues","useMemo","ContractorSelfOnboardingStatuses","parsed","formMethods","useForm","zodResolver","handleSubmit","formState","watchedType","useWatch","watchedWageType","watchedSelfOnboarding","transformFormDataToCreatePayload","basePayload","formatDateToStringDate","transformFormDataToUpdatePayload","version","onSubmit","payload","SDKInternalError","apiPayload","updateResponse","componentEvents","createResponse","ContractorOnboardingStatus","shouldShowEmailField","shouldShowBusinessFields","shouldShowIndividualFields","shouldShowHourlyRate","shouldShowSsnField","shouldShowEinField","contractorTypeOptions","wageTypeOptions","isSubmitting"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,MAAMA,IAAWC,GACXC,IAAiBC,GAGxBC,KAA0BC,EAAE,OAAO;AAAA;AAAA,EAEvC,gBAAgBA,EAAE,QAAA;AAAA,EAClB,OAAOA,EAAE,OAAA,EAAS,MAAA,EAAQ,SAAA;AAAA;AAAA,EAG1B,gBAAgBA,EAAE,KAAK,CAACH,EAAe,YAAYA,EAAe,QAAQ,CAAC;AA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AS,MAAA;AAAA,EAAM,GAIpCqE,IAAevC,KAAcG;AAEnC,SAAO;AAAA;AAAA,IAEL,aAAAM;AAAA,IACA,cAAcG,EAAaW,CAAQ;AAAA,IACnC,WAAW;AAAA,MACT,GAAGV;AAAA,MACH,cAAA0B;AAAA,IAAA;AAAA;AAAA,IAIF,sBAAAR;AAAA,IACA,0BAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,oBAAAC;AAAA;AAAA,IAGA,uBAAAC;AAAA,IACA,iBAAAC;AAAA;AAAA,IAGA,WAAW,CAAC,CAACjD;AAAA,EAAA;AAEjB;"}
|
package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js
CHANGED
|
@@ -12,7 +12,7 @@ import { Form as N } from "../../../../Common/Form/Form.js";
|
|
|
12
12
|
import { useComponentDictionary as O, useI18n as S } from "../../../../../i18n/I18n.js";
|
|
13
13
|
import { composeErrorHandler as p } from "../../../../../partner-hook-utils/composeErrorHandler.js";
|
|
14
14
|
import { composeSubmitHandler as T } from "../../../../../partner-hook-utils/form/composeSubmitHandler.js";
|
|
15
|
-
import { componentEvents as
|
|
15
|
+
import { componentEvents as l } from "../../../../../shared/constants.js";
|
|
16
16
|
function k({ dictionary: n, ...r }) {
|
|
17
17
|
return O("Employee.Compensation", n), /* @__PURE__ */ e(M, { componentName: "Employee.Compensation.Management", children: /* @__PURE__ */ e(_, { ...r }) });
|
|
18
18
|
}
|
|
@@ -22,13 +22,16 @@ function _({
|
|
|
22
22
|
defaultValues: f,
|
|
23
23
|
...u
|
|
24
24
|
}) {
|
|
25
|
-
const
|
|
26
|
-
if (
|
|
27
|
-
const o = p([
|
|
25
|
+
const a = L({ employeeId: n }, { enabled: !!n });
|
|
26
|
+
if (a.isLoading || !a.data) {
|
|
27
|
+
const o = p([a]);
|
|
28
28
|
return /* @__PURE__ */ e(c, { isLoading: !0, error: o.errors });
|
|
29
29
|
}
|
|
30
|
-
const
|
|
31
|
-
|
|
30
|
+
const s = a.data.jobs?.find((o) => o.uuid === r), t = s?.compensations?.find((o) => o.uuid === s.currentCompensationUuid), i = t ? {
|
|
31
|
+
// Title lives on compensation in the API — `job.title` can lag
|
|
32
|
+
// behind comp-level edits on secondaries, so seed directly from
|
|
33
|
+
// the comp.
|
|
34
|
+
title: t.title ?? void 0,
|
|
32
35
|
flsaStatus: t.flsaStatus ?? void 0,
|
|
33
36
|
rate: Number(t.rate),
|
|
34
37
|
paymentUnit: t.paymentUnit ?? void 0,
|
|
@@ -38,7 +41,7 @@ function _({
|
|
|
38
41
|
} : void 0;
|
|
39
42
|
return /* @__PURE__ */ e(j, { employeeId: n, jobId: r, defaultValues: i, ...u });
|
|
40
43
|
}
|
|
41
|
-
function j({ employeeId: n, jobId: r, defaultValues: f, onCancel: u, className:
|
|
44
|
+
function j({ employeeId: n, jobId: r, defaultValues: f, onCancel: u, className: a, onEvent: s }) {
|
|
42
45
|
S("Employee.Compensation");
|
|
43
46
|
const { t } = F("Employee.Compensation"), i = h({
|
|
44
47
|
employeeId: n,
|
|
@@ -63,11 +66,11 @@ function j({ employeeId: n, jobId: r, defaultValues: f, onCancel: u, className:
|
|
|
63
66
|
const E = T([i, o], async () => {
|
|
64
67
|
const m = await i.actions.onSubmit();
|
|
65
68
|
if (!m) return;
|
|
66
|
-
|
|
67
|
-
const
|
|
68
|
-
|
|
69
|
+
s(l.EMPLOYEE_JOB_UPDATED, m.data);
|
|
70
|
+
const d = await o.actions.onSubmit();
|
|
71
|
+
d && (s(l.EMPLOYEE_COMPENSATION_UPDATED, d.data), s(l.EMPLOYEE_COMPENSATION_DONE, d.data));
|
|
69
72
|
}), g = p([E]), b = i.status.isPending || o.status.isPending;
|
|
70
|
-
return /* @__PURE__ */ e("section", { className: C(y.container,
|
|
73
|
+
return /* @__PURE__ */ e("section", { className: C(y.container, a), children: /* @__PURE__ */ e(c, { error: g.errors, children: /* @__PURE__ */ e(N, { onSubmit: E.handleSubmit, children: /* @__PURE__ */ e(
|
|
71
74
|
P,
|
|
72
75
|
{
|
|
73
76
|
jobForm: i,
|
package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditCompensation.js","sources":["../../../../../../src/components/Employee/Compensation/management/EditCompensation/EditCompensation.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport { useTranslation } from 'react-i18next'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobForm } from '../../shared/useJobForm'\nimport { useCompensationForm, type CompensationFormData } from '../../shared/useCompensationForm'\nimport { ManagementCompensationFormBody } from '../ManagementCompensationFormBody'\nimport styles from './EditCompensation.module.scss'\nimport { BaseBoundaries, BaseLayout, type CommonComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { composeSubmitHandler } from '@/partner-hook-utils/form/composeSubmitHandler'\nimport { componentEvents, type EventType } from '@/shared/constants'\n\nexport interface EditCompensationProps extends CommonComponentInterface<'Employee.Compensation'> {\n employeeId: string\n jobId: string\n onCancel?: () => void\n /** Called with `EMPLOYEE_COMPENSATION_UPDATED` then `EMPLOYEE_COMPENSATION_DONE` on a successful save. Use `EMPLOYEE_COMPENSATION_DONE` to trigger navigation. */\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport function EditCompensation({ dictionary, ...props }: EditCompensationProps) {\n useComponentDictionary('Employee.Compensation', dictionary)\n return (\n <BaseBoundaries componentName=\"Employee.Compensation.Management\">\n <CompensationDefaultsLoader {...props} />\n </BaseBoundaries>\n )\n}\n\ntype LoaderProps = Omit<EditCompensationProps, 'dictionary'>\n\n// Fetches the current job's compensation data to pre-populate the form as\n// defaultValues before rendering Root. Uses the same non-suspense query that\n// useCompensationForm uses internally — React Query dedupes the request so no\n// extra network call is made once Root mounts.\n// defaultValues from CommonComponentInterface (unknown) is excluded from the\n// spread so it doesn't conflict with Root's typed defaultValues prop.\nfunction CompensationDefaultsLoader({\n employeeId,\n jobId,\n defaultValues: _baseDefaults,\n ...rest\n}: LoaderProps) {\n const jobsQuery = useJobsAndCompensationsGetJobs({ employeeId }, { enabled: !!employeeId })\n\n if (jobsQuery.isLoading || !jobsQuery.data) {\n const errorHandling = composeErrorHandler([jobsQuery])\n return <BaseLayout isLoading error={errorHandling.errors} />\n }\n\n const job = jobsQuery.data.jobs?.find(j => j.uuid === jobId)\n const currentComp = job?.compensations?.find(c => c.uuid === job.currentCompensationUuid)\n\n const defaultValues: Partial<CompensationFormData> | undefined = currentComp\n ? {\n title: currentComp.title ??
|
|
1
|
+
{"version":3,"file":"EditCompensation.js","sources":["../../../../../../src/components/Employee/Compensation/management/EditCompensation/EditCompensation.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport { useTranslation } from 'react-i18next'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobForm } from '../../shared/useJobForm'\nimport { useCompensationForm, type CompensationFormData } from '../../shared/useCompensationForm'\nimport { ManagementCompensationFormBody } from '../ManagementCompensationFormBody'\nimport styles from './EditCompensation.module.scss'\nimport { BaseBoundaries, BaseLayout, type CommonComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { composeSubmitHandler } from '@/partner-hook-utils/form/composeSubmitHandler'\nimport { componentEvents, type EventType } from '@/shared/constants'\n\nexport interface EditCompensationProps extends CommonComponentInterface<'Employee.Compensation'> {\n employeeId: string\n jobId: string\n onCancel?: () => void\n /** Called with `EMPLOYEE_COMPENSATION_UPDATED` then `EMPLOYEE_COMPENSATION_DONE` on a successful save. Use `EMPLOYEE_COMPENSATION_DONE` to trigger navigation. */\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport function EditCompensation({ dictionary, ...props }: EditCompensationProps) {\n useComponentDictionary('Employee.Compensation', dictionary)\n return (\n <BaseBoundaries componentName=\"Employee.Compensation.Management\">\n <CompensationDefaultsLoader {...props} />\n </BaseBoundaries>\n )\n}\n\ntype LoaderProps = Omit<EditCompensationProps, 'dictionary'>\n\n// Fetches the current job's compensation data to pre-populate the form as\n// defaultValues before rendering Root. Uses the same non-suspense query that\n// useCompensationForm uses internally — React Query dedupes the request so no\n// extra network call is made once Root mounts.\n// defaultValues from CommonComponentInterface (unknown) is excluded from the\n// spread so it doesn't conflict with Root's typed defaultValues prop.\nfunction CompensationDefaultsLoader({\n employeeId,\n jobId,\n defaultValues: _baseDefaults,\n ...rest\n}: LoaderProps) {\n const jobsQuery = useJobsAndCompensationsGetJobs({ employeeId }, { enabled: !!employeeId })\n\n if (jobsQuery.isLoading || !jobsQuery.data) {\n const errorHandling = composeErrorHandler([jobsQuery])\n return <BaseLayout isLoading error={errorHandling.errors} />\n }\n\n const job = jobsQuery.data.jobs?.find(j => j.uuid === jobId)\n const currentComp = job?.compensations?.find(c => c.uuid === job.currentCompensationUuid)\n\n const defaultValues: Partial<CompensationFormData> | undefined = currentComp\n ? {\n // Title lives on compensation in the API — `job.title` can lag\n // behind comp-level edits on secondaries, so seed directly from\n // the comp.\n title: currentComp.title ?? undefined,\n flsaStatus: currentComp.flsaStatus ?? undefined,\n rate: Number(currentComp.rate),\n paymentUnit: currentComp.paymentUnit ?? undefined,\n adjustForMinimumWage: currentComp.adjustForMinimumWage ?? false,\n minimumWageId: currentComp.minimumWages?.[0]?.uuid ?? '',\n // effectiveDate intentionally omitted — user must choose a future date\n }\n : undefined\n\n return <Root employeeId={employeeId} jobId={jobId} defaultValues={defaultValues} {...rest} />\n}\n\ninterface RootProps extends LoaderProps {\n defaultValues?: Partial<CompensationFormData>\n}\n\nfunction Root({ employeeId, jobId, defaultValues, onCancel, className, onEvent }: RootProps) {\n useI18n('Employee.Compensation')\n const { t } = useTranslation('Employee.Compensation')\n\n // Job form handles the non-effective-dated fields: 2% shareholder + WA WC.\n // Title is suppressed here because the compensation form owns title\n // (effective-dated alongside rate/unit/FLSA on the future-dated row).\n // Hire-date is suppressed because this surface never edits it.\n const jobForm = useJobForm({\n employeeId,\n jobId,\n withTitleField: false,\n withHireDateField: false,\n shouldFocusError: false,\n })\n\n // Compensation form runs in create mode (no compensationId) → POST\n // /v1/jobs/:jobId/compensations, creating a new future-dated compensation.\n // The form is pre-populated with the current comp's values via defaultValues\n // (fetched by CompensationDefaultsLoader) so the user can edit from the\n // current state, and picks a future effectiveDate to schedule the change.\n const compensationForm = useCompensationForm({\n employeeId,\n jobId,\n defaultValues,\n withEffectiveDateField: true,\n optionalFieldsToRequire: {\n create: ['title'],\n },\n shouldFocusError: false,\n })\n\n if (jobForm.isLoading || compensationForm.isLoading) {\n const loadingErrorHandling = composeErrorHandler([jobForm, compensationForm])\n return <BaseLayout isLoading error={loadingErrorHandling.errors} />\n }\n\n // PUT job first (immediate mutation of 2% shareholder / WC), then POST\n // the new compensation (the future-dated change). composeSubmitHandler\n // validates both forms in parallel and short-circuits before any network\n // I/O if either fails.\n const submitResult = composeSubmitHandler([jobForm, compensationForm], async () => {\n const jobResult = await jobForm.actions.onSubmit()\n if (!jobResult) return\n\n onEvent(componentEvents.EMPLOYEE_JOB_UPDATED, jobResult.data)\n\n const compensationResult = await compensationForm.actions.onSubmit()\n if (!compensationResult) return\n\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_UPDATED, compensationResult.data)\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_DONE, compensationResult.data)\n })\n\n const errorHandling = composeErrorHandler([submitResult])\n const isPending = jobForm.status.isPending || compensationForm.status.isPending\n\n return (\n <section className={classNames(styles.container, className)}>\n <BaseLayout error={errorHandling.errors}>\n <Form onSubmit={submitResult.handleSubmit}>\n <ManagementCompensationFormBody\n jobForm={jobForm}\n compensationForm={compensationForm}\n title={t('management.editCompensationTitle')}\n submitCtaLabel={t('management.saveCta')}\n isPending={isPending}\n onCancel={onCancel}\n />\n </Form>\n </BaseLayout>\n </section>\n )\n}\n"],"names":["EditCompensation","dictionary","props","useComponentDictionary","jsx","BaseBoundaries","CompensationDefaultsLoader","employeeId","jobId","_baseDefaults","rest","jobsQuery","useJobsAndCompensationsGetJobs","errorHandling","composeErrorHandler","BaseLayout","job","j","currentComp","c","defaultValues","Root","onCancel","className","onEvent","useI18n","useTranslation","jobForm","useJobForm","compensationForm","useCompensationForm","loadingErrorHandling","submitResult","composeSubmitHandler","jobResult","componentEvents","compensationResult","isPending","classNames","styles","Form","ManagementCompensationFormBody"],"mappings":";;;;;;;;;;;;;;;AAuBO,SAASA,EAAiB,EAAE,YAAAC,GAAY,GAAGC,KAAgC;AAChF,SAAAC,EAAuB,yBAAyBF,CAAU,GAExD,gBAAAG,EAACC,KAAe,eAAc,oCAC5B,4BAACC,GAAA,EAA4B,GAAGJ,GAAO,EAAA,CACzC;AAEJ;AAUA,SAASI,EAA2B;AAAA,EAClC,YAAAC;AAAA,EACA,OAAAC;AAAA,EACA,eAAeC;AAAA,EACf,GAAGC;AACL,GAAgB;AACd,QAAMC,IAAYC,EAA+B,EAAE,YAAAL,EAAA,GAAc,EAAE,SAAS,CAAC,CAACA,GAAY;AAE1F,MAAII,EAAU,aAAa,CAACA,EAAU,MAAM;AAC1C,UAAME,IAAgBC,EAAoB,CAACH,CAAS,CAAC;AACrD,6BAAQI,GAAA,EAAW,WAAS,IAAC,OAAOF,EAAc,QAAQ;AAAA,EAC5D;AAEA,QAAMG,IAAML,EAAU,KAAK,MAAM,KAAK,CAAAM,MAAKA,EAAE,SAAST,CAAK,GACrDU,IAAcF,GAAK,eAAe,KAAK,OAAKG,EAAE,SAASH,EAAI,uBAAuB,GAElFI,IAA2DF,IAC7D;AAAA;AAAA;AAAA;AAAA,IAIE,OAAOA,EAAY,SA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1D,IAAKO,MAELZ,EAAQW,EAAgB,+BAA+BC,EAAmB,IAAI,GAC9EZ,EAAQW,EAAgB,4BAA4BC,EAAmB,IAAI;AAAA,EAC7E,CAAC,GAEKvB,IAAgBC,EAAoB,CAACkB,CAAY,CAAC,GAClDK,IAAYV,EAAQ,OAAO,aAAaE,EAAiB,OAAO;AAEtE,2BACG,WAAA,EAAQ,WAAWS,EAAWC,EAAO,WAAWhB,CAAS,GACxD,UAAA,gBAAAnB,EAACW,GAAA,EAAW,OAAOF,EAAc,QAC/B,4BAAC2B,GAAA,EAAK,UAAUR,EAAa,cAC3B,UAAA,gBAAA5B;AAAA,IAACqC;AAAA,IAAA;AAAA,MACC,SAAAd;AAAA,MACA,kBAAAE;AAAA,MACA,OAAO,EAAE,kCAAkC;AAAA,MAC3C,gBAAgB,EAAE,oBAAoB;AAAA,MACtC,WAAAQ;AAAA,MACA,UAAAf;AAAA,IAAA;AAAA,EAAA,EACF,CACF,GACF,GACF;AAEJ;"}
|
|
@@ -31,8 +31,6 @@ function H({
|
|
|
31
31
|
jobId: r,
|
|
32
32
|
withTitleField: !1,
|
|
33
33
|
withHireDateField: i,
|
|
34
|
-
// hireDate is optional by default in update mode — promote it so the form
|
|
35
|
-
// validates it and the label doesn't show "(optional)".
|
|
36
34
|
optionalFieldsToRequire: i ? { update: ["hireDate"] } : void 0,
|
|
37
35
|
shouldFocusError: !1
|
|
38
36
|
}), t = T({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditPendingCompensation.js","sources":["../../../../../../src/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport { useTranslation } from 'react-i18next'\nimport { useJobForm } from '../../shared/useJobForm'\nimport { useCompensationForm } from '../../shared/useCompensationForm'\nimport { ManagementCompensationFormBody } from '../ManagementCompensationFormBody'\nimport styles from './EditPendingCompensation.module.scss'\nimport { BaseBoundaries, BaseLayout, type CommonComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { composeSubmitHandler } from '@/partner-hook-utils/form/composeSubmitHandler'\nimport { componentEvents, type EventType } from '@/shared/constants'\n\nexport interface EditPendingCompensationProps extends CommonComponentInterface<'Employee.Compensation'> {\n employeeId: string\n jobId: string\n /** The UUID of the pending (future-dated) compensation to update. Always required — this\n * component only operates in update mode. */\n compensationId: string\n /**\n * True when the job has no current (on-or-before-today) compensation — i.e. it hasn't\n * started yet. Drives which date field is shown and how the submit syncs hire_date.\n */\n isNewJob: boolean\n /**\n * True when this is the employee's primary job. Combined with `isNewJob`, determines\n * whether to show a Hire date field (primary) or Effective date field (secondary/change).\n */\n isPrimaryJob: boolean\n onCancel?: () => void\n /** Called with `EMPLOYEE_COMPENSATION_UPDATED` then `EMPLOYEE_COMPENSATION_DONE` on a\n * successful save. Use `EMPLOYEE_COMPENSATION_DONE` to trigger navigation. */\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport function EditPendingCompensation({ dictionary, ...props }: EditPendingCompensationProps) {\n useComponentDictionary('Employee.Compensation', dictionary)\n return (\n <BaseBoundaries componentName=\"Employee.Compensation.Management\">\n <Root {...props} />\n </BaseBoundaries>\n )\n}\n\ntype RootProps = Omit<EditPendingCompensationProps, 'dictionary'>\n\nfunction Root({\n employeeId,\n jobId,\n compensationId,\n isNewJob,\n isPrimaryJob,\n onCancel,\n className,\n onEvent,\n}: RootProps) {\n useI18n('Employee.Compensation')\n const { t } = useTranslation('Employee.Compensation')\n\n // For a primary new job (hire date in the future, no current comp), the hire\n // date field is shown instead of the effective date field. This keeps\n // hire_date and comp effective_date in sync so the API doesn't auto-create a\n // second compensation when the initial comp moves off the hire date.\n const isPrimaryNewJob = isNewJob && isPrimaryJob\n\n
|
|
1
|
+
{"version":3,"file":"EditPendingCompensation.js","sources":["../../../../../../src/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport { useTranslation } from 'react-i18next'\nimport { useJobForm } from '../../shared/useJobForm'\nimport { useCompensationForm } from '../../shared/useCompensationForm'\nimport { ManagementCompensationFormBody } from '../ManagementCompensationFormBody'\nimport styles from './EditPendingCompensation.module.scss'\nimport { BaseBoundaries, BaseLayout, type CommonComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { composeSubmitHandler } from '@/partner-hook-utils/form/composeSubmitHandler'\nimport { componentEvents, type EventType } from '@/shared/constants'\n\nexport interface EditPendingCompensationProps extends CommonComponentInterface<'Employee.Compensation'> {\n employeeId: string\n jobId: string\n /** The UUID of the pending (future-dated) compensation to update. Always required — this\n * component only operates in update mode. */\n compensationId: string\n /**\n * True when the job has no current (on-or-before-today) compensation — i.e. it hasn't\n * started yet. Drives which date field is shown and how the submit syncs hire_date.\n */\n isNewJob: boolean\n /**\n * True when this is the employee's primary job. Combined with `isNewJob`, determines\n * whether to show a Hire date field (primary) or Effective date field (secondary/change).\n */\n isPrimaryJob: boolean\n onCancel?: () => void\n /** Called with `EMPLOYEE_COMPENSATION_UPDATED` then `EMPLOYEE_COMPENSATION_DONE` on a\n * successful save. Use `EMPLOYEE_COMPENSATION_DONE` to trigger navigation. */\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport function EditPendingCompensation({ dictionary, ...props }: EditPendingCompensationProps) {\n useComponentDictionary('Employee.Compensation', dictionary)\n return (\n <BaseBoundaries componentName=\"Employee.Compensation.Management\">\n <Root {...props} />\n </BaseBoundaries>\n )\n}\n\ntype RootProps = Omit<EditPendingCompensationProps, 'dictionary'>\n\nfunction Root({\n employeeId,\n jobId,\n compensationId,\n isNewJob,\n isPrimaryJob,\n onCancel,\n className,\n onEvent,\n}: RootProps) {\n useI18n('Employee.Compensation')\n const { t } = useTranslation('Employee.Compensation')\n\n // For a primary new job (hire date in the future, no current comp), the hire\n // date field is shown instead of the effective date field. This keeps\n // hire_date and comp effective_date in sync so the API doesn't auto-create a\n // second compensation when the initial comp moves off the hire date.\n const isPrimaryNewJob = isNewJob && isPrimaryJob\n\n // Title is owned by `useCompensationForm` here: title is stored on\n // compensation in the API (job.title is just a denormalized snapshot of\n // the primary comp's title), so writing it via PUT /v1/compensations is\n // the direct path. The dashboard row reads the title off the comp pointed\n // to by `currentCompensationUuid`, so the change surfaces immediately\n // whether the job is in effect today or still pending.\n const jobForm = useJobForm({\n employeeId,\n jobId,\n withTitleField: false,\n withHireDateField: isPrimaryNewJob,\n optionalFieldsToRequire: isPrimaryNewJob ? { update: ['hireDate'] } : undefined,\n shouldFocusError: false,\n })\n\n const compensationForm = useCompensationForm({\n employeeId,\n jobId,\n compensationId,\n // Primary new job: comp date is set via jobForm's hire date on submit —\n // hide it here to avoid showing two date fields.\n withEffectiveDateField: !isPrimaryNewJob,\n optionalFieldsToRequire: {\n update: isPrimaryNewJob\n ? ['title', 'flsaStatus', 'rate', 'paymentUnit']\n : ['title', 'flsaStatus', 'rate', 'paymentUnit', 'effectiveDate'],\n },\n shouldFocusError: false,\n })\n\n if (jobForm.isLoading || compensationForm.isLoading) {\n const loadingErrorHandling = composeErrorHandler([jobForm, compensationForm])\n return <BaseLayout isLoading error={loadingErrorHandling.errors} />\n }\n\n const submitResult = composeSubmitHandler([jobForm, compensationForm], async () => {\n // For a primary new job, the user edits the hire date field. We read it\n // back here and pass it to the comp submit so both the job's hire_date and\n // the comp's effective_date land on the same value — preventing the API\n // from auto-creating a second compensation to fill the gap at the old date.\n const hireDateOverride = isPrimaryNewJob\n ? (jobForm.form.hookFormInternals.formMethods.getValues('hireDate') ?? undefined)\n : undefined\n\n const jobResult = await jobForm.actions.onSubmit()\n if (!jobResult) return\n\n onEvent(componentEvents.EMPLOYEE_JOB_UPDATED, jobResult.data)\n\n // When the hire date moves forward, the API auto-syncs the compensation's\n // effective_date to the new hire_date as part of the job PUT, which bumps\n // the compensation's version. Read it from the job response so the\n // subsequent compensation PUT doesn't send a stale version.\n const freshCompVersion = jobResult.data.compensations?.find(\n c => c.uuid === compensationId,\n )?.version\n\n const compensationResult = await compensationForm.actions.onSubmit({\n ...(hireDateOverride ? { effectiveDate: hireDateOverride } : {}),\n compensationVersion: freshCompVersion,\n })\n if (!compensationResult) return\n\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_UPDATED, compensationResult.data)\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_DONE, compensationResult.data)\n })\n\n const errorHandling = composeErrorHandler([submitResult])\n const isPending = jobForm.status.isPending || compensationForm.status.isPending\n\n return (\n <section className={classNames(styles.container, className)}>\n <BaseLayout error={errorHandling.errors}>\n <Form onSubmit={submitResult.handleSubmit}>\n <ManagementCompensationFormBody\n jobForm={jobForm}\n compensationForm={compensationForm}\n title={t('management.editCompensationTitle')}\n submitCtaLabel={t('management.saveCta')}\n isPending={isPending}\n onCancel={onCancel}\n />\n </Form>\n </BaseLayout>\n </section>\n )\n}\n"],"names":["EditPendingCompensation","dictionary","props","useComponentDictionary","jsx","BaseBoundaries","Root","employeeId","jobId","compensationId","isNewJob","isPrimaryJob","onCancel","className","onEvent","useI18n","t","useTranslation","isPrimaryNewJob","jobForm","useJobForm","compensationForm","useCompensationForm","loadingErrorHandling","composeErrorHandler","BaseLayout","submitResult","composeSubmitHandler","hireDateOverride","jobResult","componentEvents","freshCompVersion","c","compensationResult","errorHandling","isPending","classNames","styles","Form","ManagementCompensationFormBody"],"mappings":";;;;;;;;;;;;;;AAoCO,SAASA,EAAwB,EAAE,YAAAC,GAAY,GAAGC,KAAuC;AAC9F,SAAAC,EAAuB,yBAAyBF,CAAU,GAExD,gBAAAG,EAACC,KAAe,eAAc,oCAC5B,4BAACC,GAAA,EAAM,GAAGJ,GAAO,EAAA,CACnB;AAEJ;A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