@gusto/embedded-react-sdk 0.8.2 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/components/Common/DataView/DataCards/DataCards.js +21 -21
- package/dist/components/Common/DataView/DataCards/DataCards.js.map +1 -1
- package/dist/components/Common/UI/ComboBox/ComboBox.js +28 -27
- package/dist/components/Common/UI/ComboBox/ComboBox.js.map +1 -1
- package/dist/components/Common/UI/ComboBox/ComboBox.module.scss.js +6 -6
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +5 -3
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +5 -3
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +7 -5
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +5 -3
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +5 -3
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js +5 -3
- package/dist/components/Company/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +13 -11
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +8 -6
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +5 -3
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +5 -3
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +5 -3
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/usePaySchedule.js +7 -5
- package/dist/components/Company/PaySchedule/usePaySchedule.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js +10 -10
- package/dist/components/Company/StateTaxes/StateTaxesForm/Actions.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +29 -29
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +5 -3
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +5 -3
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Contractor/Address/Actions.d.ts +1 -0
- package/dist/components/Contractor/Address/Actions.js +13 -0
- package/dist/components/Contractor/Address/Actions.js.map +1 -0
- package/dist/components/Contractor/Address/Address.d.ts +16 -0
- package/dist/components/Contractor/Address/Address.js +74 -0
- package/dist/components/Contractor/Address/Address.js.map +1 -0
- package/dist/components/Contractor/Address/Form.d.ts +1 -0
- package/dist/components/Contractor/Address/Form.js +57 -0
- package/dist/components/Contractor/Address/Form.js.map +1 -0
- package/dist/components/Contractor/Address/Head.d.ts +1 -0
- package/dist/components/Contractor/Address/Head.js +15 -0
- package/dist/components/Contractor/Address/Head.js.map +1 -0
- package/dist/components/Contractor/Address/index.d.ts +2 -0
- package/dist/components/Contractor/Address/useAddress.d.ts +33 -0
- package/dist/components/Contractor/Address/useAddress.js +28 -0
- package/dist/components/Contractor/Address/useAddress.js.map +1 -0
- package/dist/components/Contractor/index.d.ts +2 -0
- package/dist/components/Contractor/index.js +5 -0
- package/dist/components/Contractor/index.js.map +1 -0
- package/dist/components/Employee/Compensation/Compensation.js +1 -1
- package/dist/components/Employee/Compensation/Compensation.js.map +1 -1
- package/dist/components/Employee/Deductions/useDeductions.js +8 -6
- package/dist/components/Employee/Deductions/useDeductions.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js +5 -3
- package/dist/components/Employee/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js +5 -3
- package/dist/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.js.map +1 -1
- package/dist/components/Employee/EmployeeList/EmployeeList.js +1 -1
- package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
- package/dist/components/Employee/EmployeeList/List.js +9 -9
- package/dist/components/Employee/EmployeeList/List.js.map +1 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.d.ts +2 -1
- package/dist/components/Employee/EmployeeList/useEmployeeList.js +5 -3
- package/dist/components/Employee/EmployeeList/useEmployeeList.js.map +1 -1
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +10 -8
- package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
- package/dist/components/Employee/Profile/Profile.js +92 -88
- package/dist/components/Employee/Profile/Profile.js.map +1 -1
- package/dist/components/Employee/Profile/useProfile.js +5 -3
- package/dist/components/Employee/Profile/useProfile.js.map +1 -1
- package/dist/components/Employee/Taxes/StateForm.js +1 -1
- package/dist/components/Employee/Taxes/StateForm.js.map +1 -1
- package/dist/components/Employee/Taxes/Taxes.js +78 -75
- package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
- package/dist/components/Employee/Taxes/useTaxes.d.ts +2 -2
- package/dist/components/Employee/Taxes/useTaxes.js +5 -3
- package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
- package/dist/components/index.d.ts +1 -0
- package/dist/i18n/I18n.js +11 -11
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Contractor.Address.json.js +35 -0
- package/dist/i18n/en/Contractor.Address.json.js.map +1 -0
- package/dist/index.js +9 -7
- package/dist/index.js.map +1 -1
- package/dist/shared/constants.d.ts +6 -0
- package/dist/shared/constants.js +51 -45
- package/dist/shared/constants.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/types/i18next.d.ts +20 -1
- package/package.json +5 -2
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Contractor, ContractorType } from '@gusto/embedded-api/models/components/contractor';
|
|
2
|
+
import { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
import { RequireAtLeastOne } from '../../../types/Helpers';
|
|
5
|
+
export interface AddressContextType {
|
|
6
|
+
contractor?: Contractor;
|
|
7
|
+
contractorType?: ContractorType;
|
|
8
|
+
address?: ContractorAddress;
|
|
9
|
+
isPending: boolean;
|
|
10
|
+
}
|
|
11
|
+
export type AddressDefaultValues = RequireAtLeastOne<Pick<ContractorAddress, 'street1' | 'street2' | 'city' | 'state' | 'zip'>>;
|
|
12
|
+
export declare const AddressFormSchema: z.ZodObject<{
|
|
13
|
+
street1: z.ZodString;
|
|
14
|
+
street2: z.ZodOptional<z.ZodString>;
|
|
15
|
+
city: z.ZodString;
|
|
16
|
+
state: z.ZodString;
|
|
17
|
+
zip: z.ZodString;
|
|
18
|
+
}, "strip", z.ZodTypeAny, {
|
|
19
|
+
street1: string;
|
|
20
|
+
city: string;
|
|
21
|
+
state: string;
|
|
22
|
+
zip: string;
|
|
23
|
+
street2?: string | undefined;
|
|
24
|
+
}, {
|
|
25
|
+
street1: string;
|
|
26
|
+
city: string;
|
|
27
|
+
state: string;
|
|
28
|
+
zip: string;
|
|
29
|
+
street2?: string | undefined;
|
|
30
|
+
}>;
|
|
31
|
+
export type AddressFormValues = z.infer<typeof AddressFormSchema>;
|
|
32
|
+
declare const useAddress: () => AddressContextType, AddressProvider: import('react').Provider<AddressContextType | null>;
|
|
33
|
+
export { useAddress, AddressProvider };
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { z as t } from "zod";
|
|
2
|
+
import "react/jsx-runtime";
|
|
3
|
+
import "react";
|
|
4
|
+
import "react-error-boundary";
|
|
5
|
+
import "react-i18next";
|
|
6
|
+
import "@gusto/embedded-api/models/errors/apierror";
|
|
7
|
+
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
8
|
+
import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
9
|
+
import "../../Base/useBase.js";
|
|
10
|
+
import "../../../shared/constants.js";
|
|
11
|
+
import "dompurify";
|
|
12
|
+
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
|
+
import { createCompoundContext as r } from "../../Base/createCompoundContext.js";
|
|
14
|
+
const x = t.object({
|
|
15
|
+
street1: t.string().min(1),
|
|
16
|
+
street2: t.string().optional(),
|
|
17
|
+
city: t.string().min(1),
|
|
18
|
+
state: t.string().min(1),
|
|
19
|
+
zip: t.string().min(1)
|
|
20
|
+
}), [f, u] = r(
|
|
21
|
+
"ContractorAddressContext"
|
|
22
|
+
);
|
|
23
|
+
export {
|
|
24
|
+
x as AddressFormSchema,
|
|
25
|
+
u as AddressProvider,
|
|
26
|
+
f as useAddress
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=useAddress.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useAddress.js","sources":["../../../../src/components/Contractor/Address/useAddress.ts"],"sourcesContent":["import type { Contractor, ContractorType } from '@gusto/embedded-api/models/components/contractor'\nimport type { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress'\nimport { z } from 'zod'\nimport { createCompoundContext } from '@/components/Base'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\n\nexport interface AddressContextType {\n contractor?: Contractor\n contractorType?: ContractorType\n address?: ContractorAddress\n isPending: boolean\n}\n\nexport type AddressDefaultValues = RequireAtLeastOne<\n Pick<ContractorAddress, 'street1' | 'street2' | 'city' | 'state' | 'zip'>\n>\n\nexport const AddressFormSchema = z.object({\n street1: z.string().min(1),\n street2: z.string().optional(),\n city: z.string().min(1),\n state: z.string().min(1),\n zip: z.string().min(1),\n})\n\nexport type AddressFormValues = z.infer<typeof AddressFormSchema>\n\nconst [useAddress, AddressProvider] = createCompoundContext<AddressContextType>(\n 'ContractorAddressContext',\n)\n\nexport { useAddress, AddressProvider }\n"],"names":["AddressFormSchema","z","useAddress","AddressProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;AAiBa,MAAAA,IAAoBC,EAAE,OAAO;AAAA,EACxC,SAASA,EAAE,SAAS,IAAI,CAAC;AAAA,EACzB,SAASA,EAAE,OAAO,EAAE,SAAS;AAAA,EAC7B,MAAMA,EAAE,SAAS,IAAI,CAAC;AAAA,EACtB,OAAOA,EAAE,SAAS,IAAI,CAAC;AAAA,EACvB,KAAKA,EAAE,OAAO,EAAE,IAAI,CAAC;AACvB,CAAC,GAIK,CAACC,GAAYC,CAAe,IAAIC;AAAA,EACpC;AACF;"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
|
@@ -29,7 +29,7 @@ function h(e) {
|
|
|
29
29
|
}
|
|
30
30
|
const V = (e) => e?.compensations?.find((l) => l.uuid === e.currentCompensationUuid), Je = ({ employeeId: e, startDate: l, className: A, children: D, ...u }) => {
|
|
31
31
|
ge("Employee.Compensation");
|
|
32
|
-
const { baseSubmitHandler: G, onEvent: c } = _e(), O = ye(), { data: R } = Ce({ employeeId: e }), n = R.jobList, { data: H } = Oe({ employeeId: e }), _ = H.
|
|
32
|
+
const { baseSubmitHandler: G, onEvent: c } = _e(), O = ye(), { data: R } = Ce({ employeeId: e }), n = R.jobList, { data: H } = Oe({ employeeId: e }), _ = H.employeeWorkAddressesList.find((t) => t.active), {
|
|
33
33
|
data: { minimumWageList: X }
|
|
34
34
|
} = De({
|
|
35
35
|
locationUuid: _.locationUuid
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Compensation.js","sources":["../../../../src/components/Employee/Compensation/Compensation.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { useEffect, useMemo, useState } from 'react'\nimport { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport {\n useJobsAndCompensationsGetJobsSuspense,\n invalidateJobsAndCompensationsGetJobs,\n} from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobsAndCompensationsCreateJobMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateJob'\nimport { useJobsAndCompensationsUpdateMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdate'\nimport { useJobsAndCompensationsDeleteMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsDelete'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useLocationsGetMinimumWagesSuspense } from '@gusto/embedded-api/react-query/locationsGetMinimumWages'\nimport { useEmployeeAddressesGetWorkAddressesSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { type Job } from '@gusto/embedded-api/models/components/job'\nimport { useQueryClient } from '@tanstack/react-query'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport { useFederalTaxDetailsGetSuspense } from '@gusto/embedded-api/react-query/federalTaxDetailsGet'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlow'\nimport { List } from './List'\nimport { Head } from './Head'\nimport { Edit } from './Edit'\nimport { Actions } from './Actions'\nimport {\n type CompensationInputs,\n type CompensationOutputs,\n CompensationProvider,\n CompensationSchema,\n type MODE,\n} from './useCompensation'\nimport { Form } from '@/components/Common/Form'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\nimport type { PAY_PERIODS } from '@/shared/constants'\nimport { componentEvents, FlsaStatus } from '@/shared/constants'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport {\n BaseComponent,\n type BaseComponentInterface,\n useBase,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { useFlow } from '@/components/Flow/useFlow'\n\nexport type CompensationDefaultValues = RequireAtLeastOne<{\n rate?: Job['rate']\n title?: Job['title']\n paymentUnit?: (typeof PAY_PERIODS)[keyof typeof PAY_PERIODS]\n flsaStatus?: FlsaStatusType\n}>\n\ninterface CompensationProps extends CommonComponentInterface<'Employee.Compensation'> {\n employeeId: string\n startDate: string\n defaultValues?: CompensationDefaultValues\n}\n\nexport function Compensation(props: CompensationProps & BaseComponentInterface) {\n useComponentDictionary('Employee.Compensation', props.dictionary)\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst findCurrentCompensation = (employeeJob?: Job | null) => {\n return employeeJob?.compensations?.find(comp => comp.uuid === employeeJob.currentCompensationUuid)\n}\n\nconst Root = ({ employeeId, startDate, className, children, ...props }: CompensationProps) => {\n useI18n('Employee.Compensation')\n const { baseSubmitHandler, onEvent } = useBase()\n const queryClient = useQueryClient()\n\n const { data: jobsData } = useJobsAndCompensationsGetJobsSuspense({ employeeId })\n const employeeJobs = jobsData.jobList!\n\n const { data: addressesData } = useEmployeeAddressesGetWorkAddressesSuspense({ employeeId })\n const workAddresses = addressesData.employeeWorkAddressList!\n\n const currentWorkAddress = workAddresses.find(address => address.active)!\n\n const {\n data: { minimumWageList },\n } = useLocationsGetMinimumWagesSuspense({\n locationUuid: currentWorkAddress.locationUuid!,\n })\n const minimumWages = minimumWageList!\n\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n\n if (!employee) {\n throw new Error('Employee not found')\n }\n\n const { data } = useFederalTaxDetailsGetSuspense({ companyId: employee.companyUuid! })\n const showTwoPercentStakeholder = data.federalTaxDetails!.taxPayerType === 'S-Corporation'\n\n const updateCompensationMutation = useJobsAndCompensationsUpdateCompensationMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const createEmployeeJobMutation = useJobsAndCompensationsCreateJobMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const updateEmployeeJobMutation = useJobsAndCompensationsUpdateMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const deleteEmployeeJobMutation = useJobsAndCompensationsDeleteMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n\n //Job being edited/created\n const [currentJob, setCurrentJob] = useState<Job | null>(\n employeeJobs.length === 1 ? (employeeJobs[0] ?? null) : null,\n )\n\n const [mode, setMode] = useState<MODE>(() => {\n if (!employeeJobs.length) {\n return 'ADD_INITIAL_JOB'\n }\n\n const currentCompensation = findCurrentCompensation(employeeJobs[0])\n\n if (employeeJobs.length === 1 && currentCompensation?.flsaStatus !== FlsaStatus.NONEXEMPT) {\n return 'EDIT_INITIAL_JOB'\n }\n\n return 'LIST'\n })\n\n const [showFlsaChangeWarning, setShowFlsaChangeWarning] = useState(false)\n //Getting current compensation for a job -> the one with the most recent effective date\n const currentCompensation = findCurrentCompensation(currentJob)\n /** Returns FLSA status of a current compensation of a primary job:\n * Employees can have multiple jobs, with multiple compensations, but only 1 job is primary with 1 current compensation\n */\n const primaryFlsaStatus = useMemo<string | undefined>(() => {\n return employeeJobs.reduce<string | undefined>((prev, curr) => {\n const compensation = curr.compensations?.find(\n comp => comp.uuid === curr.currentCompensationUuid,\n )\n if (!curr.primary || !compensation) return prev\n return compensation.flsaStatus ?? prev\n }, undefined)\n }, [employeeJobs])\n\n const defaultValues: CompensationInputs = useMemo(() => {\n return {\n jobTitle:\n currentJob?.title && currentJob.title !== ''\n ? currentJob.title\n : (props.defaultValues?.title ?? ''),\n flsaStatus:\n currentCompensation?.flsaStatus ?? primaryFlsaStatus ?? props.defaultValues?.flsaStatus,\n rate: Number(currentCompensation?.rate ?? props.defaultValues?.rate ?? 0),\n adjustForMinimumWage: currentCompensation?.adjustForMinimumWage ?? false,\n minimumWageId: currentCompensation?.minimumWages?.[0]?.uuid ?? '',\n paymentUnit: currentCompensation?.paymentUnit ?? props.defaultValues?.paymentUnit ?? 'Hour',\n stateWcCovered: currentJob?.stateWcCovered ?? false,\n stateWcClassCode: currentJob?.stateWcClassCode ?? '',\n } as CompensationInputs\n }, [currentJob, currentCompensation, primaryFlsaStatus, props.defaultValues])\n\n const formMethods = useForm<CompensationInputs, unknown, CompensationOutputs>({\n resolver: zodResolver(CompensationSchema),\n defaultValues,\n })\n const { resetField, setValue, handleSubmit, reset } = formMethods\n useEffect(() => {\n reset(defaultValues)\n }, [currentJob, defaultValues, reset])\n\n const submitWithEffect = async (newMode?: MODE) => {\n if (mode === 'LIST' && newMode === 'PROCEED') {\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_DONE)\n return\n }\n //If no job has been modified, switch to edit mode\n if (!currentJob && mode === 'LIST') {\n setMode('ADD_ADDITIONAL_JOB')\n return\n }\n //Performing post-submit state setting only on success\n await handleSubmit(async (data: CompensationOutputs) => {\n await onSubmit(data)\n switch (newMode) {\n case 'LIST':\n setMode('LIST')\n setCurrentJob(null)\n reset(defaultValues)\n break\n default:\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_DONE)\n }\n })()\n }\n const handleAdd = () => {\n setMode('ADD_ADDITIONAL_JOB')\n setCurrentJob(null)\n reset(defaultValues)\n }\n\n const handleCancelAddJob = () => {\n if (employeeJobs.length > 0) {\n setMode('LIST')\n } else {\n setMode('ADD_INITIAL_JOB')\n }\n\n setCurrentJob(null)\n reset(defaultValues)\n }\n\n const handleEdit = (uuid: string) => {\n const selectedJob = employeeJobs.find(job => uuid === job.uuid)\n if (selectedJob) {\n setMode('EDIT_ADDITIONAL_JOB')\n setCurrentJob(selectedJob)\n }\n }\n\n const handleDelete = async (jobId: string) => {\n await deleteEmployeeJobMutation.mutateAsync({ request: { jobId } })\n onEvent(componentEvents.EMPLOYEE_JOB_DELETED)\n }\n\n /**Update dependent field values upon change in FLSA type */\n const handleFlsaChange = (value: string | number) => {\n //Attempting to change flsa status from nonexempt should prompt user about deletion of other jobs associated with the employee\n if (currentCompensation?.flsaStatus === FlsaStatus.NONEXEMPT && employeeJobs.length > 1) {\n setShowFlsaChangeWarning(true)\n }\n if (value === FlsaStatus.OWNER) {\n setValue('paymentUnit', 'Paycheck')\n resetField('rate', { defaultValue: Number(currentCompensation?.rate) })\n } else if (\n value === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n value === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', 'Year')\n setValue('rate', 0)\n } else {\n //reset fields\n resetField('paymentUnit', { defaultValue: currentCompensation?.paymentUnit })\n resetField('rate', { defaultValue: Number(currentCompensation?.rate) })\n }\n }\n\n const onSubmit: SubmitHandler<CompensationOutputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { jobTitle, twoPercentShareholder, ...compensationData } = payload\n let updatedJobData\n //Note: some of the type fixes below are due to the fact that API incorrectly defines current_compensation_uuid as optional\n if (!currentJob) {\n //Adding new job for NONEXEMPT\n const data = await createEmployeeJobMutation.mutateAsync({\n request: {\n employeeId,\n requestBody: {\n title: jobTitle,\n hireDate: startDate,\n stateWcCovered: compensationData.stateWcCovered,\n stateWcClassCode: compensationData.stateWcCovered\n ? compensationData.stateWcClassCode\n : null,\n twoPercentShareholder: twoPercentShareholder ?? false,\n },\n },\n })\n updatedJobData = data.job!\n onEvent(componentEvents.EMPLOYEE_JOB_CREATED, updatedJobData)\n } else {\n const data = await updateEmployeeJobMutation.mutateAsync({\n request: {\n jobId: currentJob.uuid,\n requestBody: {\n title: jobTitle,\n version: currentJob.version as string,\n hireDate: startDate,\n stateWcClassCode: compensationData.stateWcCovered\n ? compensationData.stateWcClassCode\n : null,\n stateWcCovered: compensationData.stateWcCovered,\n twoPercentShareholder: twoPercentShareholder ?? false,\n },\n },\n })\n updatedJobData = data.job!\n onEvent(componentEvents.EMPLOYEE_JOB_UPDATED, updatedJobData)\n }\n\n const { compensation } = await updateCompensationMutation.mutateAsync({\n request: {\n compensationId: updatedJobData.currentCompensationUuid!,\n requestBody: {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n version: updatedJobData.compensations?.find(\n comp => comp.uuid === updatedJobData.currentCompensationUuid,\n )?.version!,\n ...compensationData,\n rate: String(compensationData.rate),\n minimumWages: compensationData.adjustForMinimumWage\n ? [{ uuid: compensationData.minimumWageId }]\n : [],\n },\n },\n })\n setShowFlsaChangeWarning(false)\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_UPDATED, compensation)\n })\n }\n return (\n <section className={className}>\n <CompensationProvider\n value={{\n employeeJobs,\n currentJob,\n primaryFlsaStatus,\n showFlsaChangeWarning,\n mode,\n minimumWages,\n handleFlsaChange,\n handleDelete,\n handleEdit,\n handleAdd,\n submitWithEffect,\n handleCancelAddJob,\n isPending:\n updateCompensationMutation.isPending ||\n createEmployeeJobMutation.isPending ||\n updateEmployeeJobMutation.isPending ||\n deleteEmployeeJobMutation.isPending,\n state: currentWorkAddress.state,\n showTwoPercentStakeholder,\n }}\n >\n <FormProvider {...formMethods}>\n <Form>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <List />\n <Edit />\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </CompensationProvider>\n </section>\n )\n}\n\nCompensation.Head = Head\nCompensation.List = List\nCompensation.Actions = Actions\nCompensation.Edit = Edit\n\nexport const CompensationContextual = () => {\n const { employeeId, onEvent, startDate, defaultValues } = useFlow<OnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId || !startDate) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'Compensation',\n param: !employeeId ? 'employeeId' : 'startDate',\n provider: 'FlowProvider',\n }),\n )\n }\n return (\n <Compensation\n employeeId={employeeId}\n startDate={startDate}\n onEvent={onEvent}\n defaultValues={defaultValues?.compensation}\n />\n )\n}\n"],"names":["Compensation","props","useComponentDictionary","jsx","BaseComponent","Root","findCurrentCompensation","employeeJob","comp","employeeId","startDate","className","children","useI18n","baseSubmitHandler","onEvent","useBase","queryClient","useQueryClient","jobsData","useJobsAndCompensationsGetJobsSuspense","employeeJobs","addressesData","useEmployeeAddressesGetWorkAddressesSuspense","currentWorkAddress","address","minimumWageList","useLocationsGetMinimumWagesSuspense","minimumWages","employee","useEmployeesGetSuspense","data","useFederalTaxDetailsGetSuspense","showTwoPercentStakeholder","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","invalidateJobsAndCompensationsGetJobs","createEmployeeJobMutation","useJobsAndCompensationsCreateJobMutation","updateEmployeeJobMutation","useJobsAndCompensationsUpdateMutation","deleteEmployeeJobMutation","useJobsAndCompensationsDeleteMutation","currentJob","setCurrentJob","useState","mode","setMode","currentCompensation","FlsaStatus","showFlsaChangeWarning","setShowFlsaChangeWarning","primaryFlsaStatus","useMemo","prev","curr","compensation","defaultValues","formMethods","useForm","zodResolver","CompensationSchema","resetField","setValue","handleSubmit","reset","useEffect","submitWithEffect","newMode","componentEvents","onSubmit","handleAdd","handleCancelAddJob","handleEdit","uuid","selectedJob","job","handleDelete","jobId","handleFlsaChange","value","payload","jobTitle","twoPercentShareholder","compensationData","updatedJobData","CompensationProvider","FormProvider","Form","jsxs","Fragment","Head","List","Edit","Actions","CompensationContextual","useFlow","t","useTranslation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyDO,SAASA,EAAaC,GAAmD;AACvD,SAAAC,GAAA,yBAAyBD,EAAM,UAAU,GAE9D,gBAAAE,EAACC,IAAe,EAAA,GAAGH,GACjB,UAAA,gBAAAE,EAACE,MAAM,GAAGJ,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,MAAMK,IAA0B,CAACC,MACxBA,GAAa,eAAe,KAAK,OAAQC,EA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K,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,EACX,CAAA,EAEJ,CAAA,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAEA9F,EAAa,OAAO2F;AACpB3F,EAAa,OAAO4F;AACpB5F,EAAa,UAAU8F;AACvB9F,EAAa,OAAO6F;AAEb,MAAME,KAAyB,MAAM;AAC1C,QAAM,EAAE,YAAAtF,GAAY,SAAAM,GAAS,WAAAL,GAAW,eAAA+C,EAAA,IAAkBuC,GAAoC,GACxF,EAAE,GAAAC,EAAA,IAAMC,GAAe,QAAQ;AAEjC,MAAA,CAACzF,KAAc,CAACC;AAClB,UAAM,IAAI;AAAA,MACRuF,EAAE,iCAAiC;AAAA,QACjC,WAAW;AAAA,QACX,OAAQxF,IAA4B,cAAf;AAAA,QACrB,UAAU;AAAA,MACX,CAAA;AAAA,IACH;AAGA,SAAA,gBAAAN;AAAA,IAACH;AAAA,IAAA;AAAA,MACC,YAAAS;AAAA,MACA,WAAAC;AAAA,MACA,SAAAK;AAAA,MACA,eAAe0C,GAAe;AAAA,IAAA;AAAA,EAChC;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"Compensation.js","sources":["../../../../src/components/Employee/Compensation/Compensation.tsx"],"sourcesContent":["import { zodResolver } from '@hookform/resolvers/zod'\nimport { useEffect, useMemo, useState } from 'react'\nimport { FormProvider, useForm, type SubmitHandler } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport {\n useJobsAndCompensationsGetJobsSuspense,\n invalidateJobsAndCompensationsGetJobs,\n} from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobsAndCompensationsCreateJobMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateJob'\nimport { useJobsAndCompensationsUpdateMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdate'\nimport { useJobsAndCompensationsDeleteMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsDelete'\nimport { useJobsAndCompensationsUpdateCompensationMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdateCompensation'\nimport { useLocationsGetMinimumWagesSuspense } from '@gusto/embedded-api/react-query/locationsGetMinimumWages'\nimport { useEmployeeAddressesGetWorkAddressesSuspense } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { type Job } from '@gusto/embedded-api/models/components/job'\nimport { useQueryClient } from '@tanstack/react-query'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport { useFederalTaxDetailsGetSuspense } from '@gusto/embedded-api/react-query/federalTaxDetailsGet'\nimport { useEmployeesGetSuspense } from '@gusto/embedded-api/react-query/employeesGet'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlow'\nimport { List } from './List'\nimport { Head } from './Head'\nimport { Edit } from './Edit'\nimport { Actions } from './Actions'\nimport {\n type CompensationInputs,\n type CompensationOutputs,\n CompensationProvider,\n CompensationSchema,\n type MODE,\n} from './useCompensation'\nimport { Form } from '@/components/Common/Form'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\nimport type { PAY_PERIODS } from '@/shared/constants'\nimport { componentEvents, FlsaStatus } from '@/shared/constants'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport {\n BaseComponent,\n type BaseComponentInterface,\n useBase,\n type CommonComponentInterface,\n} from '@/components/Base'\nimport { useFlow } from '@/components/Flow/useFlow'\n\nexport type CompensationDefaultValues = RequireAtLeastOne<{\n rate?: Job['rate']\n title?: Job['title']\n paymentUnit?: (typeof PAY_PERIODS)[keyof typeof PAY_PERIODS]\n flsaStatus?: FlsaStatusType\n}>\n\ninterface CompensationProps extends CommonComponentInterface<'Employee.Compensation'> {\n employeeId: string\n startDate: string\n defaultValues?: CompensationDefaultValues\n}\n\nexport function Compensation(props: CompensationProps & BaseComponentInterface) {\n useComponentDictionary('Employee.Compensation', props.dictionary)\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst findCurrentCompensation = (employeeJob?: Job | null) => {\n return employeeJob?.compensations?.find(comp => comp.uuid === employeeJob.currentCompensationUuid)\n}\n\nconst Root = ({ employeeId, startDate, className, children, ...props }: CompensationProps) => {\n useI18n('Employee.Compensation')\n const { baseSubmitHandler, onEvent } = useBase()\n const queryClient = useQueryClient()\n\n const { data: jobsData } = useJobsAndCompensationsGetJobsSuspense({ employeeId })\n const employeeJobs = jobsData.jobList!\n\n const { data: addressesData } = useEmployeeAddressesGetWorkAddressesSuspense({ employeeId })\n const workAddresses = addressesData.employeeWorkAddressesList!\n\n const currentWorkAddress = workAddresses.find(address => address.active)!\n\n const {\n data: { minimumWageList },\n } = useLocationsGetMinimumWagesSuspense({\n locationUuid: currentWorkAddress.locationUuid!,\n })\n const minimumWages = minimumWageList!\n\n const {\n data: { employee },\n } = useEmployeesGetSuspense({ employeeId })\n\n if (!employee) {\n throw new Error('Employee not found')\n }\n\n const { data } = useFederalTaxDetailsGetSuspense({ companyId: employee.companyUuid! })\n const showTwoPercentStakeholder = data.federalTaxDetails!.taxPayerType === 'S-Corporation'\n\n const updateCompensationMutation = useJobsAndCompensationsUpdateCompensationMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const createEmployeeJobMutation = useJobsAndCompensationsCreateJobMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const updateEmployeeJobMutation = useJobsAndCompensationsUpdateMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n const deleteEmployeeJobMutation = useJobsAndCompensationsDeleteMutation({\n onSettled: () => invalidateJobsAndCompensationsGetJobs(queryClient, [employeeId]),\n })\n\n //Job being edited/created\n const [currentJob, setCurrentJob] = useState<Job | null>(\n employeeJobs.length === 1 ? (employeeJobs[0] ?? null) : null,\n )\n\n const [mode, setMode] = useState<MODE>(() => {\n if (!employeeJobs.length) {\n return 'ADD_INITIAL_JOB'\n }\n\n const currentCompensation = findCurrentCompensation(employeeJobs[0])\n\n if (employeeJobs.length === 1 && currentCompensation?.flsaStatus !== FlsaStatus.NONEXEMPT) {\n return 'EDIT_INITIAL_JOB'\n }\n\n return 'LIST'\n })\n\n const [showFlsaChangeWarning, setShowFlsaChangeWarning] = useState(false)\n //Getting current compensation for a job -> the one with the most recent effective date\n const currentCompensation = findCurrentCompensation(currentJob)\n /** Returns FLSA status of a current compensation of a primary job:\n * Employees can have multiple jobs, with multiple compensations, but only 1 job is primary with 1 current compensation\n */\n const primaryFlsaStatus = useMemo<string | undefined>(() => {\n return employeeJobs.reduce<string | undefined>((prev, curr) => {\n const compensation = curr.compensations?.find(\n comp => comp.uuid === curr.currentCompensationUuid,\n )\n if (!curr.primary || !compensation) return prev\n return compensation.flsaStatus ?? prev\n }, undefined)\n }, [employeeJobs])\n\n const defaultValues: CompensationInputs = useMemo(() => {\n return {\n jobTitle:\n currentJob?.title && currentJob.title !== ''\n ? currentJob.title\n : (props.defaultValues?.title ?? ''),\n flsaStatus:\n currentCompensation?.flsaStatus ?? primaryFlsaStatus ?? props.defaultValues?.flsaStatus,\n rate: Number(currentCompensation?.rate ?? props.defaultValues?.rate ?? 0),\n adjustForMinimumWage: currentCompensation?.adjustForMinimumWage ?? false,\n minimumWageId: currentCompensation?.minimumWages?.[0]?.uuid ?? '',\n paymentUnit: currentCompensation?.paymentUnit ?? props.defaultValues?.paymentUnit ?? 'Hour',\n stateWcCovered: currentJob?.stateWcCovered ?? false,\n stateWcClassCode: currentJob?.stateWcClassCode ?? '',\n } as CompensationInputs\n }, [currentJob, currentCompensation, primaryFlsaStatus, props.defaultValues])\n\n const formMethods = useForm<CompensationInputs, unknown, CompensationOutputs>({\n resolver: zodResolver(CompensationSchema),\n defaultValues,\n })\n const { resetField, setValue, handleSubmit, reset } = formMethods\n useEffect(() => {\n reset(defaultValues)\n }, [currentJob, defaultValues, reset])\n\n const submitWithEffect = async (newMode?: MODE) => {\n if (mode === 'LIST' && newMode === 'PROCEED') {\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_DONE)\n return\n }\n //If no job has been modified, switch to edit mode\n if (!currentJob && mode === 'LIST') {\n setMode('ADD_ADDITIONAL_JOB')\n return\n }\n //Performing post-submit state setting only on success\n await handleSubmit(async (data: CompensationOutputs) => {\n await onSubmit(data)\n switch (newMode) {\n case 'LIST':\n setMode('LIST')\n setCurrentJob(null)\n reset(defaultValues)\n break\n default:\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_DONE)\n }\n })()\n }\n const handleAdd = () => {\n setMode('ADD_ADDITIONAL_JOB')\n setCurrentJob(null)\n reset(defaultValues)\n }\n\n const handleCancelAddJob = () => {\n if (employeeJobs.length > 0) {\n setMode('LIST')\n } else {\n setMode('ADD_INITIAL_JOB')\n }\n\n setCurrentJob(null)\n reset(defaultValues)\n }\n\n const handleEdit = (uuid: string) => {\n const selectedJob = employeeJobs.find(job => uuid === job.uuid)\n if (selectedJob) {\n setMode('EDIT_ADDITIONAL_JOB')\n setCurrentJob(selectedJob)\n }\n }\n\n const handleDelete = async (jobId: string) => {\n await deleteEmployeeJobMutation.mutateAsync({ request: { jobId } })\n onEvent(componentEvents.EMPLOYEE_JOB_DELETED)\n }\n\n /**Update dependent field values upon change in FLSA type */\n const handleFlsaChange = (value: string | number) => {\n //Attempting to change flsa status from nonexempt should prompt user about deletion of other jobs associated with the employee\n if (currentCompensation?.flsaStatus === FlsaStatus.NONEXEMPT && employeeJobs.length > 1) {\n setShowFlsaChangeWarning(true)\n }\n if (value === FlsaStatus.OWNER) {\n setValue('paymentUnit', 'Paycheck')\n resetField('rate', { defaultValue: Number(currentCompensation?.rate) })\n } else if (\n value === FlsaStatus.COMMISSION_ONLY_NONEXEMPT ||\n value === FlsaStatus.COMMISSION_ONLY_EXEMPT\n ) {\n setValue('paymentUnit', 'Year')\n setValue('rate', 0)\n } else {\n //reset fields\n resetField('paymentUnit', { defaultValue: currentCompensation?.paymentUnit })\n resetField('rate', { defaultValue: Number(currentCompensation?.rate) })\n }\n }\n\n const onSubmit: SubmitHandler<CompensationOutputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const { jobTitle, twoPercentShareholder, ...compensationData } = payload\n let updatedJobData\n //Note: some of the type fixes below are due to the fact that API incorrectly defines current_compensation_uuid as optional\n if (!currentJob) {\n //Adding new job for NONEXEMPT\n const data = await createEmployeeJobMutation.mutateAsync({\n request: {\n employeeId,\n requestBody: {\n title: jobTitle,\n hireDate: startDate,\n stateWcCovered: compensationData.stateWcCovered,\n stateWcClassCode: compensationData.stateWcCovered\n ? compensationData.stateWcClassCode\n : null,\n twoPercentShareholder: twoPercentShareholder ?? false,\n },\n },\n })\n updatedJobData = data.job!\n onEvent(componentEvents.EMPLOYEE_JOB_CREATED, updatedJobData)\n } else {\n const data = await updateEmployeeJobMutation.mutateAsync({\n request: {\n jobId: currentJob.uuid,\n requestBody: {\n title: jobTitle,\n version: currentJob.version as string,\n hireDate: startDate,\n stateWcClassCode: compensationData.stateWcCovered\n ? compensationData.stateWcClassCode\n : null,\n stateWcCovered: compensationData.stateWcCovered,\n twoPercentShareholder: twoPercentShareholder ?? false,\n },\n },\n })\n updatedJobData = data.job!\n onEvent(componentEvents.EMPLOYEE_JOB_UPDATED, updatedJobData)\n }\n\n const { compensation } = await updateCompensationMutation.mutateAsync({\n request: {\n compensationId: updatedJobData.currentCompensationUuid!,\n requestBody: {\n // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain\n version: updatedJobData.compensations?.find(\n comp => comp.uuid === updatedJobData.currentCompensationUuid,\n )?.version!,\n ...compensationData,\n rate: String(compensationData.rate),\n minimumWages: compensationData.adjustForMinimumWage\n ? [{ uuid: compensationData.minimumWageId }]\n : [],\n },\n },\n })\n setShowFlsaChangeWarning(false)\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_UPDATED, compensation)\n })\n }\n return (\n <section className={className}>\n <CompensationProvider\n value={{\n employeeJobs,\n currentJob,\n primaryFlsaStatus,\n showFlsaChangeWarning,\n mode,\n minimumWages,\n handleFlsaChange,\n handleDelete,\n handleEdit,\n handleAdd,\n submitWithEffect,\n handleCancelAddJob,\n isPending:\n updateCompensationMutation.isPending ||\n createEmployeeJobMutation.isPending ||\n updateEmployeeJobMutation.isPending ||\n deleteEmployeeJobMutation.isPending,\n state: currentWorkAddress.state,\n showTwoPercentStakeholder,\n }}\n >\n <FormProvider {...formMethods}>\n <Form>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <List />\n <Edit />\n <Actions />\n </>\n )}\n </Form>\n </FormProvider>\n </CompensationProvider>\n </section>\n )\n}\n\nCompensation.Head = Head\nCompensation.List = List\nCompensation.Actions = Actions\nCompensation.Edit = Edit\n\nexport const CompensationContextual = () => {\n const { employeeId, onEvent, startDate, defaultValues } = useFlow<OnboardingContextInterface>()\n const { t } = useTranslation('common')\n\n if (!employeeId || !startDate) {\n throw new Error(\n t('errors.missingParamsOrContext', {\n component: 'Compensation',\n param: !employeeId ? 'employeeId' : 'startDate',\n provider: 'FlowProvider',\n }),\n )\n }\n return (\n <Compensation\n employeeId={employeeId}\n startDate={startDate}\n onEvent={onEvent}\n defaultValues={defaultValues?.compensation}\n />\n )\n}\n"],"names":["Compensation","props","useComponentDictionary","jsx","BaseComponent","Root","findCurrentCompensation","employeeJob","comp","employeeId","startDate","className","children","useI18n","baseSubmitHandler","onEvent","useBase","queryClient","useQueryClient","jobsData","useJobsAndCompensationsGetJobsSuspense","employeeJobs","addressesData","useEmployeeAddressesGetWorkAddressesSuspense","currentWorkAddress","address","minimumWageList","useLocationsGetMinimumWagesSuspense","minimumWages","employee","useEmployeesGetSuspense","data","useFederalTaxDetailsGetSuspense","showTwoPercentStakeholder","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","invalidateJobsAndCompensationsGetJobs","createEmployeeJobMutation","useJobsAndCompensationsCreateJobMutation","updateEmployeeJobMutation","useJobsAndCompensationsUpdateMutation","deleteEmployeeJobMutation","useJobsAndCompensationsDeleteMutation","currentJob","setCurrentJob","useState","mode","setMode","currentCompensation","FlsaStatus","showFlsaChangeWarning","setShowFlsaChangeWarning","primaryFlsaStatus","useMemo","prev","curr","compensation","defaultValues","formMethods","useForm","zodResolver","CompensationSchema","resetField","setValue","handleSubmit","reset","useEffect","submitWithEffect","newMode","componentEvents","onSubmit","handleAdd","handleCancelAddJob","handleEdit","uuid","selectedJob","job","handleDelete","jobId","handleFlsaChange","value","payload","jobTitle","twoPercentShareholder","compensationData","updatedJobData","CompensationProvider","FormProvider","Form","jsxs","Fragment","Head","List","Edit","Actions","CompensationContextual","useFlow","t","useTranslation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAyDO,SAASA,EAAaC,GAAmD;AACvD,SAAAC,GAAA,yBAAyBD,EAAM,UAAU,GAE9D,gBAAAE,EAACC,IAAe,EAAA,GAAGH,GACjB,UAAA,gBAAAE,EAACE,MAAM,GAAGJ,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,MAAMK,IAA0B,CAACC,MACxBA,GAAa,eAAe,KAAK,OAAQC,EAAK,SAASD,EAAY,uBAAuB,GAG7FF,KAAO,CAAC,EAAE,YAAAI,GAAY,WAAAC,GAAW,WAAAC,GAAW,UAAAC,GAAU,GAAGX,QAA+B;AAC5F,EAAAY,GAAQ,uBAAuB;AAC/B,QAAM,EAAE,mBAAAC,GAAmB,SAAAC,EAAQ,IAAIC,GAAQ,GACzCC,IAAcC,GAAe,GAE7B,EAAE,MAAMC,EAAA,IAAaC,GAAuC,EAAE,YAAAX,GAAY,GAC1EY,IAAeF,EAAS,SAExB,EAAE,MAAMG,EAAA,IAAkBC,GAA6C,EAAE,YAAAd,GAAY,GAGrFe,IAFgBF,EAAc,0BAEK,KAAK,CAAAG,MAAWA,EAAQ,MAAM,GAEjE;AAAA,IACJ,MAAM,EAAE,iBAAAC,EAAgB;AAAA,MACtBC,GAAoC;AAAA,IACtC,cAAcH,EAA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cAAf;AAAA,QACrB,UAAU;AAAA,MACX,CAAA;AAAA,IACH;AAGA,SAAA,gBAAAN;AAAA,IAACH;AAAA,IAAA;AAAA,MACC,YAAAS;AAAA,MACA,WAAAC;AAAA,MACA,SAAAK;AAAA,MACA,eAAe0C,GAAe;AAAA,IAAA;AAAA,EAChC;AAEJ;"}
|
|
@@ -7,9 +7,11 @@ import "@gusto/embedded-api/models/errors/apierror";
|
|
|
7
7
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
8
8
|
import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
9
9
|
import "../../Base/useBase.js";
|
|
10
|
+
import "../../../shared/constants.js";
|
|
10
11
|
import "dompurify";
|
|
11
|
-
import
|
|
12
|
-
|
|
12
|
+
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
13
|
+
import { createCompoundContext as o } from "../../Base/createCompoundContext.js";
|
|
14
|
+
const f = r.object({
|
|
13
15
|
active: r.boolean(),
|
|
14
16
|
amount: r.number().min(0).transform(String),
|
|
15
17
|
description: r.string().min(1),
|
|
@@ -20,10 +22,10 @@ const b = r.object({
|
|
|
20
22
|
annualMaximum: r.number().min(0).transform((t) => t > 0 ? t.toString() : null).nullable(),
|
|
21
23
|
payPeriodMaximum: r.number().min(0).transform((t) => t > 0 ? t.toString() : null).nullable(),
|
|
22
24
|
deductAsPercentage: r.string().transform((t) => t === "true")
|
|
23
|
-
}), [
|
|
25
|
+
}), [x, D] = o("DeductionsContext");
|
|
24
26
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
f as DeductionSchema,
|
|
28
|
+
D as DeductionsProvider,
|
|
29
|
+
x as useDeductions
|
|
28
30
|
};
|
|
29
31
|
//# sourceMappingURL=useDeductions.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDeductions.js","sources":["../../../../src/components/Employee/Deductions/useDeductions.ts"],"sourcesContent":["import type { Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport { z } from 'zod'\nimport { createCompoundContext } from '@/components/Base'\n\nexport type MODE = 'ADD' | 'LIST' | 'INITIAL' | 'EDIT'\n\nexport const DeductionSchema = z.object({\n active: z.boolean(),\n amount: z.number().min(0).transform(String),\n description: z.string().min(1),\n courtOrdered: z.boolean(),\n times: z.number().nullable(), //The number of times to apply the garnishment. Ignored if recurring is true.\n recurring: z.string().transform(val => val === 'true'),\n annualMaximum: z\n .number()\n .min(0)\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n payPeriodMaximum: z\n .number()\n .min(0)\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n deductAsPercentage: z.string().transform(val => val === 'true'),\n})\n\nexport type DeductionInputs = z.input<typeof DeductionSchema>\nexport type DeductionPayload = z.output<typeof DeductionSchema>\n\ntype DeductionsContextType = {\n isPending: boolean\n deductions: Garnishment[]\n employeeId: string\n mode: MODE\n handleAdd: () => void\n handleCancel: () => void\n handleEdit: (deduction: Garnishment) => void\n handleDelete: (deduction: Garnishment) => void\n handlePassthrough: () => void\n}\nconst [useDeductions, DeductionsProvider] =\n createCompoundContext<DeductionsContextType>('DeductionsContext')\nexport { useDeductions, DeductionsProvider }\n"],"names":["DeductionSchema","z","val","useDeductions","DeductionsProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDeductions.js","sources":["../../../../src/components/Employee/Deductions/useDeductions.ts"],"sourcesContent":["import type { Garnishment } from '@gusto/embedded-api/models/components/garnishment'\nimport { z } from 'zod'\nimport { createCompoundContext } from '@/components/Base'\n\nexport type MODE = 'ADD' | 'LIST' | 'INITIAL' | 'EDIT'\n\nexport const DeductionSchema = z.object({\n active: z.boolean(),\n amount: z.number().min(0).transform(String),\n description: z.string().min(1),\n courtOrdered: z.boolean(),\n times: z.number().nullable(), //The number of times to apply the garnishment. Ignored if recurring is true.\n recurring: z.string().transform(val => val === 'true'),\n annualMaximum: z\n .number()\n .min(0)\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n payPeriodMaximum: z\n .number()\n .min(0)\n .transform(val => (val > 0 ? val.toString() : null))\n .nullable(),\n deductAsPercentage: z.string().transform(val => val === 'true'),\n})\n\nexport type DeductionInputs = z.input<typeof DeductionSchema>\nexport type DeductionPayload = z.output<typeof DeductionSchema>\n\ntype DeductionsContextType = {\n isPending: boolean\n deductions: Garnishment[]\n employeeId: string\n mode: MODE\n handleAdd: () => void\n handleCancel: () => void\n handleEdit: (deduction: Garnishment) => void\n handleDelete: (deduction: Garnishment) => void\n handlePassthrough: () => void\n}\nconst [useDeductions, DeductionsProvider] =\n createCompoundContext<DeductionsContextType>('DeductionsContext')\nexport { useDeductions, DeductionsProvider }\n"],"names":["DeductionSchema","z","val","useDeductions","DeductionsProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;AAMa,MAAAA,IAAkBC,EAAE,OAAO;AAAA,EACtC,QAAQA,EAAE,QAAQ;AAAA,EAClB,QAAQA,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,UAAU,MAAM;AAAA,EAC1C,aAAaA,EAAE,SAAS,IAAI,CAAC;AAAA,EAC7B,cAAcA,EAAE,QAAQ;AAAA,EACxB,OAAOA,EAAE,OAAO,EAAE,SAAS;AAAA;AAAA,EAC3B,WAAWA,EAAE,SAAS,UAAU,CAAAC,MAAOA,MAAQ,MAAM;AAAA,EACrD,eAAeD,EACZ,OAAA,EACA,IAAI,CAAC,EACL,UAAU,CAAQC,MAAAA,IAAM,IAAIA,EAAI,SAAA,IAAa,IAAK,EAClD,SAAS;AAAA,EACZ,kBAAkBD,EACf,OAAA,EACA,IAAI,CAAC,EACL,UAAU,CAAQC,MAAAA,IAAM,IAAIA,EAAI,SAAA,IAAa,IAAK,EAClD,SAAS;AAAA,EACZ,oBAAoBD,EAAE,SAAS,UAAU,CAAAC,MAAOA,MAAQ,MAAM;AAChE,CAAC,GAgBK,CAACC,GAAeC,CAAkB,IACtCC,EAA6C,mBAAmB;"}
|
|
@@ -6,11 +6,13 @@ import "@gusto/embedded-api/models/errors/apierror";
|
|
|
6
6
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
7
7
|
import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
8
8
|
import "../../../Base/useBase.js";
|
|
9
|
+
import "../../../../shared/constants.js";
|
|
9
10
|
import "dompurify";
|
|
11
|
+
import "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
10
12
|
import { createCompoundContext as t } from "../../../Base/createCompoundContext.js";
|
|
11
|
-
const [
|
|
13
|
+
const [D, L] = t("DocumentListContext");
|
|
12
14
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
L as DocumentListProvider,
|
|
16
|
+
D as useDocumentList
|
|
15
17
|
};
|
|
16
18
|
//# sourceMappingURL=useDocumentList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDocumentList.js","sources":["../../../../../src/components/Employee/DocumentSigner/DocumentList/useDocumentList.ts"],"sourcesContent":["import type { Form } from '@gusto/embedded-api/models/components/form'\nimport { createCompoundContext } from '@/components/Base'\n\ntype DocumentListContextType = {\n employeeForms: Form[]\n hasSignedAllForms: boolean\n handleContinue: () => void\n handleRequestFormToSign: (form: Form) => void\n documentListError: Error | null\n formToSign?: Form\n}\n\nconst [useDocumentList, DocumentListProvider] =\n createCompoundContext<DocumentListContextType>('DocumentListContext')\nexport { useDocumentList, DocumentListProvider }\n"],"names":["useDocumentList","DocumentListProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDocumentList.js","sources":["../../../../../src/components/Employee/DocumentSigner/DocumentList/useDocumentList.ts"],"sourcesContent":["import type { Form } from '@gusto/embedded-api/models/components/form'\nimport { createCompoundContext } from '@/components/Base'\n\ntype DocumentListContextType = {\n employeeForms: Form[]\n hasSignedAllForms: boolean\n handleContinue: () => void\n handleRequestFormToSign: (form: Form) => void\n documentListError: Error | null\n formToSign?: Form\n}\n\nconst [useDocumentList, DocumentListProvider] =\n createCompoundContext<DocumentListContextType>('DocumentListContext')\nexport { useDocumentList, DocumentListProvider }\n"],"names":["useDocumentList","DocumentListProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;AAYA,MAAM,CAACA,GAAiBC,CAAoB,IAC1CC,EAA+C,qBAAqB;"}
|
|
@@ -6,11 +6,13 @@ import "@gusto/embedded-api/models/errors/apierror";
|
|
|
6
6
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
7
7
|
import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
8
8
|
import "../../../Base/useBase.js";
|
|
9
|
+
import "../../../../shared/constants.js";
|
|
9
10
|
import "dompurify";
|
|
11
|
+
import "../../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
10
12
|
import { createCompoundContext as o } from "../../../Base/createCompoundContext.js";
|
|
11
|
-
const [
|
|
13
|
+
const [F, S] = o("SignatureFormContext");
|
|
12
14
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
S as SignatureFormProvider,
|
|
16
|
+
F as useSignatureForm
|
|
15
17
|
};
|
|
16
18
|
//# sourceMappingURL=useSignatureForm.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSignatureForm.js","sources":["../../../../../src/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.ts"],"sourcesContent":["import type { Form } from '@gusto/embedded-api/models/components/form'\nimport { createCompoundContext } from '@/components/Base'\n\ntype SignatureFormContextType = {\n form: Form\n pdfUrl?: string | null\n handleBack: () => void\n isPending: boolean\n}\n\nconst [useSignatureForm, SignatureFormProvider] =\n createCompoundContext<SignatureFormContextType>('SignatureFormContext')\nexport { useSignatureForm, SignatureFormProvider }\n"],"names":["useSignatureForm","SignatureFormProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"useSignatureForm.js","sources":["../../../../../src/components/Employee/DocumentSigner/SignatureForm/useSignatureForm.ts"],"sourcesContent":["import type { Form } from '@gusto/embedded-api/models/components/form'\nimport { createCompoundContext } from '@/components/Base'\n\ntype SignatureFormContextType = {\n form: Form\n pdfUrl?: string | null\n handleBack: () => void\n isPending: boolean\n}\n\nconst [useSignatureForm, SignatureFormProvider] =\n createCompoundContext<SignatureFormContextType>('SignatureFormContext')\nexport { useSignatureForm, SignatureFormProvider }\n"],"names":["useSignatureForm","SignatureFormProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;AAUA,MAAM,CAACA,GAAkBC,CAAqB,IAC5CC,EAAgD,sBAAsB;"}
|
|
@@ -19,7 +19,7 @@ function m(o) {
|
|
|
19
19
|
}
|
|
20
20
|
function Z({ companyId: o, className: l, children: p, dictionary: g }) {
|
|
21
21
|
J("Employee.EmployeeList"), K("Employee.EmployeeList", g);
|
|
22
|
-
const { onEvent: a, baseSubmitHandler: i } = Q(), [u, r] = y(1), [A, L] = y(5), N = j(), { data: f } = U({ companyId: o, page: u, per: A }), { httpMeta: D,
|
|
22
|
+
const { onEvent: a, baseSubmitHandler: i } = Q(), [u, r] = y(1), [A, L] = y(5), N = j(), { data: f } = U({ companyId: o, page: u, per: A }), { httpMeta: D, employees: I } = f, _ = I, { mutateAsync: M } = W(), { mutateAsync: S } = H(), E = Number(D.response.headers.get("x-total-pages") ?? 1), w = (e) => {
|
|
23
23
|
L(e);
|
|
24
24
|
}, b = () => {
|
|
25
25
|
r(1);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmployeeList.js","sources":["../../../../src/components/Employee/EmployeeList/EmployeeList.tsx"],"sourcesContent":["import { useState } from 'react'\nimport {\n useEmployeesListSuspense,\n invalidateEmployeesList,\n} from '@gusto/embedded-api/react-query/employeesList'\nimport { useEmployeesDeleteMutation } from '@gusto/embedded-api/react-query/employeesDelete'\nimport { useEmployeesUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus'\nimport { useQueryClient } from '@tanstack/react-query'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlow'\nimport { EmployeeListProvider } from './useEmployeeList'\nimport { Actions } from './Actions'\nimport {\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { Flex } from '@/components/Common'\nimport { useI18n, useComponentDictionary } from '@/i18n'\nimport { componentEvents, EmployeeOnboardingStatus } from '@/shared/constants'\nimport { Head } from '@/components/Employee/EmployeeList/Head'\nimport { List } from '@/components/Employee/EmployeeList/List'\nimport { useFlow } from '@/components/Flow/useFlow'\n\n//Interface for component specific props\ninterface EmployeeListProps extends CommonComponentInterface<'Employee.EmployeeList'> {\n companyId: string\n}\n\nexport function EmployeeList(props: EmployeeListProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\nfunction Root({ companyId, className, children, dictionary }: EmployeeListProps) {\n //Using i18n hook to directly load necessary namespace\n useI18n('Employee.EmployeeList')\n useComponentDictionary('Employee.EmployeeList', dictionary)\n //Getting props from base context\n const { onEvent, baseSubmitHandler } = useBase()\n const [currentPage, setCurrentPage] = useState(1)\n const [itemsPerPage, setItemsPerPage] = useState(5)\n const queryClient = useQueryClient()\n\n const { data } = useEmployeesListSuspense({ companyId, page: currentPage, per: itemsPerPage })\n const { httpMeta, employeeList } = data\n const employees = employeeList!\n\n const { mutateAsync: deleteEmployeeMutation } = useEmployeesDeleteMutation()\n const { mutateAsync: updateEmployeeOnboardingStatusMutation } =\n useEmployeesUpdateOnboardingStatusMutation()\n\n const totalPages = Number(httpMeta.response.headers.get('x-total-pages') ?? 1)\n\n const handleItemsPerPageChange = (newCount: number) => {\n setItemsPerPage(newCount)\n }\n const handleFirstPage = () => {\n setCurrentPage(1)\n }\n const handlePreviousPage = () => {\n setCurrentPage(prevPage => Math.max(prevPage - 1, 1))\n }\n const handleNextPage = () => {\n setCurrentPage(prevPage => Math.min(prevPage + 1, totalPages))\n }\n const handleLastPage = () => {\n setCurrentPage(totalPages)\n }\n const handleDelete = async (uuid: string) => {\n await baseSubmitHandler(uuid, async payload => {\n await deleteEmployeeMutation({\n request: { employeeId: payload },\n })\n\n await invalidateEmployeesList(queryClient, [companyId])\n onEvent(componentEvents.EMPLOYEE_DELETED, { employeeId: payload })\n })\n }\n /**Set onboarding status to self_onboarding_awaiting_admin_review and proceed to edit */\n const handleReview = async (data: string) => {\n await baseSubmitHandler(data, async employeeId => {\n await updateOnboardingStatus({\n employeeId,\n status: EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW,\n })\n onEvent(componentEvents.EMPLOYEE_UPDATE, {\n employeeId,\n onboardingStatus: EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW,\n })\n })\n }\n /**Update employee onboarding status reverting it back to admin_onboarding_incomplete */\n const handleCancelSelfOnboarding = async (data: string) => {\n await baseSubmitHandler(data, async employeeId => {\n await updateOnboardingStatus({\n employeeId,\n status: EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE,\n })\n })\n }\n const updateOnboardingStatus = async (data: { employeeId: string; status: string }) => {\n await baseSubmitHandler(data, async ({ employeeId, status }) => {\n const { employeeOnboardingStatus: responseData } =\n await updateEmployeeOnboardingStatusMutation({\n request: { employeeId, requestBody: { onboardingStatus: status } },\n })\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_STATUS_UPDATED, responseData)\n })\n }\n const handleNew = () => {\n onEvent(componentEvents.EMPLOYEE_CREATE)\n }\n const handleSkip = () => {\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_DONE)\n }\n\n const handleEdit = (uuid: string, onboardingStatus?: string) => {\n onEvent(componentEvents.EMPLOYEE_UPDATE, { employeeId: uuid, onboardingStatus })\n }\n return (\n <section className={className}>\n <EmployeeListProvider\n value={{\n handleEdit,\n handleNew,\n handleReview,\n handleDelete,\n employees,\n currentPage,\n totalPages,\n handleFirstPage,\n handlePreviousPage,\n handleNextPage,\n handleLastPage,\n handleCancelSelfOnboarding,\n handleItemsPerPageChange,\n handleSkip,\n }}\n >\n {children ? (\n children\n ) : (\n <Flex flexDirection=\"column\">\n <Head />\n <List />\n <Actions />\n </Flex>\n )}\n </EmployeeListProvider>\n </section>\n )\n}\n\nEmployeeList.Head = Head\nEmployeeList.List = List\nEmployeeList.Actions = Actions\n\n/**\n * Wrapper used inside Flows -> exposes flow context for required parameters\n */\nexport const EmployeeListContextual = () => {\n const { companyId, onEvent } = useFlow<OnboardingContextInterface>()\n return <EmployeeList companyId={companyId} onEvent={onEvent} />\n}\n"],"names":["EmployeeList","props","jsx","BaseComponent","Root","companyId","className","children","dictionary","useI18n","useComponentDictionary","onEvent","baseSubmitHandler","useBase","currentPage","setCurrentPage","useState","itemsPerPage","setItemsPerPage","queryClient","useQueryClient","data","useEmployeesListSuspense","httpMeta","employeeList","employees","deleteEmployeeMutation","useEmployeesDeleteMutation","updateEmployeeOnboardingStatusMutation","useEmployeesUpdateOnboardingStatusMutation","totalPages","handleItemsPerPageChange","newCount","handleFirstPage","handlePreviousPage","prevPage","handleNextPage","handleLastPage","handleDelete","uuid","payload","invalidateEmployeesList","componentEvents","handleReview","employeeId","updateOnboardingStatus","EmployeeOnboardingStatus","handleCancelSelfOnboarding","status","responseData","EmployeeListProvider","onboardingStatus","jsxs","Flex","Head","List","Actions","EmployeeListContextual","useFlow"],"mappings":";;;;;;;;;;;;;;;;AA6BO,SAASA,EAAaC,GAAmD;AAE5E,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AACA,SAASG,EAAK,EAAE,WAAAC,GAAW,WAAAC,GAAW,UAAAC,GAAU,YAAAC,KAAiC;AAE/E,EAAAC,EAAQ,uBAAuB,GAC/BC,EAAuB,yBAAyBF,CAAU;AAE1D,QAAM,EAAE,SAAAG,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzC,CA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C,KAEC,gBAAA6C,EAAAC,GAAA,EAAK,eAAc,UAClB,UAAA;AAAA,QAAA,gBAAAnD,EAACoD,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,EACX,CAAA;AAAA,IAAA;AAAA,EAAA,GAGN;AAEJ;AAEAxD,EAAa,OAAOsD;AACpBtD,EAAa,OAAOuD;AACpBvD,EAAa,UAAUwD;AAKhB,MAAMC,KAAyB,MAAM;AAC1C,QAAM,EAAE,WAAApD,GAAW,SAAAM,EAAQ,IAAI+C,EAAoC;AAC5D,SAAA,gBAAAxD,EAACF,GAAa,EAAA,WAAAK,GAAsB,SAAAM,EAAkB,CAAA;AAC/D;"}
|
|
1
|
+
{"version":3,"file":"EmployeeList.js","sources":["../../../../src/components/Employee/EmployeeList/EmployeeList.tsx"],"sourcesContent":["import { useState } from 'react'\nimport {\n useEmployeesListSuspense,\n invalidateEmployeesList,\n} from '@gusto/embedded-api/react-query/employeesList'\nimport type { OnboardingStatus } from '@gusto/embedded-api/models/operations/putv1employeesemployeeidonboardingstatus'\nimport { useEmployeesDeleteMutation } from '@gusto/embedded-api/react-query/employeesDelete'\nimport { useEmployeesUpdateOnboardingStatusMutation } from '@gusto/embedded-api/react-query/employeesUpdateOnboardingStatus'\nimport { useQueryClient } from '@tanstack/react-query'\nimport type { OnboardingContextInterface } from '../OnboardingFlow/OnboardingFlow'\nimport { EmployeeListProvider } from './useEmployeeList'\nimport { Actions } from './Actions'\nimport {\n BaseComponent,\n type BaseComponentInterface,\n type CommonComponentInterface,\n} from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { Flex } from '@/components/Common'\nimport { useI18n, useComponentDictionary } from '@/i18n'\nimport { componentEvents, EmployeeOnboardingStatus } from '@/shared/constants'\nimport { Head } from '@/components/Employee/EmployeeList/Head'\nimport { List } from '@/components/Employee/EmployeeList/List'\nimport { useFlow } from '@/components/Flow/useFlow'\n\n//Interface for component specific props\ninterface EmployeeListProps extends CommonComponentInterface<'Employee.EmployeeList'> {\n companyId: string\n}\n\nexport function EmployeeList(props: EmployeeListProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\nfunction Root({ companyId, className, children, dictionary }: EmployeeListProps) {\n //Using i18n hook to directly load necessary namespace\n useI18n('Employee.EmployeeList')\n useComponentDictionary('Employee.EmployeeList', dictionary)\n //Getting props from base context\n const { onEvent, baseSubmitHandler } = useBase()\n const [currentPage, setCurrentPage] = useState(1)\n const [itemsPerPage, setItemsPerPage] = useState(5)\n const queryClient = useQueryClient()\n\n const { data } = useEmployeesListSuspense({ companyId, page: currentPage, per: itemsPerPage })\n const { httpMeta, employees: employeeList } = data\n const employees = employeeList!\n\n const { mutateAsync: deleteEmployeeMutation } = useEmployeesDeleteMutation()\n const { mutateAsync: updateEmployeeOnboardingStatusMutation } =\n useEmployeesUpdateOnboardingStatusMutation()\n\n const totalPages = Number(httpMeta.response.headers.get('x-total-pages') ?? 1)\n\n const handleItemsPerPageChange = (newCount: number) => {\n setItemsPerPage(newCount)\n }\n const handleFirstPage = () => {\n setCurrentPage(1)\n }\n const handlePreviousPage = () => {\n setCurrentPage(prevPage => Math.max(prevPage - 1, 1))\n }\n const handleNextPage = () => {\n setCurrentPage(prevPage => Math.min(prevPage + 1, totalPages))\n }\n const handleLastPage = () => {\n setCurrentPage(totalPages)\n }\n const handleDelete = async (uuid: string) => {\n await baseSubmitHandler(uuid, async payload => {\n await deleteEmployeeMutation({\n request: { employeeId: payload },\n })\n\n await invalidateEmployeesList(queryClient, [companyId])\n onEvent(componentEvents.EMPLOYEE_DELETED, { employeeId: payload })\n })\n }\n /**Set onboarding status to self_onboarding_awaiting_admin_review and proceed to edit */\n const handleReview = async (data: string) => {\n await baseSubmitHandler(data, async employeeId => {\n await updateOnboardingStatus({\n employeeId,\n status: EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW,\n })\n onEvent(componentEvents.EMPLOYEE_UPDATE, {\n employeeId,\n onboardingStatus: EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW,\n })\n })\n }\n /**Update employee onboarding status reverting it back to admin_onboarding_incomplete */\n const handleCancelSelfOnboarding = async (data: string) => {\n await baseSubmitHandler(data, async employeeId => {\n await updateOnboardingStatus({\n employeeId,\n status: EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE,\n })\n })\n }\n const updateOnboardingStatus = async (data: { employeeId: string; status: OnboardingStatus }) => {\n await baseSubmitHandler(data, async ({ employeeId, status }) => {\n const { employeeOnboardingStatus: responseData } =\n await updateEmployeeOnboardingStatusMutation({\n request: { employeeId, requestBody: { onboardingStatus: status } },\n })\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_STATUS_UPDATED, responseData)\n })\n }\n const handleNew = () => {\n onEvent(componentEvents.EMPLOYEE_CREATE)\n }\n const handleSkip = () => {\n onEvent(componentEvents.EMPLOYEE_ONBOARDING_DONE)\n }\n\n const handleEdit = (uuid: string, onboardingStatus?: OnboardingStatus) => {\n onEvent(componentEvents.EMPLOYEE_UPDATE, { employeeId: uuid, onboardingStatus })\n }\n return (\n <section className={className}>\n <EmployeeListProvider\n value={{\n handleEdit,\n handleNew,\n handleReview,\n handleDelete,\n employees,\n currentPage,\n totalPages,\n handleFirstPage,\n handlePreviousPage,\n handleNextPage,\n handleLastPage,\n handleCancelSelfOnboarding,\n handleItemsPerPageChange,\n handleSkip,\n }}\n >\n {children ? (\n children\n ) : (\n <Flex flexDirection=\"column\">\n <Head />\n <List />\n <Actions />\n </Flex>\n )}\n </EmployeeListProvider>\n </section>\n )\n}\n\nEmployeeList.Head = Head\nEmployeeList.List = List\nEmployeeList.Actions = Actions\n\n/**\n * Wrapper used inside Flows -> exposes flow context for required parameters\n */\nexport const EmployeeListContextual = () => {\n const { companyId, onEvent } = useFlow<OnboardingContextInterface>()\n return <EmployeeList companyId={companyId} onEvent={onEvent} />\n}\n"],"names":["EmployeeList","props","jsx","BaseComponent","Root","companyId","className","children","dictionary","useI18n","useComponentDictionary","onEvent","baseSubmitHandler","useBase","currentPage","setCurrentPage","useState","itemsPerPage","setItemsPerPage","queryClient","useQueryClient","data","useEmployeesListSuspense","httpMeta","employeeList","employees","deleteEmployeeMutation","useEmployeesDeleteMutation","updateEmployeeOnboardingStatusMutation","useEmployeesUpdateOnboardingStatusMutation","totalPages","handleItemsPerPageChange","newCount","handleFirstPage","handlePreviousPage","prevPage","handleNextPage","handleLastPage","handleDelete","uuid","payload","invalidateEmployeesList","componentEvents","handleReview","employeeId","updateOnboardingStatus","EmployeeOnboardingStatus","handleCancelSelfOnboarding","status","responseData","EmployeeListProvider","onboardingStatus","jsxs","Flex","Head","List","Actions","EmployeeListContextual","useFlow"],"mappings":";;;;;;;;;;;;;;;;AA8BO,SAASA,EAAaC,GAAmD;AAE5E,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AACA,SAASG,EAAK,EAAE,WAAAC,GAAW,WAAAC,GAAW,UAAAC,GAAU,YAAAC,KAAiC;AAE/E,EAAAC,EAAQ,uBAAuB,GAC/BC,EAAuB,yBAAyBF,CAAU;AAE1D,QAAM,EAAE,SAAAG,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzC,CAACC,GAAaC,CAAc,IAAIC,EAAS,CAAC,GAC1C,CAACC,GAAcC,CAAe,IAAIF,EAAS,CAAC,GAC5CG,IAAcC,EAAe,GAE7B,EAAE,MAAAC,MAASC,EAAyB,EAAE,WAAAjB,GAAW,MAAMS,GAAa,KAAKG,GAAc,GACvF,EAAE,UAAAM,GAAU,WAAWC,EAAiB,IAAAH,GACxCI,IAAYD,GAEZ,EAAE,aAAaE,EAAuB,IAAIC,EAA2B,GACrE,EAAE,aAAaC,EAAuC,IAC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AAM,EAAE,WAAApD,GAAW,SAAAM,EAAQ,IAAI+C,EAAoC;AAC5D,SAAA,gBAAAxD,EAACF,GAAa,EAAA,WAAAK,GAAsB,SAAAM,EAAkB,CAAA;AAC/D;"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { jsx as a, jsxs as c, Fragment as
|
|
2
|
-
import { useTranslation as
|
|
3
|
-
import { useState as
|
|
4
|
-
import
|
|
5
|
-
import { useEmployeeList as
|
|
1
|
+
import { jsx as a, jsxs as c, Fragment as v } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation as w } from "react-i18next";
|
|
3
|
+
import { useState as A } from "react";
|
|
4
|
+
import T from "./List.module.scss.js";
|
|
5
|
+
import { useEmployeeList as k } from "./useEmployeeList.js";
|
|
6
6
|
import { EmptyData as B } from "../../Common/EmptyData/EmptyData.js";
|
|
7
7
|
import { ActionsLayout as h } from "../../Common/ActionsLayout/ActionsLayout.js";
|
|
8
8
|
import { useComponentContext as M } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
@@ -29,7 +29,7 @@ const at = () => {
|
|
|
29
29
|
currentPage: O,
|
|
30
30
|
totalPages: _,
|
|
31
31
|
handleSkip: D
|
|
32
|
-
} =
|
|
32
|
+
} = k(), r = M(), { t: n } = w("Employee.EmployeeList"), [I, l] = A(/* @__PURE__ */ new Set()), { ...P } = F({
|
|
33
33
|
data: d,
|
|
34
34
|
columns: [
|
|
35
35
|
{
|
|
@@ -53,7 +53,7 @@ const at = () => {
|
|
|
53
53
|
return (t.onboardingStatus === i.ADMIN_ONBOARDING_INCOMPLETE || t.onboardingStatus === i.SELF_ONBOARDING_PENDING_INVITE || t.onboardingStatus === i.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW || t.onboardingStatus === i.ONBOARDING_COMPLETED) && e.push({
|
|
54
54
|
label: n("editCta"),
|
|
55
55
|
onClick: () => {
|
|
56
|
-
b(t.uuid, t.onboardingStatus);
|
|
56
|
+
b(t.uuid, t.onboardingStatus ?? void 0);
|
|
57
57
|
},
|
|
58
58
|
icon: /* @__PURE__ */ a(s, { "aria-hidden": !0 })
|
|
59
59
|
}), x.has(t.onboarding_status ?? "") && e.push({
|
|
@@ -102,9 +102,9 @@ const at = () => {
|
|
|
102
102
|
/* @__PURE__ */ a(r.Button, { variant: "primary", onClick: u, children: n("addEmployeeCTA") })
|
|
103
103
|
] }) })
|
|
104
104
|
});
|
|
105
|
-
return /* @__PURE__ */ c(
|
|
105
|
+
return /* @__PURE__ */ c(v, { children: [
|
|
106
106
|
d.length > 0 && /* @__PURE__ */ a(h, { children: /* @__PURE__ */ a(r.Button, { variant: "secondary", onClick: u, children: n("addAnotherCta") }) }),
|
|
107
|
-
/* @__PURE__ */ a("div", { className:
|
|
107
|
+
/* @__PURE__ */ a("div", { className: T.container, children: /* @__PURE__ */ a(V, { label: n("employeeListLabel"), ...P }) })
|
|
108
108
|
] });
|
|
109
109
|
};
|
|
110
110
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"List.js","sources":["../../../../src/components/Employee/EmployeeList/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useState } from 'react'\nimport style from './List.module.scss'\nimport { useEmployeeList } from './useEmployeeList'\nimport { DataView, EmptyData, ActionsLayout, useDataView } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport TrashCanSvg from '@/assets/icons/trashcan.svg?react'\nimport { EmployeeOnboardingStatus, EmployeeSelfOnboardingStatuses } from '@/shared/constants'\nimport { firstLastName } from '@/helpers/formattedStrings'\n\n/**List of employees slot for EmployeeList component */\nexport const List = () => {\n const {\n handleDelete,\n employees,\n handleEdit,\n handleReview,\n handleNew,\n handleCancelSelfOnboarding,\n handleFirstPage,\n handlePreviousPage,\n handleNextPage,\n handleLastPage,\n handleItemsPerPageChange,\n currentPage,\n totalPages,\n handleSkip,\n } = useEmployeeList()\n const Components = useComponentContext()\n\n const { t } = useTranslation('Employee.EmployeeList')\n const [deleting, setDeleting] = useState<Set<string>>(new Set())\n const { ...dataViewProps } = useDataView({\n data: employees,\n columns: [\n {\n key: 'name',\n title: t('nameLabel'),\n render: employee => {\n return firstLastName({\n first_name: employee.firstName,\n last_name: employee.lastName,\n })\n },\n },\n {\n key: 'status',\n title: t('statusLabel'),\n render: employee => {\n return (\n <Components.Badge status={employee.onboarded ? 'success' : 'warning'}>\n {t(`onboardingStatus.${employee.onboardingStatus ?? 'undefined'}`, {\n ns: 'common',\n })}\n </Components.Badge>\n )\n },\n },\n ],\n itemMenu: employee => {\n const menuItems = []\n\n // Edit item\n if (\n employee.onboardingStatus === EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE ||\n employee.onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE ||\n employee.onboardingStatus ===\n EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW ||\n employee.onboardingStatus === EmployeeOnboardingStatus.ONBOARDING_COMPLETED\n ) {\n menuItems.push({\n label: t('editCta'),\n onClick: () => {\n handleEdit(employee.uuid, employee.onboardingStatus)\n },\n icon: <PencilSvg aria-hidden />,\n })\n }\n\n // Cancel self onboarding item\n /* @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses */\n if (EmployeeSelfOnboardingStatuses.has(employee.onboarding_status ?? '')) {\n menuItems.push({\n label: t('cancelSelfOnboardingCta'),\n onClick: async () => {\n await handleCancelSelfOnboarding(employee.uuid)\n },\n icon: <PencilSvg aria-hidden />,\n })\n }\n\n // Review item\n if (\n employee.onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_COMPLETED_BY_EMPLOYEE\n ) {\n menuItems.push({\n label: t('reviewCta'),\n onClick: () => {\n void handleReview(employee.uuid)\n },\n icon: <PencilSvg aria-hidden />,\n })\n }\n\n // Delete item\n if (!employee.onboarded) {\n menuItems.push({\n label: t('deleteCta'),\n onClick: () => {\n setDeleting(prev => new Set(prev).add(employee.uuid))\n void handleDelete(employee.uuid).then(() => {\n setDeleting(prev => {\n const newSet = new Set(prev)\n newSet.delete(employee.uuid)\n return newSet\n })\n })\n },\n icon: <TrashCanSvg aria-hidden />,\n })\n }\n\n return (\n <HamburgerMenu\n items={menuItems}\n triggerLabel={t('hamburgerTitle')}\n isLoading={deleting.has(employee.uuid)}\n />\n )\n },\n pagination: {\n handleNextPage,\n handleFirstPage,\n handleLastPage,\n handlePreviousPage,\n handleItemsPerPageChange,\n currentPage,\n totalPages,\n },\n emptyState: () => (\n <EmptyData title={t('emptyTableTitle')} description={t('emptyTableDescription')}>\n <ActionsLayout justifyContent=\"center\">\n <Components.Button variant=\"secondary\" onClick={handleSkip}>\n {t('skipCta')}\n </Components.Button>\n <Components.Button variant=\"primary\" onClick={handleNew}>\n {t('addEmployeeCTA')}\n </Components.Button>\n </ActionsLayout>\n </EmptyData>\n ),\n })\n return (\n <>\n {employees.length > 0 && (\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={handleNew}>\n {t('addAnotherCta')}\n </Components.Button>\n </ActionsLayout>\n )}\n <div className={style.container}>\n <DataView label={t('employeeListLabel')} {...dataViewProps} />\n </div>\n </>\n )\n}\n"],"names":["List","handleDelete","employees","handleEdit","handleReview","handleNew","handleCancelSelfOnboarding","handleFirstPage","handlePreviousPage","handleNextPage","handleLastPage","handleItemsPerPageChange","currentPage","totalPages","handleSkip","useEmployeeList","Components","useComponentContext","t","useTranslation","deleting","setDeleting","useState","dataViewProps","useDataView","employee","firstLastName","jsx","menuItems","EmployeeOnboardingStatus","PencilSvg","EmployeeSelfOnboardingStatuses","prev","newSet","TrashCanSvg","HamburgerMenu","EmptyData","jsxs","ActionsLayout","Fragment","style","DataView"],"mappings":";;;;;;;;;;;;;;;AAaO,MAAMA,KAAO,MAAM;AAClB,QAAA;AAAA,IACJ,cAAAC;AAAA,IACA,WAAAC;AAAA,IACA,YAAAC;AAAA,IACA,cAAAC;AAAA,IACA,WAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,aAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,MACEC,EAAgB,GACdC,IAAaC,EAAoB,GAEjC,EAAE,GAAAC,EAAA,IAAMC,EAAe,uBAAuB,GAC9C,CAACC,GAAUC,CAAW,IAAIC,EAAsB,oBAAI,KAAK,GACzD,EAAE,GAAGC,EAAc,IAAIC,EAAY;AAAA,IACvC,MAAMtB;AAAA,IACN,SAAS;AAAA,MACP;AAAA,QACE,KAAK;AAAA,QACL,OAAOgB,EAAE,WAAW;AAAA,QACpB,QAAQ,CAAYO,MACXC,EAAc;AAAA,UACnB,YAAYD,EAAS;AAAA,UACrB,WAAWA,EAAS;AAAA,QAAA,CACrB;AAAA,MAEL;AAAA,MACA;AAAA,QACE,KAAK;AAAA,QACL,OAAOP,EAAE,aAAa;AAAA,QACtB,QAAQ,CAAYO,MAEf,gBAAAE,EAAAX,EAAW,OAAX,EAAiB,QAAQS,EAAS,YAAY,YAAY,WACxD,UAAEP,EAAA,oBAAoBO,EAAS,oBAAoB,WAAW,IAAI;AAAA,UACjE,IAAI;AAAA,QACL,CAAA,GACH;AAAA,MAEJ;AAAA,IAEJ;AAAA,IACA,UAAU,CAAYA,MAAA;AACpB,YAAMG,IAAY,CAAC;AAGnB,cACEH,EAAS,qBAAqBI,EAAyB,+BACvDJ,EAAS,qBAAqBI,EAAyB,kCACvDJ,EAAS,qBACPI,EAAyB,yCAC3BJ,EAAS,qBAAqBI,EAAyB,yBAEvDD,EAAU,KAAK;AAAA,QACb,OAAOV,EAAE,SAAS;AAAA,QAClB,SAAS,MAAM;
|
|
1
|
+
{"version":3,"file":"List.js","sources":["../../../../src/components/Employee/EmployeeList/List.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useState } from 'react'\nimport style from './List.module.scss'\nimport { useEmployeeList } from './useEmployeeList'\nimport { DataView, EmptyData, ActionsLayout, useDataView } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { HamburgerMenu } from '@/components/Common/HamburgerMenu'\nimport PencilSvg from '@/assets/icons/pencil.svg?react'\nimport TrashCanSvg from '@/assets/icons/trashcan.svg?react'\nimport { EmployeeOnboardingStatus, EmployeeSelfOnboardingStatuses } from '@/shared/constants'\nimport { firstLastName } from '@/helpers/formattedStrings'\n\n/**List of employees slot for EmployeeList component */\nexport const List = () => {\n const {\n handleDelete,\n employees,\n handleEdit,\n handleReview,\n handleNew,\n handleCancelSelfOnboarding,\n handleFirstPage,\n handlePreviousPage,\n handleNextPage,\n handleLastPage,\n handleItemsPerPageChange,\n currentPage,\n totalPages,\n handleSkip,\n } = useEmployeeList()\n const Components = useComponentContext()\n\n const { t } = useTranslation('Employee.EmployeeList')\n const [deleting, setDeleting] = useState<Set<string>>(new Set())\n const { ...dataViewProps } = useDataView({\n data: employees,\n columns: [\n {\n key: 'name',\n title: t('nameLabel'),\n render: employee => {\n return firstLastName({\n first_name: employee.firstName,\n last_name: employee.lastName,\n })\n },\n },\n {\n key: 'status',\n title: t('statusLabel'),\n render: employee => {\n return (\n <Components.Badge status={employee.onboarded ? 'success' : 'warning'}>\n {t(`onboardingStatus.${employee.onboardingStatus ?? 'undefined'}`, {\n ns: 'common',\n })}\n </Components.Badge>\n )\n },\n },\n ],\n itemMenu: employee => {\n const menuItems = []\n\n // Edit item\n if (\n employee.onboardingStatus === EmployeeOnboardingStatus.ADMIN_ONBOARDING_INCOMPLETE ||\n employee.onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_PENDING_INVITE ||\n employee.onboardingStatus ===\n EmployeeOnboardingStatus.SELF_ONBOARDING_AWAITING_ADMIN_REVIEW ||\n employee.onboardingStatus === EmployeeOnboardingStatus.ONBOARDING_COMPLETED\n ) {\n menuItems.push({\n label: t('editCta'),\n onClick: () => {\n handleEdit(employee.uuid, employee.onboardingStatus ?? undefined)\n },\n icon: <PencilSvg aria-hidden />,\n })\n }\n\n // Cancel self onboarding item\n /* @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses */\n if (EmployeeSelfOnboardingStatuses.has(employee.onboarding_status ?? '')) {\n menuItems.push({\n label: t('cancelSelfOnboardingCta'),\n onClick: async () => {\n await handleCancelSelfOnboarding(employee.uuid)\n },\n icon: <PencilSvg aria-hidden />,\n })\n }\n\n // Review item\n if (\n employee.onboardingStatus === EmployeeOnboardingStatus.SELF_ONBOARDING_COMPLETED_BY_EMPLOYEE\n ) {\n menuItems.push({\n label: t('reviewCta'),\n onClick: () => {\n void handleReview(employee.uuid)\n },\n icon: <PencilSvg aria-hidden />,\n })\n }\n\n // Delete item\n if (!employee.onboarded) {\n menuItems.push({\n label: t('deleteCta'),\n onClick: () => {\n setDeleting(prev => new Set(prev).add(employee.uuid))\n void handleDelete(employee.uuid).then(() => {\n setDeleting(prev => {\n const newSet = new Set(prev)\n newSet.delete(employee.uuid)\n return newSet\n })\n })\n },\n icon: <TrashCanSvg aria-hidden />,\n })\n }\n\n return (\n <HamburgerMenu\n items={menuItems}\n triggerLabel={t('hamburgerTitle')}\n isLoading={deleting.has(employee.uuid)}\n />\n )\n },\n pagination: {\n handleNextPage,\n handleFirstPage,\n handleLastPage,\n handlePreviousPage,\n handleItemsPerPageChange,\n currentPage,\n totalPages,\n },\n emptyState: () => (\n <EmptyData title={t('emptyTableTitle')} description={t('emptyTableDescription')}>\n <ActionsLayout justifyContent=\"center\">\n <Components.Button variant=\"secondary\" onClick={handleSkip}>\n {t('skipCta')}\n </Components.Button>\n <Components.Button variant=\"primary\" onClick={handleNew}>\n {t('addEmployeeCTA')}\n </Components.Button>\n </ActionsLayout>\n </EmptyData>\n ),\n })\n return (\n <>\n {employees.length > 0 && (\n <ActionsLayout>\n <Components.Button variant=\"secondary\" onClick={handleNew}>\n {t('addAnotherCta')}\n </Components.Button>\n </ActionsLayout>\n )}\n <div className={style.container}>\n <DataView label={t('employeeListLabel')} {...dataViewProps} />\n </div>\n </>\n )\n}\n"],"names":["List","handleDelete","employees","handleEdit","handleReview","handleNew","handleCancelSelfOnboarding","handleFirstPage","handlePreviousPage","handleNextPage","handleLastPage","handleItemsPerPageChange","currentPage","totalPages","handleSkip","useEmployeeList","Components","useComponentContext","t","useTranslation","deleting","setDeleting","useState","dataViewProps","useDataView","employee","firstLastName","jsx","menuItems","EmployeeOnboardingStatus","PencilSvg","EmployeeSelfOnboardingStatuses","prev","newSet","TrashCanSvg","HamburgerMenu","EmptyData","jsxs","ActionsLayout","Fragment","style","DataView"],"mappings":";;;;;;;;;;;;;;;AAaO,MAAMA,KAAO,MAAM;AAClB,QAAA;AAAA,IACJ,cAAAC;AAAA,IACA,WAAAC;AAAA,IACA,YAAAC;AAAA,IACA,cAAAC;AAAA,IACA,WAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,iBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,gBAAAC;AAAA,IACA,0BAAAC;AAAA,IACA,aAAAC;AAAA,IACA,YAAAC;AAAA,IACA,YAAAC;AAAA,MACEC,EAAgB,GACdC,IAAaC,EAAoB,GAEjC,EAAE,GAAAC,EAAA,IAAMC,EAAe,uBAAuB,GAC9C,CAACC,GAAUC,CAAW,IAAIC,EAAsB,oBAAI,KAAK,GACzD,EAAE,GAAGC,EAAc,IAAIC,EAAY;AAAA,IACvC,MAAMtB;AAAA,IACN,SAAS;AAAA,MACP;AAAA,QACE,KAAK;AAAA,QACL,OAAOgB,EAAE,WAAW;AAAA,QACpB,QAAQ,CAAYO,MACXC,EAAc;AAAA,UACnB,YAAYD,EAAS;AAAA,UACrB,WAAWA,EAAS;AAAA,QAAA,CACrB;AAAA,MAEL;AAAA,MACA;AAAA,QACE,KAAK;AAAA,QACL,OAAOP,EAAE,aAAa;AAAA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GAC7C,UAAEa,EAAA,eAAe,EACpB,CAAA,GACF;AAAA,IAED,gBAAAS,EAAA,OAAA,EAAI,WAAWa,EAAM,WACpB,UAAA,gBAAAb,EAACc,GAAS,EAAA,OAAOvB,EAAE,mBAAmB,GAAI,GAAGK,GAAe,EAC9D,CAAA;AAAA,EAAA,GACF;AAEJ;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Employee } from '@gusto/embedded-api/models/components/employee';
|
|
2
|
+
import { OnboardingStatus } from '@gusto/embedded-api/models/operations/putv1employeesemployeeidonboardingstatus';
|
|
2
3
|
type EmployeeListContextType = {
|
|
3
|
-
handleEdit: (uuid: string, onboardingStatus?:
|
|
4
|
+
handleEdit: (uuid: string, onboardingStatus?: OnboardingStatus) => void;
|
|
4
5
|
handleDelete: (uuid: string) => Promise<void>;
|
|
5
6
|
handleCancelSelfOnboarding: (employeeId: string) => Promise<void>;
|
|
6
7
|
handleReview: (employeeId: string) => Promise<void>;
|
|
@@ -6,11 +6,13 @@ import "@gusto/embedded-api/models/errors/apierror";
|
|
|
6
6
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
7
7
|
import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
8
8
|
import "../../Base/useBase.js";
|
|
9
|
+
import "../../../shared/constants.js";
|
|
9
10
|
import "dompurify";
|
|
11
|
+
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
10
12
|
import { createCompoundContext as o } from "../../Base/createCompoundContext.js";
|
|
11
|
-
const [
|
|
13
|
+
const [E, L] = o("EmployeeListContext");
|
|
12
14
|
export {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
L as EmployeeListProvider,
|
|
16
|
+
E as useEmployeeList
|
|
15
17
|
};
|
|
16
18
|
//# sourceMappingURL=useEmployeeList.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useEmployeeList.js","sources":["../../../../src/components/Employee/EmployeeList/useEmployeeList.ts"],"sourcesContent":["import type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport { createCompoundContext } from '@/components/Base'\n\n//Interface for context passed down to component slots\ntype EmployeeListContextType = {\n handleEdit: (uuid: string, onboardingStatus?:
|
|
1
|
+
{"version":3,"file":"useEmployeeList.js","sources":["../../../../src/components/Employee/EmployeeList/useEmployeeList.ts"],"sourcesContent":["import type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { OnboardingStatus } from '@gusto/embedded-api/models/operations/putv1employeesemployeeidonboardingstatus'\nimport { createCompoundContext } from '@/components/Base'\n\n//Interface for context passed down to component slots\ntype EmployeeListContextType = {\n handleEdit: (uuid: string, onboardingStatus?: OnboardingStatus) => void\n handleDelete: (uuid: string) => Promise<void>\n handleCancelSelfOnboarding: (employeeId: string) => Promise<void>\n handleReview: (employeeId: string) => Promise<void>\n handleNew: () => void\n handleSkip: () => void\n handleFirstPage: () => void\n handlePreviousPage: () => void\n handleNextPage: () => void\n handleLastPage: () => void\n handleItemsPerPageChange: (newCount: number) => void\n currentPage: number\n totalPages: number\n employees: Employee[]\n}\n\nconst [useEmployeeList, EmployeeListProvider] =\n createCompoundContext<EmployeeListContextType>('EmployeeListContext')\nexport { useEmployeeList, EmployeeListProvider }\n"],"names":["useEmployeeList","EmployeeListProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;AAsBA,MAAM,CAACA,GAAiBC,CAAoB,IAC1CC,EAA+C,qBAAqB;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z as t } from "zod";
|
|
2
|
-
import { BankAccountSchema as
|
|
2
|
+
import { BankAccountSchema as l } from "./BankAccount.js";
|
|
3
3
|
import "react/jsx-runtime";
|
|
4
4
|
import "react";
|
|
5
5
|
import "react-error-boundary";
|
|
@@ -8,10 +8,12 @@ import "@gusto/embedded-api/models/errors/apierror";
|
|
|
8
8
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
9
9
|
import "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
|
|
10
10
|
import "../../Base/useBase.js";
|
|
11
|
+
import "../../../shared/constants.js";
|
|
11
12
|
import "dompurify";
|
|
13
|
+
import "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
12
14
|
import { createCompoundContext as a } from "../../Base/createCompoundContext.js";
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
+
const j = t.union([
|
|
16
|
+
l.extend({
|
|
15
17
|
type: t.literal("Direct Deposit"),
|
|
16
18
|
isSplit: t.literal(!1)
|
|
17
19
|
}),
|
|
@@ -41,15 +43,15 @@ const P = t.union([
|
|
|
41
43
|
splitBy: t.literal("Amount"),
|
|
42
44
|
priority: t.record(t.string(), t.number()).refine((r) => {
|
|
43
45
|
const e = Object.values(r);
|
|
44
|
-
return e.filter((i,
|
|
46
|
+
return e.filter((i, o) => e.indexOf(i) !== o).length === 0;
|
|
45
47
|
}),
|
|
46
48
|
splitAmount: t.record(t.string(), t.number().min(0).nullable()),
|
|
47
49
|
remainder: t.string()
|
|
48
50
|
})
|
|
49
|
-
]), [
|
|
51
|
+
]), [x, B] = a("PaymentMethodContext");
|
|
50
52
|
export {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
j as CombinedSchema,
|
|
54
|
+
B as PaymentMethodProvider,
|
|
55
|
+
x as usePaymentMethod
|
|
54
56
|
};
|
|
55
57
|
//# sourceMappingURL=usePaymentMethod.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePaymentMethod.js","sources":["../../../../src/components/Employee/PaymentMethod/usePaymentMethod.ts"],"sourcesContent":["import type { EmployeeBankAccount } from '@gusto/embedded-api/models/components/employeebankaccount'\nimport type { EmployeePaymentMethod } from '@gusto/embedded-api/models/components/employeepaymentmethod'\nimport { z } from 'zod'\nimport { BankAccountSchema } from './BankAccount'\nimport { createCompoundContext } from '@/components/Base'\n\nexport const CombinedSchema = z.union([\n BankAccountSchema.extend({\n type: z.literal('Direct Deposit'),\n isSplit: z.literal(false),\n }),\n z.object({\n type: z.literal('Direct Deposit'),\n isSplit: z.literal(false),\n hasBankPayload: z.literal(false),\n }),\n z.object({\n type: z.literal('Check'),\n }),\n z.object({\n type: z.literal('Direct Deposit'),\n isSplit: z.literal(true),\n hasBankPayload: z.literal(false),\n splitBy: z.literal('Percentage'),\n splitAmount: z\n .record(z.string(), z.number().max(100).min(0))\n .refine(\n input => Object.values(input).reduce((acc, curr) => acc + curr, 0) === 100,\n 'Must be 100',\n ),\n priority: z.record(z.string(), z.number()),\n }),\n z.object({\n type: z.literal('Direct Deposit'),\n isSplit: z.literal(true),\n hasBankPayload: z.literal(false),\n splitBy: z.literal('Amount'),\n priority: z.record(z.string(), z.number()).refine(input => {\n const arr = Object.values(input)\n return arr.filter((item, index) => arr.indexOf(item) !== index).length === 0\n }),\n splitAmount: z.record(z.string(), z.number().min(0).nullable()),\n remainder: z.string(),\n }),\n])\n\nexport type CombinedSchemaInputs = z.input<typeof CombinedSchema>\nexport type CombinedSchemaOutputs = z.output<typeof CombinedSchema>\n\ntype PaymentMethodContextType = {\n bankAccounts: EmployeeBankAccount[]\n isPending: boolean\n watchedType?: string\n mode: MODE\n paymentMethod: EmployeePaymentMethod\n handleAdd: () => void\n handleSplit: () => void\n handleCancel: () => void\n handleDelete: (uuid: string) => void\n}\n\nexport type MODE = 'ADD' | 'LIST' | 'SPLIT' | 'INITIAL'\n\nconst [usePaymentMethod, PaymentMethodProvider] =\n createCompoundContext<PaymentMethodContextType>('PaymentMethodContext')\nexport { usePaymentMethod, PaymentMethodProvider }\n"],"names":["CombinedSchema","z","BankAccountSchema","input","acc","curr","arr","item","index","usePaymentMethod","PaymentMethodProvider","createCompoundContext"],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePaymentMethod.js","sources":["../../../../src/components/Employee/PaymentMethod/usePaymentMethod.ts"],"sourcesContent":["import type { EmployeeBankAccount } from '@gusto/embedded-api/models/components/employeebankaccount'\nimport type { EmployeePaymentMethod } from '@gusto/embedded-api/models/components/employeepaymentmethod'\nimport { z } from 'zod'\nimport { BankAccountSchema } from './BankAccount'\nimport { createCompoundContext } from '@/components/Base'\n\nexport const CombinedSchema = z.union([\n BankAccountSchema.extend({\n type: z.literal('Direct Deposit'),\n isSplit: z.literal(false),\n }),\n z.object({\n type: z.literal('Direct Deposit'),\n isSplit: z.literal(false),\n hasBankPayload: z.literal(false),\n }),\n z.object({\n type: z.literal('Check'),\n }),\n z.object({\n type: z.literal('Direct Deposit'),\n isSplit: z.literal(true),\n hasBankPayload: z.literal(false),\n splitBy: z.literal('Percentage'),\n splitAmount: z\n .record(z.string(), z.number().max(100).min(0))\n .refine(\n input => Object.values(input).reduce((acc, curr) => acc + curr, 0) === 100,\n 'Must be 100',\n ),\n priority: z.record(z.string(), z.number()),\n }),\n z.object({\n type: z.literal('Direct Deposit'),\n isSplit: z.literal(true),\n hasBankPayload: z.literal(false),\n splitBy: z.literal('Amount'),\n priority: z.record(z.string(), z.number()).refine(input => {\n const arr = Object.values(input)\n return arr.filter((item, index) => arr.indexOf(item) !== index).length === 0\n }),\n splitAmount: z.record(z.string(), z.number().min(0).nullable()),\n remainder: z.string(),\n }),\n])\n\nexport type CombinedSchemaInputs = z.input<typeof CombinedSchema>\nexport type CombinedSchemaOutputs = z.output<typeof CombinedSchema>\n\ntype PaymentMethodContextType = {\n bankAccounts: EmployeeBankAccount[]\n isPending: boolean\n watchedType?: string\n mode: MODE\n paymentMethod: EmployeePaymentMethod\n handleAdd: () => void\n handleSplit: () => void\n handleCancel: () => void\n handleDelete: (uuid: string) => void\n}\n\nexport type MODE = 'ADD' | 'LIST' | 'SPLIT' | 'INITIAL'\n\nconst [usePaymentMethod, PaymentMethodProvider] =\n createCompoundContext<PaymentMethodContextType>('PaymentMethodContext')\nexport { usePaymentMethod, PaymentMethodProvider }\n"],"names":["CombinedSchema","z","BankAccountSchema","input","acc","curr","arr","item","index","usePaymentMethod","PaymentMethodProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;AAMa,MAAAA,IAAiBC,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