@gusto/embedded-react-sdk 0.46.0 → 0.46.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +50 -0
- package/dist/components/Common/DataView/DataCards/DataCards.d.ts +2 -1
- package/dist/components/Common/DataView/DataCards/DataCards.js +14 -13
- package/dist/components/Common/DataView/DataCards/DataCards.js.map +1 -1
- package/dist/components/Common/DataView/DataTable/DataTable.d.ts +2 -1
- package/dist/components/Common/DataView/DataTable/DataTable.js +51 -50
- package/dist/components/Common/DataView/DataTable/DataTable.js.map +1 -1
- package/dist/components/Common/DataView/DataView.d.ts +1 -0
- package/dist/components/Common/DataView/DataView.js.map +1 -1
- package/dist/components/Common/DataView/useDataView.d.ts +8 -1
- package/dist/components/Common/DataView/useDataView.js +20 -17
- package/dist/components/Common/DataView/useDataView.js.map +1 -1
- package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.d.ts +9 -0
- package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.js +76 -0
- package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.js.map +1 -0
- package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.module.scss.js +8 -0
- package/dist/components/Employee/Compensation/management/AddAnotherJob/AddAnotherJob.module.scss.js.map +1 -0
- package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js +57 -202
- package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js.map +1 -1
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.d.ts +25 -0
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js +81 -0
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.js.map +1 -0
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.module.scss.js +8 -0
- package/dist/components/Employee/Compensation/management/EditPendingCompensation/EditPendingCompensation.module.scss.js.map +1 -0
- package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.d.ts +18 -0
- package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js +171 -0
- package/dist/components/Employee/Compensation/management/ManagementCompensationFormBody.js.map +1 -0
- package/dist/components/Employee/Compensation/management/index.d.ts +3 -0
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.d.ts +6 -1
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js +67 -209
- package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.d.ts +18 -0
- package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.js +169 -0
- package/dist/components/Employee/Compensation/shared/AddCompensationFormBody.js.map +1 -0
- package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.d.ts +16 -0
- package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.js +36 -30
- package/dist/components/Employee/Compensation/shared/useCompensationForm/compensationSchema.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.d.ts +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +213 -191
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
- package/dist/components/Employee/Dashboard/Dashboard.js +65 -53
- package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Employee/Dashboard/DashboardComponents.d.ts +3 -3
- package/dist/components/Employee/Dashboard/DashboardComponents.js +138 -101
- package/dist/components/Employee/Dashboard/DashboardComponents.js.map +1 -1
- package/dist/components/Employee/Dashboard/JobAndPayView.js +340 -320
- package/dist/components/Employee/Dashboard/JobAndPayView.js.map +1 -1
- package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js +5 -3
- package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js.map +1 -1
- package/dist/components/Employee/Dashboard/dashboardStateMachine.js +147 -148
- package/dist/components/Employee/Dashboard/dashboardStateMachine.js.map +1 -1
- package/dist/components/Employee/Dashboard/getPendingCompensationChanges.d.ts +6 -0
- package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js +13 -12
- package/dist/components/Employee/Dashboard/getPendingCompensationChanges.js.map +1 -1
- package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.d.ts +2 -2
- package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js +34 -35
- package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js.map +1 -1
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeList.js +37 -40
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeList.js.map +1 -1
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.d.ts +1 -2
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.js +64 -71
- package/dist/components/Employee/EmployeeList/management/ManagementEmployeeListView.js.map +1 -1
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.d.ts +2 -0
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js +25 -0
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js.map +1 -0
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.d.ts +13 -0
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.js +37 -0
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.js.map +1 -0
- package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.d.ts +6 -0
- package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js +69 -0
- package/dist/components/Employee/EmployeeListFlow/employeeListStateMachine.js.map +1 -0
- package/dist/components/Employee/EmployeeListFlow/index.d.ts +3 -0
- package/dist/components/Employee/HomeAddress/management/HomeAddress.js +15 -12
- package/dist/components/Employee/HomeAddress/management/HomeAddress.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/HomeAddressView.d.ts +2 -1
- package/dist/components/Employee/HomeAddress/management/HomeAddressView.js +86 -83
- package/dist/components/Employee/HomeAddress/management/HomeAddressView.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddress.js +14 -11
- package/dist/components/Employee/WorkAddress/management/WorkAddress.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.d.ts +2 -1
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.js +92 -89
- package/dist/components/Employee/WorkAddress/management/WorkAddressView.js.map +1 -1
- package/dist/components/Employee/exports/employeeManagement.d.ts +2 -0
- package/dist/components/Employee/exports/employeeManagement.js +18 -16
- package/dist/components/Employee/exports/employeeManagement.js.map +1 -1
- package/dist/components/Employee/index.d.ts +2 -0
- package/dist/components/Employee/index.js +32 -30
- package/dist/components/Employee/index.js.map +1 -1
- package/dist/components/Flow/FlowHeader.js +34 -31
- package/dist/components/Flow/FlowHeader.js.map +1 -1
- package/dist/components/Flow/useFlow.d.ts +12 -0
- package/dist/components/Flow/useFlow.js.map +1 -1
- package/dist/components/TimeOff/PolicyList/PolicyList.js +92 -69
- package/dist/components/TimeOff/PolicyList/PolicyList.js.map +1 -1
- package/dist/components/TimeOff/PolicyList/PolicyListPresentation.js +23 -23
- package/dist/components/TimeOff/PolicyList/PolicyListPresentation.js.map +1 -1
- package/dist/components/TimeOff/TimeOffFlow/TimeOffFlowComponents.d.ts +1 -1
- package/dist/components/TimeOff/TimeOffFlow/TimeOffFlowComponents.js.map +1 -1
- package/dist/components/TimeOff/TimeOffFlow/timeOffStateMachine.js +73 -56
- package/dist/components/TimeOff/TimeOffFlow/timeOffStateMachine.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationForm.js +58 -58
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationForm.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.d.ts +1 -1
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.js +91 -87
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormPresentation.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/PolicyConfigurationForm/PolicyConfigurationFormTypes.d.ts +2 -0
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesHoliday.js +91 -124
- 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 +72 -87
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentation.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesPresentationTypes.d.ts +1 -6
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js +160 -220
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/SelectEmployeesTimeOff.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.d.ts +7 -3
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js +77 -54
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.js.map +1 -1
- package/dist/components/TimeOff/TimeOffManagement/SelectEmployees/useSelectEmployeesData.test.d.ts +1 -0
- package/dist/components/TimeOff/TimeOffPolicyDetail/EditEmployeeBalanceModal.js +12 -11
- package/dist/components/TimeOff/TimeOffPolicyDetail/EditEmployeeBalanceModal.js.map +1 -1
- package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetail.js +177 -147
- package/dist/components/TimeOff/TimeOffPolicyDetail/TimeOffPolicyDetail.js.map +1 -1
- package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.d.ts +1 -1
- package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js +38 -36
- package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTable.js.map +1 -1
- package/dist/components/TimeOff/shared/EmployeeTable/EmployeeTableTypes.d.ts +2 -0
- package/dist/i18n/en/Company.TimeOff.SelectEmployees.json.js +10 -10
- package/dist/i18n/en/Company.TimeOff.TimeOffPolicies.json.js +17 -15
- package/dist/i18n/en/Company.TimeOff.TimeOffPolicies.json.js.map +1 -1
- package/dist/i18n/en/Company.TimeOff.TimeOffPolicyDetails.json.js +9 -9
- package/dist/i18n/en/Employee.Compensation.json.js +64 -56
- package/dist/i18n/en/Employee.Compensation.json.js.map +1 -1
- package/dist/i18n/en/Employee.Dashboard.json.js +26 -24
- package/dist/i18n/en/Employee.Dashboard.json.js.map +1 -1
- package/dist/i18n/en/Employee.HomeAddress.Management.json.js +12 -10
- package/dist/i18n/en/Employee.HomeAddress.Management.json.js.map +1 -1
- package/dist/i18n/en/Employee.ManagementEmployeeList.json.js +32 -30
- package/dist/i18n/en/Employee.ManagementEmployeeList.json.js.map +1 -1
- package/dist/i18n/en/Employee.WorkAddress.Management.json.js +16 -14
- package/dist/i18n/en/Employee.WorkAddress.Management.json.js.map +1 -1
- package/dist/i18n/en/common.json.d.ts +14 -0
- package/dist/partner-hook-utils/form/fields/DatePickerHookField.js +33 -32
- package/dist/partner-hook-utils/form/fields/DatePickerHookField.js.map +1 -1
- package/dist/partner-hook-utils/types.d.ts +4 -0
- package/dist/shared/constants.d.ts +2 -0
- package/dist/shared/constants.js +13 -12
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +26 -12
- package/docs/reference/endpoint-inventory.json +24 -8
- package/package.json +1 -1
package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useCompensationForm.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Compensation, PaymentUnit } from '@gusto/embedded-api/models/components/compensation'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobsAndCompensationsCreateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateCompensation'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useLocationsGetMinimumWages } from '@gusto/embedded-api/react-query/locationsGetMinimumWages'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n createCompensationSchema,\n type CompensationOptionalFieldsToRequire,\n type CompensationFormData,\n type CompensationFormOutputs,\n} from './compensationSchema'\nimport {\n TitleField,\n FlsaStatusField,\n RateField,\n PaymentUnitField,\n AdjustForMinimumWageField,\n MinimumWageIdField,\n EffectiveDateField,\n} from './fields'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { FlsaStatus, PAY_PERIODS, TIP_CREDITS_UNSUPPORTED_STATES } from '@/shared/constants'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\n\nexport interface CompensationSubmitOptions {\n /** Override jobId — required when creating a compensation if not configured at hook construction (e.g. when the parent job was just created in the same submit chain). */\n jobId?: string\n /** Override compensationId — when present, forces update (PUT) routing regardless of hook construction. */\n compensationId?: string\n /**\n * Compensation version for optimistic locking on PUT. Required when forcing\n * update routing post-create (e.g. updating the auto-created stub returned\n * from `POST /v1/employees/:id/jobs`). When omitted, the hook reads the\n * version from its cached `currentCompensation`.\n */\n compensationVersion?: string\n /**\n * Supply `effectiveDate` at submit time. When `withEffectiveDateField`\n * is `true`, this overrides the form's value. When `withEffectiveDateField`\n * is `false`, this is the only way to put `effective_date` on the wire —\n * the form value is not read in that mode (matching the options-only\n * convention of `useWorkAddressForm` / `useHomeAddressForm` / `useJobForm`).\n */\n effectiveDate?: string\n}\n\nexport interface UseCompensationFormProps {\n employeeId?: string\n /** The parent job's UUID. Required in create mode (scopes `POST /v1/jobs/:jobId/compensations`). Optional in update mode — the parent job is derived from the loaded compensation. */\n jobId?: string\n /** Present → update mode (PUT /v1/compensations/:id). Omitted → create mode (POST /v1/jobs/:jobId/compensations). */\n compensationId?: string\n optionalFieldsToRequire?: CompensationOptionalFieldsToRequire\n defaultValues?: Partial<CompensationFormData>\n validationMode?: UseFormProps['mode']\n shouldFocusError?: boolean\n /**\n * When `false`, hides `Fields.EffectiveDate` (becomes `undefined`) and\n * removes `effectiveDate` from schema validation. In this mode the hook\n * does not read any form value at submit time — `effective_date` is\n * omitted from the request body unless explicitly supplied via\n * `CompensationSubmitOptions.effectiveDate`. This matches the\n * options-only convention of `useWorkAddressForm` /\n * `useHomeAddressForm` / `useJobForm`, and means the\n * `willDeleteSecondaryJobs` carve-out's form-state side effects do not\n * leak onto the wire (there is no field to render them in anyway).\n * Defaults to `true`.\n */\n withEffectiveDateField?: boolean\n}\n\nexport interface CompensationFormFields {\n Title: typeof TitleField\n FlsaStatus: typeof FlsaStatusField | undefined\n Rate: typeof RateField\n PaymentUnit: typeof PaymentUnitField\n AdjustForMinimumWage: typeof AdjustForMinimumWageField | undefined\n MinimumWageId: typeof MinimumWageIdField | undefined\n EffectiveDate: typeof EffectiveDateField | undefined\n}\n\nexport interface UseCompensationFormReady extends BaseFormHookReady<\n FieldsMetadata,\n CompensationFormData,\n CompensationFormFields\n> {\n data: {\n /** The compensation row loaded for update; `null` in create mode. */\n compensation: Compensation | null\n /** The parent job. In update mode it's derived from the loaded compensation; in create mode it's looked up by `jobId`. `null` if neither resolves. */\n currentJob: Job | null\n minimumWages: MinimumWage[]\n /** Lower bound for `effectiveDate` (typically the parent job's hire date). */\n minimumEffectiveDate: string | null\n /** Upper bound for `effectiveDate` — the next scheduled future compensation's effective date, when one exists. */\n maximumEffectiveDate: string | null\n /** True when at least one future-dated compensation already exists for this job. */\n hasPendingFutureCompensation: boolean\n }\n status: {\n isPending: boolean\n mode: 'create' | 'update'\n /**\n * True when submitting the form right now would delete the employee's\n * secondary jobs server-side (the \"carve-out\" branch). Reactive:\n * derived from the current `flsaStatus` form value, the loaded\n * compensation, and the other-jobs count, so this flips as you change\n * inputs.\n *\n * Conditions: update mode, the loaded compensation is Nonexempt, the\n * form's `flsaStatus` has been changed to a non-Nonexempt value, and\n * the employee has at least one secondary job.\n *\n * While this flag is true the hook also takes the `effectiveDate`\n * field over: it forces the form value to today (so submits route\n * through a PUT that immediately deletes secondaries) and exposes\n * `fieldsMetadata.effectiveDate.isDisabled = true` so `Fields.EffectiveDate`\n * renders as disabled. On revert (FLSA back to Nonexempt) the prior\n * `effectiveDate` is restored. Render an inline warning keyed off\n * this flag — no separate confirmation step is needed.\n */\n willDeleteSecondaryJobs: boolean\n }\n actions: {\n onSubmit: (\n options?: CompensationSubmitOptions,\n ) => Promise<HookSubmitResult<Compensation> | undefined>\n }\n}\n\nfunction resolveCompAndJob(\n jobs: Job[] | undefined,\n compensationId: string | undefined,\n jobId: string | undefined,\n): { compensation: Compensation | null; job: Job | null } {\n if (!jobs) return { compensation: null, job: null }\n if (compensationId) {\n for (const job of jobs) {\n const compensation = job.compensations?.find(c => c.uuid === compensationId)\n if (compensation) return { compensation, job }\n }\n return { compensation: null, job: null }\n }\n if (jobId) return { compensation: null, job: jobs.find(j => j.uuid === jobId) ?? null }\n return { compensation: null, job: null }\n}\n\nfunction findPrimaryFlsaStatus(jobs: Job[] | undefined): FlsaStatusType | null {\n if (!jobs) return null\n for (const job of jobs) {\n if (!job.primary) continue\n const compensation = job.compensations?.find(c => c.uuid === job.currentCompensationUuid)\n if (compensation?.flsaStatus) return compensation.flsaStatus\n }\n return null\n}\n\nfunction findFutureCompensations(job: Job | null): Compensation[] {\n if (!job?.compensations) return []\n const today = todayISO()\n return job.compensations.filter(c => c.effectiveDate !== undefined && c.effectiveDate > today)\n}\n\nfunction minEffectiveDate(comps: Compensation[]): string | null {\n if (comps.length === 0) return null\n return comps.reduce<string | null>((min, c) => {\n const d = c.effectiveDate\n if (!d) return min\n if (!min || d < min) return d\n return min\n }, null)\n}\n\nconst flsaStatusEntries: FlsaStatusType[] = [\n FlsaStatus.EXEMPT,\n FlsaStatus.SALARIED_NONEXEMPT,\n FlsaStatus.NONEXEMPT,\n FlsaStatus.OWNER,\n FlsaStatus.COMMISSION_ONLY_EXEMPT,\n FlsaStatus.COMMISSION_ONLY_NONEXEMPT,\n]\n\nconst flsaOptions = flsaStatusEntries.map(status => ({ value: status, label: status }))\n\nconst paymentUnitEntries: PaymentUnit[] = [\n PAY_PERIODS.HOUR,\n PAY_PERIODS.WEEK,\n PAY_PERIODS.MONTH,\n PAY_PERIODS.YEAR,\n PAY_PERIODS.PAYCHECK,\n]\n\nconst paymentUnitOptions = paymentUnitEntries.map(unit => ({ value: unit, label: unit }))\n\nfunction todayISO(): string {\n return new Date().toISOString().split('T')[0]!\n}\n\nexport function useCompensationForm({\n employeeId,\n jobId,\n compensationId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n withEffectiveDateField = true,\n}: UseCompensationFormProps): HookLoadingResult | UseCompensationFormReady {\n const jobsQuery = useJobsAndCompensationsGetJobs(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const addressesQuery = useEmployeeAddressesGetWorkAddresses(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const employeeQuery = useEmployeesGet({ employeeId: employeeId ?? '' }, { enabled: !!employeeId })\n\n const employeeJobs = jobsQuery.data?.jobs\n const workAddresses = addressesQuery.data?.employeeWorkAddressesList\n const currentWorkAddress = workAddresses?.find(address => address.active)\n const locationUuid = currentWorkAddress?.locationUuid\n const employee = employeeQuery.data?.employee\n\n const minWagesQuery = useLocationsGetMinimumWages(\n { locationUuid: locationUuid ?? '' },\n { enabled: !!locationUuid },\n )\n\n const minimumWages = minWagesQuery.data?.minimumWageList ?? []\n\n const { compensation: currentCompensation, job: currentJob } = resolveCompAndJob(\n employeeJobs,\n compensationId,\n jobId,\n )\n\n const otherJobsCount =\n employeeJobs && currentJob ? employeeJobs.filter(j => j.uuid !== currentJob.uuid).length : 0\n\n // Snapshot — written exactly once, on the first render where `employeeJobs`\n // is defined (i.e., the initial `getJobs` query has resolved) — capturing\n // whether the employee already had a primary job at that moment.\n //\n // Used to ignore the API-generated stub primary (FLSA Nonexempt, rate \"0.00\")\n // that briefly appears between the chained job POST and comp PUT during\n // onboarding: `getJobs` invalidates between the two mutations and\n // momentarily includes the stub, which would otherwise flip\n // `isAddingSecondaryJob` to true and hide `Fields.FlsaStatus` mid-submit.\n //\n // In steady-state flows (edit primary, edit secondary, add secondary), the\n // real primary already exists when the query first resolves, so the snapshot\n // is `true` and live `employeeJobs` continues to drive `primaryFlsaStatus`.\n // Recovery for the rare case where a partner mounts before any jobs exist\n // and a primary is created externally mid-form is to remount the hook\n // (e.g., via a `key` change).\n const hadPrimaryAtMountRef = useRef<boolean | null>(null)\n if (hadPrimaryAtMountRef.current === null && employeeJobs !== undefined) {\n hadPrimaryAtMountRef.current = employeeJobs.some(job => job.primary)\n }\n const hadPrimaryAtMount = hadPrimaryAtMountRef.current === true\n\n // FLSA status of the employee's primary job's current compensation, when one\n // exists. Used as a fallback default when adding a *secondary* job/comp so the\n // multi-job classification stays consistent with the primary by default — the\n // user can still override it (when allowed). Null when there was no primary\n // job at the moment the hook first observed `employeeJobs`, or when the\n // primary has no current compensation yet.\n const primaryFlsaStatus = hadPrimaryAtMount ? findPrimaryFlsaStatus(employeeJobs) : null\n\n const hireDate = currentJob?.hireDate ?? null\n\n const futureCompensations = findFutureCompensations(currentJob)\n const hasPendingFutureCompensation = futureCompensations.length > 0\n const maximumEffectiveDate = minEffectiveDate(futureCompensations)\n\n const isCreateMode = !compensationId\n const mode = isCreateMode ? 'create' : 'update'\n // Adding a secondary job (the employee already has a primary). The Gusto API\n // only allows secondaries when the primary's current FLSA is Nonexempt, and\n // the secondary itself must match — so the FLSA field is not user-editable\n // in this branch. We force the form value to the primary's FLSA below and\n // hide `Fields.FlsaStatus`.\n // True when adding a brand-new secondary job (not when scheduling a future\n // comp for the primary). The distinction matters: for the primary's future\n // comp, FLSA should be editable; for a secondary, it must match the primary.\n const isAddingSecondaryJob =\n isCreateMode && primaryFlsaStatus === FlsaStatus.NONEXEMPT && currentJob?.primary !== true\n\n const [schema, metadataConfig] = useMemo(\n () =>\n createCompensationSchema({\n mode,\n optionalFieldsToRequire,\n hireDate,\n withEffectiveDateField,\n }),\n [mode, optionalFieldsToRequire, hireDate, withEffectiveDateField],\n )\n\n const state = currentWorkAddress?.state\n\n // `flsaStatus` is intentionally allowed to be undefined so the field renders\n // an empty placeholder when nothing is provided — partners can choose to\n // seed it via `defaultValues.flsaStatus`. When a `compensation` is loaded we\n // seed from it; for a brand-new secondary job we inherit from the primary's\n // current compensation so multi-job classification stays consistent. The\n // schema enforces requiredness on submit in `create` mode (see\n // `requiredFieldsConfig` in compensationSchema.ts).\n //\n // `title` falls back to the parent job's title when the loaded compensation\n // row has none — a compensation only carries a non-null `title` when an\n // explicit title change has been scheduled on it. For steady-state edits\n // we want the input to show the employee's current title as the starting\n // value so the user can edit-in-place rather than re-typing.\n const resolvedDefaults: CompensationFormData = useMemo(\n () => ({\n title: currentCompensation?.title ?? currentJob?.title ?? partnerDefaults?.title ?? '',\n // When adding a secondary, the FLSA must match the primary's — force it\n // here (overriding any partner default) so the form submits the right\n // value even though `Fields.FlsaStatus` is hidden.\n flsaStatus: isAddingSecondaryJob\n ? primaryFlsaStatus\n : (currentCompensation?.flsaStatus ??\n partnerDefaults?.flsaStatus ??\n primaryFlsaStatus ??\n undefined),\n rate: Number(currentCompensation?.rate ?? partnerDefaults?.rate ?? 0),\n adjustForMinimumWage:\n currentCompensation?.adjustForMinimumWage ?? partnerDefaults?.adjustForMinimumWage ?? false,\n minimumWageId:\n currentCompensation?.minimumWages?.[0]?.uuid ?? partnerDefaults?.minimumWageId ?? '',\n paymentUnit:\n currentCompensation?.paymentUnit ?? partnerDefaults?.paymentUnit ?? PAY_PERIODS.HOUR,\n effectiveDate: currentCompensation?.effectiveDate ?? partnerDefaults?.effectiveDate ?? null,\n }),\n [currentCompensation, currentJob, partnerDefaults, primaryFlsaStatus, isAddingSecondaryJob],\n )\n\n const formMethods = useForm<CompensationFormData, unknown, CompensationFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const { control, getValues, setValue } = formMethods\n const watchedFlsaStatus = useWatch({ control, name: 'flsaStatus' })\n const watchedAdjustForMinimumWage = useWatch({\n control,\n name: 'adjustForMinimumWage',\n })\n\n useEffect(() => {\n if (watchedFlsaStatus === FlsaStatus.OWNER) {\n setValue('paymentUnit', PAY_PERIODS.PAYCHECK)\n } else if (\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', PAY_PERIODS.YEAR)\n setValue('rate', 0)\n } else {\n setValue('paymentUnit', resolvedDefaults.paymentUnit)\n }\n }, [watchedFlsaStatus, setValue, resolvedDefaults.paymentUnit])\n\n // The FLSA status that represents the employee's current classification.\n // In update mode this is the compensation being edited. In create mode\n // `currentCompensation` is null, so fall back to the job's active\n // compensation (identified by currentCompensationUuid) — this lets the\n // secondary-job warning fire even when scheduling a future-dated change.\n const currentJobActiveComp = currentJob\n ? currentJob.compensations?.find(c => c.uuid === currentJob.currentCompensationUuid)\n : undefined\n const effectiveBaseFlsaStatus =\n currentCompensation?.flsaStatus ?? currentJobActiveComp?.flsaStatus ?? null\n\n // True when the user is changing FLSA away from Nonexempt on a job that has\n // secondary jobs — those secondaries will be deleted by the API when the\n // new classification takes effect (immediately in update mode, at the chosen\n // effective date in create mode). Drives the warning and, in update mode\n // only, the effectiveDate-lock side effect below.\n const willDeleteSecondaryJobs =\n effectiveBaseFlsaStatus === FlsaStatus.NONEXEMPT &&\n watchedFlsaStatus !== undefined &&\n watchedFlsaStatus !== FlsaStatus.NONEXEMPT &&\n otherJobsCount > 0\n\n // Carve-out UX — update mode only: while willDeleteSecondaryJobs is active\n // the server deletes secondaries immediately on PUT. Mirror this by forcing\n // `effectiveDate` to today and disabling the field. In create mode the\n // deletion happens at the chosen future date, so we show the warning but\n // leave the date field editable.\n const carveOutActiveRef = useRef(false)\n const priorEffectiveDateRef = useRef<string | null>(null)\n useEffect(() => {\n if (!isCreateMode && willDeleteSecondaryJobs && !carveOutActiveRef.current) {\n priorEffectiveDateRef.current = getValues('effectiveDate') ?? null\n setValue('effectiveDate', todayISO(), { shouldDirty: true, shouldValidate: false })\n carveOutActiveRef.current = true\n } else if (!isCreateMode && !willDeleteSecondaryJobs && carveOutActiveRef.current) {\n setValue('effectiveDate', priorEffectiveDateRef.current ?? null, {\n shouldDirty: true,\n shouldValidate: false,\n })\n priorEffectiveDateRef.current = null\n carveOutActiveRef.current = false\n }\n }, [isCreateMode, willDeleteSecondaryJobs, getValues, setValue])\n\n const updateCompensationMutation = useJobsAndCompensationsUpdateCompensationMutation()\n const createCompensationMutation = useJobsAndCompensationsCreateCompensationMutation()\n\n const isPending = updateCompensationMutation.isPending || createCompensationMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('CompensationForm')\n\n const queriesForErrors = employeeId\n ? [jobsQuery, addressesQuery, employeeQuery, minWagesQuery]\n : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const isCommissionOnly =\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n const isOwner = watchedFlsaStatus === FlsaStatus.OWNER\n\n // Hide `Fields.FlsaStatus` when the user has no meaningful choice:\n // - update mode editing a secondary whose comp is already Nonexempt\n // (must keep matching the primary), and\n // - create mode while adding a secondary (must inherit primary's FLSA).\n // The first job's create flow and primary-job edits keep the field exposed.\n const isFlsaSelectionEnabled =\n !isAddingSecondaryJob &&\n (watchedFlsaStatus !== FlsaStatus.NONEXEMPT || currentJob?.primary === true || isCreateMode)\n\n const isAdjustMinimumWageEnabled =\n watchedFlsaStatus === FlsaStatus.NONEXEMPT &&\n minimumWages.length > 0 &&\n state !== undefined &&\n !TIP_CREDITS_UNSUPPORTED_STATES.includes(state)\n\n // Min-wage adjustment is only valid for Nonexempt FLSA (and a state that\n // allows tip credit). When the gate flips off — typically because the user\n // changed FLSA away from Nonexempt — `Fields.AdjustForMinimumWage` and\n // `Fields.MinimumWageId` stop rendering, but the underlying form values\n // persist in react-hook-form state. That would leak an\n // `adjust_for_minimum_wage: true` + `minimum_wages: [...]` body on submit\n // (server rejects with \"Minimum wage adjustments only valid for\n // flsa_status: Nonexempt\"). Reset both values to safe defaults so the\n // submitted payload always matches what the user can actually see.\n useEffect(() => {\n if (isAdjustMinimumWageEnabled) return\n if (getValues('adjustForMinimumWage')) {\n setValue('adjustForMinimumWage', false, { shouldDirty: true, shouldValidate: false })\n }\n if (getValues('minimumWageId')) {\n setValue('minimumWageId', '', { shouldDirty: true, shouldValidate: false })\n }\n }, [isAdjustMinimumWageEnabled, getValues, setValue])\n\n const minimumWageOptions = minimumWages.map(wage => ({\n value: wage.uuid,\n label: `${wage.wage} - ${wage.authority}: ${wage.notes ?? ''}`,\n }))\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = {\n title: baseMetadata.title,\n effectiveDate: {\n ...baseMetadata.effectiveDate,\n isDisabled: willDeleteSecondaryJobs && !isCreateMode,\n },\n flsaStatus: withOptions<FlsaStatusType>(\n baseMetadata.flsaStatus,\n flsaOptions,\n flsaStatusEntries,\n ),\n rate: { ...baseMetadata.rate, isDisabled: isCommissionOnly },\n paymentUnit: withOptions<PaymentUnit>(\n { ...baseMetadata.paymentUnit, isDisabled: isOwner || isCommissionOnly },\n paymentUnitOptions,\n paymentUnitEntries,\n ),\n adjustForMinimumWage: {\n ...baseMetadata.adjustForMinimumWage,\n isDisabled: !isAdjustMinimumWageEnabled,\n },\n minimumWageId: withOptions<MinimumWage>(\n baseMetadata.minimumWageId,\n minimumWageOptions,\n minimumWages,\n ),\n }\n\n const onSubmit = async (\n options?: CompensationSubmitOptions,\n ): Promise<HookSubmitResult<Compensation> | undefined> => {\n let submitResult: HookSubmitResult<Compensation> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: CompensationFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedJobId = options?.jobId ?? jobId\n const resolvedCompensationId = options?.compensationId ?? compensationId\n const resolvedMode = resolvedCompensationId ? 'update' : 'create'\n\n // When the field is rendered, the validated payload value wins\n // unless an explicit submit-time override is supplied. When the\n // field is hidden (`withEffectiveDateField: false`) we are\n // strictly options-only — matching `useWorkAddressForm` and the\n // hidden-field behavior of `useHomeAddressForm` / `useJobForm`.\n // The carve-out's form-state side effect (force value to today)\n // is therefore inert in the hidden-field path; partners who\n // need a specific date there must supply it via\n // `CompensationSubmitOptions.effectiveDate`.\n const resolvedEffectiveDate = withEffectiveDateField\n ? (options?.effectiveDate ?? payload.effectiveDate ?? undefined)\n : (options?.effectiveDate ?? undefined)\n\n const requestBodyBase = {\n rate: String(payload.rate),\n paymentUnit: payload.paymentUnit,\n flsaStatus: payload.flsaStatus,\n effectiveDate: resolvedEffectiveDate,\n title: payload.title || undefined,\n adjustForMinimumWage: payload.adjustForMinimumWage,\n minimumWages: payload.adjustForMinimumWage ? [{ uuid: payload.minimumWageId }] : [],\n }\n\n let result: Compensation | undefined\n\n if (resolvedMode === 'create') {\n if (!resolvedJobId) {\n throw new SDKInternalError(\n 'jobId is required to create a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n // Schema's `requiredFieldsConfig` guarantees `flsaStatus` is set\n // on create-mode submit; the runtime guard appeases the API\n // request-body type (which requires a non-undefined value on\n // POST, vs. the optional PUT body).\n if (!payload.flsaStatus) {\n throw new SDKInternalError('flsaStatus is required to create a compensation.')\n }\n const createResponse = await createCompensationMutation.mutateAsync({\n request: {\n jobId: resolvedJobId,\n compensationsRequestBody: { ...requestBodyBase, flsaStatus: payload.flsaStatus },\n },\n })\n result = createResponse.compensation\n if (!result) throw new SDKInternalError('Compensation creation failed')\n } else {\n if (!resolvedCompensationId) {\n throw new SDKInternalError(\n 'compensationId is required to update a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n const resolvedVersion =\n options?.compensationVersion ?? (currentCompensation?.version as string | undefined)\n if (!resolvedVersion) {\n throw new SDKInternalError(\n 'compensation version is required to update a compensation. Pass it via submit options when threading post-create, or ensure the compensation is loaded.',\n )\n }\n const updateResponse = await updateCompensationMutation.mutateAsync({\n request: {\n compensationId: resolvedCompensationId,\n compensationsUpdateRequestBody: {\n version: resolvedVersion,\n ...requestBodyBase,\n },\n },\n })\n result = updateResponse.compensation\n if (!result) throw new SDKInternalError('Compensation update failed')\n }\n\n submitResult = { mode: resolvedMode, data: result }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const isDataLoading = employeeId\n ? jobsQuery.isLoading ||\n addressesQuery.isLoading ||\n employeeQuery.isLoading ||\n minWagesQuery.isLoading\n : false\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (isDataLoading || (employeeId && (!employeeJobs || !employee))) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n compensation: currentCompensation,\n currentJob,\n minimumWages,\n minimumEffectiveDate: hireDate,\n maximumEffectiveDate,\n hasPendingFutureCompensation,\n },\n status: {\n isPending,\n mode,\n willDeleteSecondaryJobs,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Title: TitleField,\n FlsaStatus: isFlsaSelectionEnabled ? FlsaStatusField : undefined,\n Rate: RateField,\n PaymentUnit: PaymentUnitField,\n AdjustForMinimumWage: isAdjustMinimumWageEnabled ? AdjustForMinimumWageField : undefined,\n MinimumWageId:\n isAdjustMinimumWageEnabled && watchedAdjustForMinimumWage\n ? MinimumWageIdField\n : undefined,\n EffectiveDate: withEffectiveDateField ? EffectiveDateField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\nexport type UseCompensationFormResult = HookLoadingResult | UseCompensationFormReady\nexport type CompensationFieldsMetadata = UseCompensationFormReady['form']['fieldsMetadata']\n"],"names":["resolveCompAndJob","jobs","compensationId","jobId","job","compensation","c","j","findPrimaryFlsaStatus","findFutureCompensations","today","todayISO","minEffectiveDate","comps","min","d","flsaStatusEntries","FlsaStatus","flsaOptions","status","paymentUnitEntries","PAY_PERIODS","paymentUnitOptions","unit","useCompensationForm","employeeId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","withEffectiveDateField","jobsQuery","useJobsAndCompensationsGetJobs","addressesQuery","useEmployeeAddressesGetWorkAddresses","employeeQuery","useEmployeesGet","employeeJobs","currentWorkAddress","address","locationUuid","employee","minWagesQuery","useLocationsGetMinimumWages","minimumWages","currentCompensation","currentJob","otherJobsCount","hadPrimaryAtMountRef","useRef","primaryFlsaStatus","hireDate","futureCompensations","hasPendingFutureCompensation","maximumEffectiveDate","isCreateMode","mode","isAddingSecondaryJob","schema","metadataConfig","useMemo","createCompensationSchema","state","resolvedDefaults","formMethods","useForm","zodResolver","control","getValues","setValue","watchedFlsaStatus","useWatch","watchedAdjustForMinimumWage","useEffect","currentJobActiveComp","willDeleteSecondaryJobs","carveOutActiveRef","priorEffectiveDateRef","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","createCompensationMutation","useJobsAndCompensationsCreateCompensationMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","isCommissionOnly","isOwner","isFlsaSelectionEnabled","isAdjustMinimumWageEnabled","TIP_CREDITS_UNSUPPORTED_STATES","minimumWageOptions","wage","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","withOptions","onSubmit","options","submitResult","resolve","data","payload","resolvedJobId","resolvedCompensationId","resolvedMode","resolvedEffectiveDate","requestBodyBase","result","SDKInternalError","resolvedVersion","isDataLoading","hookFormInternals","useHookFormInternals","TitleField","FlsaStatusField","RateField","PaymentUnitField","AdjustForMinimumWageField","MinimumWageIdField","EffectiveDateField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;AAsJA,SAASA,GACPC,GACAC,GACAC,GACwD;AACxD,MAAI,CAACF,EAAM,QAAO,EAAE,cAAc,MAAM,KAAK,KAAA;AAC7C,MAAIC,GAAgB;AAClB,eAAWE,KAAOH,GAAM;AACtB,YAAMI,IAAeD,EAAI,eAAe,KAAK,CAAAE,MAAKA,EAAE,SAASJ,CAAc;AAC3E,UAAIG,EAAc,QAAO,EAAE,cAAAA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AA,MACA,8BAAAD;AAAA,IAAA;AAAA,IAEF,QAAQ;AAAA,MACN,WAAA6B;AAAA,MACA,MAAA1B;AAAA,MACA,yBAAAmB;AAAA,IAAA;AAAA,IAEF,SAAS,EAAE,UAAAyB,GAAA;AAAA,IACX,eAAAb;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,OAAO8B;AAAA,QACP,YAAY1B,KAAyB2B,KAAkB;AAAA,QACvD,MAAMC;AAAA,QACN,aAAaC;AAAA,QACb,sBAAsB5B,IAA6B6B,KAA4B;AAAA,QAC/E,eACE7B,KAA8BpB,KAC1BkD,KACA;AAAA,QACN,eAAe5F,IAAyB6F,KAAqB;AAAA,MAAA;AAAA,MAE/D,gBAAAzB;AAAA,MACA,mBAAAiB;AAAA,MACA,yBAAyBS,GAA8B5D,GAAaN,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"useCompensationForm.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.tsx"],"sourcesContent":["import { useEffect, useMemo, useRef } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Compensation, PaymentUnit } from '@gusto/embedded-api/models/components/compensation'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { GetV1EmployeesEmployeeIdJobsQueryParamInclude } from '@gusto/embedded-api/models/operations/getv1employeesemployeeidjobs'\nimport { useJobsAndCompensationsCreateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateCompensation'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useLocationsGetMinimumWages } from '@gusto/embedded-api/react-query/locationsGetMinimumWages'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n createCompensationSchema,\n type CompensationOptionalFieldsToRequire,\n type CompensationFormData,\n type CompensationFormOutputs,\n} from './compensationSchema'\nimport {\n TitleField,\n FlsaStatusField,\n RateField,\n PaymentUnitField,\n AdjustForMinimumWageField,\n MinimumWageIdField,\n EffectiveDateField,\n} from './fields'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { FlsaStatus, PAY_PERIODS, TIP_CREDITS_UNSUPPORTED_STATES } from '@/shared/constants'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { addDays, formatDateToStringDate } from '@/helpers/dateFormatting'\n\nexport interface CompensationSubmitOptions {\n /** Override jobId — required when creating a compensation if not configured at hook construction (e.g. when the parent job was just created in the same submit chain). */\n jobId?: string\n /** Override compensationId — when present, forces update (PUT) routing regardless of hook construction. */\n compensationId?: string\n /**\n * Compensation version for optimistic locking on PUT. Required when forcing\n * update routing post-create (e.g. updating the auto-created stub returned\n * from `POST /v1/employees/:id/jobs`). When omitted, the hook reads the\n * version from its cached `currentCompensation`.\n */\n compensationVersion?: string\n /**\n * Supply `effectiveDate` at submit time. When `withEffectiveDateField`\n * is `true`, this overrides the form's value. When `withEffectiveDateField`\n * is `false`, this is the only way to put `effective_date` on the wire —\n * the form value is not read in that mode (matching the options-only\n * convention of `useWorkAddressForm` / `useHomeAddressForm` / `useJobForm`).\n */\n effectiveDate?: string\n}\n\nexport interface UseCompensationFormProps {\n employeeId?: string\n /** The parent job's UUID. Required in create mode (scopes `POST /v1/jobs/:jobId/compensations`). Optional in update mode — the parent job is derived from the loaded compensation. */\n jobId?: string\n /** Present → update mode (PUT /v1/compensations/:id). Omitted → create mode (POST /v1/jobs/:jobId/compensations). */\n compensationId?: string\n optionalFieldsToRequire?: CompensationOptionalFieldsToRequire\n defaultValues?: Partial<CompensationFormData>\n validationMode?: UseFormProps['mode']\n shouldFocusError?: boolean\n /**\n * When `false`, hides `Fields.EffectiveDate` (becomes `undefined`) and\n * removes `effectiveDate` from schema validation. In this mode the hook\n * does not read any form value at submit time — `effective_date` is\n * omitted from the request body unless explicitly supplied via\n * `CompensationSubmitOptions.effectiveDate`. This matches the\n * options-only convention of `useWorkAddressForm` /\n * `useHomeAddressForm` / `useJobForm`, and means the\n * `willDeleteSecondaryJobs` carve-out's form-state side effects do not\n * leak onto the wire (there is no field to render them in anyway).\n * Defaults to `true`.\n */\n withEffectiveDateField?: boolean\n}\n\nexport interface CompensationFormFields {\n Title: typeof TitleField\n FlsaStatus: typeof FlsaStatusField | undefined\n Rate: typeof RateField\n PaymentUnit: typeof PaymentUnitField\n AdjustForMinimumWage: typeof AdjustForMinimumWageField | undefined\n MinimumWageId: typeof MinimumWageIdField | undefined\n EffectiveDate: typeof EffectiveDateField | undefined\n}\n\nexport interface UseCompensationFormReady extends BaseFormHookReady<\n FieldsMetadata,\n CompensationFormData,\n CompensationFormFields\n> {\n data: {\n /** The compensation row loaded for update; `null` in create mode. */\n compensation: Compensation | null\n /** The parent job. In update mode it's derived from the loaded compensation; in create mode it's looked up by `jobId`. `null` if neither resolves. */\n currentJob: Job | null\n minimumWages: MinimumWage[]\n /** Lower bound for `effectiveDate` (typically the parent job's hire date). */\n minimumEffectiveDate: string | null\n /** Upper bound for `effectiveDate` — the next scheduled future compensation's effective date, when one exists. */\n maximumEffectiveDate: string | null\n /** True when at least one future-dated compensation already exists for this job. */\n hasPendingFutureCompensation: boolean\n }\n status: {\n isPending: boolean\n mode: 'create' | 'update'\n /**\n * True when submitting the form right now would delete the employee's\n * secondary jobs server-side (the \"carve-out\" branch). Reactive:\n * derived from the current `flsaStatus` form value, the loaded\n * compensation, and the other-jobs count, so this flips as you change\n * inputs.\n *\n * Conditions: update mode, the loaded compensation is Nonexempt, the\n * form's `flsaStatus` has been changed to a non-Nonexempt value, and\n * the employee has at least one secondary job.\n *\n * While this flag is true the hook also takes the `effectiveDate`\n * field over: it forces the form value to today (so submits route\n * through a PUT that immediately deletes secondaries) and exposes\n * `fieldsMetadata.effectiveDate.isDisabled = true` so `Fields.EffectiveDate`\n * renders as disabled. On revert (FLSA back to Nonexempt) the prior\n * `effectiveDate` is restored. Render an inline warning keyed off\n * this flag — no separate confirmation step is needed.\n */\n willDeleteSecondaryJobs: boolean\n }\n actions: {\n onSubmit: (\n options?: CompensationSubmitOptions,\n ) => Promise<HookSubmitResult<Compensation> | undefined>\n }\n}\n\nfunction resolveCompAndJob(\n jobs: Job[] | undefined,\n compensationId: string | undefined,\n jobId: string | undefined,\n): { compensation: Compensation | null; job: Job | null } {\n if (!jobs) return { compensation: null, job: null }\n if (compensationId) {\n for (const job of jobs) {\n const compensation = job.compensations?.find(c => c.uuid === compensationId)\n if (compensation) return { compensation, job }\n }\n // If the comp isn't in any job's compensations list, still try to resolve\n // the job by jobId so callers can check job metadata (e.g. job.primary).\n const fallbackJob = jobId ? (jobs.find(j => j.uuid === jobId) ?? null) : null\n return { compensation: null, job: fallbackJob }\n }\n if (jobId) return { compensation: null, job: jobs.find(j => j.uuid === jobId) ?? null }\n return { compensation: null, job: null }\n}\n\nfunction findPrimaryFlsaStatus(jobs: Job[] | undefined): FlsaStatusType | null {\n if (!jobs) return null\n for (const job of jobs) {\n if (!job.primary) continue\n const compensation = job.compensations?.find(c => c.uuid === job.currentCompensationUuid)\n if (compensation?.flsaStatus) return compensation.flsaStatus\n }\n return null\n}\n\nfunction findFutureCompensations(job: Job | null): Compensation[] {\n if (!job?.compensations) return []\n const today = todayISO()\n return job.compensations.filter(c => c.effectiveDate !== undefined && c.effectiveDate > today)\n}\n\nfunction earliestEffectiveDate(comps: Compensation[]): string | null {\n if (comps.length === 0) return null\n return comps.reduce<string | null>((min, c) => {\n const d = c.effectiveDate\n if (!d) return min\n if (!min || d < min) return d\n return min\n }, null)\n}\n\nconst flsaStatusEntries: FlsaStatusType[] = [\n FlsaStatus.EXEMPT,\n FlsaStatus.SALARIED_NONEXEMPT,\n FlsaStatus.NONEXEMPT,\n FlsaStatus.OWNER,\n FlsaStatus.COMMISSION_ONLY_EXEMPT,\n FlsaStatus.COMMISSION_ONLY_NONEXEMPT,\n]\n\nconst flsaOptions = flsaStatusEntries.map(status => ({ value: status, label: status }))\n\nconst paymentUnitEntries: PaymentUnit[] = [\n PAY_PERIODS.HOUR,\n PAY_PERIODS.WEEK,\n PAY_PERIODS.MONTH,\n PAY_PERIODS.YEAR,\n PAY_PERIODS.PAYCHECK,\n]\n\nconst paymentUnitOptions = paymentUnitEntries.map(unit => ({ value: unit, label: unit }))\n\nfunction todayISO(): string {\n return new Date().toISOString().split('T')[0]!\n}\n\nexport function useCompensationForm({\n employeeId,\n jobId,\n compensationId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n withEffectiveDateField = true,\n}: UseCompensationFormProps): HookLoadingResult | UseCompensationFormReady {\n const jobsQuery = useJobsAndCompensationsGetJobs(\n {\n employeeId: employeeId ?? '',\n // Fetch all effective-dated compensations when editing an existing one so\n // resolveCompAndJob can find the target comp (future-dated comps are\n // omitted from the default response, which only returns the current comp).\n include: compensationId\n ? GetV1EmployeesEmployeeIdJobsQueryParamInclude.AllCompensations\n : undefined,\n },\n { enabled: !!employeeId },\n )\n const addressesQuery = useEmployeeAddressesGetWorkAddresses(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const employeeQuery = useEmployeesGet({ employeeId: employeeId ?? '' }, { enabled: !!employeeId })\n\n const employeeJobs = jobsQuery.data?.jobs\n const workAddresses = addressesQuery.data?.employeeWorkAddressesList\n const currentWorkAddress = workAddresses?.find(address => address.active)\n const locationUuid = currentWorkAddress?.locationUuid\n const employee = employeeQuery.data?.employee\n\n const minWagesQuery = useLocationsGetMinimumWages(\n { locationUuid: locationUuid ?? '' },\n { enabled: !!locationUuid },\n )\n\n const minimumWages = minWagesQuery.data?.minimumWageList ?? []\n\n const { compensation: currentCompensation, job: currentJob } = resolveCompAndJob(\n employeeJobs,\n compensationId,\n jobId,\n )\n\n const otherJobsCount =\n employeeJobs && currentJob ? employeeJobs.filter(j => j.uuid !== currentJob.uuid).length : 0\n\n // Snapshot — written exactly once, on the first render where `employeeJobs`\n // is defined (i.e., the initial `getJobs` query has resolved) — capturing\n // whether the employee already had a primary job at that moment.\n //\n // Used to ignore the API-generated stub primary (FLSA Nonexempt, rate \"0.00\")\n // that briefly appears between the chained job POST and comp PUT during\n // onboarding: `getJobs` invalidates between the two mutations and\n // momentarily includes the stub, which would otherwise flip\n // `isAddingSecondaryJob` to true and hide `Fields.FlsaStatus` mid-submit.\n //\n // In steady-state flows (edit primary, edit secondary, add secondary), the\n // real primary already exists when the query first resolves, so the snapshot\n // is `true` and live `employeeJobs` continues to drive `primaryFlsaStatus`.\n // Recovery for the rare case where a partner mounts before any jobs exist\n // and a primary is created externally mid-form is to remount the hook\n // (e.g., via a `key` change).\n const hadPrimaryAtMountRef = useRef<boolean | null>(null)\n if (hadPrimaryAtMountRef.current === null && employeeJobs !== undefined) {\n hadPrimaryAtMountRef.current = employeeJobs.some(job => job.primary)\n }\n const hadPrimaryAtMount = hadPrimaryAtMountRef.current === true\n\n // FLSA status of the employee's primary job's current compensation, when one\n // exists. Used as a fallback default when adding a *secondary* job/comp so the\n // multi-job classification stays consistent with the primary by default — the\n // user can still override it (when allowed). Null when there was no primary\n // job at the moment the hook first observed `employeeJobs`, or when the\n // primary has no current compensation yet.\n const primaryFlsaStatus = hadPrimaryAtMount ? findPrimaryFlsaStatus(employeeJobs) : null\n\n const hireDate =\n currentJob?.hireDate ??\n // Secondary jobs being created (AddAnotherJob) have no hireDate until the\n // job POST completes. Fall back to the primary job's hireDate so the schema\n // can enforce EFFECTIVE_DATE_BEFORE_HIRE during that window.\n employeeJobs?.find(j => j.primary)?.hireDate ??\n null\n\n // In update mode, exclude the compensation being edited so it doesn't\n // bound `maximumEffectiveDate` to its own current date — that would prevent\n // the user from pushing the pending effective date further out.\n const futureCompensations = findFutureCompensations(currentJob).filter(\n c => c.uuid !== compensationId,\n )\n const hasPendingFutureCompensation = futureCompensations.length > 0\n const maximumEffectiveDate = earliestEffectiveDate(futureCompensations)\n\n const isCreateMode = !compensationId\n const mode = isCreateMode ? 'create' : 'update'\n // Adding a secondary job (the employee already has a primary). The Gusto API\n // only allows secondaries when the primary's current FLSA is Nonexempt, and\n // the secondary itself must match — so the FLSA field is not user-editable\n // in this branch. We force the form value to the primary's FLSA below and\n // hide `Fields.FlsaStatus`.\n // True when adding a brand-new secondary job (not when scheduling a future\n // comp for the primary). The distinction matters: for the primary's future\n // comp, FLSA should be editable; for a secondary, it must match the primary.\n const isAddingSecondaryJob =\n isCreateMode && primaryFlsaStatus === FlsaStatus.NONEXEMPT && currentJob?.primary !== true\n\n // Derive the effective-date floor internally so consumers don't need to wire\n // it up. Rules by mode and job type:\n // create (any job): tomorrow — new comp must be future-dated\n // update, primary: undefined — the carve-out (willDeleteSecondaryJobs) can\n // force effectiveDate to today on a disabled field; enforcing a floor here\n // would produce a spurious EFFECTIVE_DATE_BEFORE_MIN on submit.\n // update, secondary: tomorrow — must be in the future\n // The hire-date lower bound is handled separately in the schema via the\n // `hireDate` option (→ EFFECTIVE_DATE_BEFORE_HIRE), which fires alongside\n // this check so each violation gets its own error message.\n const internalMinEffectiveDate = useMemo(() => {\n if (!withEffectiveDateField) return undefined\n if (!isCreateMode && currentJob?.primary === true) return undefined\n\n return formatDateToStringDate(addDays(new Date(), 1)) ?? undefined\n }, [isCreateMode, currentJob?.primary, withEffectiveDateField])\n\n const [schema, metadataConfig] = useMemo(\n () =>\n createCompensationSchema({\n mode,\n optionalFieldsToRequire,\n hireDate,\n minEffectiveDate: internalMinEffectiveDate,\n withEffectiveDateField,\n }),\n [mode, optionalFieldsToRequire, hireDate, internalMinEffectiveDate, withEffectiveDateField],\n )\n\n const state = currentWorkAddress?.state\n\n // `flsaStatus` is intentionally allowed to be undefined so the field renders\n // an empty placeholder when nothing is provided — partners can choose to\n // seed it via `defaultValues.flsaStatus`. When a `compensation` is loaded we\n // seed from it; for a brand-new secondary job we inherit from the primary's\n // current compensation so multi-job classification stays consistent. The\n // schema enforces requiredness on submit in `create` mode (see\n // `requiredFieldsConfig` in compensationSchema.ts).\n //\n // `title` falls back to the parent job's title when the loaded compensation\n // row has none — a compensation only carries a non-null `title` when an\n // explicit title change has been scheduled on it. For steady-state edits\n // we want the input to show the employee's current title as the starting\n // value so the user can edit-in-place rather than re-typing.\n const resolvedDefaults: CompensationFormData = useMemo(\n () => ({\n title: currentCompensation?.title ?? currentJob?.title ?? partnerDefaults?.title ?? '',\n // When adding a secondary, the FLSA must match the primary's — force it\n // here (overriding any partner default) so the form submits the right\n // value even though `Fields.FlsaStatus` is hidden.\n flsaStatus: isAddingSecondaryJob\n ? primaryFlsaStatus\n : (currentCompensation?.flsaStatus ??\n partnerDefaults?.flsaStatus ??\n primaryFlsaStatus ??\n undefined),\n rate: Number(currentCompensation?.rate ?? partnerDefaults?.rate ?? 0),\n adjustForMinimumWage:\n currentCompensation?.adjustForMinimumWage ?? partnerDefaults?.adjustForMinimumWage ?? false,\n minimumWageId:\n currentCompensation?.minimumWages?.[0]?.uuid ?? partnerDefaults?.minimumWageId ?? '',\n paymentUnit:\n currentCompensation?.paymentUnit ?? partnerDefaults?.paymentUnit ?? PAY_PERIODS.HOUR,\n effectiveDate: currentCompensation?.effectiveDate ?? partnerDefaults?.effectiveDate ?? null,\n }),\n [currentCompensation, currentJob, partnerDefaults, primaryFlsaStatus, isAddingSecondaryJob],\n )\n\n const formMethods = useForm<CompensationFormData, unknown, CompensationFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const { control, getValues, setValue } = formMethods\n const watchedFlsaStatus = useWatch({ control, name: 'flsaStatus' })\n const watchedAdjustForMinimumWage = useWatch({\n control,\n name: 'adjustForMinimumWage',\n })\n\n useEffect(() => {\n if (watchedFlsaStatus === FlsaStatus.OWNER) {\n setValue('paymentUnit', PAY_PERIODS.PAYCHECK)\n } else if (\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', PAY_PERIODS.YEAR)\n setValue('rate', 0)\n } else {\n setValue('paymentUnit', resolvedDefaults.paymentUnit)\n }\n }, [watchedFlsaStatus, setValue, resolvedDefaults.paymentUnit])\n\n // The FLSA status that represents the employee's current classification.\n // In update mode this is the compensation being edited. In create mode\n // `currentCompensation` is null, so fall back to the job's active\n // compensation (identified by currentCompensationUuid) — this lets the\n // secondary-job warning fire even when scheduling a future-dated change.\n const currentJobActiveComp = currentJob\n ? currentJob.compensations?.find(c => c.uuid === currentJob.currentCompensationUuid)\n : undefined\n const effectiveBaseFlsaStatus =\n currentCompensation?.flsaStatus ?? currentJobActiveComp?.flsaStatus ?? null\n\n // True when the user is changing FLSA away from Nonexempt on a job that has\n // secondary jobs — those secondaries will be deleted by the API when the\n // new classification takes effect (immediately in update mode, at the chosen\n // effective date in create mode). Drives the warning and, in update mode\n // only, the effectiveDate-lock side effect below.\n const willDeleteSecondaryJobs =\n effectiveBaseFlsaStatus === FlsaStatus.NONEXEMPT &&\n watchedFlsaStatus !== undefined &&\n watchedFlsaStatus !== FlsaStatus.NONEXEMPT &&\n otherJobsCount > 0\n\n // Carve-out UX — update mode only: while willDeleteSecondaryJobs is active\n // the server deletes secondaries immediately on PUT. Mirror this by forcing\n // `effectiveDate` to today and disabling the field. In create mode the\n // deletion happens at the chosen future date, so we show the warning but\n // leave the date field editable.\n const carveOutActiveRef = useRef(false)\n const priorEffectiveDateRef = useRef<string | null>(null)\n useEffect(() => {\n if (!isCreateMode && willDeleteSecondaryJobs && !carveOutActiveRef.current) {\n priorEffectiveDateRef.current = getValues('effectiveDate') ?? null\n setValue('effectiveDate', todayISO(), { shouldDirty: true, shouldValidate: false })\n carveOutActiveRef.current = true\n } else if (!isCreateMode && !willDeleteSecondaryJobs && carveOutActiveRef.current) {\n setValue('effectiveDate', priorEffectiveDateRef.current ?? null, {\n shouldDirty: true,\n shouldValidate: false,\n })\n priorEffectiveDateRef.current = null\n carveOutActiveRef.current = false\n }\n }, [isCreateMode, willDeleteSecondaryJobs, getValues, setValue])\n\n const updateCompensationMutation = useJobsAndCompensationsUpdateCompensationMutation()\n const createCompensationMutation = useJobsAndCompensationsCreateCompensationMutation()\n\n const isPending = updateCompensationMutation.isPending || createCompensationMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('CompensationForm')\n\n const queriesForErrors = employeeId\n ? [jobsQuery, addressesQuery, employeeQuery, minWagesQuery]\n : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const isCommissionOnly =\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n watchedFlsaStatus === FlsaStatus.COMMISSION_ONLY_EXEMPT\n const isOwner = watchedFlsaStatus === FlsaStatus.OWNER\n\n // Hide `Fields.FlsaStatus` when the user has no meaningful choice:\n // - update mode editing a secondary whose comp is already Nonexempt\n // (must keep matching the primary), and\n // - create mode while adding a secondary (must inherit primary's FLSA).\n // The first job's create flow and primary-job edits keep the field exposed.\n const isFlsaSelectionEnabled =\n !isAddingSecondaryJob &&\n (watchedFlsaStatus !== FlsaStatus.NONEXEMPT || currentJob?.primary === true || isCreateMode)\n\n const isAdjustMinimumWageEnabled =\n watchedFlsaStatus === FlsaStatus.NONEXEMPT &&\n minimumWages.length > 0 &&\n state !== undefined &&\n !TIP_CREDITS_UNSUPPORTED_STATES.includes(state)\n\n // Min-wage adjustment is only valid for Nonexempt FLSA (and a state that\n // allows tip credit). When the gate flips off — typically because the user\n // changed FLSA away from Nonexempt — `Fields.AdjustForMinimumWage` and\n // `Fields.MinimumWageId` stop rendering, but the underlying form values\n // persist in react-hook-form state. That would leak an\n // `adjust_for_minimum_wage: true` + `minimum_wages: [...]` body on submit\n // (server rejects with \"Minimum wage adjustments only valid for\n // flsa_status: Nonexempt\"). Reset both values to safe defaults so the\n // submitted payload always matches what the user can actually see.\n useEffect(() => {\n if (isAdjustMinimumWageEnabled) return\n if (getValues('adjustForMinimumWage')) {\n setValue('adjustForMinimumWage', false, { shouldDirty: true, shouldValidate: false })\n }\n if (getValues('minimumWageId')) {\n setValue('minimumWageId', '', { shouldDirty: true, shouldValidate: false })\n }\n }, [isAdjustMinimumWageEnabled, getValues, setValue])\n\n const minimumWageOptions = minimumWages.map(wage => ({\n value: wage.uuid,\n label: `${wage.wage} - ${wage.authority}: ${wage.notes ?? ''}`,\n }))\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const effectiveDateMinDate = useMemo(\n () =>\n [internalMinEffectiveDate, hireDate]\n .filter((d): d is string => !!d)\n .reduce<string | null>((max, d) => (!max || d > max ? d : max), null),\n [internalMinEffectiveDate, hireDate],\n )\n const fieldsMetadata = {\n title: baseMetadata.title,\n effectiveDate: {\n ...baseMetadata.effectiveDate,\n isDisabled: willDeleteSecondaryJobs && !isCreateMode,\n minDate: effectiveDateMinDate,\n maxDate: maximumEffectiveDate,\n },\n flsaStatus: withOptions<FlsaStatusType>(\n baseMetadata.flsaStatus,\n flsaOptions,\n flsaStatusEntries,\n ),\n rate: { ...baseMetadata.rate, isDisabled: isCommissionOnly },\n paymentUnit: withOptions<PaymentUnit>(\n { ...baseMetadata.paymentUnit, isDisabled: isOwner || isCommissionOnly },\n paymentUnitOptions,\n paymentUnitEntries,\n ),\n adjustForMinimumWage: {\n ...baseMetadata.adjustForMinimumWage,\n isDisabled: !isAdjustMinimumWageEnabled,\n },\n minimumWageId: withOptions<MinimumWage>(\n baseMetadata.minimumWageId,\n minimumWageOptions,\n minimumWages,\n ),\n }\n\n const onSubmit = async (\n options?: CompensationSubmitOptions,\n ): Promise<HookSubmitResult<Compensation> | undefined> => {\n let submitResult: HookSubmitResult<Compensation> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: CompensationFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedJobId = options?.jobId ?? jobId\n const resolvedCompensationId = options?.compensationId ?? compensationId\n const resolvedMode = resolvedCompensationId ? 'update' : 'create'\n\n // When the field is rendered, the validated payload value wins\n // unless an explicit submit-time override is supplied. When the\n // field is hidden (`withEffectiveDateField: false`) we are\n // strictly options-only — matching `useWorkAddressForm` and the\n // hidden-field behavior of `useHomeAddressForm` / `useJobForm`.\n // The carve-out's form-state side effect (force value to today)\n // is therefore inert in the hidden-field path; partners who\n // need a specific date there must supply it via\n // `CompensationSubmitOptions.effectiveDate`.\n const resolvedEffectiveDate = withEffectiveDateField\n ? (options?.effectiveDate ?? payload.effectiveDate ?? undefined)\n : (options?.effectiveDate ?? undefined)\n\n const requestBodyBase = {\n rate: String(payload.rate),\n paymentUnit: payload.paymentUnit,\n flsaStatus: payload.flsaStatus,\n effectiveDate: resolvedEffectiveDate,\n title: payload.title || undefined,\n adjustForMinimumWage: payload.adjustForMinimumWage,\n minimumWages: payload.adjustForMinimumWage ? [{ uuid: payload.minimumWageId }] : [],\n }\n\n let result: Compensation | undefined\n\n if (resolvedMode === 'create') {\n if (!resolvedJobId) {\n throw new SDKInternalError(\n 'jobId is required to create a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n // Schema's `requiredFieldsConfig` guarantees `flsaStatus` is set\n // on create-mode submit; the runtime guard appeases the API\n // request-body type (which requires a non-undefined value on\n // POST, vs. the optional PUT body).\n if (!payload.flsaStatus) {\n throw new SDKInternalError('flsaStatus is required to create a compensation.')\n }\n const createResponse = await createCompensationMutation.mutateAsync({\n request: {\n jobId: resolvedJobId,\n compensationsRequestBody: { ...requestBodyBase, flsaStatus: payload.flsaStatus },\n },\n })\n result = createResponse.compensation\n if (!result) throw new SDKInternalError('Compensation creation failed')\n } else {\n if (!resolvedCompensationId) {\n throw new SDKInternalError(\n 'compensationId is required to update a compensation. Pass it as a hook prop or via submit options.',\n )\n }\n const resolvedVersion =\n options?.compensationVersion ?? (currentCompensation?.version as string | undefined)\n if (!resolvedVersion) {\n throw new SDKInternalError(\n 'compensation version is required to update a compensation. Pass it via submit options when threading post-create, or ensure the compensation is loaded.',\n )\n }\n const updateResponse = await updateCompensationMutation.mutateAsync({\n request: {\n compensationId: resolvedCompensationId,\n compensationsUpdateRequestBody: {\n version: resolvedVersion,\n ...requestBodyBase,\n },\n },\n })\n result = updateResponse.compensation\n if (!result) throw new SDKInternalError('Compensation update failed')\n }\n\n submitResult = { mode: resolvedMode, data: result }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const isDataLoading = employeeId\n ? jobsQuery.isLoading ||\n addressesQuery.isLoading ||\n employeeQuery.isLoading ||\n minWagesQuery.isLoading\n : false\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (isDataLoading || (employeeId && (!employeeJobs || !employee))) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n compensation: currentCompensation,\n currentJob,\n minimumWages,\n minimumEffectiveDate: effectiveDateMinDate,\n maximumEffectiveDate,\n hasPendingFutureCompensation,\n },\n status: {\n isPending,\n mode,\n willDeleteSecondaryJobs,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Title: TitleField,\n FlsaStatus: isFlsaSelectionEnabled ? FlsaStatusField : undefined,\n Rate: RateField,\n PaymentUnit: PaymentUnitField,\n AdjustForMinimumWage: isAdjustMinimumWageEnabled ? AdjustForMinimumWageField : undefined,\n MinimumWageId:\n isAdjustMinimumWageEnabled && watchedAdjustForMinimumWage\n ? MinimumWageIdField\n : undefined,\n EffectiveDate: withEffectiveDateField ? EffectiveDateField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\nexport type UseCompensationFormResult = HookLoadingResult | UseCompensationFormReady\nexport type CompensationFieldsMetadata = UseCompensationFormReady['form']['fieldsMetadata']\n"],"names":["resolveCompAndJob","jobs","compensationId","jobId","job","compensation","c","j","findPrimaryFlsaStatus","findFutureCompensations","today","todayISO","earliestEffectiveDate","comps","min","d","flsaStatusEntries","FlsaStatus","flsaOptions","status","paymentUnitEntries","PAY_PERIODS","paymentUnitOptions","unit","useCompensationForm","employeeId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","withEffectiveDateField","jobsQuery","useJobsAndCompensationsGetJobs","GetV1EmployeesEmployeeIdJobsQueryParamInclude","addressesQuery","useEmployeeAddressesGetWorkAddresses","employeeQuery","useEmployeesGet","employeeJobs","currentWorkAddress","address","locationUuid","employee","minWagesQuery","useLocationsGetMinimumWages","minimumWages","currentCompensation","currentJob","otherJobsCount","hadPrimaryAtMountRef","useRef","primaryFlsaStatus","hireDate","futureCompensations","hasPendingFutureCompensation","maximumEffectiveDate","isCreateMode","mode","isAddingSecondaryJob","internalMinEffectiveDate","useMemo","formatDateToStringDate","addDays","schema","metadataConfig","createCompensationSchema","state","resolvedDefaults","formMethods","useForm","zodResolver","control","getValues","setValue","watchedFlsaStatus","useWatch","watchedAdjustForMinimumWage","useEffect","currentJobActiveComp","willDeleteSecondaryJobs","carveOutActiveRef","priorEffectiveDateRef","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","createCompensationMutation","useJobsAndCompensationsCreateCompensationMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","isCommissionOnly","isOwner","isFlsaSelectionEnabled","isAdjustMinimumWageEnabled","TIP_CREDITS_UNSUPPORTED_STATES","minimumWageOptions","wage","baseMetadata","useDeriveFieldsMetadata","effectiveDateMinDate","max","fieldsMetadata","withOptions","onSubmit","options","submitResult","resolve","data","payload","resolvedJobId","resolvedCompensationId","resolvedMode","resolvedEffectiveDate","requestBodyBase","result","SDKInternalError","resolvedVersion","isDataLoading","hookFormInternals","useHookFormInternals","TitleField","FlsaStatusField","RateField","PaymentUnitField","AdjustForMinimumWageField","MinimumWageIdField","EffectiveDateField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAwJA,SAASA,GACPC,GACAC,GACAC,GACwD;AACxD,MAAI,CAACF,EAAM,QAAO,EAAE,cAAc,MAAM,KAAK,KAAA;AAC7C,MAAIC,GAAgB;AAClB,eAAWE,KAAOH,GAAM;AACtB,YAAMI,IAAeD,EAAI,eAAe,KAAK,CAAAE,MAAKA,EAAE,SAASJ,CAAc;AAC3E,UAAIG,EAAc,QAAO,EAAE,cAAAA,GAAc,KAAAD,EAAA;AAAA,IAC3C;AAIA,WAAO,EAAE,cAAc,MAAM,KADTD,IAASF,EAAK,KAAK,OAAKM,EAAE,SAASJ,CAAK,KAAK,OAAQ,KACvC;AAAA,EACpC;AACA,SAAIA,IAAc,EAAE,cAAc,MAAM,KAAKF,EAAK,KAAK,CAAAM,MAAKA,EAAE,SAASJ,CAAK,KAAK,KAAA,IAC1E,EAAE,cAAc,MAAM,KAAK,KAAA;AACpC;AAEA,SAASK,GAAsBP,GAAgD;AAC7E,MAAI,CAACA,EAAM,QAAO;AAClB,aAAWG,KAAOH,GAAM;AACtB,QAAI,CAACG,EAAI,QAAS;AA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AAA,IACF,CAAC,GAEMD;AAAA,EACT,GAEMY,KAAgB/F,IAClBM,EAAU,aACVG,EAAe,aACfE,EAAc,aACdO,EAAc,YACd,IAEE8E,KAAoBC,GAAqBtD,CAAW;AAE1D,SAAIoD,MAAkB/F,MAAe,CAACa,KAAgB,CAACI,MAC9C,EAAE,WAAW,IAAe,eAAAiD,GAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,cAAc7C;AAAA,MACd,YAAAC;AAAA,MACA,cAAAF;AAAA,MACA,sBAAsByD;AAAA,MACtB,sBAAA/C;AAAA,MACA,8BAAAD;AAAA,IAAA;AAAA,IAEF,QAAQ;AAAA,MACN,WAAAgC;AAAA,MACA,MAAA7B;AAAA,MACA,yBAAAsB;AAAA,IAAA;AAAA,IAEF,SAAS,EAAE,UAAA2B,GAAA;AAAA,IACX,eAAAf;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,OAAOgC;AAAA,QACP,YAAY5B,KAAyB6B,KAAkB;AAAA,QACvD,MAAMC;AAAA,QACN,aAAaC;AAAA,QACb,sBAAsB9B,IAA6B+B,KAA4B;AAAA,QAC/E,eACE/B,KAA8BpB,KAC1BoD,KACA;AAAA,QACN,eAAelG,IAAyBmG,KAAqB;AAAA,MAAA;AAAA,MAE/D,gBAAAzB;AAAA,MACA,mBAAAiB;AAAA,MACA,yBAAyBS,GAA8B9D,GAAaL,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
@@ -1,132 +1,144 @@
|
|
|
1
|
-
import { jsx as s, jsxs as
|
|
2
|
-
import { useState as B, useCallback as o, Suspense as
|
|
3
|
-
import { useTranslation as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
1
|
+
import { jsx as s, jsxs as D } from "react/jsx-runtime";
|
|
2
|
+
import { useState as B, useCallback as o, Suspense as l } from "react";
|
|
3
|
+
import { useTranslation as m } from "react-i18next";
|
|
4
|
+
import { useEmployeesGetSuspense as R } from "@gusto/embedded-api/react-query/employeesGet";
|
|
5
|
+
import { BasicDetailsViewWithData as k } from "./BasicDetailsView.js";
|
|
6
|
+
import { JobAndPayView as H } from "./JobAndPayView.js";
|
|
6
7
|
import { TaxesViewWithData as F } from "./TaxesView.js";
|
|
7
8
|
import { DocumentsViewWithData as J } from "./DocumentsView.js";
|
|
8
|
-
import { Flex as
|
|
9
|
-
import { useComponentContext as
|
|
10
|
-
import { BaseBoundaries as
|
|
11
|
-
import { useI18n as
|
|
9
|
+
import { Flex as b } from "../../Common/Flex/Flex.js";
|
|
10
|
+
import { useComponentContext as u } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
11
|
+
import { BaseBoundaries as V, BaseLayout as E } from "../../Base/Base.js";
|
|
12
|
+
import { useI18n as W, useComponentDictionary as w } from "../../../i18n/I18n.js";
|
|
12
13
|
import { componentEvents as i } from "../../../shared/constants.js";
|
|
13
|
-
|
|
14
|
+
import { firstLastName as j } from "../../../helpers/formattedStrings.js";
|
|
15
|
+
function G({
|
|
14
16
|
employeeId: a,
|
|
15
|
-
dictionary:
|
|
17
|
+
dictionary: r,
|
|
16
18
|
onEvent: t,
|
|
17
|
-
selectedTab:
|
|
19
|
+
selectedTab: d
|
|
18
20
|
}) {
|
|
19
|
-
|
|
20
|
-
const { t:
|
|
21
|
+
W("Employee.Dashboard"), w("Employee.Dashboard", r);
|
|
22
|
+
const { t: c } = m("Employee.Dashboard"), A = u(), [_, f] = B("basicDetails"), e = d ?? _, T = o(() => {
|
|
21
23
|
t(i.EMPLOYEE_UPDATE, { employeeId: a });
|
|
22
24
|
}, [t, a]), O = o(() => {
|
|
23
25
|
t(i.EMPLOYEE_HOME_ADDRESS, { employeeId: a });
|
|
24
|
-
}, [t, a]),
|
|
26
|
+
}, [t, a]), L = o(() => {
|
|
25
27
|
t(i.EMPLOYEE_WORK_ADDRESS, { employeeId: a });
|
|
26
|
-
}, [t, a]),
|
|
28
|
+
}, [t, a]), M = o(
|
|
27
29
|
(n) => {
|
|
28
30
|
t(i.EMPLOYEE_COMPENSATION_CREATE, { employeeId: a, job: n });
|
|
29
31
|
},
|
|
30
32
|
[t, a]
|
|
31
|
-
),
|
|
33
|
+
), x = o(() => {
|
|
32
34
|
t(i.EMPLOYEE_JOB_ADD, { employeeId: a });
|
|
33
|
-
}, [t, a]), M = o(() => {
|
|
34
|
-
t(i.EMPLOYEE_JOB_ADD_ANOTHER, { employeeId: a });
|
|
35
35
|
}, [t, a]), P = o(() => {
|
|
36
|
+
t(i.EMPLOYEE_JOB_ADD_ANOTHER, { employeeId: a });
|
|
37
|
+
}, [t, a]), S = o(() => {
|
|
36
38
|
t(i.EMPLOYEE_DEDUCTION_ADD, { employeeId: a });
|
|
37
|
-
}, [t, a]),
|
|
39
|
+
}, [t, a]), C = o(
|
|
38
40
|
(n) => {
|
|
39
41
|
t(i.EMPLOYEE_DEDUCTION_EDIT, n);
|
|
40
42
|
},
|
|
41
43
|
[t]
|
|
42
|
-
),
|
|
44
|
+
), g = o(
|
|
43
45
|
(n) => {
|
|
44
46
|
t(i.EMPLOYEE_FEDERAL_TAXES_EDIT, { employeeId: a, federalTaxes: n });
|
|
45
47
|
},
|
|
46
48
|
[t, a]
|
|
47
|
-
),
|
|
49
|
+
), p = o(() => {
|
|
48
50
|
t(i.EMPLOYEE_STATE_TAXES_EDIT, { employeeId: a });
|
|
49
51
|
}, [t, a]), Y = o(
|
|
50
52
|
(n) => {
|
|
51
53
|
t(i.EMPLOYEE_VIEW_FORM_TO_SIGN, { employeeId: a, formId: n });
|
|
52
54
|
},
|
|
53
55
|
[t, a]
|
|
54
|
-
),
|
|
56
|
+
), N = [
|
|
55
57
|
{
|
|
56
58
|
id: "basicDetails",
|
|
57
|
-
label:
|
|
59
|
+
label: c("tabs.basicDetails"),
|
|
58
60
|
content: null
|
|
59
61
|
},
|
|
60
62
|
{
|
|
61
63
|
id: "jobAndPay",
|
|
62
|
-
label:
|
|
64
|
+
label: c("tabs.jobAndPay"),
|
|
63
65
|
content: null
|
|
64
66
|
},
|
|
65
67
|
{
|
|
66
68
|
id: "taxes",
|
|
67
|
-
label:
|
|
69
|
+
label: c("tabs.taxes"),
|
|
68
70
|
content: null
|
|
69
71
|
},
|
|
70
72
|
{
|
|
71
73
|
id: "documents",
|
|
72
|
-
label:
|
|
74
|
+
label: c("tabs.documents"),
|
|
73
75
|
content: null
|
|
74
76
|
}
|
|
75
77
|
];
|
|
76
|
-
return /* @__PURE__ */ b
|
|
78
|
+
return /* @__PURE__ */ D(b, { flexDirection: "column", gap: 32, children: [
|
|
79
|
+
/* @__PURE__ */ s(l, { fallback: null, children: /* @__PURE__ */ s(U, { employeeId: a }) }),
|
|
77
80
|
/* @__PURE__ */ s(
|
|
78
|
-
|
|
81
|
+
A.Tabs,
|
|
79
82
|
{
|
|
80
|
-
tabs:
|
|
81
|
-
selectedId:
|
|
83
|
+
tabs: N,
|
|
84
|
+
selectedId: e,
|
|
82
85
|
onSelectionChange: (n) => {
|
|
83
|
-
const
|
|
84
|
-
|
|
86
|
+
const h = n;
|
|
87
|
+
f(h), t(i.EMPLOYEE_DASHBOARD_TAB_CHANGE, { tab: h });
|
|
85
88
|
},
|
|
86
|
-
"aria-label":
|
|
89
|
+
"aria-label": c("tabsLabel")
|
|
87
90
|
}
|
|
88
91
|
),
|
|
89
|
-
/* @__PURE__ */ b
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
/* @__PURE__ */ D(b, { flexDirection: "column", gap: 24, children: [
|
|
93
|
+
e === "basicDetails" && /* @__PURE__ */ s(l, { fallback: /* @__PURE__ */ s(E, { isLoading: !0 }), children: /* @__PURE__ */ s(
|
|
94
|
+
k,
|
|
92
95
|
{
|
|
93
96
|
employeeId: a,
|
|
94
97
|
onEditBasicDetails: T,
|
|
95
98
|
onManageHomeAddress: O,
|
|
96
|
-
onManageWorkAddress:
|
|
99
|
+
onManageWorkAddress: L
|
|
97
100
|
}
|
|
98
101
|
) }),
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
e === "jobAndPay" && /* @__PURE__ */ s(l, { fallback: /* @__PURE__ */ s(E, { isLoading: !0 }), children: /* @__PURE__ */ s(
|
|
103
|
+
H,
|
|
101
104
|
{
|
|
102
105
|
employeeId: a,
|
|
103
106
|
onEvent: t,
|
|
104
|
-
onEditCompensation:
|
|
105
|
-
onAddJob:
|
|
106
|
-
onAddAnotherJob:
|
|
107
|
-
onAddDeduction:
|
|
108
|
-
onEditDeduction:
|
|
107
|
+
onEditCompensation: M,
|
|
108
|
+
onAddJob: x,
|
|
109
|
+
onAddAnotherJob: P,
|
|
110
|
+
onAddDeduction: S,
|
|
111
|
+
onEditDeduction: C
|
|
109
112
|
}
|
|
110
113
|
) }),
|
|
111
|
-
|
|
114
|
+
e === "taxes" && /* @__PURE__ */ s(l, { fallback: /* @__PURE__ */ s(E, { isLoading: !0 }), children: /* @__PURE__ */ s(
|
|
112
115
|
F,
|
|
113
116
|
{
|
|
114
117
|
employeeId: a,
|
|
115
|
-
onEditFederalTaxes:
|
|
116
|
-
onEditStateTaxes:
|
|
118
|
+
onEditFederalTaxes: g,
|
|
119
|
+
onEditStateTaxes: p
|
|
117
120
|
}
|
|
118
121
|
) }),
|
|
119
|
-
|
|
122
|
+
e === "documents" && /* @__PURE__ */ s(l, { fallback: /* @__PURE__ */ s(E, { isLoading: !0 }), children: /* @__PURE__ */ s(J, { employeeId: a, onViewForm: Y }) })
|
|
120
123
|
] })
|
|
121
124
|
] });
|
|
122
125
|
}
|
|
123
|
-
function
|
|
126
|
+
function U({ employeeId: a }) {
|
|
127
|
+
const { t: r } = m("Employee.Dashboard"), t = u(), {
|
|
128
|
+
data: { employee: d }
|
|
129
|
+
} = R({ employeeId: a });
|
|
130
|
+
return /* @__PURE__ */ D(b, { flexDirection: "column", gap: 4, children: [
|
|
131
|
+
/* @__PURE__ */ s(t.Heading, { as: "h2", children: j({ first_name: d?.firstName, last_name: d?.lastName }) }),
|
|
132
|
+
/* @__PURE__ */ s(t.Text, { children: r("employeeRoleLabel") })
|
|
133
|
+
] });
|
|
134
|
+
}
|
|
135
|
+
function oa({
|
|
124
136
|
FallbackComponent: a,
|
|
125
|
-
...
|
|
137
|
+
...r
|
|
126
138
|
}) {
|
|
127
|
-
return /* @__PURE__ */ s(
|
|
139
|
+
return /* @__PURE__ */ s(V, { componentName: "Employee.Dashboard", FallbackComponent: a, children: /* @__PURE__ */ s(G, { ...r }) });
|
|
128
140
|
}
|
|
129
141
|
export {
|
|
130
|
-
|
|
142
|
+
oa as Dashboard
|
|
131
143
|
};
|
|
132
144
|
//# sourceMappingURL=Dashboard.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Dashboard.js","sources":["../../../../src/components/Employee/Dashboard/Dashboard.tsx"],"sourcesContent":["import { Suspense, useState, useCallback } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport type { GetV1EmployeesEmployeeIdFederalTaxesResponse } from '@gusto/embedded-api/models/operations/getv1employeesemployeeidfederaltaxes'\nimport { BasicDetailsViewWithData } from './BasicDetailsView'\nimport { JobAndPayView } from './JobAndPayView'\nimport { TaxesViewWithData } from './TaxesView'\nimport { DocumentsViewWithData } from './DocumentsView'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { BaseBoundaries, BaseLayout, type BaseComponentInterface } from '@/components/Base/Base'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\n\ntype EmployeeFederalTax = NonNullable<\n GetV1EmployeesEmployeeIdFederalTaxesResponse['employeeFederalTax']\n>\n\nexport type DashboardTab = 'basicDetails' | 'jobAndPay' | 'taxes' | 'documents'\n\nexport interface DashboardProps extends BaseComponentInterface<'Employee.Dashboard'> {\n employeeId: string\n selectedTab?: DashboardTab\n}\n\nfunction DashboardRoot({\n employeeId,\n dictionary,\n onEvent,\n selectedTab: controlledTab,\n}: DashboardProps) {\n useI18n('Employee.Dashboard')\n useComponentDictionary('Employee.Dashboard', dictionary)\n const { t } = useTranslation('Employee.Dashboard')\n const Components = useComponentContext()\n const [internalTab, setInternalTab] = useState<DashboardTab>('basicDetails')\n const selectedTab = controlledTab ?? internalTab\n\n const handleEditBasicDetails = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_UPDATE, { employeeId })\n }, [onEvent, employeeId])\n\n const handleManageHomeAddress = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_HOME_ADDRESS, { employeeId })\n }, [onEvent, employeeId])\n\n const handleManageWorkAddress = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS, { employeeId })\n }, [onEvent, employeeId])\n\n const handleEditCompensation = useCallback(\n (job: Job) => {\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_CREATE, { employeeId, job })\n },\n [onEvent, employeeId],\n )\n\n const handleAddJob = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_JOB_ADD, { employeeId })\n }, [onEvent, employeeId])\n\n const handleAddAnotherJob = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_JOB_ADD_ANOTHER, { employeeId })\n }, [onEvent, employeeId])\n\n const handleAddDeduction = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_ADD, { employeeId })\n }, [onEvent, employeeId])\n\n const handleEditDeduction = useCallback(\n (deduction: Garnishment) => {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_EDIT, deduction)\n },\n [onEvent],\n )\n\n const handleEditFederalTaxes = useCallback(\n (federalTaxes: EmployeeFederalTax | undefined) => {\n onEvent(componentEvents.EMPLOYEE_FEDERAL_TAXES_EDIT, { employeeId, federalTaxes })\n },\n [onEvent, employeeId],\n )\n\n const handleEditStateTaxes = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_STATE_TAXES_EDIT, { employeeId })\n }, [onEvent, employeeId])\n\n const handleViewForm = useCallback(\n (formId: string) => {\n onEvent(componentEvents.EMPLOYEE_VIEW_FORM_TO_SIGN, { employeeId, formId })\n },\n [onEvent, employeeId],\n )\n\n const tabs = [\n {\n id: 'basicDetails' as const,\n label: t('tabs.basicDetails'),\n content: null,\n },\n {\n id: 'jobAndPay' as const,\n label: t('tabs.jobAndPay'),\n content: null,\n },\n {\n id: 'taxes' as const,\n label: t('tabs.taxes'),\n content: null,\n },\n {\n id: 'documents' as const,\n label: t('tabs.documents'),\n content: null,\n },\n ]\n\n return (\n <Flex flexDirection=\"column\" gap={32}>\n <Components.Tabs\n tabs={tabs}\n selectedId={selectedTab}\n onSelectionChange={id => {\n const next = id as DashboardTab\n setInternalTab(next)\n onEvent(componentEvents.EMPLOYEE_DASHBOARD_TAB_CHANGE, { tab: next })\n }}\n aria-label={t('tabsLabel')}\n />\n\n <Flex flexDirection=\"column\" gap={24}>\n {selectedTab === 'basicDetails' && (\n <Suspense fallback={<BaseLayout isLoading />}>\n <BasicDetailsViewWithData\n employeeId={employeeId}\n onEditBasicDetails={handleEditBasicDetails}\n onManageHomeAddress={handleManageHomeAddress}\n onManageWorkAddress={handleManageWorkAddress}\n />\n </Suspense>\n )}\n\n {selectedTab === 'jobAndPay' && (\n <Suspense fallback={<BaseLayout isLoading />}>\n <JobAndPayView\n employeeId={employeeId}\n onEvent={onEvent}\n onEditCompensation={handleEditCompensation}\n onAddJob={handleAddJob}\n onAddAnotherJob={handleAddAnotherJob}\n onAddDeduction={handleAddDeduction}\n onEditDeduction={handleEditDeduction}\n />\n </Suspense>\n )}\n\n {selectedTab === 'taxes' && (\n <Suspense fallback={<BaseLayout isLoading />}>\n <TaxesViewWithData\n employeeId={employeeId}\n onEditFederalTaxes={handleEditFederalTaxes}\n onEditStateTaxes={handleEditStateTaxes}\n />\n </Suspense>\n )}\n\n {selectedTab === 'documents' && (\n <Suspense fallback={<BaseLayout isLoading />}>\n <DocumentsViewWithData employeeId={employeeId} onViewForm={handleViewForm} />\n </Suspense>\n )}\n </Flex>\n </Flex>\n )\n}\n\nexport function Dashboard({\n FallbackComponent,\n ...props\n}: DashboardProps & BaseComponentInterface) {\n return (\n <BaseBoundaries componentName=\"Employee.Dashboard\" FallbackComponent={FallbackComponent}>\n <DashboardRoot {...props} />\n </BaseBoundaries>\n )\n}\n"],"names":["DashboardRoot","employeeId","dictionary","onEvent","controlledTab","useI18n","useComponentDictionary","t","useTranslation","Components","useComponentContext","internalTab","setInternalTab","useState","selectedTab","handleEditBasicDetails","useCallback","componentEvents","handleManageHomeAddress","handleManageWorkAddress","handleEditCompensation","job","handleAddJob","handleAddAnotherJob","handleAddDeduction","handleEditDeduction","deduction","handleEditFederalTaxes","federalTaxes","handleEditStateTaxes","handleViewForm","formId","tabs","jsxs","Flex","jsx","id","next","Suspense","BaseLayout","BasicDetailsViewWithData","JobAndPayView","TaxesViewWithData","DocumentsViewWithData","Dashboard","FallbackComponent","props","BaseBoundaries"],"mappings":";;;;;;;;;;;;AA0BA,SAASA,EAAc;AAAA,EACrB,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,aAAaC;AACf,GAAmB;AACjB,EAAAC,EAAQ,oBAAoB,GAC5BC,EAAuB,sBAAsBJ,CAAU;AACvD,QAAM,EAAE,GAAAK,EAAA,IAAMC,EAAe,oBAAoB,GAC3CC,IAAaC,EAAA,GACb,CAACC,GAAaC,CAAc,IAAIC,EAAuB,cAAc,GACrEC,IAAcV,KAAiBO,GAE/BI,IAAyBC,EAAY,MAAM;AAC/C,IAAAb,EAAQc,EAAgB,iBAAiB,EAAE,YAAAhB,EAAA,CAAY;AAAA,EACzD,GAAG,CAACE,GAASF,CAAU,CAAC,GAElBiB,IAA0BF,EAAY,MAAM;AAChD,IAAAb,EAAQc,EAAgB,uBAAuB,EAAE,YAAAhB,EAAA,CAAY;AAAA,EAC/D,GAAG,CAACE,GAASF,CAAU,CAAC,GAElBkB,IAA0BH,EAAY,MAAM;AAChD,IAAAb,EAAQc,EAAgB,uBAAuB,EAAE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AAAA,UACC,YAAAxC;AAAA,UACA,SAAAE;AAAA,UACA,oBAAoBiB;AAAA,UACpB,UAAUE;AAAA,UACV,iBAAiBC;AAAA,UACjB,gBAAgBC;AAAA,UAChB,iBAAiBC;AAAA,QAAA;AAAA,MAAA,GAErB;AAAA,MAGDX,MAAgB,WACf,gBAAAqB,EAACG,GAAA,EAAS,UAAU,gBAAAH,EAACI,GAAA,EAAW,WAAS,IAAC,GACxC,UAAA,gBAAAJ;AAAA,QAACO;AAAA,QAAA;AAAA,UACC,YAAAzC;AAAA,UACA,oBAAoB0B;AAAA,UACpB,kBAAkBE;AAAA,QAAA;AAAA,MAAA,GAEtB;AAAA,MAGDf,MAAgB,eACf,gBAAAqB,EAACG,GAAA,EAAS,UAAU,gBAAAH,EAACI,GAAA,EAAW,WAAS,GAAA,CAAC,GACxC,UAAA,gBAAAJ,EAACQ,GAAA,EAAsB,YAAA1C,GAAwB,YAAY6B,GAAgB,EAAA,CAC7E;AAAA,IAAA,EAAA,CAEJ;AAAA,EAAA,GACF;AAEJ;AAEO,SAASc,EAAU;AAAA,EACxB,mBAAAC;AAAA,EACA,GAAGC;AACL,GAA4C;AAC1C,SACE,gBAAAX,EAACY,KAAe,eAAc,sBAAqB,mBAAAF,GACjD,UAAA,gBAAAV,EAACnC,GAAA,EAAe,GAAG8C,EAAA,CAAO,EAAA,CAC5B;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Dashboard.js","sources":["../../../../src/components/Employee/Dashboard/Dashboard.tsx"],"sourcesContent":["import { Suspense, useState, useCallback } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport type { GetV1EmployeesEmployeeIdFederalTaxesResponse } from '@gusto/embedded-api/models/operations/getv1employeesemployeeidfederaltaxes'\nimport { BasicDetailsViewWithData } from './BasicDetailsView'\nimport { JobAndPayView } from './JobAndPayView'\nimport { TaxesViewWithData } from './TaxesView'\nimport { DocumentsViewWithData } from './DocumentsView'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { BaseBoundaries, BaseLayout, type BaseComponentInterface } from '@/components/Base/Base'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { firstLastName } from '@/helpers/formattedStrings'\n\ntype EmployeeFederalTax = NonNullable<\n GetV1EmployeesEmployeeIdFederalTaxesResponse['employeeFederalTax']\n>\n\nexport type DashboardTab = 'basicDetails' | 'jobAndPay' | 'taxes' | 'documents'\n\nexport interface DashboardProps extends BaseComponentInterface<'Employee.Dashboard'> {\n employeeId: string\n selectedTab?: DashboardTab\n}\n\nfunction DashboardRoot({\n employeeId,\n dictionary,\n onEvent,\n selectedTab: controlledTab,\n}: DashboardProps) {\n useI18n('Employee.Dashboard')\n useComponentDictionary('Employee.Dashboard', dictionary)\n const { t } = useTranslation('Employee.Dashboard')\n const Components = useComponentContext()\n const [internalTab, setInternalTab] = useState<DashboardTab>('basicDetails')\n const selectedTab = controlledTab ?? internalTab\n\n const handleEditBasicDetails = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_UPDATE, { employeeId })\n }, [onEvent, employeeId])\n\n const handleManageHomeAddress = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_HOME_ADDRESS, { employeeId })\n }, [onEvent, employeeId])\n\n const handleManageWorkAddress = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_WORK_ADDRESS, { employeeId })\n }, [onEvent, employeeId])\n\n const handleEditCompensation = useCallback(\n (job: Job) => {\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_CREATE, { employeeId, job })\n },\n [onEvent, employeeId],\n )\n\n const handleAddJob = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_JOB_ADD, { employeeId })\n }, [onEvent, employeeId])\n\n const handleAddAnotherJob = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_JOB_ADD_ANOTHER, { employeeId })\n }, [onEvent, employeeId])\n\n const handleAddDeduction = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_ADD, { employeeId })\n }, [onEvent, employeeId])\n\n const handleEditDeduction = useCallback(\n (deduction: Garnishment) => {\n onEvent(componentEvents.EMPLOYEE_DEDUCTION_EDIT, deduction)\n },\n [onEvent],\n )\n\n const handleEditFederalTaxes = useCallback(\n (federalTaxes: EmployeeFederalTax | undefined) => {\n onEvent(componentEvents.EMPLOYEE_FEDERAL_TAXES_EDIT, { employeeId, federalTaxes })\n },\n [onEvent, employeeId],\n )\n\n const handleEditStateTaxes = useCallback(() => {\n onEvent(componentEvents.EMPLOYEE_STATE_TAXES_EDIT, { employeeId })\n }, [onEvent, employeeId])\n\n const handleViewForm = useCallback(\n (formId: string) => {\n onEvent(componentEvents.EMPLOYEE_VIEW_FORM_TO_SIGN, { employeeId, formId })\n },\n [onEvent, employeeId],\n )\n\n const tabs = [\n {\n id: 'basicDetails' as const,\n label: t('tabs.basicDetails'),\n content: null,\n },\n {\n id: 'jobAndPay' as const,\n label: t('tabs.jobAndPay'),\n content: null,\n },\n {\n id: 'taxes' as const,\n label: t('tabs.taxes'),\n content: null,\n },\n {\n id: 'documents' as const,\n label: t('tabs.documents'),\n content: null,\n },\n ]\n\n return (\n <Flex flexDirection=\"column\" gap={32}>\n <Suspense fallback={null}>\n <DashboardHeader employeeId={employeeId} />\n </Suspense>\n <Components.Tabs\n tabs={tabs}\n selectedId={selectedTab}\n onSelectionChange={id => {\n const next = id as DashboardTab\n setInternalTab(next)\n onEvent(componentEvents.EMPLOYEE_DASHBOARD_TAB_CHANGE, { tab: next })\n }}\n aria-label={t('tabsLabel')}\n />\n\n <Flex flexDirection=\"column\" gap={24}>\n {selectedTab === 'basicDetails' && (\n <Suspense fallback={<BaseLayout isLoading />}>\n <BasicDetailsViewWithData\n employeeId={employeeId}\n onEditBasicDetails={handleEditBasicDetails}\n onManageHomeAddress={handleManageHomeAddress}\n onManageWorkAddress={handleManageWorkAddress}\n />\n </Suspense>\n )}\n\n {selectedTab === 'jobAndPay' && (\n <Suspense fallback={<BaseLayout isLoading />}>\n <JobAndPayView\n employeeId={employeeId}\n onEvent={onEvent}\n onEditCompensation={handleEditCompensation}\n onAddJob={handleAddJob}\n onAddAnotherJob={handleAddAnotherJob}\n onAddDeduction={handleAddDeduction}\n onEditDeduction={handleEditDeduction}\n />\n </Suspense>\n )}\n\n {selectedTab === 'taxes' && (\n <Suspense fallback={<BaseLayout isLoading />}>\n <TaxesViewWithData\n employeeId={employeeId}\n onEditFederalTaxes={handleEditFederalTaxes}\n onEditStateTaxes={handleEditStateTaxes}\n />\n </Suspense>\n )}\n\n {selectedTab === 'documents' && (\n <Suspense fallback={<BaseLayout isLoading />}>\n <DocumentsViewWithData employeeId={employeeId} onViewForm={handleViewForm} />\n </Suspense>\n )}\n </Flex>\n </Flex>\n )\n}\n\nfunction DashboardHeader({ employeeId }: { employeeId: string }) {\n const { t } = useTranslation('Employee.Dashboard')\n const Components = useComponentContext()\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n\n return (\n <Flex flexDirection=\"column\" gap={4}>\n <Components.Heading as=\"h2\">\n {firstLastName({ first_name: employee?.firstName, last_name: employee?.lastName })}\n </Components.Heading>\n <Components.Text>{t('employeeRoleLabel')}</Components.Text>\n </Flex>\n )\n}\n\nexport function Dashboard({\n FallbackComponent,\n ...props\n}: DashboardProps & BaseComponentInterface) {\n return (\n <BaseBoundaries componentName=\"Employee.Dashboard\" FallbackComponent={FallbackComponent}>\n <DashboardRoot {...props} />\n </BaseBoundaries>\n )\n}\n"],"names":["DashboardRoot","employeeId","dictionary","onEvent","controlledTab","useI18n","useComponentDictionary","t","useTranslation","Components","useComponentContext","internalTab","setInternalTab","useState","selectedTab","handleEditBasicDetails","useCallback","componentEvents","handleManageHomeAddress","handleManageWorkAddress","handleEditCompensation","job","handleAddJob","handleAddAnotherJob","handleAddDeduction","handleEditDeduction","deduction","handleEditFederalTaxes","federalTaxes","handleEditStateTaxes","handleViewForm","formId","tabs","jsxs","Flex","jsx","Suspense","DashboardHeader","id","next","BaseLayout","BasicDetailsViewWithData","JobAndPayView","TaxesViewWithData","DocumentsViewWithData","employee","useEmployeesGetSuspense","firstLastName","Dashboard","FallbackComponent","props","BaseBoundaries"],"mappings":";;;;;;;;;;;;;;AA4BA,SAASA,EAAc;AAAA,EACrB,YAAAC;AAAA,EACA,YAAAC;AAAA,EACA,SAAAC;AAAA,EACA,aAAaC;AACf,GAAmB;AACjB,EAAAC,EAAQ,oBAAoB,GAC5BC,EAAuB,sBAAsBJ,CAAU;AACvD,QAAM,EAAE,GAAAK,EAAA,IAAMC,EAAe,oBAAoB,GAC3CC,IAAaC,EAAA,GACb,CAACC,GAAaC,CAAc,IAAIC,EAAuB,cAAc,GACrEC,IAAcV,KAAiBO,GAE/BI,IAAyBC,EAAY,MAAM;AAC/C,IAAAb,EAAQc,EAAgB,iBAAiB,EAAE,YAAAhB,EAAA,CAAY;AAAA,EACzD,GAAG,CAACE,GAASF,CAAU,CAAC,GAElBiB,IAA0BF,EAAY,MAAM;AAChD,IAAAb,EAAQc,EAAgB,uBAAuB,EAAE,YAAAhB,EAAA,CAAY;AAAA,EAC/D,GAAG,CAACE,GAASF,CAAU,CAAC,GAElBkB,IAA0BH,EAAY,MAAM;AAChD,IAAAb,EAAQc,EAAgB,uBAAuB,EAAE,YAAAhB,EAAA,CAAY;AAAA,EAC/D,GAAG,CAACE,GAASF,CAAU,CAAC,GAElBmB,IAAyBJ;AAAA,IAC7B,CAACK,MAAa;AACZ,MAAAlB,EAAQc,EAAgB,8BAA8B,EAAE,YAAAhB,GAAY,KAAAoB,GAAK;AAAA,IAC3E;AAAA,IACA,CAAClB,GAASF,CAAU;AAAA,EAAA,GAGhBqB,IAAeN,EAAY,MAAM;AACrC,IAAAb,EAAQc,EAAgB,kBAAkB,EAA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DashboardTab } from './Dashboard';
|
|
3
3
|
import { FlowContextInterface } from '../../Flow/useFlow';
|
|
4
|
-
export type DashboardSuccessAlert = 'bankAccountAdded' | 'bankAccountDeleted' | 'splitUpdated' | 'deductionAdded' | 'deductionUpdated' | 'deductionDeleted';
|
|
4
|
+
export type DashboardSuccessAlert = 'bankAccountAdded' | 'bankAccountDeleted' | 'splitUpdated' | 'deductionAdded' | 'deductionUpdated' | 'deductionDeleted' | 'jobAdded';
|
|
5
5
|
export interface DashboardContextInterface extends FlowContextInterface {
|
|
6
6
|
employeeId: string;
|
|
7
7
|
formId?: string;
|
|
@@ -24,6 +24,6 @@ export declare function PaymentBankFormContextual(): import("react/jsx-runtime")
|
|
|
24
24
|
export declare function PaymentSplitViewContextual(): import("react/jsx-runtime").JSX.Element;
|
|
25
25
|
export declare function DocumentManagerContextual(): import("react/jsx-runtime").JSX.Element;
|
|
26
26
|
export declare function DeductionFormContextual(): import("react/jsx-runtime").JSX.Element;
|
|
27
|
-
export declare function
|
|
27
|
+
export declare function AddJobContextual(): import("react/jsx-runtime").JSX.Element;
|
|
28
28
|
export declare function EditCompensationContextual(): import("react/jsx-runtime").JSX.Element;
|
|
29
|
-
export declare function
|
|
29
|
+
export declare function AddAnotherJobContextual(): import("react/jsx-runtime").JSX.Element;
|