@gusto/embedded-react-sdk 0.45.0 → 0.46.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +20 -4
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +20 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +22 -6
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +20 -4
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +20 -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 +28 -12
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +23 -7
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +20 -4
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +20 -4
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +20 -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 +20 -4
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +20 -4
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/useAddress.js +22 -6
- package/dist/components/Contractor/Address/useAddress.js.map +1 -1
- package/dist/components/Contractor/Profile/useContractorProfile.js +52 -42
- package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
- package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.d.ts +11 -0
- package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js +230 -0
- package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js.map +1 -0
- package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.module.scss.js +8 -0
- package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.module.scss.js.map +1 -0
- package/dist/components/Employee/Compensation/management/EditCompensation/index.d.ts +3 -0
- package/dist/components/Employee/Compensation/management/index.d.ts +3 -0
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js +6 -6
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js +4 -4
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +114 -111
- 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/jobSchema.d.ts +8 -0
- package/dist/components/Employee/Compensation/shared/useJobForm/jobSchema.js +22 -17
- package/dist/components/Employee/Compensation/shared/useJobForm/jobSchema.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.d.ts +12 -2
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +115 -110
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
- package/dist/components/Employee/Dashboard/BasicDetailsView.d.ts +8 -3
- package/dist/components/Employee/Dashboard/BasicDetailsView.js +108 -84
- package/dist/components/Employee/Dashboard/BasicDetailsView.js.map +1 -1
- package/dist/components/Employee/Dashboard/Dashboard.d.ts +2 -0
- package/dist/components/Employee/Dashboard/Dashboard.js +64 -58
- package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Employee/Dashboard/DashboardComponents.d.ts +5 -1
- package/dist/components/Employee/Dashboard/DashboardComponents.js +82 -65
- package/dist/components/Employee/Dashboard/DashboardComponents.js.map +1 -1
- package/dist/components/Employee/Dashboard/DocumentsView.js +18 -11
- package/dist/components/Employee/Dashboard/DocumentsView.js.map +1 -1
- package/dist/components/Employee/Dashboard/JobAndPayView.js +358 -338
- package/dist/components/Employee/Dashboard/JobAndPayView.js.map +1 -1
- package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js +8 -0
- package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js.map +1 -0
- package/dist/components/Employee/Dashboard/TaxesView.d.ts +7 -2
- package/dist/components/Employee/Dashboard/TaxesView.js +68 -54
- package/dist/components/Employee/Dashboard/TaxesView.js.map +1 -1
- package/dist/components/Employee/Dashboard/dashboardStateMachine.js +16 -5
- package/dist/components/Employee/Dashboard/dashboardStateMachine.js.map +1 -1
- package/dist/components/Employee/Dashboard/hooks/useEmployeeBasicDetails.d.ts +12 -5
- package/dist/components/Employee/Dashboard/hooks/useEmployeeBasicDetails.js +21 -21
- package/dist/components/Employee/Dashboard/hooks/useEmployeeBasicDetails.js.map +1 -1
- package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.d.ts +13 -3
- package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js +55 -56
- package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js.map +1 -1
- package/dist/components/Employee/Dashboard/hooks/useEmployeeForms.d.ts +10 -4
- package/dist/components/Employee/Dashboard/hooks/useEmployeeForms.js +10 -12
- package/dist/components/Employee/Dashboard/hooks/useEmployeeForms.js.map +1 -1
- package/dist/components/Employee/Dashboard/hooks/useEmployeeTaxes.d.ts +10 -3
- package/dist/components/Employee/Dashboard/hooks/useEmployeeTaxes.js +19 -14
- package/dist/components/Employee/Dashboard/hooks/useEmployeeTaxes.js.map +1 -1
- 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 +20 -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/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/useWorkAddressForm/fields.js +4 -4
- package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +8 -8
- package/dist/components/Employee/Taxes/useTaxes.js +20 -4
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +34 -26
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +36 -22
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/components/TimeOff/PolicySettings/PolicySettingsPresentation.js +52 -40
- package/dist/components/TimeOff/PolicySettings/PolicySettingsPresentation.js.map +1 -1
- package/dist/i18n/en/Employee.Compensation.json.js +48 -44
- package/dist/i18n/en/Employee.Compensation.json.js.map +1 -1
- package/dist/i18n/en/Employee.Dashboard.json.js +1 -1
- package/dist/i18n/en/Employee.DocumentManager.json.js +1 -1
- package/dist/i18n/en/common.json.d.ts +7 -0
- package/dist/shared/constants.d.ts +2 -0
- package/dist/shared/constants.js +19 -18
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +22 -2
- package/package.json +1 -1
package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as t, jsxs as R } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
3
|
-
import
|
|
2
|
+
import { useState as W } from "react";
|
|
3
|
+
import I from "classnames";
|
|
4
4
|
import { useTranslation as U, Trans as g } from "react-i18next";
|
|
5
5
|
import { useJobForm as D } from "../../shared/useJobForm/useJobForm.js";
|
|
6
6
|
import { useCompensationForm as H } from "../../shared/useCompensationForm/useCompensationForm.js";
|
|
@@ -31,7 +31,7 @@ function J({
|
|
|
31
31
|
onEvent: m
|
|
32
32
|
}) {
|
|
33
33
|
j("Employee.Compensation");
|
|
34
|
-
const [a, n] =
|
|
34
|
+
const [a, n] = W(c ?? void 0), o = D({
|
|
35
35
|
employeeId: i,
|
|
36
36
|
jobId: a,
|
|
37
37
|
// The Compensation flow does not surface a hire-date field — the date is
|
|
@@ -82,7 +82,7 @@ function J({
|
|
|
82
82
|
r.data
|
|
83
83
|
);
|
|
84
84
|
const M = r.data.compensations?.find(
|
|
85
|
-
(
|
|
85
|
+
(T) => T.uuid === r.data.currentCompensationUuid
|
|
86
86
|
), C = await d.actions.onSubmit({
|
|
87
87
|
jobId: r.data.uuid,
|
|
88
88
|
compensationId: r.data.currentCompensationUuid ?? void 0,
|
|
@@ -94,7 +94,7 @@ function J({
|
|
|
94
94
|
}
|
|
95
95
|
m(E.EMPLOYEE_COMPENSATION_UPDATED, C.data);
|
|
96
96
|
}), S = L([b]), k = o.status.isPending || d.status.isPending;
|
|
97
|
-
return /* @__PURE__ */ t("section", { className:
|
|
97
|
+
return /* @__PURE__ */ t("section", { className: I(O.container, l), children: /* @__PURE__ */ t(v, { error: S.errors, children: /* @__PURE__ */ t(P, { onSubmit: b.handleSubmit, children: /* @__PURE__ */ t(
|
|
98
98
|
Q,
|
|
99
99
|
{
|
|
100
100
|
jobForm: o,
|
|
@@ -124,7 +124,7 @@ function Q({
|
|
|
124
124
|
status: "warning"
|
|
125
125
|
}
|
|
126
126
|
),
|
|
127
|
-
/* @__PURE__ */ t(
|
|
127
|
+
a.Title && /* @__PURE__ */ t(
|
|
128
128
|
a.Title,
|
|
129
129
|
{
|
|
130
130
|
label: e("jobTitle"),
|
package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EditCompensation.js","sources":["../../../../../../src/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.tsx"],"sourcesContent":["import { useState } from 'react'\nimport classNames from 'classnames'\nimport { Trans, useTranslation } from 'react-i18next'\nimport type { PaymentUnit } from '@gusto/embedded-api/models/components/compensation'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport type { CompensationDefaultValues } from '../Compensation'\nimport { useJobForm, type UseJobFormReady } from '../../shared/useJobForm'\nimport {\n useCompensationForm,\n type UseCompensationFormReady,\n} from '../../shared/useCompensationForm'\nimport styles from './EditCompensation.module.scss'\nimport { BaseBoundaries, BaseLayout, type CommonComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { ActionsLayout, Flex } from '@/components/Common'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { composeSubmitHandler } from '@/partner-hook-utils/form/composeSubmitHandler'\nimport { componentEvents, FLSA_OVERTIME_SALARY_LIMIT, type EventType } from '@/shared/constants'\nimport useNumberFormatter from '@/hooks/useNumberFormatter'\n\nexport interface EditCompensationProps extends CommonComponentInterface<'Employee.Compensation'> {\n employeeId: string\n startDate: string\n currentJobId?: string | null\n title: string\n submitCtaLabel: string\n onCancel?: () => void\n partnerDefaultValues?: CompensationDefaultValues\n /**\n * Receives the broadcast events: `EMPLOYEE_JOB_CREATED` / `EMPLOYEE_JOB_UPDATED`\n * (with the saved `Job`), then `EMPLOYEE_COMPENSATION_UPDATED` (with the saved\n * `Compensation`) on a successful submit chain. Use `EMPLOYEE_COMPENSATION_UPDATED`\n * for \"save complete\" branching.\n */\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\">\n <Root {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction Root({\n employeeId,\n startDate,\n currentJobId,\n title,\n submitCtaLabel,\n onCancel,\n partnerDefaultValues,\n className,\n onEvent,\n}: EditCompensationProps) {\n useI18n('Employee.Compensation')\n\n // Track jobId locally so a partial-failure submit chain (job POST succeeds,\n // comp PUT fails) doesn't re-POST and create a duplicate job on retry. We\n // initialize from the prop and only write back when the partner-supplied\n // `currentJobId` was nullish (i.e. add-job flow) — see the submit handler.\n const [resolvedJobId, setResolvedJobId] = useState<string | undefined>(currentJobId ?? undefined)\n\n const jobForm = useJobForm({\n employeeId,\n jobId: resolvedJobId,\n // The Compensation flow does not surface a hire-date field — the date is\n // derived from the employee's `startDate` (passed via submit options\n // below). Hiding via the hook flag also drops the field from the schema\n // so partner forms don't silently fail validation on create.\n withHireDateField: false,\n defaultValues: {\n title: partnerDefaultValues?.title ?? '',\n },\n // The Compensation flow always shows a job title field, even when editing\n // an existing job. The hook's schema only requires `title` on create; we\n // require it on update too to preserve the existing UX.\n optionalFieldsToRequire: { update: ['title'] },\n shouldFocusError: false,\n })\n\n // Resolve the compensationId from the job we just loaded so the comp form can\n // seed from the existing comp on edit. While the job form is still loading we\n // pass undefined (compensation form starts in create mode); once the job\n // resolves the prop change re-renders the comp form into update mode with the\n // existing compensation as the seed.\n const resolvedCompensationId = jobForm.isLoading\n ? undefined\n : (jobForm.data.currentJob?.currentCompensationUuid ?? undefined)\n\n const compensationForm = useCompensationForm({\n employeeId,\n jobId: resolvedJobId,\n compensationId: resolvedCompensationId,\n // No effective-date field is surfaced, and no `effectiveDate` is\n // threaded into `actions.onSubmit` either: the server initializes\n // `effective_date` on the auto-stub created by the parent job POST,\n // and subsequent updates omit it from the PUT body so the existing\n // value is preserved (e.g. a deliberately-set future-dated comp\n // wouldn't be silently overwritten on an unrelated edit).\n withEffectiveDateField: false,\n // The Compensation flow always presents flsaStatus, rate, and paymentUnit\n // as required, even when editing an existing compensation. The hook's\n // schema marks them `'create'`-only by default; we promote them on update\n // here to preserve the existing UX (no \"(optional)\" labels).\n optionalFieldsToRequire: { update: ['flsaStatus', 'rate', 'paymentUnit'] },\n defaultValues: {\n flsaStatus: partnerDefaultValues?.flsaStatus,\n rate:\n typeof partnerDefaultValues?.rate === 'number'\n ? partnerDefaultValues.rate\n : partnerDefaultValues?.rate\n ? Number(partnerDefaultValues.rate)\n : undefined,\n paymentUnit: partnerDefaultValues?.paymentUnit,\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 const jobResult = await jobForm.actions.onSubmit({ employeeId, hireDate: startDate })\n if (!jobResult) return\n\n onEvent(\n jobResult.mode === 'create'\n ? componentEvents.EMPLOYEE_JOB_CREATED\n : componentEvents.EMPLOYEE_JOB_UPDATED,\n jobResult.data,\n )\n\n // Always thread through the freshly returned job's currentCompensationUuid +\n // its version so we PUT against the latest comp regardless of whether the job\n // POST just auto-created the stub or the job PUT bumped a version.\n const stubCompensation = jobResult.data.compensations?.find(\n c => c.uuid === jobResult.data.currentCompensationUuid,\n )\n\n const compensationResult = await compensationForm.actions.onSubmit({\n jobId: jobResult.data.uuid,\n compensationId: jobResult.data.currentCompensationUuid ?? undefined,\n compensationVersion: stubCompensation?.version ?? undefined,\n })\n if (!compensationResult) {\n if (!currentJobId) setResolvedJobId(jobResult.data.uuid)\n return\n }\n\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_UPDATED, compensationResult.data)\n })\n\n const errorHandling = composeErrorHandler([submitResult])\n\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 <FormBody\n jobForm={jobForm}\n compensationForm={compensationForm}\n title={title}\n submitCtaLabel={submitCtaLabel}\n isPending={isPending}\n onCancel={onCancel}\n />\n </Form>\n </BaseLayout>\n </section>\n )\n}\n\ninterface FormBodyProps {\n jobForm: UseJobFormReady\n compensationForm: UseCompensationFormReady\n title: string\n submitCtaLabel: string\n isPending: boolean\n onCancel?: () => void\n}\n\nfunction FormBody({\n jobForm,\n compensationForm,\n title,\n submitCtaLabel,\n isPending,\n onCancel,\n}: FormBodyProps) {\n const { t } = useTranslation('Employee.Compensation')\n const Components = useComponentContext()\n const format = useNumberFormatter('currency')\n\n const JobFields = jobForm.form.Fields\n const CompFields = compensationForm.form.Fields\n\n return (\n <Flex flexDirection=\"column\" gap={32}>\n <Components.Heading as=\"h2\">{title}</Components.Heading>\n\n {compensationForm.status.willDeleteSecondaryJobs && (\n <Components.Alert\n label={t('validations.classificationChangeNotification')}\n status=\"warning\"\n />\n )}\n\n <JobFields.Title\n label={t('jobTitle')}\n validationMessages={{ REQUIRED: t('validations.title') }}\n formHookResult={jobForm}\n />\n\n {CompFields.FlsaStatus && (\n <CompFields.FlsaStatus\n label={t('employeeClassification')}\n description={\n <Trans\n t={t}\n i18nKey=\"classificationLink\"\n components={{ ClassificationLink: <Components.Link /> }}\n />\n }\n validationMessages={{\n REQUIRED: t('validations.exemptThreshold', {\n limit: format(FLSA_OVERTIME_SALARY_LIMIT),\n }),\n }}\n getOptionLabel={(status: FlsaStatusType) => t(`flsaStatusLabels.${status}`)}\n formHookResult={compensationForm}\n />\n )}\n\n <CompFields.Rate\n label={t('amount')}\n validationMessages={{\n REQUIRED: t('validations.rate'),\n RATE_MINIMUM: t('validations.nonZeroRate'),\n RATE_EXEMPT_THRESHOLD: t('validations.rateExemptThreshold', {\n limit: format(FLSA_OVERTIME_SALARY_LIMIT),\n }),\n }}\n formHookResult={compensationForm}\n />\n\n <CompFields.PaymentUnit\n label={t('paymentUnitLabel')}\n description={t('paymentUnitDescription')}\n validationMessages={{ REQUIRED: t('validations.paymentUnit') }}\n getOptionLabel={(unit: PaymentUnit) => t(`paymentUnitOptions.${unit}`)}\n formHookResult={compensationForm}\n />\n\n {CompFields.AdjustForMinimumWage && (\n <CompFields.AdjustForMinimumWage\n label={t('adjustForMinimumWage')}\n description={t('adjustForMinimumWageDescription')}\n formHookResult={compensationForm}\n />\n )}\n\n {CompFields.MinimumWageId && (\n <CompFields.MinimumWageId\n label={t('minimumWageLabel')}\n description={t('minimumWageDescription')}\n validationMessages={{ REQUIRED: t('validations.minimumWage') }}\n getOptionLabel={(wage: MinimumWage) =>\n `${format(Number(wage.wage))} - ${wage.authority}: ${wage.notes ?? ''}`\n }\n formHookResult={compensationForm}\n />\n )}\n\n {JobFields.TwoPercentShareholder && (\n <JobFields.TwoPercentShareholder\n label={t('twoPercentStakeholderLabel')}\n formHookResult={jobForm}\n />\n )}\n\n {JobFields.StateWcCovered && (\n <JobFields.StateWcCovered\n label={t('stateWcCoveredLabel')}\n description={\n <Trans\n t={t}\n i18nKey=\"stateWcCoveredDescription\"\n components={{\n wcLink: (\n <Components.Link\n href=\"https://www.lni.wa.gov/insurance/rates-risk-classes/risk-classes-for-workers-compensation/risk-class-lookup#/\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n />\n ),\n }}\n />\n }\n getOptionLabel={(covered: boolean) =>\n covered ? t('stateWcCoveredOptions.yes') : t('stateWcCoveredOptions.no')\n }\n formHookResult={jobForm}\n />\n )}\n\n {JobFields.StateWcClassCode && (\n <JobFields.StateWcClassCode\n label={t('stateWcClassCodeLabel')}\n description={t('stateWcClassCodeDescription')}\n placeholder={t('stateWcClassCodeLabel')}\n validationMessages={{ REQUIRED: t('validations.stateWcClassCode') }}\n formHookResult={jobForm}\n />\n )}\n\n <ActionsLayout>\n {onCancel && (\n <Components.Button variant=\"secondary\" onClick={onCancel} isDisabled={isPending}>\n {t('cancelNewJobCta')}\n </Components.Button>\n )}\n <Components.Button type=\"submit\" isLoading={isPending}>\n {submitCtaLabel}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n )\n}\n"],"names":["EditCompensation","dictionary","props","useComponentDictionary","jsx","BaseBoundaries","Root","employeeId","startDate","currentJobId","title","submitCtaLabel","onCancel","partnerDefaultValues","className","onEvent","useI18n","resolvedJobId","setResolvedJobId","useState","jobForm","useJobForm","resolvedCompensationId","compensationForm","useCompensationForm","loadingErrorHandling","composeErrorHandler","BaseLayout","submitResult","composeSubmitHandler","jobResult","componentEvents","stubCompensation","c","compensationResult","errorHandling","isPending","classNames","styles","Form","FormBody","t","useTranslation","Components","useComponentContext","format","useNumberFormatter","JobFields","CompFields","jsxs","Flex","Trans","FLSA_OVERTIME_SALARY_LIMIT","status","unit","wage","covered","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;;;AAyCO,SAASA,GAAiB,EAAE,YAAAC,GAAY,GAAGC,KAAgC;AAChF,SAAAC,EAAuB,yBAAyBF,CAAU,GAExD,gBAAAG,EAACC,KAAe,eAAc,yBAC5B,4BAACC,GAAA,EAAM,GAAGJ,GAAO,EAAA,CACnB;AAEJ;AAEA,SAASI,EAAK;AAAA,EACZ,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,OAAAC;AAAA,EACA,gBAAAC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AAU;AAAA,MAAV;AAAA,QACC,OAAON,EAAE,qBAAqB;AAAA,QAC9B,aACE,gBAAArC;AAAA,UAAC+C;AAAA,UAAA;AAAA,YACC,GAAAV;AAAA,YACA,SAAQ;AAAA,YACR,YAAY;AAAA,cACV,QACE,gBAAArC;AAAA,gBAACuC,EAAW;AAAA,gBAAX;AAAA,kBACC,MAAK;AAAA,kBACL,QAAO;AAAA,kBACP,KAAI;AAAA,gBAAA;AAAA,cAAA;AAAA,YACN;AAAA,UAEJ;AAAA,QAAA;AAAA,QAGJ,gBAAgB,CAACa,MACLf,EAAVe,IAAY,8BAAiC,0BAAN;AAAA,QAEzC,gBAAgBpC;AAAA,MAAA;AAAA,IAAA;AAAA,IAInB2B,EAAU,oBACT,gBAAA3C;AAAA,MAAC2C,EAAU;AAAA,MAAV;AAAA,QACC,OAAON,EAAE,uBAAuB;AAAA,QAChC,aAAaA,EAAE,6BAA6B;AAAA,QAC5C,aAAaA,EAAE,uBAAuB;AAAA,QACtC,oBAAoB,EAAE,UAAUA,EAAE,8BAA8B,EAAA;AAAA,QAChE,gBAAgBrB;AAAA,MAAA;AAAA,IAAA;AAAA,sBAInBqC,GAAA,EACE,UAAA;AAAA,MAAA7C,KACC,gBAAAR,EAACuC,EAAW,QAAX,EAAkB,SAAQ,aAAY,SAAS/B,GAAU,YAAYwB,GACnE,UAAAK,EAAE,iBAAiB,EAAA,CACtB;AAAA,MAEF,gBAAArC,EAACuC,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAWP,GACzC,UAAAzB,EAAA,CACH;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"EditCompensation.js","sources":["../../../../../../src/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.tsx"],"sourcesContent":["import { useState } from 'react'\nimport classNames from 'classnames'\nimport { Trans, useTranslation } from 'react-i18next'\nimport type { PaymentUnit } from '@gusto/embedded-api/models/components/compensation'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport type { CompensationDefaultValues } from '../Compensation'\nimport { useJobForm, type UseJobFormReady } from '../../shared/useJobForm'\nimport {\n useCompensationForm,\n type UseCompensationFormReady,\n} from '../../shared/useCompensationForm'\nimport styles from './EditCompensation.module.scss'\nimport { BaseBoundaries, BaseLayout, type CommonComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { ActionsLayout, Flex } from '@/components/Common'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { composeSubmitHandler } from '@/partner-hook-utils/form/composeSubmitHandler'\nimport { componentEvents, FLSA_OVERTIME_SALARY_LIMIT, type EventType } from '@/shared/constants'\nimport useNumberFormatter from '@/hooks/useNumberFormatter'\n\nexport interface EditCompensationProps extends CommonComponentInterface<'Employee.Compensation'> {\n employeeId: string\n startDate: string\n currentJobId?: string | null\n title: string\n submitCtaLabel: string\n onCancel?: () => void\n partnerDefaultValues?: CompensationDefaultValues\n /**\n * Receives the broadcast events: `EMPLOYEE_JOB_CREATED` / `EMPLOYEE_JOB_UPDATED`\n * (with the saved `Job`), then `EMPLOYEE_COMPENSATION_UPDATED` (with the saved\n * `Compensation`) on a successful submit chain. Use `EMPLOYEE_COMPENSATION_UPDATED`\n * for \"save complete\" branching.\n */\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\">\n <Root {...props} />\n </BaseBoundaries>\n )\n}\n\nfunction Root({\n employeeId,\n startDate,\n currentJobId,\n title,\n submitCtaLabel,\n onCancel,\n partnerDefaultValues,\n className,\n onEvent,\n}: EditCompensationProps) {\n useI18n('Employee.Compensation')\n\n // Track jobId locally so a partial-failure submit chain (job POST succeeds,\n // comp PUT fails) doesn't re-POST and create a duplicate job on retry. We\n // initialize from the prop and only write back when the partner-supplied\n // `currentJobId` was nullish (i.e. add-job flow) — see the submit handler.\n const [resolvedJobId, setResolvedJobId] = useState<string | undefined>(currentJobId ?? undefined)\n\n const jobForm = useJobForm({\n employeeId,\n jobId: resolvedJobId,\n // The Compensation flow does not surface a hire-date field — the date is\n // derived from the employee's `startDate` (passed via submit options\n // below). Hiding via the hook flag also drops the field from the schema\n // so partner forms don't silently fail validation on create.\n withHireDateField: false,\n defaultValues: {\n title: partnerDefaultValues?.title ?? '',\n },\n // The Compensation flow always shows a job title field, even when editing\n // an existing job. The hook's schema only requires `title` on create; we\n // require it on update too to preserve the existing UX.\n optionalFieldsToRequire: { update: ['title'] },\n shouldFocusError: false,\n })\n\n // Resolve the compensationId from the job we just loaded so the comp form can\n // seed from the existing comp on edit. While the job form is still loading we\n // pass undefined (compensation form starts in create mode); once the job\n // resolves the prop change re-renders the comp form into update mode with the\n // existing compensation as the seed.\n const resolvedCompensationId = jobForm.isLoading\n ? undefined\n : (jobForm.data.currentJob?.currentCompensationUuid ?? undefined)\n\n const compensationForm = useCompensationForm({\n employeeId,\n jobId: resolvedJobId,\n compensationId: resolvedCompensationId,\n // No effective-date field is surfaced, and no `effectiveDate` is\n // threaded into `actions.onSubmit` either: the server initializes\n // `effective_date` on the auto-stub created by the parent job POST,\n // and subsequent updates omit it from the PUT body so the existing\n // value is preserved (e.g. a deliberately-set future-dated comp\n // wouldn't be silently overwritten on an unrelated edit).\n withEffectiveDateField: false,\n // The Compensation flow always presents flsaStatus, rate, and paymentUnit\n // as required, even when editing an existing compensation. The hook's\n // schema marks them `'create'`-only by default; we promote them on update\n // here to preserve the existing UX (no \"(optional)\" labels).\n optionalFieldsToRequire: { update: ['flsaStatus', 'rate', 'paymentUnit'] },\n defaultValues: {\n flsaStatus: partnerDefaultValues?.flsaStatus,\n rate:\n typeof partnerDefaultValues?.rate === 'number'\n ? partnerDefaultValues.rate\n : partnerDefaultValues?.rate\n ? Number(partnerDefaultValues.rate)\n : undefined,\n paymentUnit: partnerDefaultValues?.paymentUnit,\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 const jobResult = await jobForm.actions.onSubmit({ employeeId, hireDate: startDate })\n if (!jobResult) return\n\n onEvent(\n jobResult.mode === 'create'\n ? componentEvents.EMPLOYEE_JOB_CREATED\n : componentEvents.EMPLOYEE_JOB_UPDATED,\n jobResult.data,\n )\n\n // Always thread through the freshly returned job's currentCompensationUuid +\n // its version so we PUT against the latest comp regardless of whether the job\n // POST just auto-created the stub or the job PUT bumped a version.\n const stubCompensation = jobResult.data.compensations?.find(\n c => c.uuid === jobResult.data.currentCompensationUuid,\n )\n\n const compensationResult = await compensationForm.actions.onSubmit({\n jobId: jobResult.data.uuid,\n compensationId: jobResult.data.currentCompensationUuid ?? undefined,\n compensationVersion: stubCompensation?.version ?? undefined,\n })\n if (!compensationResult) {\n if (!currentJobId) setResolvedJobId(jobResult.data.uuid)\n return\n }\n\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_UPDATED, compensationResult.data)\n })\n\n const errorHandling = composeErrorHandler([submitResult])\n\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 <FormBody\n jobForm={jobForm}\n compensationForm={compensationForm}\n title={title}\n submitCtaLabel={submitCtaLabel}\n isPending={isPending}\n onCancel={onCancel}\n />\n </Form>\n </BaseLayout>\n </section>\n )\n}\n\ninterface FormBodyProps {\n jobForm: UseJobFormReady\n compensationForm: UseCompensationFormReady\n title: string\n submitCtaLabel: string\n isPending: boolean\n onCancel?: () => void\n}\n\nfunction FormBody({\n jobForm,\n compensationForm,\n title,\n submitCtaLabel,\n isPending,\n onCancel,\n}: FormBodyProps) {\n const { t } = useTranslation('Employee.Compensation')\n const Components = useComponentContext()\n const format = useNumberFormatter('currency')\n\n const JobFields = jobForm.form.Fields\n const CompFields = compensationForm.form.Fields\n\n return (\n <Flex flexDirection=\"column\" gap={32}>\n <Components.Heading as=\"h2\">{title}</Components.Heading>\n\n {compensationForm.status.willDeleteSecondaryJobs && (\n <Components.Alert\n label={t('validations.classificationChangeNotification')}\n status=\"warning\"\n />\n )}\n\n {JobFields.Title && (\n <JobFields.Title\n label={t('jobTitle')}\n validationMessages={{ REQUIRED: t('validations.title') }}\n formHookResult={jobForm}\n />\n )}\n\n {CompFields.FlsaStatus && (\n <CompFields.FlsaStatus\n label={t('employeeClassification')}\n description={\n <Trans\n t={t}\n i18nKey=\"classificationLink\"\n components={{ ClassificationLink: <Components.Link /> }}\n />\n }\n validationMessages={{\n REQUIRED: t('validations.exemptThreshold', {\n limit: format(FLSA_OVERTIME_SALARY_LIMIT),\n }),\n }}\n getOptionLabel={(status: FlsaStatusType) => t(`flsaStatusLabels.${status}`)}\n formHookResult={compensationForm}\n />\n )}\n\n <CompFields.Rate\n label={t('amount')}\n validationMessages={{\n REQUIRED: t('validations.rate'),\n RATE_MINIMUM: t('validations.nonZeroRate'),\n RATE_EXEMPT_THRESHOLD: t('validations.rateExemptThreshold', {\n limit: format(FLSA_OVERTIME_SALARY_LIMIT),\n }),\n }}\n formHookResult={compensationForm}\n />\n\n <CompFields.PaymentUnit\n label={t('paymentUnitLabel')}\n description={t('paymentUnitDescription')}\n validationMessages={{ REQUIRED: t('validations.paymentUnit') }}\n getOptionLabel={(unit: PaymentUnit) => t(`paymentUnitOptions.${unit}`)}\n formHookResult={compensationForm}\n />\n\n {CompFields.AdjustForMinimumWage && (\n <CompFields.AdjustForMinimumWage\n label={t('adjustForMinimumWage')}\n description={t('adjustForMinimumWageDescription')}\n formHookResult={compensationForm}\n />\n )}\n\n {CompFields.MinimumWageId && (\n <CompFields.MinimumWageId\n label={t('minimumWageLabel')}\n description={t('minimumWageDescription')}\n validationMessages={{ REQUIRED: t('validations.minimumWage') }}\n getOptionLabel={(wage: MinimumWage) =>\n `${format(Number(wage.wage))} - ${wage.authority}: ${wage.notes ?? ''}`\n }\n formHookResult={compensationForm}\n />\n )}\n\n {JobFields.TwoPercentShareholder && (\n <JobFields.TwoPercentShareholder\n label={t('twoPercentStakeholderLabel')}\n formHookResult={jobForm}\n />\n )}\n\n {JobFields.StateWcCovered && (\n <JobFields.StateWcCovered\n label={t('stateWcCoveredLabel')}\n description={\n <Trans\n t={t}\n i18nKey=\"stateWcCoveredDescription\"\n components={{\n wcLink: (\n <Components.Link\n href=\"https://www.lni.wa.gov/insurance/rates-risk-classes/risk-classes-for-workers-compensation/risk-class-lookup#/\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n />\n ),\n }}\n />\n }\n getOptionLabel={(covered: boolean) =>\n covered ? t('stateWcCoveredOptions.yes') : t('stateWcCoveredOptions.no')\n }\n formHookResult={jobForm}\n />\n )}\n\n {JobFields.StateWcClassCode && (\n <JobFields.StateWcClassCode\n label={t('stateWcClassCodeLabel')}\n description={t('stateWcClassCodeDescription')}\n placeholder={t('stateWcClassCodeLabel')}\n validationMessages={{ REQUIRED: t('validations.stateWcClassCode') }}\n formHookResult={jobForm}\n />\n )}\n\n <ActionsLayout>\n {onCancel && (\n <Components.Button variant=\"secondary\" onClick={onCancel} isDisabled={isPending}>\n {t('cancelNewJobCta')}\n </Components.Button>\n )}\n <Components.Button type=\"submit\" isLoading={isPending}>\n {submitCtaLabel}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n )\n}\n"],"names":["EditCompensation","dictionary","props","useComponentDictionary","jsx","BaseBoundaries","Root","employeeId","startDate","currentJobId","title","submitCtaLabel","onCancel","partnerDefaultValues","className","onEvent","useI18n","resolvedJobId","setResolvedJobId","useState","jobForm","useJobForm","resolvedCompensationId","compensationForm","useCompensationForm","loadingErrorHandling","composeErrorHandler","BaseLayout","submitResult","composeSubmitHandler","jobResult","componentEvents","stubCompensation","c","compensationResult","errorHandling","isPending","classNames","styles","Form","FormBody","t","useTranslation","Components","useComponentContext","format","useNumberFormatter","JobFields","CompFields","jsxs","Flex","Trans","FLSA_OVERTIME_SALARY_LIMIT","status","unit","wage","covered","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;;;AAyCO,SAASA,GAAiB,EAAE,YAAAC,GAAY,GAAGC,KAAgC;AAChF,SAAAC,EAAuB,yBAAyBF,CAAU,GAExD,gBAAAG,EAACC,KAAe,eAAc,yBAC5B,4BAACC,GAAA,EAAM,GAAGJ,GAAO,EAAA,CACnB;AAEJ;AAEA,SAASI,EAAK;AAAA,EACZ,YAAAC;AAAA,EACA,WAAAC;AAAA,EACA,cAAAC;AAAA,EACA,OAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,UAAAC;AAAA,EACA,sBAAAC;AAAA,EACA,WAAAC;AAAA,EACA,SAAAC;AACF,GAA0B;AACxB,EAAAC,EAAQ,uBAAuB;AAM/B,QAAM,CAACC,GAAeC,CAAgB,IAAIC,EAA6BV,KAAgB,MAAS,GAE1FW,IAAUC,EAAW;AAAA,IACzB,YAAAd;AAAA,IACA,OAAOU;AAAA;AAAA;AAAA;AAAA;AAAA,IAKP,mBAAmB;AAAA,IACnB,eAAe;AAAA,MACb,OAAOJ,GAAsB,SAAS;AAAA,IAAA;AAAA;AAAA;AAAA;AAAA,IAKxC,yBAAyB,EAAE,QAAQ,CAAC,OAAO,EAAA;AAAA,IAC3C,kBAAkB;AAAA,EAAA,CACnB,GAOKS,IAAyBF,EAAQ,YACnC,SACCA,EAAQ,KAAK,YAAY,2BAA2B,QAEnDG,IAAmBC,EAAoB;AAAA,IAC3C,YAAAjB;AAAA,IACA,OAAOU;AAAA,IACP,gBAAgBK;AAAA;AAAA;AAAA;AAAA;AA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C,oBAAoB,EAAE,UAAUA,EAAE,8BAA8B,EAAA;AAAA,QAChE,gBAAgBrB;AAAA,MAAA;AAAA,IAAA;AAAA,sBAInBqC,GAAA,EACE,UAAA;AAAA,MAAA7C,KACC,gBAAAR,EAACuC,EAAW,QAAX,EAAkB,SAAQ,aAAY,SAAS/B,GAAU,YAAYwB,GACnE,UAAAK,EAAE,iBAAiB,EAAA,CACtB;AAAA,MAEF,gBAAArC,EAACuC,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAWP,GACzC,UAAAzB,EAAA,CACH;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -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,
|
package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { useRef as X, useMemo as
|
|
2
|
-
import { useForm as De, useWatch as
|
|
1
|
+
import { useRef as X, useMemo as se, useEffect as V } from "react";
|
|
2
|
+
import { useForm as De, useWatch as oe } from "react-hook-form";
|
|
3
3
|
import { zodResolver as Ae } from "@hookform/resolvers/zod";
|
|
4
4
|
import { useJobsAndCompensationsGetJobs as Ie } from "@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs";
|
|
5
5
|
import { useJobsAndCompensationsCreateCompensationMutation as Ue } from "@gusto/embedded-api/react-query/jobsAndCompensationsCreateCompensation";
|
|
@@ -14,66 +14,66 @@ import { createGetFormSubmissionValues as He } from "../../../../../partner-hook
|
|
|
14
14
|
import { useDeriveFieldsMetadata as Be } from "../../../../../partner-hook-utils/form/useDeriveFieldsMetadata.js";
|
|
15
15
|
import { useHookFormInternals as Ge } from "../../../../../partner-hook-utils/form/useHookFormInternals.js";
|
|
16
16
|
import { composeErrorHandler as Ke } from "../../../../../partner-hook-utils/composeErrorHandler.js";
|
|
17
|
-
import {
|
|
17
|
+
import { FlsaStatus as n, PAY_PERIODS as l, TIP_CREDITS_UNSUPPORTED_STATES as Qe } from "../../../../../shared/constants.js";
|
|
18
18
|
import { useBaseSubmit as $e } from "../../../../Base/useBaseSubmit.js";
|
|
19
|
-
import { SDKInternalError as
|
|
20
|
-
function xe(e,
|
|
19
|
+
import { SDKInternalError as S } from "../../../../../types/sdkError.js";
|
|
20
|
+
function xe(e, s, o) {
|
|
21
21
|
if (!e) return { compensation: null, job: null };
|
|
22
|
-
if (
|
|
22
|
+
if (s) {
|
|
23
23
|
for (const i of e) {
|
|
24
|
-
const
|
|
25
|
-
if (
|
|
24
|
+
const r = i.compensations?.find((C) => C.uuid === s);
|
|
25
|
+
if (r) return { compensation: r, job: i };
|
|
26
26
|
}
|
|
27
27
|
return { compensation: null, job: null };
|
|
28
28
|
}
|
|
29
|
-
return
|
|
29
|
+
return o ? { compensation: null, job: e.find((i) => i.uuid === o) ?? null } : { compensation: null, job: null };
|
|
30
30
|
}
|
|
31
31
|
function ze(e) {
|
|
32
32
|
if (!e) return null;
|
|
33
|
-
for (const
|
|
34
|
-
if (!
|
|
35
|
-
const
|
|
36
|
-
if (
|
|
33
|
+
for (const s of e) {
|
|
34
|
+
if (!s.primary) continue;
|
|
35
|
+
const o = s.compensations?.find((i) => i.uuid === s.currentCompensationUuid);
|
|
36
|
+
if (o?.flsaStatus) return o.flsaStatus;
|
|
37
37
|
}
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
40
40
|
function Ze(e) {
|
|
41
41
|
if (!e?.compensations) return [];
|
|
42
|
-
const
|
|
43
|
-
return e.compensations.filter((
|
|
42
|
+
const s = re();
|
|
43
|
+
return e.compensations.filter((o) => o.effectiveDate !== void 0 && o.effectiveDate > s);
|
|
44
44
|
}
|
|
45
45
|
function et(e) {
|
|
46
|
-
return e.length === 0 ? null : e.reduce((
|
|
47
|
-
const i =
|
|
48
|
-
return i && (!
|
|
46
|
+
return e.length === 0 ? null : e.reduce((s, o) => {
|
|
47
|
+
const i = o.effectiveDate;
|
|
48
|
+
return i && (!s || i < s) ? i : s;
|
|
49
49
|
}, null);
|
|
50
50
|
}
|
|
51
51
|
const ie = [
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
52
|
+
n.EXEMPT,
|
|
53
|
+
n.SALARIED_NONEXEMPT,
|
|
54
|
+
n.NONEXEMPT,
|
|
55
|
+
n.OWNER,
|
|
56
|
+
n.COMMISSION_ONLY_EXEMPT,
|
|
57
|
+
n.COMMISSION_ONLY_NONEXEMPT
|
|
58
58
|
], tt = ie.map((e) => ({ value: e, label: e })), ae = [
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
l.HOUR,
|
|
60
|
+
l.WEEK,
|
|
61
|
+
l.MONTH,
|
|
62
|
+
l.YEAR,
|
|
63
|
+
l.PAYCHECK
|
|
64
64
|
], nt = ae.map((e) => ({ value: e, label: e }));
|
|
65
65
|
function re() {
|
|
66
66
|
return (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
67
67
|
}
|
|
68
|
-
function
|
|
68
|
+
function Ct({
|
|
69
69
|
employeeId: e,
|
|
70
|
-
jobId:
|
|
71
|
-
compensationId:
|
|
70
|
+
jobId: s,
|
|
71
|
+
compensationId: o,
|
|
72
72
|
optionalFieldsToRequire: i,
|
|
73
|
-
defaultValues:
|
|
73
|
+
defaultValues: r,
|
|
74
74
|
validationMode: C = "onSubmit",
|
|
75
75
|
shouldFocusError: ue = !0,
|
|
76
|
-
withEffectiveDateField:
|
|
76
|
+
withEffectiveDateField: y = !0
|
|
77
77
|
}) {
|
|
78
78
|
const P = Ie(
|
|
79
79
|
{ employeeId: e ?? "" },
|
|
@@ -81,37 +81,37 @@ function ht({
|
|
|
81
81
|
), D = je(
|
|
82
82
|
{ employeeId: e ?? "" },
|
|
83
83
|
{ enabled: !!e }
|
|
84
|
-
), A = we({ employeeId: e ?? "" }, { enabled: !!e }),
|
|
84
|
+
), A = we({ employeeId: e ?? "" }, { enabled: !!e }), f = P.data?.jobs, Y = D.data?.employeeWorkAddressesList?.find((t) => t.active), k = Y?.locationUuid, me = A.data?.employee, I = Te(
|
|
85
85
|
{ locationUuid: k ?? "" },
|
|
86
86
|
{ enabled: !!k }
|
|
87
|
-
),
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
), ce =
|
|
92
|
-
U.current === null &&
|
|
93
|
-
const W = U.current === !0 ? ze(
|
|
87
|
+
), F = I.data?.minimumWageList ?? [], { compensation: u, job: a } = xe(
|
|
88
|
+
f,
|
|
89
|
+
o,
|
|
90
|
+
s
|
|
91
|
+
), ce = f && a ? f.filter((t) => t.uuid !== a.uuid).length : 0, U = X(null);
|
|
92
|
+
U.current === null && f !== void 0 && (U.current = f.some((t) => t.primary));
|
|
93
|
+
const W = U.current === !0 ? ze(f) : null, R = a?.hireDate ?? null, q = Ze(a), de = q.length > 0, le = et(q), p = !o, T = p ? "create" : "update", j = p && W === n.NONEXEMPT && a?.primary !== !0, [H, fe] = se(
|
|
94
94
|
() => Le({
|
|
95
95
|
mode: T,
|
|
96
96
|
optionalFieldsToRequire: i,
|
|
97
97
|
hireDate: R,
|
|
98
|
-
withEffectiveDateField:
|
|
98
|
+
withEffectiveDateField: y
|
|
99
99
|
}),
|
|
100
|
-
[T, i, R,
|
|
101
|
-
), B = Y?.state, N =
|
|
100
|
+
[T, i, R, y]
|
|
101
|
+
), B = Y?.state, N = se(
|
|
102
102
|
() => ({
|
|
103
|
-
title:
|
|
103
|
+
title: u?.title ?? a?.title ?? r?.title ?? "",
|
|
104
104
|
// When adding a secondary, the FLSA must match the primary's — force it
|
|
105
105
|
// here (overriding any partner default) so the form submits the right
|
|
106
106
|
// value even though `Fields.FlsaStatus` is hidden.
|
|
107
|
-
flsaStatus: j ? W :
|
|
108
|
-
rate: Number(
|
|
109
|
-
adjustForMinimumWage:
|
|
110
|
-
minimumWageId:
|
|
111
|
-
paymentUnit:
|
|
112
|
-
effectiveDate:
|
|
107
|
+
flsaStatus: j ? W : u?.flsaStatus ?? r?.flsaStatus ?? W ?? void 0,
|
|
108
|
+
rate: Number(u?.rate ?? r?.rate ?? 0),
|
|
109
|
+
adjustForMinimumWage: u?.adjustForMinimumWage ?? r?.adjustForMinimumWage ?? !1,
|
|
110
|
+
minimumWageId: u?.minimumWages?.[0]?.uuid ?? r?.minimumWageId ?? "",
|
|
111
|
+
paymentUnit: u?.paymentUnit ?? r?.paymentUnit ?? l.HOUR,
|
|
112
|
+
effectiveDate: u?.effectiveDate ?? r?.effectiveDate ?? null
|
|
113
113
|
}),
|
|
114
|
-
[
|
|
114
|
+
[u, a, r, W, j]
|
|
115
115
|
), M = De({
|
|
116
116
|
resolver: Ae(H),
|
|
117
117
|
mode: C,
|
|
@@ -119,94 +119,97 @@ function ht({
|
|
|
119
119
|
defaultValues: N,
|
|
120
120
|
values: N,
|
|
121
121
|
resetOptions: { keepDirtyValues: !0 }
|
|
122
|
-
}), { control: G, getValues:
|
|
122
|
+
}), { control: G, getValues: v, setValue: m } = M, c = oe({ control: G, name: "flsaStatus" }), pe = oe({
|
|
123
123
|
control: G,
|
|
124
124
|
name: "adjustForMinimumWage"
|
|
125
125
|
});
|
|
126
126
|
V(() => {
|
|
127
|
-
|
|
128
|
-
}, [
|
|
129
|
-
const Ee =
|
|
127
|
+
c === n.OWNER ? m("paymentUnit", l.PAYCHECK) : c === n.COMMISSION_ONLY_NONEXEMPT || c === n.COMMISSION_ONLY_EXEMPT ? (m("paymentUnit", l.YEAR), m("rate", 0)) : m("paymentUnit", N.paymentUnit);
|
|
128
|
+
}, [c, m, N.paymentUnit]);
|
|
129
|
+
const Ee = a ? a.compensations?.find((t) => t.uuid === a.currentCompensationUuid) : void 0, g = (u?.flsaStatus ?? Ee?.flsaStatus ?? null) === n.NONEXEMPT && c !== void 0 && c !== n.NONEXEMPT && ce > 0, h = X(!1), w = X(null);
|
|
130
130
|
V(() => {
|
|
131
|
-
|
|
131
|
+
!p && g && !h.current ? (w.current = v("effectiveDate") ?? null, m("effectiveDate", re(), { shouldDirty: !0, shouldValidate: !1 }), h.current = !0) : !p && !g && h.current && (m("effectiveDate", w.current ?? null, {
|
|
132
132
|
shouldDirty: !0,
|
|
133
133
|
shouldValidate: !1
|
|
134
134
|
}), w.current = null, h.current = !1);
|
|
135
|
-
}, [
|
|
136
|
-
const K = Re(), Q = Ue(),
|
|
137
|
-
baseSubmitHandler:
|
|
135
|
+
}, [p, g, v, m]);
|
|
136
|
+
const K = Re(), Q = Ue(), Se = K.isPending || Q.isPending, {
|
|
137
|
+
baseSubmitHandler: Me,
|
|
138
138
|
error: ve,
|
|
139
139
|
setError: ge
|
|
140
|
-
} = $e("CompensationForm"), $ = Ke(e ? [P, D, A, I] : [], { submitError: ve, setSubmitError: ge }), x =
|
|
140
|
+
} = $e("CompensationForm"), $ = Ke(e ? [P, D, A, I] : [], { submitError: ve, setSubmitError: ge }), x = c === n.COMMISSION_ONLY_NONEXEMPT || c === n.COMMISSION_ONLY_EXEMPT, be = c === n.OWNER, Oe = !j && (c !== n.NONEXEMPT || a?.primary === !0 || p), b = c === n.NONEXEMPT && F.length > 0 && B !== void 0 && !Qe.includes(B);
|
|
141
141
|
V(() => {
|
|
142
|
-
|
|
143
|
-
}, [
|
|
144
|
-
const ye =
|
|
145
|
-
value:
|
|
146
|
-
label: `${
|
|
147
|
-
})),
|
|
148
|
-
title:
|
|
149
|
-
effectiveDate: {
|
|
142
|
+
b || (v("adjustForMinimumWage") && m("adjustForMinimumWage", !1, { shouldDirty: !0, shouldValidate: !1 }), v("minimumWageId") && m("minimumWageId", "", { shouldDirty: !0, shouldValidate: !1 }));
|
|
143
|
+
}, [b, v, m]);
|
|
144
|
+
const ye = F.map((t) => ({
|
|
145
|
+
value: t.uuid,
|
|
146
|
+
label: `${t.wage} - ${t.authority}: ${t.notes ?? ""}`
|
|
147
|
+
})), E = Be(fe, M.control), Fe = {
|
|
148
|
+
title: E.title,
|
|
149
|
+
effectiveDate: {
|
|
150
|
+
...E.effectiveDate,
|
|
151
|
+
isDisabled: g && !p
|
|
152
|
+
},
|
|
150
153
|
flsaStatus: J(
|
|
151
|
-
|
|
154
|
+
E.flsaStatus,
|
|
152
155
|
tt,
|
|
153
156
|
ie
|
|
154
157
|
),
|
|
155
|
-
rate: { ...
|
|
158
|
+
rate: { ...E.rate, isDisabled: x },
|
|
156
159
|
paymentUnit: J(
|
|
157
|
-
{ ...
|
|
160
|
+
{ ...E.paymentUnit, isDisabled: be || x },
|
|
158
161
|
nt,
|
|
159
162
|
ae
|
|
160
163
|
),
|
|
161
164
|
adjustForMinimumWage: {
|
|
162
|
-
...
|
|
163
|
-
isDisabled: !
|
|
165
|
+
...E.adjustForMinimumWage,
|
|
166
|
+
isDisabled: !b
|
|
164
167
|
},
|
|
165
168
|
minimumWageId: J(
|
|
166
|
-
|
|
169
|
+
E.minimumWageId,
|
|
167
170
|
ye,
|
|
168
|
-
|
|
171
|
+
F
|
|
169
172
|
)
|
|
170
|
-
},
|
|
173
|
+
}, We = async (t) => {
|
|
171
174
|
let z;
|
|
172
175
|
return await new Promise((Z) => {
|
|
173
176
|
M.handleSubmit(
|
|
174
177
|
async (Ce) => {
|
|
175
|
-
await
|
|
176
|
-
const ee =
|
|
177
|
-
rate: String(
|
|
178
|
-
paymentUnit:
|
|
179
|
-
flsaStatus:
|
|
178
|
+
await Me(Ce, async (d) => {
|
|
179
|
+
const ee = t?.jobId ?? s, L = t?.compensationId ?? o, te = L ? "update" : "create", Pe = y ? t?.effectiveDate ?? d.effectiveDate ?? void 0 : t?.effectiveDate ?? void 0, ne = {
|
|
180
|
+
rate: String(d.rate),
|
|
181
|
+
paymentUnit: d.paymentUnit,
|
|
182
|
+
flsaStatus: d.flsaStatus,
|
|
180
183
|
effectiveDate: Pe,
|
|
181
|
-
title:
|
|
182
|
-
adjustForMinimumWage:
|
|
183
|
-
minimumWages:
|
|
184
|
+
title: d.title || void 0,
|
|
185
|
+
adjustForMinimumWage: d.adjustForMinimumWage,
|
|
186
|
+
minimumWages: d.adjustForMinimumWage ? [{ uuid: d.minimumWageId }] : []
|
|
184
187
|
};
|
|
185
|
-
let
|
|
188
|
+
let O;
|
|
186
189
|
if (te === "create") {
|
|
187
190
|
if (!ee)
|
|
188
|
-
throw new
|
|
191
|
+
throw new S(
|
|
189
192
|
"jobId is required to create a compensation. Pass it as a hook prop or via submit options."
|
|
190
193
|
);
|
|
191
|
-
if (!
|
|
192
|
-
throw new
|
|
193
|
-
if (
|
|
194
|
+
if (!d.flsaStatus)
|
|
195
|
+
throw new S("flsaStatus is required to create a compensation.");
|
|
196
|
+
if (O = (await Q.mutateAsync({
|
|
194
197
|
request: {
|
|
195
198
|
jobId: ee,
|
|
196
|
-
compensationsRequestBody: { ...ne, flsaStatus:
|
|
199
|
+
compensationsRequestBody: { ...ne, flsaStatus: d.flsaStatus }
|
|
197
200
|
}
|
|
198
|
-
})).compensation, !
|
|
201
|
+
})).compensation, !O) throw new S("Compensation creation failed");
|
|
199
202
|
} else {
|
|
200
203
|
if (!L)
|
|
201
|
-
throw new
|
|
204
|
+
throw new S(
|
|
202
205
|
"compensationId is required to update a compensation. Pass it as a hook prop or via submit options."
|
|
203
206
|
);
|
|
204
|
-
const _ =
|
|
207
|
+
const _ = t?.compensationVersion ?? u?.version;
|
|
205
208
|
if (!_)
|
|
206
|
-
throw new
|
|
209
|
+
throw new S(
|
|
207
210
|
"compensation version is required to update a compensation. Pass it via submit options when threading post-create, or ensure the compensation is loaded."
|
|
208
211
|
);
|
|
209
|
-
if (
|
|
212
|
+
if (O = (await K.mutateAsync({
|
|
210
213
|
request: {
|
|
211
214
|
compensationId: L,
|
|
212
215
|
compensationsUpdateRequestBody: {
|
|
@@ -214,9 +217,9 @@ function ht({
|
|
|
214
217
|
...ne
|
|
215
218
|
}
|
|
216
219
|
}
|
|
217
|
-
})).compensation, !
|
|
220
|
+
})).compensation, !O) throw new S("Compensation update failed");
|
|
218
221
|
}
|
|
219
|
-
z = { mode: te, data:
|
|
222
|
+
z = { mode: te, data: O };
|
|
220
223
|
}), Z();
|
|
221
224
|
},
|
|
222
225
|
() => {
|
|
@@ -225,22 +228,22 @@ function ht({
|
|
|
225
228
|
)();
|
|
226
229
|
}), z;
|
|
227
230
|
}, Ne = e ? P.isLoading || D.isLoading || A.isLoading || I.isLoading : !1, he = Ge(M);
|
|
228
|
-
return Ne || e && (!
|
|
231
|
+
return Ne || e && (!f || !me) ? { isLoading: !0, errorHandling: $ } : {
|
|
229
232
|
isLoading: !1,
|
|
230
233
|
data: {
|
|
231
|
-
compensation:
|
|
232
|
-
currentJob:
|
|
233
|
-
minimumWages:
|
|
234
|
+
compensation: u,
|
|
235
|
+
currentJob: a,
|
|
236
|
+
minimumWages: F,
|
|
234
237
|
minimumEffectiveDate: R,
|
|
235
238
|
maximumEffectiveDate: le,
|
|
236
239
|
hasPendingFutureCompensation: de
|
|
237
240
|
},
|
|
238
241
|
status: {
|
|
239
|
-
isPending:
|
|
242
|
+
isPending: Se,
|
|
240
243
|
mode: T,
|
|
241
|
-
willDeleteSecondaryJobs:
|
|
244
|
+
willDeleteSecondaryJobs: g
|
|
242
245
|
},
|
|
243
|
-
actions: { onSubmit:
|
|
246
|
+
actions: { onSubmit: We },
|
|
244
247
|
errorHandling: $,
|
|
245
248
|
form: {
|
|
246
249
|
Fields: {
|
|
@@ -248,17 +251,17 @@ function ht({
|
|
|
248
251
|
FlsaStatus: Oe ? ke : void 0,
|
|
249
252
|
Rate: Ye,
|
|
250
253
|
PaymentUnit: Je,
|
|
251
|
-
AdjustForMinimumWage:
|
|
252
|
-
MinimumWageId:
|
|
253
|
-
EffectiveDate:
|
|
254
|
+
AdjustForMinimumWage: b ? Ve : void 0,
|
|
255
|
+
MinimumWageId: b && pe ? Xe : void 0,
|
|
256
|
+
EffectiveDate: y ? _e : void 0
|
|
254
257
|
},
|
|
255
|
-
fieldsMetadata:
|
|
258
|
+
fieldsMetadata: Fe,
|
|
256
259
|
hookFormInternals: he,
|
|
257
260
|
getFormSubmissionValues: He(M, H)
|
|
258
261
|
}
|
|
259
262
|
};
|
|
260
263
|
}
|
|
261
264
|
export {
|
|
262
|
-
|
|
265
|
+
Ct as useCompensationForm
|
|
263
266
|
};
|
|
264
267
|
//# sourceMappingURL=useCompensationForm.js.map
|