@gusto/embedded-react-sdk 0.57.2 → 0.57.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/dist/components/Common/DateRangeFilter/DateRangeFilter.js +32 -32
- package/dist/components/Common/DateRangeFilter/DateRangeFilter.js.map +1 -1
- package/dist/components/Common/OnboardingStatusBadge/index.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js +34 -14
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.js +106 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.js +136 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js +38 -20
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js +78 -44
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js +45 -37
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js +244 -95
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js +22 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.js +13 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js +48 -43
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.js +57 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.js +83 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.js +84 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js +109 -39
- package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js.map +1 -1
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.js.map +1 -1
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js +5 -5
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js.map +1 -1
- package/dist/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.js +1 -1
- package/dist/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.js.map +1 -1
- package/dist/components/Contractor/Compensation/shared/useContractorCompensationSummary/useContractorCompensationSummary.js +4 -4
- package/dist/components/Contractor/Compensation/shared/useContractorCompensationSummary/useContractorCompensationSummary.js.map +1 -1
- package/dist/components/Contractor/Compensation/shared/useContractorPayForm/useContractorPayForm.js +3 -3
- package/dist/components/Contractor/Compensation/shared/useContractorPayForm/useContractorPayForm.js.map +1 -1
- package/dist/components/Contractor/ContractorList/shared/useContractorList.js +6 -6
- package/dist/components/Contractor/ContractorList/shared/useContractorList.js.map +1 -1
- package/dist/components/Contractor/Dashboard/Dashboard.js +20 -20
- package/dist/components/Contractor/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Contractor/Dismissal/useDismissal/useDismissal.js +10 -10
- package/dist/components/Contractor/Dismissal/useDismissal/useDismissal.js.map +1 -1
- package/dist/components/Contractor/Landing/Landing.js +43 -39
- package/dist/components/Contractor/Landing/Landing.js.map +1 -1
- package/dist/components/Contractor/NewHireReport/NewHireReport.js +3 -3
- package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
- package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js +1 -1
- package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js +10 -10
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -1
- package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js +4 -4
- package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js +8 -8
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js +5 -5
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js +3 -3
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js.map +1 -1
- package/dist/components/Contractor/Profile/onboarding/SelfOnboardingContractorProfile.js +1 -1
- package/dist/components/Contractor/Profile/onboarding/SelfOnboardingContractorProfile.js.map +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js.map +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorProfileSummary/useContractorProfileSummary.js +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorProfileSummary/useContractorProfileSummary.js.map +1 -1
- package/dist/components/Contractor/SelfOnboardingFlow/SelfOnboardingComponents.js +2 -9
- package/dist/components/Contractor/SelfOnboardingFlow/SelfOnboardingComponents.js.map +1 -1
- package/dist/components/Contractor/Submit/Submit.js +18 -18
- package/dist/components/Contractor/Submit/Submit.js.map +1 -1
- package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js +6 -6
- package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +25 -25
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.js +15 -15
- package/dist/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +1 -1
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
- package/dist/components/Employee/Dashboard/Dashboard.js +25 -25
- package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js +7 -7
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js +1 -1
- package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js +6 -6
- package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js.map +1 -1
- package/dist/components/Employee/Landing/Landing.js +37 -33
- package/dist/components/Employee/Landing/Landing.js.map +1 -1
- package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js +27 -27
- package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js +6 -6
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.js +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.js.map +1 -1
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.js +8 -15
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js +11 -11
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js +12 -12
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js +26 -26
- package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +66 -64
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +1 -1
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js +6 -6
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistory.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +6 -6
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js +9 -9
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js.map +1 -1
- package/dist/components/Payroll/helpers.js +1 -1
- package/dist/components/Payroll/helpers.js.map +1 -1
- package/dist/components/Payroll/payrollTypes.js +1 -1
- package/dist/components/Payroll/payrollTypes.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js +1 -1
- package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js.map +1 -1
- package/dist/i18n/en/Company.Management.PaySchedule.json.js +31 -13
- package/dist/i18n/en/Company.Management.PaySchedule.json.js.map +1 -1
- package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js +20 -12
- package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollHistory.json.js +1 -1
- package/dist/i18n/en/Payroll.PayrollList.json.js +5 -5
- package/dist/package.json.js +1 -1
- package/dist/shared/constants.js +5 -5
- package/dist/shared/constants.js.map +1 -1
- package/dist/src/components/Common/DateRangeFilter/DateRangeFilter.d.ts +2 -2
- package/dist/src/components/Common/OnboardingStatusBadge/index.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.d.ts +10 -3
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.d.ts +21 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.d.ts +34 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.d.ts +9 -3
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.d.ts +5 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.d.ts +10 -10
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.d.ts +12 -4
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.d.ts +19 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.d.ts +17 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.d.ts +34 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/usePayScheduleAssignment.d.ts +16 -3
- package/dist/src/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.d.ts +23 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.d.ts +25 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleManagementComponents.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.d.ts +1 -1
- package/dist/src/components/Contractor/Landing/Landing.d.ts +5 -2
- package/dist/src/components/Employee/Landing/Landing.d.ts +5 -2
- package/dist/src/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.d.ts +2 -2
- package/dist/src/components/Payroll/PayrollHistory/PayrollHistoryPresentation.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollList/PayrollListPresentation.d.ts +2 -2
- package/dist/src/components/Payroll/PayrollOverview/PayrollOverviewPresentation.d.ts +1 -1
- package/dist/src/components/Payroll/helpers.d.ts +2 -2
- package/dist/src/components/Payroll/usePreparedPayrollData.d.ts +2 -2
- package/dist/src/i18n/types.d.ts +82 -4
- package/dist/src/models/external.d.ts +63 -48
- package/dist/src/shared/constants.d.ts +1 -1
- package/docs/guides/endpoint-inventory.json +33 -13
- package/package.json +18 -18
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayScheduleAssignment.js","sources":["../../../../../../src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useEffect, useMemo, useState } from 'react'\nimport { useGustoEmbeddedContext } from '@gusto/embedded-api/react-query/_context'\nimport { usePaySchedulesGetAssignmentsSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAssignments'\nimport { PayScheduleAssignmentType } from '@gusto/embedded-api/models/components/payscheduleassignment'\nimport type { PayScheduleAssignment as PayScheduleAssignmentEntity } from '@gusto/embedded-api/models/components/payscheduleassignment'\nimport { payScheduleAssignmentStateMachine } from './payScheduleAssignmentStateMachine'\nimport { AssignmentTypeStep } from './PayScheduleAssignmentComponents'\nimport type {\n PayScheduleAssignmentContextInterface,\n SupportedAssignmentType,\n} from './usePayScheduleAssignment'\nimport { stripNullAssignmentPreviewFields } from './stripNullAssignmentPreviewFields'\nimport { Flow } from '@/components/Flow/Flow'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport type { BaseComponentKeys } from '@/components/Base/Base'\nimport { useI18n } from '@/i18n'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\n\ntype AssignmentSeed = Pick<\n PayScheduleAssignmentContextInterface,\n 'assignmentType' | 'defaultPayScheduleUuid' | 'hourlyPayScheduleUuid' | 'salariedPayScheduleUuid'\n>\n\nfunction toSupportedType(\n type: PayScheduleAssignmentType | null | undefined,\n): SupportedAssignmentType | undefined {\n switch (type) {\n case PayScheduleAssignmentType.Single:\n case PayScheduleAssignmentType.HourlySalaried:\n return type\n default:\n // by_employee and by_department have no step implementations; start from the type step\n // with nothing preselected rather than seeding a type the flow can't render.\n return undefined\n }\n}\n\n/**\n * Builds the flow's starting context from the company's current assignment, so the flow opens\n * on what's already configured instead of proposing a change the user didn't ask for. The type\n * and the uuids have to travel together — without the type, the type step's first Continue\n * counts as a type change and clears the uuids.\n */\nfunction toAssignmentSeed(assignment: PayScheduleAssignmentEntity | undefined): AssignmentSeed {\n const assignmentType = toSupportedType(assignment?.type)\n\n if (!assignmentType) {\n return {}\n }\n\n return {\n assignmentType,\n defaultPayScheduleUuid: assignment?.defaultPayScheduleUuid ?? undefined,\n hourlyPayScheduleUuid: assignment?.hourlyPayScheduleUuid ?? undefined,\n salariedPayScheduleUuid: assignment?.salariedPayScheduleUuid ?? undefined,\n }\n}\n\n/**\n * Props for {@link PayScheduleAssignment}.\n *\n * @alpha\n */\nexport interface PayScheduleAssignmentProps extends BaseComponentInterface<'Company.Management.PayScheduleAssignment'> {\n /** Company whose pay schedule assignment is managed. */\n companyId: string\n}\n\n/**\n * Assigns a company's employees to a pay schedule.\n *\n * @remarks\n * Walks through choosing an assignment type, picking (or creating) a pay schedule, and reviewing\n * the employees and transition payrolls affected before submitting. Opens on the company's\n * current assignment, so submitting without changing anything is a no-op rather than a\n * reassignment. Two assignment types are\n * supported: one schedule for everyone (`single`), or separate schedules for hourly and salaried\n * employees (`hourly_salaried`). Picking the same schedule for both compensation types is\n * submitted as `single`. Can be mounted directly or launched from\n * `CompanyManagement.PaySchedule`'s Manage action.\n *\n * The internal step-to-step selection events (assignment type chosen, schedule picked) also\n * bubble through `onEvent` as a side effect of how the underlying `Flow` re-emits every event —\n * they carry no information a host needs mid-flow, since `assigned` reports the final outcome,\n * so they're intentionally left out of the table below.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `paySchedule/create` | The user chose to add a new pay schedule from the picker step | — |\n * | `paySchedule/created` | A new pay schedule was created from the picker step | `{ paySchedule: PayScheduleShow }` |\n * | `paySchedule/management/assignment/cancel` | The user backed out of the flow entirely, from the first step | — |\n * | `paySchedule/management/assignment/assigned` | The assignment was submitted successfully | `{ employeeChanges: PayScheduleAssignmentEmployeeChange[] }` plus either `{ type: 'single'; defaultPayScheduleUuid: string }` or `{ type: 'hourly_salaried'; hourlyPayScheduleUuid: string; salariedPayScheduleUuid: string }` |\n *\n * @alpha\n */\nexport const PayScheduleAssignment = ({\n companyId,\n dictionary,\n ...props\n}: PayScheduleAssignmentProps) => {\n useUnstableFeature('managePaySchedules', { throwIfDisabled: true })\n\n return (\n <BaseComponent {...props}>\n <Root companyId={companyId} dictionary={dictionary} />\n </BaseComponent>\n )\n}\n\nfunction Root({ companyId, dictionary }: Omit<PayScheduleAssignmentProps, BaseComponentKeys>) {\n useI18n('Company.Management.PayScheduleAssignment')\n useComponentDictionary('Company.Management.PayScheduleAssignment', dictionary)\n // AssignmentCreateScheduleStep reuses the onboarding PayScheduleForm, whose translations live\n // under its own namespace and are otherwise never loaded from this flow.\n useI18n('Company.PaySchedule')\n const { onEvent } = useBase()\n\n // Temporary: patch the assignment-preview response before the SDK validates it, and log\n // request/error details for debugging. See stripNullAssignmentPreviewFields for why —\n // remove both alongside it once the OAS is fixed upstream.\n const client = useGustoEmbeddedContext()\n useEffect(() => {\n const hooks = client._options.hooks\n if (!hooks) return\n hooks.registerAfterSuccessHook(stripNullAssignmentPreviewFields)\n\n return () => {\n // Remove only the single instance this effect registered — filtering the array would\n // also drop another concurrently-mounted instance's registration of the same hook.\n const index = hooks.afterSuccessHooks.indexOf(stripNullAssignmentPreviewFields)\n if (index !== -1) {\n hooks.afterSuccessHooks.splice(index, 1)\n }\n }\n }, [client])\n\n const { data: assignments } = usePaySchedulesGetAssignmentsSuspense({ companyId })\n\n /**\n * Freeze the company's current assignment as the flow's starting point. Submitting the flow\n * invalidates the whole SDK namespace, so this query refetches mid-submit — recomputing the\n * seed would re-seat the machine back to the first step and orphan its interpreter.\n */\n const [seed] = useState(() => toAssignmentSeed(assignments.payScheduleAssignment))\n\n const machine = useMemo(\n () =>\n createMachine(\n 'assignmentType',\n payScheduleAssignmentStateMachine,\n (initialContext: PayScheduleAssignmentContextInterface) => ({\n ...initialContext,\n component: AssignmentTypeStep,\n companyId,\n ...seed,\n }),\n ),\n [companyId, seed],\n )\n\n return <Flow machine={machine} onEvent={onEvent} />\n}\n"],"names":["toSupportedType","type","PayScheduleAssignmentType","toAssignmentSeed","assignment","assignmentType","PayScheduleAssignment","companyId","dictionary","props","useUnstableFeature","jsx","BaseComponent","Root","useI18n","useComponentDictionary","onEvent","useBase","client","useGustoEmbeddedContext","useEffect","hooks","stripNullAssignmentPreviewFields","index","assignments","usePaySchedulesGetAssignmentsSuspense","seed","useState","machine","useMemo","createMachine","payScheduleAssignmentStateMachine","initialContext","AssignmentTypeStep","Flow"],"mappings":";;;;;;;;;;;;;;AAyBA,SAASA,EACPC,GACqC;AACrC,UAAQA,GAAA;AAAA,IACN,KAAKC,EAA0B;AAAA,IAC/B,KAAKA,EAA0B;AAC7B,aAAOD;AAAA,IACT;AAGE;AAAA,EAAO;AAEb;AAQA,SAASE,EAAiBC,GAAqE;AAC7F,QAAMC,IAAiBL,EAAgBI,GAAY,IAAI;AAEvD,SAAKC,IAIE;AAAA,IACL,gBAAAA;AAAA,IACA,wBAAwBD,GAAY,0BAA0B;AAAA,IAC9D,uBAAuBA,GAAY,yBAAyB;AAAA,IAC5D,yBAAyBA,GAAY,2BAA2B;AAAA,EAAA,IAPzD,CAAA;AASX;AAwCO,MAAME,IAAwB,CAAC;AAAA,EACpC,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,GAAGC;AACL,OACEC,EAAmB,sBAAsB,EAAE,iBAAiB,GAAA,CAAM,GAGhE,gBAAAC,EAACC,KAAe,GAAGH,GACjB,4BAACI,GAAA,EAAK,WAAAN,GAAsB,YAAAC,GAAwB,EAAA,CACtD;AAIJ,SAASK,EAAK,EAAE,WAAAN,GAAW,YAAAC,KAAmE;AAC5F,EAAAM,EAAQ,0CAA0C,GAClDC,EAAuB,4CAA4CP,CAAU,GAG7EM,EAAQ,qBAAqB;AAC7B,QAAM,EAAE,SAAAE,EAAA,IAAYC,EAAA,GAKdC,IAASC,EAAA;AACf,EAAAC,EAAU,MAAM;AACd,UAAMC,IAAQH,EAAO,SAAS;AAC9B,QAAKG;AACL,aAAAA,EAAM,yBAAyBC,CAAgC,GAExD,MAAM;AAGX,cAAMC,IAAQF,EAAM,kBAAkB,QAAQC,CAAgC;AAC9E,QAAIC,MAAU,MACZF,EAAM,kBAAkB,OAAOE,GAAO,CAAC;AAAA,MAE3C;AAAA,EACF,GAAG,CAACL,CAAM,CAAC;AAEX,QAAM,EAAE,MAAMM,EAAA,IAAgBC,EAAsC,EAAE,WAAAlB,GAAW,GAO3E,CAACmB,CAAI,IAAIC,EAAS,MAAMxB,EAAiBqB,EAAY,qBAAqB,CAAC,GAE3EI,IAAUC;AAAA,IACd,MACEC;AAAA,MACE;AAAA,MACAC;AAAA,MACA,CAACC,OAA2D;AAAA,QAC1D,GAAGA;AAAA,QACH,WAAWC;AAAA,QACX,WAAA1B;AAAA,QACA,GAAGmB;AAAA,MAAA;AAAA,IACL;AAAA,IAEJ,CAACnB,GAAWmB,CAAI;AAAA,EAAA;AAGlB,SAAO,gBAAAf,EAACuB,GAAA,EAAK,SAAAN,GAAkB,SAAAZ,EAAA,CAAkB;AACnD;"}
|
|
1
|
+
{"version":3,"file":"PayScheduleAssignment.js","sources":["../../../../../../src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useEffect, useMemo, useState } from 'react'\nimport { useGustoEmbeddedContext } from '@gusto/embedded-api/react-query/_context'\nimport { usePaySchedulesGetAssignmentsSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAssignments'\nimport { PayScheduleAssignmentType } from '@gusto/embedded-api/models/components/payscheduleassignment'\nimport type { PayScheduleAssignment as PayScheduleAssignmentEntity } from '@gusto/embedded-api/models/components/payscheduleassignment'\nimport { payScheduleAssignmentStateMachine } from './payScheduleAssignmentStateMachine'\nimport { AssignmentTypeStep } from './PayScheduleAssignmentComponents'\nimport type {\n PayScheduleAssignmentContextInterface,\n SupportedAssignmentType,\n} from './usePayScheduleAssignment'\nimport { stripNullAssignmentPreviewFields } from './stripNullAssignmentPreviewFields'\nimport { Flow } from '@/components/Flow/Flow'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport type { BaseComponentKeys } from '@/components/Base/Base'\nimport { useI18n } from '@/i18n'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\n\ntype AssignmentSeed = Pick<\n PayScheduleAssignmentContextInterface,\n | 'assignmentType'\n | 'defaultPayScheduleUuid'\n | 'hourlyPayScheduleUuid'\n | 'salariedPayScheduleUuid'\n | 'departments'\n | 'employees'\n>\n\nfunction toSupportedType(\n type: PayScheduleAssignmentType | null | undefined,\n): SupportedAssignmentType | undefined {\n switch (type) {\n case PayScheduleAssignmentType.Single:\n case PayScheduleAssignmentType.HourlySalaried:\n case PayScheduleAssignmentType.ByDepartment:\n case PayScheduleAssignmentType.ByEmployee:\n return type\n default:\n return undefined\n }\n}\n\n/**\n * Builds the flow's starting context from the company's current assignment, so the flow opens\n * on what's already configured instead of proposing a change the user didn't ask for. The type\n * and the uuids have to travel together — without the type, the type step's first Continue\n * counts as a type change and clears the uuids.\n */\nfunction toAssignmentSeed(assignment: PayScheduleAssignmentEntity | undefined): AssignmentSeed {\n const assignmentType = toSupportedType(assignment?.type)\n\n if (!assignmentType) {\n return {}\n }\n\n return {\n assignmentType,\n defaultPayScheduleUuid: assignment?.defaultPayScheduleUuid ?? undefined,\n hourlyPayScheduleUuid: assignment?.hourlyPayScheduleUuid ?? undefined,\n salariedPayScheduleUuid: assignment?.salariedPayScheduleUuid ?? undefined,\n employees: assignment?.employees?.flatMap(({ employeeUuid, payScheduleUuid }) =>\n employeeUuid && payScheduleUuid ? [{ employeeUuid, payScheduleUuid }] : [],\n ),\n departments: assignment?.departments?.flatMap(({ departmentUuid, payScheduleUuid }) =>\n departmentUuid && payScheduleUuid ? [{ departmentUuid, payScheduleUuid }] : [],\n ),\n }\n}\n\n/**\n * Props for {@link PayScheduleAssignment}.\n *\n * @alpha\n */\nexport interface PayScheduleAssignmentProps extends BaseComponentInterface<'Company.Management.PayScheduleAssignment'> {\n /** Company whose pay schedule assignment is managed. */\n companyId: string\n}\n\n/**\n * Assigns a company's employees to a pay schedule.\n *\n * @remarks\n * Walks through choosing an assignment type, picking (or creating) a pay schedule, and reviewing\n * the employees and transition payrolls affected before submitting. Opens on the company's\n * current assignment, so submitting without changing anything is a no-op rather than a\n * reassignment. Supports one schedule for everyone (`single`), separate schedules for hourly\n * and salaried employees (`hourly_salaried`), or schedules by department (`by_department`),\n * including a default for employees without a department, or individually (`by_employee`).\n * Employee assignment requires employee and compensation read access and excludes terminated,\n * historical, incomplete-onboarding, and missing-compensation employees. Selecting one schedule for every\n * group is submitted as `single`. Can be mounted directly or launched from\n * `CompanyManagement.PaySchedule`'s Manage action.\n *\n * Step selection events also bubble through `onEvent`; the `assigned` event reports the\n * final outcome. Adding a pay schedule can include the current selections in its event payload.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `paySchedule/create` | The user chose to add a new pay schedule from the picker step | Optional current selections: `{ defaultPayScheduleUuid?: string; hourlyPayScheduleUuid?: string; salariedPayScheduleUuid?: string; departments?: { departmentUuid: string; payScheduleUuid: string }[]; employees?: { employeeUuid: string; payScheduleUuid: string }[] }` |\n * | `paySchedule/created` | A new pay schedule was created from the picker step | `{ paySchedule: PayScheduleShow }` |\n * | `paySchedule/management/assignment/cancel` | The user backed out of the flow entirely, from the first step | — |\n * | `paySchedule/management/assignment/assigned` | The assignment was submitted successfully | `{ employeeChanges: PayScheduleAssignmentEmployeeChange[] }` plus either `{ type: 'single'; defaultPayScheduleUuid: string }` or `{ type: 'hourly_salaried'; hourlyPayScheduleUuid: string; salariedPayScheduleUuid: string }` or `{ type: 'by_department'; defaultPayScheduleUuid: string; departments: { departmentUuid: string; payScheduleUuid: string }[] }` or `{ type: 'by_employee'; employees: { employeeUuid: string; payScheduleUuid: string }[] }` |\n *\n * @alpha\n */\nexport const PayScheduleAssignment = ({\n companyId,\n dictionary,\n ...props\n}: PayScheduleAssignmentProps) => {\n useUnstableFeature('managePaySchedules', { throwIfDisabled: true })\n\n return (\n <BaseComponent {...props}>\n <Root companyId={companyId} dictionary={dictionary} />\n </BaseComponent>\n )\n}\n\nfunction Root({ companyId, dictionary }: Omit<PayScheduleAssignmentProps, BaseComponentKeys>) {\n useI18n('Company.Management.PayScheduleAssignment')\n useComponentDictionary('Company.Management.PayScheduleAssignment', dictionary)\n // AssignmentCreateScheduleStep reuses the onboarding PayScheduleForm, whose translations live\n // under its own namespace and are otherwise never loaded from this flow.\n useI18n('Company.PaySchedule')\n const { onEvent } = useBase()\n\n // Temporary: patch the assignment-preview response before the SDK validates it, and log\n // request/error details for debugging. See stripNullAssignmentPreviewFields for why —\n // remove both alongside it once the OAS is fixed upstream.\n const client = useGustoEmbeddedContext()\n useEffect(() => {\n const hooks = client._options.hooks\n if (!hooks) return\n hooks.registerAfterSuccessHook(stripNullAssignmentPreviewFields)\n\n return () => {\n // Remove only the single instance this effect registered — filtering the array would\n // also drop another concurrently-mounted instance's registration of the same hook.\n const index = hooks.afterSuccessHooks.indexOf(stripNullAssignmentPreviewFields)\n if (index !== -1) {\n hooks.afterSuccessHooks.splice(index, 1)\n }\n }\n }, [client])\n\n const { data: assignments } = usePaySchedulesGetAssignmentsSuspense({ companyId })\n\n /**\n * Freeze the company's current assignment as the flow's starting point. Submitting the flow\n * invalidates the whole SDK namespace, so this query refetches mid-submit — recomputing the\n * seed would re-seat the machine back to the first step and orphan its interpreter.\n */\n const [seed] = useState(() => toAssignmentSeed(assignments.payScheduleAssignment))\n\n const machine = useMemo(\n () =>\n createMachine(\n 'assignmentType',\n payScheduleAssignmentStateMachine,\n (initialContext: PayScheduleAssignmentContextInterface) => ({\n ...initialContext,\n component: AssignmentTypeStep,\n companyId,\n ...seed,\n }),\n ),\n [companyId, seed],\n )\n\n return <Flow machine={machine} onEvent={onEvent} />\n}\n"],"names":["toSupportedType","type","PayScheduleAssignmentType","toAssignmentSeed","assignment","assignmentType","employeeUuid","payScheduleUuid","departmentUuid","PayScheduleAssignment","companyId","dictionary","props","useUnstableFeature","jsx","BaseComponent","Root","useI18n","useComponentDictionary","onEvent","useBase","client","useGustoEmbeddedContext","useEffect","hooks","stripNullAssignmentPreviewFields","index","assignments","usePaySchedulesGetAssignmentsSuspense","seed","useState","machine","useMemo","createMachine","payScheduleAssignmentStateMachine","initialContext","AssignmentTypeStep","Flow"],"mappings":";;;;;;;;;;;;;;AA8BA,SAASA,EACPC,GACqC;AACrC,UAAQA,GAAA;AAAA,IACN,KAAKC,EAA0B;AAAA,IAC/B,KAAKA,EAA0B;AAAA,IAC/B,KAAKA,EAA0B;AAAA,IAC/B,KAAKA,EAA0B;AAC7B,aAAOD;AAAA,IACT;AACE;AAAA,EAAO;AAEb;AAQA,SAASE,EAAiBC,GAAqE;AAC7F,QAAMC,IAAiBL,EAAgBI,GAAY,IAAI;AAEvD,SAAKC,IAIE;AAAA,IACL,gBAAAA;AAAA,IACA,wBAAwBD,GAAY,0BAA0B;AAAA,IAC9D,uBAAuBA,GAAY,yBAAyB;AAAA,IAC5D,yBAAyBA,GAAY,2BAA2B;AAAA,IAChE,WAAWA,GAAY,WAAW;AAAA,MAAQ,CAAC,EAAE,cAAAE,GAAc,iBAAAC,EAAA,MACzDD,KAAgBC,IAAkB,CAAC,EAAE,cAAAD,GAAc,iBAAAC,EAAA,CAAiB,IAAI,CAAA;AAAA,IAAC;AAAA,IAE3E,aAAaH,GAAY,aAAa;AAAA,MAAQ,CAAC,EAAE,gBAAAI,GAAgB,iBAAAD,EAAA,MAC/DC,KAAkBD,IAAkB,CAAC,EAAE,gBAAAC,GAAgB,iBAAAD,EAAA,CAAiB,IAAI,CAAA;AAAA,IAAC;AAAA,EAC/E,IAbO,CAAA;AAeX;AAwCO,MAAME,IAAwB,CAAC;AAAA,EACpC,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,GAAGC;AACL,OACEC,EAAmB,sBAAsB,EAAE,iBAAiB,GAAA,CAAM,GAGhE,gBAAAC,EAACC,KAAe,GAAGH,GACjB,4BAACI,GAAA,EAAK,WAAAN,GAAsB,YAAAC,GAAwB,EAAA,CACtD;AAIJ,SAASK,EAAK,EAAE,WAAAN,GAAW,YAAAC,KAAmE;AAC5F,EAAAM,EAAQ,0CAA0C,GAClDC,EAAuB,4CAA4CP,CAAU,GAG7EM,EAAQ,qBAAqB;AAC7B,QAAM,EAAE,SAAAE,EAAA,IAAYC,EAAA,GAKdC,IAASC,EAAA;AACf,EAAAC,EAAU,MAAM;AACd,UAAMC,IAAQH,EAAO,SAAS;AAC9B,QAAKG;AACL,aAAAA,EAAM,yBAAyBC,CAAgC,GAExD,MAAM;AAGX,cAAMC,IAAQF,EAAM,kBAAkB,QAAQC,CAAgC;AAC9E,QAAIC,MAAU,MACZF,EAAM,kBAAkB,OAAOE,GAAO,CAAC;AAAA,MAE3C;AAAA,EACF,GAAG,CAACL,CAAM,CAAC;AAEX,QAAM,EAAE,MAAMM,EAAA,IAAgBC,EAAsC,EAAE,WAAAlB,GAAW,GAO3E,CAACmB,CAAI,IAAIC,EAAS,MAAM3B,EAAiBwB,EAAY,qBAAqB,CAAC,GAE3EI,IAAUC;AAAA,IACd,MACEC;AAAA,MACE;AAAA,MACAC;AAAA,MACA,CAACC,OAA2D;AAAA,QAC1D,GAAGA;AAAA,QACH,WAAWC;AAAA,QACX,WAAA1B;AAAA,QACA,GAAGmB;AAAA,MAAA;AAAA,IACL;AAAA,IAEJ,CAACnB,GAAWmB,CAAI;AAAA,EAAA;AAGlB,SAAO,gBAAAf,EAACuB,GAAA,EAAK,SAAAN,GAAkB,SAAAZ,EAAA,CAAkB;AACnD;"}
|
|
@@ -1,89 +1,217 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
1
|
+
import { jsx as m, jsxs as B, Fragment as I } from "react/jsx-runtime";
|
|
2
|
+
import { usePaySchedulesGetAssignmentsSuspense as M } from "@gusto/embedded-api/react-query/paySchedulesGetAssignments";
|
|
3
|
+
import { useDepartmentsGetAll as Y, useDepartmentsGetAllSuspense as G } from "@gusto/embedded-api/react-query/departmentsGetAll";
|
|
4
|
+
import { useTranslation as v } from "react-i18next";
|
|
5
|
+
import { useState as b, useMemo as k, useEffect as L } from "react";
|
|
6
|
+
import { usePaySchedulesGetAllSuspense as w } from "@gusto/embedded-api/react-query/paySchedulesGetAll";
|
|
7
|
+
import { usePaySchedulesPreviewAssignmentMutation as R } from "@gusto/embedded-api/react-query/paySchedulesPreviewAssignment";
|
|
8
|
+
import { usePaySchedulesAssignMutation as O } from "@gusto/embedded-api/react-query/paySchedulesAssign";
|
|
9
|
+
import { PayScheduleAssignmentBodyType as r } from "@gusto/embedded-api/models/components/payscheduleassignmentbody";
|
|
10
|
+
import { AssignmentEmployeeStepPresentation as F } from "./AssignmentEmployeeStepPresentation.js";
|
|
11
|
+
import { useAssignableEmployees as K, useAssignableEmployeesSuspense as x } from "./useAssignableEmployees.js";
|
|
12
|
+
import { AssignmentDepartmentStepPresentation as q } from "./AssignmentDepartmentStepPresentation.js";
|
|
13
|
+
import { AssignmentTypeStepPresentation as X } from "./AssignmentTypeStepPresentation.js";
|
|
14
|
+
import { AssignmentScheduleStepPresentation as j } from "./AssignmentScheduleStepPresentation.js";
|
|
15
|
+
import { AssignmentCompensationStepPresentation as W } from "./AssignmentCompensationStepPresentation.js";
|
|
16
|
+
import { AssignmentReviewStepPresentation as z } from "./AssignmentReviewStepPresentation.js";
|
|
17
|
+
import { isAssignmentAccessDenied as N, getCompanyDepartments as H } from "./departmentAccess.js";
|
|
18
|
+
import { getPrimaryCompensation as J } from "./employeeJob.js";
|
|
19
|
+
import { PayScheduleForm as Q } from "../../PayScheduleForm.js";
|
|
20
|
+
import { useFlow as U } from "../../../../Flow/useFlow.js";
|
|
21
|
+
import { BaseLayout as T } from "../../../../Base/Base.js";
|
|
22
|
+
import { useBase as V } from "../../../../Base/useBase.js";
|
|
23
|
+
import { ensureRequired as y } from "../../../../../helpers/ensureRequired.js";
|
|
24
|
+
import { componentEvents as a, FlsaStatus as D } from "../../../../../shared/constants.js";
|
|
25
|
+
import { useComponentContext as Z } from "../../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
26
|
+
function Te() {
|
|
27
|
+
const { companyId: n, assignmentType: i, onEvent: l } = U(), { data: u, error: d, isPending: c } = Y(
|
|
28
|
+
{ companyUuid: n },
|
|
22
29
|
{
|
|
23
|
-
|
|
30
|
+
throwOnError: (s) => !N(s)
|
|
31
|
+
}
|
|
32
|
+
), t = K(n);
|
|
33
|
+
return c || t.status === "loading" ? /* @__PURE__ */ m(T, { isLoading: !0 }) : /* @__PURE__ */ m(
|
|
34
|
+
X,
|
|
35
|
+
{
|
|
36
|
+
hasEmployees: t.employees.length > 0,
|
|
37
|
+
employeeAccessDenied: t.accessDenied,
|
|
38
|
+
hasDepartments: H(u?.departmentList).length > 0,
|
|
39
|
+
departmentAccessDenied: N(d),
|
|
40
|
+
defaultType: i,
|
|
24
41
|
onBack: () => {
|
|
25
|
-
|
|
42
|
+
l(a.PAY_SCHEDULE_ASSIGNMENT_CANCEL);
|
|
26
43
|
},
|
|
27
44
|
onContinue: (s) => {
|
|
28
|
-
|
|
45
|
+
l(a.PAY_SCHEDULE_ASSIGNMENT_TYPE_SELECTED, { type: s });
|
|
29
46
|
}
|
|
30
47
|
}
|
|
31
48
|
);
|
|
32
49
|
}
|
|
33
|
-
function
|
|
50
|
+
function Ne() {
|
|
34
51
|
const {
|
|
35
52
|
companyId: n,
|
|
36
|
-
assignmentType:
|
|
37
|
-
defaultPayScheduleUuid:
|
|
38
|
-
hourlyPayScheduleUuid:
|
|
39
|
-
salariedPayScheduleUuid:
|
|
40
|
-
onEvent:
|
|
41
|
-
} =
|
|
42
|
-
companyId:
|
|
43
|
-
}),
|
|
44
|
-
return
|
|
45
|
-
|
|
53
|
+
assignmentType: i,
|
|
54
|
+
defaultPayScheduleUuid: l,
|
|
55
|
+
hourlyPayScheduleUuid: u,
|
|
56
|
+
salariedPayScheduleUuid: d,
|
|
57
|
+
onEvent: c
|
|
58
|
+
} = U(), { data: t } = w({
|
|
59
|
+
companyId: y(n)
|
|
60
|
+
}), s = t.payScheduleShowResponse ?? [], E = s.find((e) => e.active), A = (e) => s.some((h) => h.uuid === e) ? e : E?.uuid;
|
|
61
|
+
return i === r.ByEmployee ? /* @__PURE__ */ m($, { schedules: s }) : i === r.ByDepartment ? /* @__PURE__ */ m(ne, { schedules: s }) : i === r.HourlySalaried ? /* @__PURE__ */ m(
|
|
62
|
+
W,
|
|
46
63
|
{
|
|
47
|
-
schedules:
|
|
48
|
-
hourlyPayScheduleUuid:
|
|
49
|
-
salariedPayScheduleUuid:
|
|
50
|
-
onBack: () => {
|
|
51
|
-
|
|
64
|
+
schedules: s,
|
|
65
|
+
hourlyPayScheduleUuid: A(u),
|
|
66
|
+
salariedPayScheduleUuid: A(d),
|
|
67
|
+
onBack: (e) => {
|
|
68
|
+
c(a.PAY_SCHEDULE_ASSIGNMENT_BACK, e);
|
|
52
69
|
},
|
|
53
|
-
onAddPaySchedule: () => {
|
|
54
|
-
|
|
70
|
+
onAddPaySchedule: (e) => {
|
|
71
|
+
c(a.PAY_SCHEDULE_CREATE, e);
|
|
55
72
|
},
|
|
56
73
|
onContinue: (e) => {
|
|
57
|
-
|
|
74
|
+
c(a.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED, e);
|
|
58
75
|
}
|
|
59
76
|
}
|
|
60
|
-
) : /* @__PURE__ */
|
|
61
|
-
|
|
77
|
+
) : /* @__PURE__ */ m(
|
|
78
|
+
j,
|
|
62
79
|
{
|
|
63
|
-
schedules:
|
|
64
|
-
defaultPayScheduleUuid:
|
|
65
|
-
onBack: () => {
|
|
66
|
-
|
|
80
|
+
schedules: s,
|
|
81
|
+
defaultPayScheduleUuid: A(l),
|
|
82
|
+
onBack: (e) => {
|
|
83
|
+
c(a.PAY_SCHEDULE_ASSIGNMENT_BACK, e);
|
|
67
84
|
},
|
|
68
|
-
onAddPaySchedule: () => {
|
|
69
|
-
|
|
85
|
+
onAddPaySchedule: (e) => {
|
|
86
|
+
c(a.PAY_SCHEDULE_CREATE, e);
|
|
70
87
|
},
|
|
71
88
|
onContinue: (e) => {
|
|
72
|
-
|
|
89
|
+
c(a.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED, {
|
|
73
90
|
defaultPayScheduleUuid: e
|
|
74
91
|
});
|
|
75
92
|
}
|
|
76
93
|
}
|
|
77
94
|
);
|
|
78
95
|
}
|
|
79
|
-
function
|
|
80
|
-
const {
|
|
81
|
-
|
|
82
|
-
|
|
96
|
+
function $({ schedules: n }) {
|
|
97
|
+
const {
|
|
98
|
+
companyId: i,
|
|
99
|
+
employees: l,
|
|
100
|
+
onEvent: u
|
|
101
|
+
} = U(), d = x(i), { data: c } = M({ companyId: i }), t = c.payScheduleAssignment, s = !d.accessDenied && d.employees.length === 0, { t: E } = v("Company.Management.PayScheduleAssignment");
|
|
102
|
+
if (L(() => {
|
|
103
|
+
s && u(a.PAY_SCHEDULE_CREATE, {
|
|
104
|
+
assignmentType: r.Single,
|
|
105
|
+
employees: void 0,
|
|
106
|
+
defaultPayScheduleUuid: void 0
|
|
107
|
+
});
|
|
108
|
+
}, [s, u]), d.accessDenied)
|
|
109
|
+
return /* @__PURE__ */ m(T, { children: /* @__PURE__ */ m(
|
|
110
|
+
ee,
|
|
111
|
+
{
|
|
112
|
+
onBack: () => {
|
|
113
|
+
u(a.PAY_SCHEDULE_ASSIGNMENT_BACK);
|
|
114
|
+
},
|
|
115
|
+
label: E("employeeAccessDenied"),
|
|
116
|
+
backLabel: E("backCta")
|
|
117
|
+
}
|
|
118
|
+
) });
|
|
119
|
+
if (s) return null;
|
|
120
|
+
const A = n.find((o) => o.active)?.uuid ?? n[0]?.uuid ?? "", e = (o) => n.find((g) => g.uuid === o)?.uuid ?? A, h = {
|
|
121
|
+
employees: d.employees.map((o) => {
|
|
122
|
+
const g = l?.find(
|
|
123
|
+
(S) => S.employeeUuid === o.uuid
|
|
124
|
+
)?.payScheduleUuid;
|
|
125
|
+
let P = t?.defaultPayScheduleUuid;
|
|
126
|
+
if (t?.type === r.ByEmployee)
|
|
127
|
+
P = t.employees?.find((S) => S.employeeUuid === o.uuid)?.payScheduleUuid ?? P;
|
|
128
|
+
else if (t?.type === r.ByDepartment)
|
|
129
|
+
P = t.departments?.find((S) => S.departmentUuid === o.departmentUuid)?.payScheduleUuid ?? P;
|
|
130
|
+
else if (t?.type === r.HourlySalaried) {
|
|
131
|
+
const S = o.flsaStatus ?? J(o)?.flsaStatus;
|
|
132
|
+
P = S === D.NONEXEMPT || S === D.SALARIED_NONEXEMPT || S === D.COMMISSION_ONLY_NONEXEMPT ? t.hourlyPayScheduleUuid : t.salariedPayScheduleUuid;
|
|
133
|
+
}
|
|
134
|
+
return { employeeUuid: o.uuid, payScheduleUuid: e(g ?? P) };
|
|
135
|
+
})
|
|
136
|
+
};
|
|
137
|
+
return /* @__PURE__ */ m(
|
|
138
|
+
F,
|
|
139
|
+
{
|
|
140
|
+
employees: d.employees,
|
|
141
|
+
schedules: n,
|
|
142
|
+
selection: h,
|
|
143
|
+
onBack: (o) => {
|
|
144
|
+
u(a.PAY_SCHEDULE_ASSIGNMENT_BACK, o);
|
|
145
|
+
},
|
|
146
|
+
onAddPaySchedule: (o) => {
|
|
147
|
+
u(a.PAY_SCHEDULE_CREATE, o);
|
|
148
|
+
},
|
|
149
|
+
onContinue: (o) => {
|
|
150
|
+
u(a.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED, o);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
function ee({
|
|
156
|
+
onBack: n,
|
|
157
|
+
label: i,
|
|
158
|
+
backLabel: l
|
|
159
|
+
}) {
|
|
160
|
+
const u = Z();
|
|
161
|
+
return /* @__PURE__ */ B(I, { children: [
|
|
162
|
+
/* @__PURE__ */ m(u.Alert, { status: "warning", label: i }),
|
|
163
|
+
/* @__PURE__ */ m(u.Button, { variant: "secondary", onClick: n, children: l })
|
|
164
|
+
] });
|
|
165
|
+
}
|
|
166
|
+
function ne({ schedules: n }) {
|
|
167
|
+
const {
|
|
168
|
+
companyId: i,
|
|
169
|
+
departments: l,
|
|
170
|
+
defaultPayScheduleUuid: u,
|
|
171
|
+
onEvent: d
|
|
172
|
+
} = U(), { data: c } = G({ companyUuid: i }), t = H(c.departmentList), s = t.length > 0;
|
|
173
|
+
if (L(() => {
|
|
174
|
+
s || d(a.PAY_SCHEDULE_CREATE, {
|
|
175
|
+
assignmentType: r.Single,
|
|
176
|
+
departments: void 0,
|
|
177
|
+
defaultPayScheduleUuid: void 0
|
|
178
|
+
});
|
|
179
|
+
}, [s, d]), !s) return null;
|
|
180
|
+
const E = n.find((e) => e.active)?.uuid ?? n[0]?.uuid ?? "", A = (e) => n.find((h) => h.uuid === e)?.uuid ?? E;
|
|
181
|
+
return /* @__PURE__ */ m(
|
|
182
|
+
q,
|
|
183
|
+
{
|
|
184
|
+
departments: t,
|
|
185
|
+
schedules: n,
|
|
186
|
+
selection: {
|
|
187
|
+
defaultPayScheduleUuid: A(u),
|
|
188
|
+
departments: t.map((e) => ({
|
|
189
|
+
departmentUuid: y(e.uuid),
|
|
190
|
+
payScheduleUuid: A(
|
|
191
|
+
l?.find((h) => h.departmentUuid === e.uuid)?.payScheduleUuid
|
|
192
|
+
)
|
|
193
|
+
}))
|
|
194
|
+
},
|
|
195
|
+
onBack: (e) => {
|
|
196
|
+
d(a.PAY_SCHEDULE_ASSIGNMENT_BACK, e);
|
|
197
|
+
},
|
|
198
|
+
onAddPaySchedule: (e) => {
|
|
199
|
+
d(a.PAY_SCHEDULE_CREATE, e);
|
|
200
|
+
},
|
|
201
|
+
onContinue: (e) => {
|
|
202
|
+
d(a.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED, e);
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
function ve() {
|
|
208
|
+
const { t: n } = v("Company.Management.PayScheduleAssignment"), { companyId: i, onEvent: l } = U();
|
|
209
|
+
return /* @__PURE__ */ m(
|
|
210
|
+
Q,
|
|
83
211
|
{
|
|
84
212
|
variant: "management",
|
|
85
|
-
companyId:
|
|
86
|
-
onEvent:
|
|
213
|
+
companyId: y(i),
|
|
214
|
+
onEvent: l,
|
|
87
215
|
copy: {
|
|
88
216
|
anchorEndOfPayPeriodDescription: n("scheduleForm.anchorEndOfPayPeriodDescription"),
|
|
89
217
|
payrollDeadline: n("scheduleForm.payrollDeadline")
|
|
@@ -91,63 +219,84 @@ function ne() {
|
|
|
91
219
|
}
|
|
92
220
|
);
|
|
93
221
|
}
|
|
94
|
-
function
|
|
222
|
+
function He() {
|
|
95
223
|
const {
|
|
96
224
|
companyId: n,
|
|
97
|
-
assignmentType:
|
|
98
|
-
defaultPayScheduleUuid:
|
|
99
|
-
hourlyPayScheduleUuid:
|
|
100
|
-
salariedPayScheduleUuid:
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
225
|
+
assignmentType: i,
|
|
226
|
+
defaultPayScheduleUuid: l,
|
|
227
|
+
hourlyPayScheduleUuid: u,
|
|
228
|
+
salariedPayScheduleUuid: d,
|
|
229
|
+
departments: c,
|
|
230
|
+
employees: t,
|
|
231
|
+
onEvent: s
|
|
232
|
+
} = U(), { baseSubmitHandler: E, error: A } = V(), [e, h] = b(null), { mutateAsync: o, isPending: g } = R(), { mutateAsync: P, isPending: S } = O(), C = k(() => {
|
|
233
|
+
if (i === r.ByEmployee) {
|
|
234
|
+
const p = y(t), f = p[0]?.payScheduleUuid;
|
|
235
|
+
return f && p.every((_) => _.payScheduleUuid === f) ? { type: r.Single, defaultPayScheduleUuid: f } : { type: r.ByEmployee, employees: p };
|
|
236
|
+
}
|
|
237
|
+
if (i === r.ByDepartment) {
|
|
238
|
+
const p = y(l), f = y(c);
|
|
239
|
+
return f.length === 0 || f.every((_) => _.payScheduleUuid === p) ? { type: r.Single, defaultPayScheduleUuid: p } : {
|
|
240
|
+
type: r.ByDepartment,
|
|
241
|
+
defaultPayScheduleUuid: p,
|
|
242
|
+
departments: f
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
if (i === r.HourlySalaried) {
|
|
246
|
+
const p = y(u), f = y(d);
|
|
247
|
+
return p === f ? {
|
|
248
|
+
type: r.Single,
|
|
249
|
+
defaultPayScheduleUuid: p
|
|
108
250
|
} : {
|
|
109
|
-
type:
|
|
110
|
-
hourlyPayScheduleUuid:
|
|
111
|
-
salariedPayScheduleUuid:
|
|
251
|
+
type: r.HourlySalaried,
|
|
252
|
+
hourlyPayScheduleUuid: p,
|
|
253
|
+
salariedPayScheduleUuid: f
|
|
112
254
|
};
|
|
113
255
|
}
|
|
114
256
|
return {
|
|
115
|
-
type:
|
|
116
|
-
defaultPayScheduleUuid:
|
|
257
|
+
type: r.Single,
|
|
258
|
+
defaultPayScheduleUuid: y(l)
|
|
117
259
|
};
|
|
118
|
-
}, [
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
260
|
+
}, [
|
|
261
|
+
i,
|
|
262
|
+
l,
|
|
263
|
+
u,
|
|
264
|
+
d,
|
|
265
|
+
c,
|
|
266
|
+
t
|
|
267
|
+
]);
|
|
268
|
+
return L(() => {
|
|
269
|
+
E(void 0, async () => {
|
|
270
|
+
const p = await o({
|
|
271
|
+
request: { companyId: y(n), payScheduleAssignmentBody: C }
|
|
123
272
|
});
|
|
124
|
-
|
|
273
|
+
h(p.payScheduleAssignmentPreview?.employeeChanges ?? []);
|
|
125
274
|
});
|
|
126
|
-
}, [n,
|
|
127
|
-
|
|
275
|
+
}, [n, C, o, E]), A ? null : g || !e ? /* @__PURE__ */ m(T, { isLoading: !0 }) : /* @__PURE__ */ m(
|
|
276
|
+
z,
|
|
128
277
|
{
|
|
129
|
-
employeeChanges:
|
|
130
|
-
isSubmitting:
|
|
278
|
+
employeeChanges: e,
|
|
279
|
+
isSubmitting: S,
|
|
131
280
|
onBack: () => {
|
|
132
|
-
|
|
281
|
+
s(a.PAY_SCHEDULE_ASSIGNMENT_BACK);
|
|
133
282
|
},
|
|
134
283
|
onSubmit: () => {
|
|
135
|
-
|
|
136
|
-
await
|
|
284
|
+
E(void 0, async () => {
|
|
285
|
+
await P({
|
|
137
286
|
request: {
|
|
138
|
-
companyId:
|
|
139
|
-
payScheduleAssignmentBody:
|
|
287
|
+
companyId: y(n),
|
|
288
|
+
payScheduleAssignmentBody: C
|
|
140
289
|
}
|
|
141
|
-
}),
|
|
290
|
+
}), s(a.PAY_SCHEDULE_ASSIGNED, { ...C, employeeChanges: e });
|
|
142
291
|
});
|
|
143
292
|
}
|
|
144
293
|
}
|
|
145
294
|
);
|
|
146
295
|
}
|
|
147
296
|
export {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
297
|
+
ve as AssignmentCreateScheduleStep,
|
|
298
|
+
He as AssignmentReviewStep,
|
|
299
|
+
Ne as AssignmentScheduleStep,
|
|
300
|
+
Te as AssignmentTypeStep
|
|
152
301
|
};
|
|
153
302
|
//# sourceMappingURL=PayScheduleAssignmentComponents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayScheduleAssignmentComponents.js","sources":["../../../../../../src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useEffect, useMemo, useState } from 'react'\nimport { usePaySchedulesGetAllSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAll'\nimport { usePaySchedulesPreviewAssignmentMutation } from '@gusto/embedded-api/react-query/paySchedulesPreviewAssignment'\nimport { usePaySchedulesAssignMutation } from '@gusto/embedded-api/react-query/paySchedulesAssign'\nimport { PayScheduleAssignmentBodyType } from '@gusto/embedded-api/models/components/payscheduleassignmentbody'\nimport type { PayScheduleAssignmentEmployeeChange } from '@gusto/embedded-api/models/components/payscheduleassignmentemployeechange'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { AssignmentTypeStepPresentation } from './AssignmentTypeStepPresentation'\nimport { AssignmentScheduleStepPresentation } from './AssignmentScheduleStepPresentation'\nimport { AssignmentCompensationStepPresentation } from './AssignmentCompensationStepPresentation'\nimport { AssignmentReviewStepPresentation } from './AssignmentReviewStepPresentation'\nimport type {\n PayScheduleAssignmentContextInterface,\n SupportedAssignmentType,\n} from './usePayScheduleAssignment'\nimport { PayScheduleForm } from '@/components/Company/PaySchedule/PayScheduleForm'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { useBase, BaseLayout } from '@/components/Base'\nimport { ensureRequired } from '@/helpers/ensureRequired'\nimport { componentEvents } from '@/shared/constants'\n\n/**\n * The assignment the user built, already collapsed to the type that actually gets submitted.\n * Doubles as the request body and as the `assigned` event payload.\n *\n * @internal\n */\nexport type AssignmentSelection =\n | {\n type: typeof PayScheduleAssignmentBodyType.Single\n defaultPayScheduleUuid: string\n }\n | {\n type: typeof PayScheduleAssignmentBodyType.HourlySalaried\n hourlyPayScheduleUuid: string\n salariedPayScheduleUuid: string\n }\n\n/** @internal */\nexport type EventPayloads = {\n [componentEvents.PAY_SCHEDULE_ASSIGNMENT_TYPE_SELECTED]: { type: SupportedAssignmentType }\n [componentEvents.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED]:\n | { defaultPayScheduleUuid: string }\n | { hourlyPayScheduleUuid: string; salariedPayScheduleUuid: string }\n [componentEvents.PAY_SCHEDULE_CREATED]: { paySchedule: PayScheduleShow }\n [componentEvents.PAY_SCHEDULE_ASSIGNED]: AssignmentSelection & {\n employeeChanges: PayScheduleAssignmentEmployeeChange[]\n }\n}\n\n/** @internal */\nexport function AssignmentTypeStep() {\n const { assignmentType, onEvent } = useFlow<PayScheduleAssignmentContextInterface>()\n\n return (\n <AssignmentTypeStepPresentation\n defaultType={assignmentType}\n onBack={() => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_CANCEL)\n }}\n onContinue={type => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_TYPE_SELECTED, { type })\n }}\n />\n )\n}\n\n/** @internal */\nexport function AssignmentScheduleStep() {\n const {\n companyId,\n assignmentType,\n defaultPayScheduleUuid,\n hourlyPayScheduleUuid,\n salariedPayScheduleUuid,\n onEvent,\n } = useFlow<PayScheduleAssignmentContextInterface>()\n const { data: paySchedules } = usePaySchedulesGetAllSuspense({\n companyId: ensureRequired(companyId),\n })\n const schedules = paySchedules.payScheduleShowResponse ?? []\n const activeSchedule = schedules.find(s => s.active)\n /**\n * A uuid carried in from the company's existing assignment has no option to select if the\n * schedule is no longer in the company's list, which would leave the dropdown blank.\n */\n const preselect = (uuid: string | undefined) =>\n schedules.some(s => s.uuid === uuid) ? uuid : activeSchedule?.uuid\n\n if (assignmentType === PayScheduleAssignmentBodyType.HourlySalaried) {\n return (\n <AssignmentCompensationStepPresentation\n schedules={schedules}\n hourlyPayScheduleUuid={preselect(hourlyPayScheduleUuid)}\n salariedPayScheduleUuid={preselect(salariedPayScheduleUuid)}\n onBack={() => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_BACK)\n }}\n onAddPaySchedule={() => {\n onEvent(componentEvents.PAY_SCHEDULE_CREATE)\n }}\n onContinue={selection => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED, selection)\n }}\n />\n )\n }\n\n return (\n <AssignmentScheduleStepPresentation\n schedules={schedules}\n defaultPayScheduleUuid={preselect(defaultPayScheduleUuid)}\n onBack={() => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_BACK)\n }}\n onAddPaySchedule={() => {\n onEvent(componentEvents.PAY_SCHEDULE_CREATE)\n }}\n onContinue={uuid => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED, {\n defaultPayScheduleUuid: uuid,\n })\n }}\n />\n )\n}\n\n/** @internal */\nexport function AssignmentCreateScheduleStep() {\n const { t } = useTranslation('Company.Management.PayScheduleAssignment')\n const { companyId, onEvent } = useFlow<PayScheduleAssignmentContextInterface>()\n\n return (\n <PayScheduleForm\n variant=\"management\"\n companyId={ensureRequired(companyId)}\n onEvent={onEvent}\n copy={{\n anchorEndOfPayPeriodDescription: t('scheduleForm.anchorEndOfPayPeriodDescription'),\n payrollDeadline: t('scheduleForm.payrollDeadline'),\n }}\n />\n )\n}\n\n/** @internal */\nexport function AssignmentReviewStep() {\n const {\n companyId,\n assignmentType,\n defaultPayScheduleUuid,\n hourlyPayScheduleUuid,\n salariedPayScheduleUuid,\n onEvent,\n } = useFlow<PayScheduleAssignmentContextInterface>()\n const { baseSubmitHandler, error } = useBase()\n const [employeeChanges, setEmployeeChanges] = useState<\n PayScheduleAssignmentEmployeeChange[] | null\n >(null)\n const { mutateAsync: previewAssignment, isPending: isPreviewLoading } =\n usePaySchedulesPreviewAssignmentMutation()\n const { mutateAsync: assignSchedules, isPending: isAssigning } = usePaySchedulesAssignMutation()\n\n const assignment: AssignmentSelection = useMemo(() => {\n if (assignmentType === PayScheduleAssignmentBodyType.HourlySalaried) {\n const hourly = ensureRequired(hourlyPayScheduleUuid)\n const salaried = ensureRequired(salariedPayScheduleUuid)\n\n // One schedule for both compensation types is a single-schedule assignment. Collapsing\n // here rather than at submit keeps the previewed changes identical to what gets sent.\n if (hourly === salaried) {\n return {\n type: PayScheduleAssignmentBodyType.Single,\n defaultPayScheduleUuid: hourly,\n }\n }\n\n return {\n type: PayScheduleAssignmentBodyType.HourlySalaried,\n hourlyPayScheduleUuid: hourly,\n salariedPayScheduleUuid: salaried,\n }\n }\n\n return {\n type: PayScheduleAssignmentBodyType.Single,\n defaultPayScheduleUuid: ensureRequired(defaultPayScheduleUuid),\n }\n }, [assignmentType, defaultPayScheduleUuid, hourlyPayScheduleUuid, salariedPayScheduleUuid])\n\n useEffect(() => {\n void baseSubmitHandler(undefined, async () => {\n const response = await previewAssignment({\n request: { companyId: ensureRequired(companyId), payScheduleAssignmentBody: assignment },\n })\n setEmployeeChanges(response.payScheduleAssignmentPreview?.employeeChanges ?? [])\n })\n }, [companyId, assignment, previewAssignment, baseSubmitHandler])\n\n // The enclosing BaseComponent's own BaseLayout already renders `error` for this whole\n // component tree, so surface only the loading state here to avoid rendering it twice.\n if (error) {\n return null\n }\n if (isPreviewLoading || !employeeChanges) {\n return <BaseLayout isLoading />\n }\n\n return (\n <AssignmentReviewStepPresentation\n employeeChanges={employeeChanges}\n isSubmitting={isAssigning}\n onBack={() => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_BACK)\n }}\n onSubmit={() => {\n void baseSubmitHandler(undefined, async () => {\n await assignSchedules({\n request: {\n companyId: ensureRequired(companyId),\n payScheduleAssignmentBody: assignment,\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNED, { ...assignment, employeeChanges })\n })\n }}\n />\n )\n}\n"],"names":["AssignmentTypeStep","assignmentType","onEvent","useFlow","jsx","AssignmentTypeStepPresentation","componentEvents","type","AssignmentScheduleStep","companyId","defaultPayScheduleUuid","hourlyPayScheduleUuid","salariedPayScheduleUuid","paySchedules","usePaySchedulesGetAllSuspense","ensureRequired","schedules","activeSchedule","s","preselect","uuid","PayScheduleAssignmentBodyType","AssignmentCompensationStepPresentation","selection","AssignmentScheduleStepPresentation","AssignmentCreateScheduleStep","t","useTranslation","PayScheduleForm","AssignmentReviewStep","baseSubmitHandler","error","useBase","employeeChanges","setEmployeeChanges","useState","previewAssignment","isPreviewLoading","usePaySchedulesPreviewAssignmentMutation","assignSchedules","isAssigning","usePaySchedulesAssignMutation","assignment","useMemo","hourly","salaried","useEffect","response","BaseLayout","AssignmentReviewStepPresentation"],"mappings":";;;;;;;;;;;;;;;;;AAoDO,SAASA,IAAqB;AACnC,QAAM,EAAE,gBAAAC,GAAgB,SAAAC,EAAA,IAAYC,EAAA;AAEpC,SACE,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,aAAaJ;AAAA,MACb,QAAQ,MAAM;AACZ,QAAAC,EAAQI,EAAgB,8BAA8B;AAAA,MACxD;AAAA,MACA,YAAY,CAAAC,MAAQ;AAClB,QAAAL,EAAQI,EAAgB,uCAAuC,EAAE,MAAAC,EAAA,CAAM;AAAA,MACzE;AAAA,IAAA;AAAA,EAAA;AAGN;AAGO,SAASC,KAAyB;AACvC,QAAM;AAAA,IACJ,WAAAC;AAAA,IACA,gBAAAR;AAAA,IACA,wBAAAS;AAAA,IACA,uBAAAC;AAAA,IACA,yBAAAC;AAAA,IACA,SAAAV;AAAA,EAAA,IACEC,EAAA,GACE,EAAE,MAAMU,EAAA,IAAiBC,EAA8B;AAAA,IAC3D,WAAWC,EAAeN,CAAS;AAAA,EAAA,CACpC,GACKO,IAAYH,EAAa,2BAA2B,CAAA,GACpDI,IAAiBD,EAAU,KAAK,CAAAE,MAAKA,EAAE,MAAM,GAK7CC,IAAY,CAACC,MACjBJ,EAAU,KAAK,CAAAE,MAAKA,EAAE,SAASE,CAAI,IAAIA,IAAOH,GAAgB;AAEhE,SAAIhB,MAAmBoB,EAA8B,iBAEjD,gBAAAjB;AAAA,IAACkB;AAAA,IAAA;AAAA,MACC,WAAAN;AAAA,MACA,uBAAuBG,EAAUR,CAAqB;AAAA,MACtD,yBAAyBQ,EAAUP,CAAuB;AAAA,MAC1D,QAAQ,MAAM;AACZ,QAAAV,EAAQI,EAAgB,4BAA4B;AAAA,MACtD;AAAA,MACA,kBAAkB,MAAM;AACtB,QAAAJ,EAAQI,EAAgB,mBAAmB;AAAA,MAC7C;AAAA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A,UAC7B,CACD,GACDxC,EAAQI,EAAgB,uBAAuB,EAAE,GAAGoC,GAAY,iBAAAT,GAAiB;AAAA,QACnF,CAAC;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"PayScheduleAssignmentComponents.js","sources":["../../../../../../src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.tsx"],"sourcesContent":["import { usePaySchedulesGetAssignmentsSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAssignments'\nimport {\n useDepartmentsGetAll,\n useDepartmentsGetAllSuspense,\n} from '@gusto/embedded-api/react-query/departmentsGetAll'\nimport { useTranslation } from 'react-i18next'\nimport { useEffect, useMemo, useState } from 'react'\nimport { usePaySchedulesGetAllSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAll'\nimport { usePaySchedulesPreviewAssignmentMutation } from '@gusto/embedded-api/react-query/paySchedulesPreviewAssignment'\nimport { usePaySchedulesAssignMutation } from '@gusto/embedded-api/react-query/paySchedulesAssign'\nimport { PayScheduleAssignmentBodyType } from '@gusto/embedded-api/models/components/payscheduleassignmentbody'\nimport type { PayScheduleAssignmentEmployeeChange } from '@gusto/embedded-api/models/components/payscheduleassignmentemployeechange'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payschedulelistitem'\nimport {\n AssignmentEmployeeStepPresentation,\n type EmployeeSelection,\n} from './AssignmentEmployeeStepPresentation'\nimport { useAssignableEmployees, useAssignableEmployeesSuspense } from './useAssignableEmployees'\nimport {\n AssignmentDepartmentStepPresentation,\n type DepartmentSelection,\n} from './AssignmentDepartmentStepPresentation'\nimport { AssignmentTypeStepPresentation } from './AssignmentTypeStepPresentation'\nimport { AssignmentScheduleStepPresentation } from './AssignmentScheduleStepPresentation'\nimport { AssignmentCompensationStepPresentation } from './AssignmentCompensationStepPresentation'\nimport { AssignmentReviewStepPresentation } from './AssignmentReviewStepPresentation'\nimport { getCompanyDepartments, isAssignmentAccessDenied } from './departmentAccess'\nimport type {\n AssignmentDraft,\n PayScheduleAssignmentContextInterface,\n SupportedAssignmentType,\n} from './usePayScheduleAssignment'\nimport { getPrimaryCompensation } from './employeeJob'\nimport { PayScheduleForm } from '@/components/Company/PaySchedule/PayScheduleForm'\nimport { useFlow } from '@/components/Flow/useFlow'\nimport { useBase, BaseLayout } from '@/components/Base'\nimport { ensureRequired } from '@/helpers/ensureRequired'\nimport { componentEvents, FlsaStatus } from '@/shared/constants'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\n/**\n * The assignment the user built, already collapsed to the type that actually gets submitted.\n * Doubles as the request body and as the `assigned` event payload.\n *\n * @internal\n */\nexport type AssignmentSelection =\n | {\n type: typeof PayScheduleAssignmentBodyType.Single\n defaultPayScheduleUuid: string\n }\n | {\n type: typeof PayScheduleAssignmentBodyType.HourlySalaried\n hourlyPayScheduleUuid: string\n salariedPayScheduleUuid: string\n }\n | ({ type: typeof PayScheduleAssignmentBodyType.ByDepartment } & DepartmentSelection)\n | ({ type: typeof PayScheduleAssignmentBodyType.ByEmployee } & EmployeeSelection)\n\n/** @internal */\nexport type EventPayloads = {\n [componentEvents.PAY_SCHEDULE_ASSIGNMENT_TYPE_SELECTED]: { type: SupportedAssignmentType }\n [componentEvents.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED]:\n | { defaultPayScheduleUuid: string }\n | { hourlyPayScheduleUuid: string; salariedPayScheduleUuid: string }\n | DepartmentSelection\n | EmployeeSelection\n [componentEvents.PAY_SCHEDULE_CREATE]: AssignmentDraft | undefined\n [componentEvents.PAY_SCHEDULE_ASSIGNMENT_BACK]: AssignmentDraft | undefined\n [componentEvents.PAY_SCHEDULE_CREATED]: { paySchedule: PayScheduleShow }\n [componentEvents.PAY_SCHEDULE_ASSIGNED]: AssignmentSelection & {\n employeeChanges: PayScheduleAssignmentEmployeeChange[]\n }\n}\n\n/** @internal */\nexport function AssignmentTypeStep() {\n const { companyId, assignmentType, onEvent } = useFlow<PayScheduleAssignmentContextInterface>()\n\n const { data, error, isPending } = useDepartmentsGetAll(\n { companyUuid: companyId },\n {\n throwOnError: error => !isAssignmentAccessDenied(error),\n },\n )\n const employees = useAssignableEmployees(companyId)\n if (isPending || employees.status === 'loading') return <BaseLayout isLoading />\n\n return (\n <AssignmentTypeStepPresentation\n hasEmployees={employees.employees.length > 0}\n employeeAccessDenied={employees.accessDenied}\n hasDepartments={getCompanyDepartments(data?.departmentList).length > 0}\n departmentAccessDenied={isAssignmentAccessDenied(error)}\n defaultType={assignmentType}\n onBack={() => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_CANCEL)\n }}\n onContinue={type => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_TYPE_SELECTED, { type })\n }}\n />\n )\n}\n\n/** @internal */\nexport function AssignmentScheduleStep() {\n const {\n companyId,\n assignmentType,\n defaultPayScheduleUuid,\n hourlyPayScheduleUuid,\n salariedPayScheduleUuid,\n onEvent,\n } = useFlow<PayScheduleAssignmentContextInterface>()\n const { data: paySchedules } = usePaySchedulesGetAllSuspense({\n companyId: ensureRequired(companyId),\n })\n const schedules = paySchedules.payScheduleShowResponse ?? []\n const activeSchedule = schedules.find(s => s.active)\n /**\n * A uuid carried in from the company's existing assignment has no option to select if the\n * schedule is no longer in the company's list, which would leave the dropdown blank.\n */\n const preselect = (uuid: string | undefined) =>\n schedules.some(s => s.uuid === uuid) ? uuid : activeSchedule?.uuid\n\n if (assignmentType === PayScheduleAssignmentBodyType.ByEmployee) {\n return <AssignmentEmployeeStep schedules={schedules} />\n }\n\n if (assignmentType === PayScheduleAssignmentBodyType.ByDepartment) {\n return <AssignmentDepartmentStep schedules={schedules} />\n }\n\n if (assignmentType === PayScheduleAssignmentBodyType.HourlySalaried) {\n return (\n <AssignmentCompensationStepPresentation\n schedules={schedules}\n hourlyPayScheduleUuid={preselect(hourlyPayScheduleUuid)}\n salariedPayScheduleUuid={preselect(salariedPayScheduleUuid)}\n onBack={selection => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_BACK, selection)\n }}\n onAddPaySchedule={selection => {\n onEvent(componentEvents.PAY_SCHEDULE_CREATE, selection)\n }}\n onContinue={selection => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED, selection)\n }}\n />\n )\n }\n\n return (\n <AssignmentScheduleStepPresentation\n schedules={schedules}\n defaultPayScheduleUuid={preselect(defaultPayScheduleUuid)}\n onBack={selection => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_BACK, selection)\n }}\n onAddPaySchedule={selection => {\n onEvent(componentEvents.PAY_SCHEDULE_CREATE, selection)\n }}\n onContinue={uuid => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED, {\n defaultPayScheduleUuid: uuid,\n })\n }}\n />\n )\n}\n\nfunction AssignmentEmployeeStep({ schedules }: { schedules: PayScheduleShow[] }) {\n const {\n companyId,\n employees: selectedEmployees,\n onEvent,\n } = useFlow<PayScheduleAssignmentContextInterface>()\n const roster = useAssignableEmployeesSuspense(companyId)\n const { data } = usePaySchedulesGetAssignmentsSuspense({ companyId })\n const assignment = data.payScheduleAssignment\n const isEmpty = !roster.accessDenied && roster.employees.length === 0\n const { t } = useTranslation('Company.Management.PayScheduleAssignment')\n useEffect(() => {\n if (isEmpty) {\n onEvent(componentEvents.PAY_SCHEDULE_CREATE, {\n assignmentType: PayScheduleAssignmentBodyType.Single,\n employees: undefined,\n defaultPayScheduleUuid: undefined,\n })\n }\n }, [isEmpty, onEvent])\n if (roster.accessDenied)\n return (\n <BaseLayout>\n <EmployeeAccessWarning\n onBack={() => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_BACK)\n }}\n label={t('employeeAccessDenied')}\n backLabel={t('backCta')}\n />\n </BaseLayout>\n )\n if (isEmpty) return null\n const fallback = schedules.find(schedule => schedule.active)?.uuid ?? schedules[0]?.uuid ?? ''\n const validSchedule = (uuid: string | null | undefined) =>\n schedules.find(schedule => schedule.uuid === uuid)?.uuid ?? fallback\n const selection: EmployeeSelection = {\n employees: roster.employees.map(employee => {\n const selected = selectedEmployees?.find(\n entry => entry.employeeUuid === employee.uuid,\n )?.payScheduleUuid\n let stored = assignment?.defaultPayScheduleUuid\n if (assignment?.type === PayScheduleAssignmentBodyType.ByEmployee) {\n stored =\n assignment.employees?.find(entry => entry.employeeUuid === employee.uuid)\n ?.payScheduleUuid ?? stored\n } else if (assignment?.type === PayScheduleAssignmentBodyType.ByDepartment) {\n stored =\n assignment.departments?.find(entry => entry.departmentUuid === employee.departmentUuid)\n ?.payScheduleUuid ?? stored\n } else if (assignment?.type === PayScheduleAssignmentBodyType.HourlySalaried) {\n const status = employee.flsaStatus ?? getPrimaryCompensation(employee)?.flsaStatus\n stored =\n status === FlsaStatus.NONEXEMPT ||\n status === FlsaStatus.SALARIED_NONEXEMPT ||\n status === FlsaStatus.COMMISSION_ONLY_NONEXEMPT\n ? assignment.hourlyPayScheduleUuid\n : assignment.salariedPayScheduleUuid\n }\n return { employeeUuid: employee.uuid, payScheduleUuid: validSchedule(selected ?? stored) }\n }),\n }\n return (\n <AssignmentEmployeeStepPresentation\n employees={roster.employees}\n schedules={schedules}\n selection={selection}\n onBack={draft => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_BACK, draft)\n }}\n onAddPaySchedule={draft => {\n onEvent(componentEvents.PAY_SCHEDULE_CREATE, draft)\n }}\n onContinue={draft => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED, draft)\n }}\n />\n )\n}\n\nfunction EmployeeAccessWarning({\n onBack,\n label,\n backLabel,\n}: {\n onBack: () => void\n label: string\n backLabel: string\n}) {\n const Components = useComponentContext()\n return (\n <>\n <Components.Alert status=\"warning\" label={label} />\n <Components.Button variant=\"secondary\" onClick={onBack}>\n {backLabel}\n </Components.Button>\n </>\n )\n}\n\nfunction AssignmentDepartmentStep({ schedules }: { schedules: PayScheduleShow[] }) {\n const {\n companyId,\n departments: selectedDepartments,\n defaultPayScheduleUuid,\n onEvent,\n } = useFlow<PayScheduleAssignmentContextInterface>()\n const { data } = useDepartmentsGetAllSuspense({ companyUuid: companyId })\n const departments = getCompanyDepartments(data.departmentList)\n const hasDepartments = departments.length > 0\n\n useEffect(() => {\n if (!hasDepartments) {\n onEvent(componentEvents.PAY_SCHEDULE_CREATE, {\n assignmentType: PayScheduleAssignmentBodyType.Single,\n departments: undefined,\n defaultPayScheduleUuid: undefined,\n })\n }\n }, [hasDepartments, onEvent])\n\n if (!hasDepartments) return null\n\n const fallbackUuid = schedules.find(schedule => schedule.active)?.uuid ?? schedules[0]?.uuid ?? ''\n const preselect = (uuid: string | undefined) =>\n schedules.find(schedule => schedule.uuid === uuid)?.uuid ?? fallbackUuid\n\n return (\n <AssignmentDepartmentStepPresentation\n departments={departments}\n schedules={schedules}\n selection={{\n defaultPayScheduleUuid: preselect(defaultPayScheduleUuid),\n departments: departments.map(department => ({\n departmentUuid: ensureRequired(department.uuid),\n payScheduleUuid: preselect(\n selectedDepartments?.find(selection => selection.departmentUuid === department.uuid)\n ?.payScheduleUuid,\n ),\n })),\n }}\n onBack={selection => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_BACK, selection)\n }}\n onAddPaySchedule={selection => {\n onEvent(componentEvents.PAY_SCHEDULE_CREATE, selection)\n }}\n onContinue={selection => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_SCHEDULE_SELECTED, selection)\n }}\n />\n )\n}\n\n/** @internal */\nexport function AssignmentCreateScheduleStep() {\n const { t } = useTranslation('Company.Management.PayScheduleAssignment')\n const { companyId, onEvent } = useFlow<PayScheduleAssignmentContextInterface>()\n\n return (\n <PayScheduleForm\n variant=\"management\"\n companyId={ensureRequired(companyId)}\n onEvent={onEvent}\n copy={{\n anchorEndOfPayPeriodDescription: t('scheduleForm.anchorEndOfPayPeriodDescription'),\n payrollDeadline: t('scheduleForm.payrollDeadline'),\n }}\n />\n )\n}\n\n/** @internal */\nexport function AssignmentReviewStep() {\n const {\n companyId,\n assignmentType,\n defaultPayScheduleUuid,\n hourlyPayScheduleUuid,\n salariedPayScheduleUuid,\n departments,\n employees,\n onEvent,\n } = useFlow<PayScheduleAssignmentContextInterface>()\n const { baseSubmitHandler, error } = useBase()\n const [employeeChanges, setEmployeeChanges] = useState<\n PayScheduleAssignmentEmployeeChange[] | null\n >(null)\n const { mutateAsync: previewAssignment, isPending: isPreviewLoading } =\n usePaySchedulesPreviewAssignmentMutation()\n const { mutateAsync: assignSchedules, isPending: isAssigning } = usePaySchedulesAssignMutation()\n\n const assignment: AssignmentSelection = useMemo(() => {\n if (assignmentType === PayScheduleAssignmentBodyType.ByEmployee) {\n const selections = ensureRequired(employees)\n const firstSchedule = selections[0]?.payScheduleUuid\n if (\n firstSchedule &&\n selections.every(selection => selection.payScheduleUuid === firstSchedule)\n ) {\n return { type: PayScheduleAssignmentBodyType.Single, defaultPayScheduleUuid: firstSchedule }\n }\n return { type: PayScheduleAssignmentBodyType.ByEmployee, employees: selections }\n }\n if (assignmentType === PayScheduleAssignmentBodyType.ByDepartment) {\n const defaultUuid = ensureRequired(defaultPayScheduleUuid)\n const selections = ensureRequired(departments)\n if (\n selections.length === 0 ||\n selections.every(selection => selection.payScheduleUuid === defaultUuid)\n ) {\n return { type: PayScheduleAssignmentBodyType.Single, defaultPayScheduleUuid: defaultUuid }\n }\n return {\n type: PayScheduleAssignmentBodyType.ByDepartment,\n defaultPayScheduleUuid: defaultUuid,\n departments: selections,\n }\n }\n if (assignmentType === PayScheduleAssignmentBodyType.HourlySalaried) {\n const hourly = ensureRequired(hourlyPayScheduleUuid)\n const salaried = ensureRequired(salariedPayScheduleUuid)\n\n // One schedule for both compensation types is a single-schedule assignment. Collapsing\n // here rather than at submit keeps the previewed changes identical to what gets sent.\n if (hourly === salaried) {\n return {\n type: PayScheduleAssignmentBodyType.Single,\n defaultPayScheduleUuid: hourly,\n }\n }\n\n return {\n type: PayScheduleAssignmentBodyType.HourlySalaried,\n hourlyPayScheduleUuid: hourly,\n salariedPayScheduleUuid: salaried,\n }\n }\n\n return {\n type: PayScheduleAssignmentBodyType.Single,\n defaultPayScheduleUuid: ensureRequired(defaultPayScheduleUuid),\n }\n }, [\n assignmentType,\n defaultPayScheduleUuid,\n hourlyPayScheduleUuid,\n salariedPayScheduleUuid,\n departments,\n employees,\n ])\n\n useEffect(() => {\n void baseSubmitHandler(undefined, async () => {\n const response = await previewAssignment({\n request: { companyId: ensureRequired(companyId), payScheduleAssignmentBody: assignment },\n })\n setEmployeeChanges(response.payScheduleAssignmentPreview?.employeeChanges ?? [])\n })\n }, [companyId, assignment, previewAssignment, baseSubmitHandler])\n\n // The enclosing BaseComponent's own BaseLayout already renders `error` for this whole\n // component tree, so surface only the loading state here to avoid rendering it twice.\n if (error) {\n return null\n }\n if (isPreviewLoading || !employeeChanges) {\n return <BaseLayout isLoading />\n }\n\n return (\n <AssignmentReviewStepPresentation\n employeeChanges={employeeChanges}\n isSubmitting={isAssigning}\n onBack={() => {\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNMENT_BACK)\n }}\n onSubmit={() => {\n void baseSubmitHandler(undefined, async () => {\n await assignSchedules({\n request: {\n companyId: ensureRequired(companyId),\n payScheduleAssignmentBody: assignment,\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_ASSIGNED, { ...assignment, employeeChanges })\n })\n }}\n />\n )\n}\n"],"names":["AssignmentTypeStep","companyId","assignmentType","onEvent","useFlow","data","error","isPending","useDepartmentsGetAll","isAssignmentAccessDenied","employees","useAssignableEmployees","jsx","BaseLayout","AssignmentTypeStepPresentation","getCompanyDepartments","componentEvents","type","AssignmentScheduleStep","defaultPayScheduleUuid","hourlyPayScheduleUuid","salariedPayScheduleUuid","paySchedules","usePaySchedulesGetAllSuspense","ensureRequired","schedules","activeSchedule","s","preselect","uuid","PayScheduleAssignmentBodyType","AssignmentEmployeeStep","AssignmentDepartmentStep","AssignmentCompensationStepPresentation","selection","AssignmentScheduleStepPresentation","selectedEmployees","roster","useAssignableEmployeesSuspense","usePaySchedulesGetAssignmentsSuspense","assignment","isEmpty","t","useTranslation","useEffect","EmployeeAccessWarning","fallback","schedule","validSchedule","employee","selected","entry","stored","status","getPrimaryCompensation","FlsaStatus","AssignmentEmployeeStepPresentation","draft","onBack","label","backLabel","Components","useComponentContext","jsxs","Fragment","selectedDepartments","useDepartmentsGetAllSuspense","departments","hasDepartments","fallbackUuid","AssignmentDepartmentStepPresentation","department","AssignmentCreateScheduleStep","PayScheduleForm","AssignmentReviewStep","baseSubmitHandler","useBase","employeeChanges","setEmployeeChanges","useState","previewAssignment","isPreviewLoading","usePaySchedulesPreviewAssignmentMutation","assignSchedules","isAssigning","usePaySchedulesAssignMutation","useMemo","selections","firstSchedule","defaultUuid","hourly","salaried","response","AssignmentReviewStepPresentation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AA4EO,SAASA,KAAqB;AACnC,QAAM,EAAE,WAAAC,GAAW,gBAAAC,GAAgB,SAAAC,EAAA,IAAYC,EAAA,GAEzC,EAAE,MAAAC,GAAM,OAAAC,GAAO,WAAAC,EAAA,IAAcC;AAAA,IACjC,EAAE,aAAaP,EAAA;AAAA,IACf;AAAA,MACE,cAAc,CAAAK,MAAS,CAACG,EAAyBH,CAAK;AAAA,IAAA;AAAA,EACxD,GAEII,IAAYC,EAAuBV,CAAS;AAClD,SAAIM,KAAaG,EAAU,WAAW,YAAkB,gBAAAE,EAACC,GAAA,EAAW,WAAS,IAAC,IAG5E,gBAAAD;AAAA,IAACE;AAAA,IAAA;AAAA,MACC,cAAcJ,EAAU,UAAU,SAAS;AAAA,MAC3C,sBAAsBA,EAAU;AAAA,MAChC,gBAAgBK,EAAsBV,GAAM,cAAc,EAAE,SAAS;AAAA,MACrE,wBAAwBI,EAAyBH,CAAK;AAAA,MACtD,aAAaJ;AAAA,MACb,QAAQ,MAAM;AACZ,QAAAC,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,EAEjE,GAAG;AAAA,IACDjB;AAAA,IACAiB;AAAA,IACAC;AAAA,IACAC;AAAA,IACA8C;AAAA,IACAzD;AAAA,EAAA,CACD;AAaD,SAXAkC,EAAU,MAAM;AACd,IAAK+B,EAAkB,QAAW,YAAY;AAC5C,YAAMiB,IAAW,MAAMZ,EAAkB;AAAA,QACvC,SAAS,EAAE,WAAWxD,EAAevB,CAAS,GAAG,2BAA2BuC,EAAA;AAAA,MAAW,CACxF;AACD,MAAAsC,EAAmBc,EAAS,8BAA8B,mBAAmB,CAAA,CAAE;AAAA,IACjF,CAAC;AAAA,EACH,GAAG,CAAC3F,GAAWuC,GAAYwC,GAAmBL,CAAiB,CAAC,GAI5DrE,IACK,OAEL2E,KAAoB,CAACJ,IAChB,gBAAAjE,EAACC,GAAA,EAAW,WAAS,GAAA,CAAC,IAI7B,gBAAAD;AAAA,IAACiF;AAAA,IAAA;AAAA,MACC,iBAAAhB;AAAA,MACA,cAAcO;AAAA,MACd,QAAQ,MAAM;AACZ,QAAAjF,EAAQa,EAAgB,4BAA4B;AAAA,MACtD;AAAA,MACA,UAAU,MAAM;AACd,QAAK2D,EAAkB,QAAW,YAAY;AAC5C,gBAAMQ,EAAgB;AAAA,YACpB,SAAS;AAAA,cACP,WAAW3D,EAAevB,CAAS;AAAA,cACnC,2BAA2BuC;AAAA,YAAA;AAAA,UAC7B,CACD,GACDrC,EAAQa,EAAgB,uBAAuB,EAAE,GAAGwB,GAAY,iBAAAqC,GAAiB;AAAA,QACnF,CAAC;AAAA,MACH;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { GustoEmbeddedError as r } from "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
2
|
+
function n(t) {
|
|
3
|
+
return (t ?? []).filter(
|
|
4
|
+
(e) => !!e.uuid
|
|
5
|
+
);
|
|
6
|
+
}
|
|
7
|
+
function a(t) {
|
|
8
|
+
if (!(t instanceof r) || t.httpMeta.response.status !== 403) return !1;
|
|
9
|
+
try {
|
|
10
|
+
const e = JSON.parse(t.httpMeta.body);
|
|
11
|
+
return typeof e == "object" && e !== null && "errors" in e && Array.isArray(e.errors) && e.errors.some(
|
|
12
|
+
(o) => typeof o == "object" && o !== null && "category" in o && o.category === "missing_oauth_scopes"
|
|
13
|
+
);
|
|
14
|
+
} catch {
|
|
15
|
+
return !1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
n as getCompanyDepartments,
|
|
20
|
+
a as isAssignmentAccessDenied
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=departmentAccess.js.map
|
package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"departmentAccess.js","sources":["../../../../../../src/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.ts"],"sourcesContent":["import { GustoEmbeddedError } from '@gusto/embedded-api/models/errors/gustoembeddederror'\nimport type { Department } from '@gusto/embedded-api/models/components/department'\n\n/**\n * Narrows department responses to entries that can be assigned a schedule.\n *\n * @param departments - Departments returned by the API.\n * @returns Departments with a usable UUID.\n * @internal\n */\nexport function getCompanyDepartments(departments: Department[] | undefined) {\n return (departments ?? []).filter((department): department is Department & { uuid: string } =>\n Boolean(department.uuid),\n )\n}\n\n/**\n * Identifies an assignment data request rejected for missing OAuth scopes.\n *\n * @param error - Assignment query error.\n * @returns Whether access is unavailable because a required scope is missing.\n * @internal\n */\nexport function isAssignmentAccessDenied(error: unknown): boolean {\n if (!(error instanceof GustoEmbeddedError) || error.httpMeta.response.status !== 403) return false\n try {\n const body: unknown = JSON.parse(error.httpMeta.body)\n return (\n typeof body === 'object' &&\n body !== null &&\n 'errors' in body &&\n Array.isArray(body.errors) &&\n body.errors.some(\n (entry: unknown) =>\n typeof entry === 'object' &&\n entry !== null &&\n 'category' in entry &&\n entry.category === 'missing_oauth_scopes',\n )\n )\n } catch {\n return false\n }\n}\n"],"names":["getCompanyDepartments","departments","department","isAssignmentAccessDenied","error","GustoEmbeddedError","body","entry"],"mappings":";AAUO,SAASA,EAAsBC,GAAuC;AAC3E,UAAQA,KAAe,CAAA,GAAI;AAAA,IAAO,CAACC,MACjC,EAAQA,EAAW;AAAA,EAAI;AAE3B;AASO,SAASC,EAAyBC,GAAyB;AAChE,MAAI,EAAEA,aAAiBC,MAAuBD,EAAM,SAAS,SAAS,WAAW,IAAK,QAAO;AAC7F,MAAI;AACF,UAAME,IAAgB,KAAK,MAAMF,EAAM,SAAS,IAAI;AACpD,WACE,OAAOE,KAAS,YAChBA,MAAS,QACT,YAAYA,KACZ,MAAM,QAAQA,EAAK,MAAM,KACzBA,EAAK,OAAO;AAAA,MACV,CAACC,MACC,OAAOA,KAAU,YACjBA,MAAU,QACV,cAAcA,KACdA,EAAM,aAAa;AAAA,IAAA;AAAA,EAG3B,QAAQ;AACN,WAAO;AAAA,EACT;AACF;"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
function r(o) {
|
|
2
|
+
return o.jobs?.find((n) => n.primary) ?? o.jobs?.[0];
|
|
3
|
+
}
|
|
4
|
+
function t(o) {
|
|
5
|
+
const n = r(o);
|
|
6
|
+
if (n?.currentCompensationUuid !== null)
|
|
7
|
+
return n?.currentCompensationUuid ? n.compensations?.find((i) => i.uuid === n.currentCompensationUuid) : n?.compensations?.[0];
|
|
8
|
+
}
|
|
9
|
+
export {
|
|
10
|
+
t as getPrimaryCompensation,
|
|
11
|
+
r as getPrimaryJob
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=employeeJob.js.map
|
package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"employeeJob.js","sources":["../../../../../../src/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.ts"],"sourcesContent":["import type { ShowEmployees } from '@gusto/embedded-api/models/components/showemployees'\n\n/**\n * Finds the primary job, falling back to the first job for older responses.\n *\n * @param employee - Employee whose job is needed.\n * @returns The primary job, or undefined when no jobs exist.\n * @internal\n */\nexport function getPrimaryJob(employee: Pick<ShowEmployees, 'jobs'>) {\n return employee.jobs?.find(job => job.primary) ?? employee.jobs?.[0]\n}\n\n/**\n * Finds the primary job's current compensation without depending on array order.\n *\n * @param employee - Employee whose compensation is needed.\n * @returns The named current compensation, or the first record when no pointer is supplied.\n * @internal\n */\nexport function getPrimaryCompensation(employee: Pick<ShowEmployees, 'jobs'>) {\n const job = getPrimaryJob(employee)\n if (job?.currentCompensationUuid === null) return undefined\n return job?.currentCompensationUuid\n ? job.compensations?.find(compensation => compensation.uuid === job.currentCompensationUuid)\n : job?.compensations?.[0]\n}\n"],"names":["getPrimaryJob","employee","job","getPrimaryCompensation","compensation"],"mappings":"AASO,SAASA,EAAcC,GAAuC;AACnE,SAAOA,EAAS,MAAM,KAAK,CAAAC,MAAOA,EAAI,OAAO,KAAKD,EAAS,OAAO,CAAC;AACrE;AASO,SAASE,EAAuBF,GAAuC;AAC5E,QAAMC,IAAMF,EAAcC,CAAQ;AAClC,MAAIC,GAAK,4BAA4B;AACrC,WAAOA,GAAK,0BACRA,EAAI,eAAe,KAAK,CAAAE,MAAgBA,EAAa,SAASF,EAAI,uBAAuB,IACzFA,GAAK,gBAAgB,CAAC;AAC5B;"}
|