@gusto/embedded-react-sdk 0.35.0-rc.3 → 0.36.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +20 -11
  2. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js +58 -57
  3. package/dist/components/Company/AssignSignatory/CreateSignatory/CreateSignatory.js.map +1 -1
  4. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js +18 -18
  5. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatory.js.map +1 -1
  6. package/dist/components/Company/BankAccount/BankAccountVerify/BankAccountVerify.js +17 -13
  7. package/dist/components/Company/BankAccount/BankAccountVerify/BankAccountVerify.js.map +1 -1
  8. package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js +1 -1
  9. package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
  10. package/dist/components/Company/DocumentSigner/DocumentSigner.js +5 -5
  11. package/dist/components/Company/DocumentSigner/DocumentSigner.js.map +1 -1
  12. package/dist/components/Employee/Compensation/Compensation.js +21 -21
  13. package/dist/components/Employee/Compensation/Compensation.js.map +1 -1
  14. package/dist/components/Employee/FederalTaxes/FederalForm.d.ts +2 -8
  15. package/dist/components/Employee/FederalTaxes/FederalForm.js +29 -84
  16. package/dist/components/Employee/FederalTaxes/FederalForm.js.map +1 -1
  17. package/dist/components/Employee/FederalTaxes/FederalTaxes.js +44 -49
  18. package/dist/components/Employee/FederalTaxes/FederalTaxes.js.map +1 -1
  19. package/dist/components/Employee/Taxes/FederalForm.d.ts +2 -8
  20. package/dist/components/Employee/Taxes/FederalForm.js +29 -84
  21. package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
  22. package/dist/components/Employee/Taxes/Taxes.js +69 -74
  23. package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
  24. package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +6 -6
  25. package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
  26. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js +12 -12
  27. package/dist/components/Payroll/PayrollBlocker/components/PayrollBlockerList.js.map +1 -1
  28. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +2 -2
  29. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
  30. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
  31. package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js +6 -4
  32. package/dist/components/Payroll/PayrollLanding/PayrollLandingFlowComponents.js.map +1 -1
  33. package/dist/components/Payroll/PayrollList/PayrollList.js +8 -6
  34. package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
  35. package/dist/components/Payroll/helpers.d.ts +1 -1
  36. package/dist/components/Payroll/helpers.js.map +1 -1
  37. package/package.json +9 -9
@@ -14,8 +14,8 @@ import { useFederalTaxDetailsGetSuspense as ue } from "@gusto/embedded-api/react
14
14
  import { useEmployeesGetSuspense as de } from "@gusto/embedded-api/react-query/employeesGet";
15
15
  import { List as le } from "./List.js";
16
16
  import { Head as ce } from "./Head.js";
17
- import { Edit as fe } from "./Edit.js";
18
- import { Actions as pe } from "./Actions.js";
17
+ import { Edit as pe } from "./Edit.js";
18
+ import { Actions as fe } from "./Actions.js";
19
19
  import { CompensationSchema as Ce, CompensationProvider as Ee } from "./useCompensation.js";
20
20
  import { Form as he } from "../../Common/Form/Form.js";
21
21
  import { FlsaStatus as h, componentEvents as C } from "../../../shared/constants.js";
@@ -37,19 +37,19 @@ const B = (t) => t?.compensations?.find((d) => d.uuid === t.currentCompensationU
37
37
  } = de({ employeeId: t });
38
38
  if (!g)
39
39
  throw new Error("Employee not found");
40
- const { data: q } = ue({ companyId: g.companyUuid }), G = q.federalTaxDetails.taxPayerType === "S-Corporation", N = re(), _ = ne(), L = se(), J = ae(), [o, S] = W(
40
+ const { data: q } = ue({ companyId: g.companyUuid }), R = q.federalTaxDetails.taxPayerType === "S-Corporation", N = re(), _ = ne(), L = se(), J = ae(), [o, S] = W(
41
41
  n.length === 1 ? n[0] ?? null : null
42
42
  ), [y, c] = W(() => {
43
43
  if (!n.length)
44
44
  return "ADD_INITIAL_JOB";
45
45
  const e = B(n[0]);
46
46
  return n.length === 1 && e?.flsaStatus !== h.NONEXEMPT ? "EDIT_INITIAL_JOB" : "LIST";
47
- }), [R, w] = W(!1), a = B(o), I = F(() => n.reduce((e, i) => {
48
- const p = i.compensations?.find(
47
+ }), [G, w] = W(!1), a = B(o), I = F(() => n.reduce((e, i) => {
48
+ const f = i.compensations?.find(
49
49
  (O) => O.uuid === i.currentCompensationUuid
50
50
  );
51
- return !i.primary || !p ? e : p.flsaStatus ?? e;
52
- }, void 0), [n]), f = F(() => ({
51
+ return !i.primary || !f ? e : f.flsaStatus ?? e;
52
+ }, void 0), [n]), p = F(() => ({
53
53
  jobTitle: o?.title && o.title !== "" ? o.title : m.defaultValues?.title ?? "",
54
54
  flsaStatus: a?.flsaStatus ?? I ?? m.defaultValues?.flsaStatus,
55
55
  rate: Number(a?.rate ?? m.defaultValues?.rate ?? 0),
@@ -61,18 +61,18 @@ const B = (t) => t?.compensations?.find((d) => d.uuid === t.currentCompensationU
61
61
  twoPercentShareholder: o?.twoPercentShareholder ?? !1
62
62
  }), [o, a, I, m.defaultValues]), v = $({
63
63
  resolver: Q(Ce),
64
- defaultValues: f
64
+ defaultValues: p
65
65
  }), { resetField: P, setValue: b, handleSubmit: X, reset: E } = v;
66
66
  return Z(() => {
67
- E(f);
68
- }, [o, f, E]), /* @__PURE__ */ s("section", { className: A, children: /* @__PURE__ */ s(
67
+ E(p);
68
+ }, [o, p, E]), /* @__PURE__ */ s("section", { className: A, children: /* @__PURE__ */ s(
69
69
  Ee,
70
70
  {
71
71
  value: {
72
72
  employeeJobs: n,
73
73
  currentJob: o,
74
74
  primaryFlsaStatus: I,
75
- showFlsaChangeWarning: R,
75
+ showFlsaChangeWarning: G,
76
76
  mode: y,
77
77
  minimumWages: x,
78
78
  handleFlsaChange: (e) => {
@@ -82,11 +82,11 @@ const B = (t) => t?.compensations?.find((d) => d.uuid === t.currentCompensationU
82
82
  await J.mutateAsync({ request: { jobId: e } }), l(C.EMPLOYEE_JOB_DELETED);
83
83
  },
84
84
  handleEdit: (e) => {
85
- const i = n.find((p) => e === p.uuid);
85
+ const i = n.find((f) => e === f.uuid);
86
86
  i && (c("EDIT_ADDITIONAL_JOB"), S(i));
87
87
  },
88
88
  handleAdd: () => {
89
- c("ADD_ADDITIONAL_JOB"), S(null), E(f);
89
+ c("ADD_ADDITIONAL_JOB"), S(null), E(p);
90
90
  },
91
91
  submitWithEffect: async (e) => {
92
92
  if (y === "LIST" && e === "PROCEED") {
@@ -98,8 +98,8 @@ const B = (t) => t?.compensations?.find((d) => d.uuid === t.currentCompensationU
98
98
  return;
99
99
  }
100
100
  await X(async (i) => {
101
- await j(i, async (p) => {
102
- const { jobTitle: O, twoPercentShareholder: U, ...r } = p;
101
+ await j(i, async (f) => {
102
+ const { jobTitle: O, twoPercentShareholder: U, ...r } = f;
103
103
  let u;
104
104
  o ? (u = (await L.mutateAsync({
105
105
  request: {
@@ -128,7 +128,7 @@ const B = (t) => t?.compensations?.find((d) => d.uuid === t.currentCompensationU
128
128
  const { compensation: H } = await N.mutateAsync({
129
129
  request: {
130
130
  compensationId: u.currentCompensationUuid,
131
- requestBody: {
131
+ compensationsUpdateRequestBody: {
132
132
  // eslint-disable-next-line @typescript-eslint/no-non-null-asserted-optional-chain
133
133
  version: u.compensations?.find(
134
134
  (T) => T.uuid === u.currentCompensationUuid
@@ -141,7 +141,7 @@ const B = (t) => t?.compensations?.find((d) => d.uuid === t.currentCompensationU
141
141
  });
142
142
  switch (w(!1), l(C.EMPLOYEE_COMPENSATION_UPDATED, H), e) {
143
143
  case "LIST":
144
- c("LIST"), S(null), E(f);
144
+ c("LIST"), S(null), E(p);
145
145
  break;
146
146
  default:
147
147
  l(C.EMPLOYEE_COMPENSATION_DONE);
@@ -150,17 +150,17 @@ const B = (t) => t?.compensations?.find((d) => d.uuid === t.currentCompensationU
150
150
  })();
151
151
  },
152
152
  handleCancelAddJob: () => {
153
- n.length > 0 ? c("LIST") : c("ADD_INITIAL_JOB"), S(null), E(f);
153
+ n.length > 0 ? c("LIST") : c("ADD_INITIAL_JOB"), S(null), E(p);
154
154
  },
155
155
  isPending: N.isPending || _.isPending || L.isPending || J.isPending,
156
156
  state: M.state,
157
- showTwoPercentStakeholder: G
157
+ showTwoPercentStakeholder: R
158
158
  },
159
159
  children: /* @__PURE__ */ s(ee, { ...v, children: /* @__PURE__ */ s(he, { children: D || /* @__PURE__ */ z(K, { children: [
160
160
  /* @__PURE__ */ s(ce, {}),
161
161
  /* @__PURE__ */ s(le, {}),
162
- /* @__PURE__ */ s(fe, {}),
163
- /* @__PURE__ */ s(pe, {})
162
+ /* @__PURE__ */ s(pe, {}),
163
+ /* @__PURE__ */ s(fe, {})
164
164
  ] }) }) })
165
165
  }
166
166
  ) });
@@ -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 } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { useJobsAndCompensationsGetJobsSuspense } 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 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/OnboardingFlowComponents'\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\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 const createEmployeeJobMutation = useJobsAndCompensationsCreateJobMutation()\n const updateEmployeeJobMutation = useJobsAndCompensationsUpdateMutation()\n const deleteEmployeeJobMutation = useJobsAndCompensationsDeleteMutation()\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 twoPercentShareholder: currentJob?.twoPercentShareholder ?? false,\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 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 // Success logic only runs if no errors were thrown above\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 }\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 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\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","jobsData","useJobsAndCompensationsGetJobsSuspense","employeeJobs","addressesData","useEmployeeAddressesGetWorkAddressesSuspense","currentWorkAddress","address","minimumWageList","useLocationsGetMinimumWagesSuspense","minimumWages","employee","useEmployeesGetSuspense","data","useFederalTaxDetailsGetSuspense","showTwoPercentStakeholder","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","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","CompensationProvider","value","jobId","componentEvents","uuid","selectedJob","job","newMode","payload","jobTitle","twoPercentShareholder","compensationData","updatedJobData","FormProvider","Form","jsxs","Fragment","Head","List","Edit","Actions","CompensationContextual","useFlow","t","useTranslation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqDO,SAASA,GAAaC,GAAmD;AAC9E,SAAAC,GAAuB,yBAAyBD,EAAM,UAAU,GAE9D,gBAAA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GAAY,SAAAM,GAAS,WAAAL,GAAW,eAAA4C,EAAA,IAAkBgC,GAAA,GACpD,EAAE,GAAAC,EAAA,IAAMC,GAAe,QAAQ;AAErC,MAAI,CAAC/E,KAAc,CAACC;AAClB,UAAM,IAAI;AAAA,MACR6E,EAAE,iCAAiC;AAAA,QACjC,WAAW;AAAA,QACX,OAAQ9E,IAA4B,cAAf;AAAA,QACrB,UAAU;AAAA,MAAA,CACX;AAAA,IAAA;AAGL,SACE,gBAAAN;AAAA,IAACH;AAAA,IAAA;AAAA,MACC,YAAAS;AAAA,MACA,WAAAC;AAAA,MACA,SAAAK;AAAA,MACA,eAAeuC,GAAe;AAAA,IAAA;AAAA,EAAA;AAGpC;"}
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 } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { useJobsAndCompensationsGetJobsSuspense } 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 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/OnboardingFlowComponents'\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\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 const createEmployeeJobMutation = useJobsAndCompensationsCreateJobMutation()\n const updateEmployeeJobMutation = useJobsAndCompensationsUpdateMutation()\n const deleteEmployeeJobMutation = useJobsAndCompensationsDeleteMutation()\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 twoPercentShareholder: currentJob?.twoPercentShareholder ?? false,\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 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 compensationsUpdateRequestBody: {\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 // Success logic only runs if no errors were thrown above\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 }\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 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\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","jobsData","useJobsAndCompensationsGetJobsSuspense","employeeJobs","addressesData","useEmployeeAddressesGetWorkAddressesSuspense","currentWorkAddress","address","minimumWageList","useLocationsGetMinimumWagesSuspense","minimumWages","employee","useEmployeesGetSuspense","data","useFederalTaxDetailsGetSuspense","showTwoPercentStakeholder","updateCompensationMutation","useJobsAndCompensationsUpdateCompensationMutation","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","CompensationProvider","value","jobId","componentEvents","uuid","selectedJob","job","newMode","payload","jobTitle","twoPercentShareholder","compensationData","updatedJobData","FormProvider","Form","jsxs","Fragment","Head","List","Edit","Actions","CompensationContextual","useFlow","t","useTranslation"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAqDO,SAASA,GAAaC,GAAmD;AAC9E,SAAAC,GAAuB,yBAAyBD,EAAM,UAAU,GAE9D,gBAAAE,EAACC,IAAA,EAAe,GAAGH,GACjB,UAAA,gBAAAE,EAACE,MAAM,GAAGJ,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,MAAMK,IAA0B,CAACC,MACxBA,GAAa,eAAe,KAAK,OAAQC,EAAK,SAASD,EAAY,uBAAuB,GAG7FF,KAAO,CA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Q9E,IAA4B,cAAf;AAAA,QACrB,UAAU;AAAA,MAAA,CACX;AAAA,IAAA;AAGL,SACE,gBAAAN;AAAA,IAACH;AAAA,IAAA;AAAA,MACC,YAAAS;AAAA,MACA,WAAAC;AAAA,MACA,SAAAK;AAAA,MACA,eAAeuC,GAAe;AAAA,IAAA;AAAA,EAAA;AAGpC;"}
@@ -1,18 +1,12 @@
1
1
  import { z } from 'zod';
2
- export declare const FederalFormSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
3
- w4DataType: z.ZodLiteral<"rev_2020_w4">;
2
+ export declare const FederalFormSchema: z.ZodObject<{
4
3
  filingStatus: z.ZodString;
5
4
  twoJobs: z.ZodString;
6
5
  dependentsAmount: z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>;
7
6
  otherIncome: z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>;
8
7
  deductions: z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>;
9
8
  extraWithholding: z.ZodPipe<z.ZodNumber, z.ZodTransform<string, number>>;
10
- }, z.core.$strip>, z.ZodObject<{
11
- w4DataType: z.ZodLiteral<"pre_2020_w4">;
12
- filingStatus: z.ZodString;
13
- federalWithholdingAllowance: z.ZodNumber;
14
- additionalWithholding: z.ZodString;
15
- }, z.core.$strip>], "w4DataType">;
9
+ }, z.core.$strip>;
16
10
  export type FederalFormInputs = z.input<typeof FederalFormSchema>;
17
11
  export type FederalFormPayload = z.output<typeof FederalFormSchema>;
18
12
  export declare function FederalForm(): import("react/jsx-runtime").JSX.Element;
@@ -1,67 +1,55 @@
1
- import { jsx as t, jsxs as n, Fragment as a } from "react/jsx-runtime";
2
- import { useTranslation as o, Trans as u } from "react-i18next";
3
- import { useFormContext as m } from "react-hook-form";
1
+ import { jsxs as l, Fragment as a, jsx as r } from "react/jsx-runtime";
2
+ import { useTranslation as s, Trans as m } from "react-i18next";
4
3
  import { z as i } from "zod";
5
4
  import "../../../shared/constants.js";
6
5
  import "classnames";
7
- import { RadioGroupField as g } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
8
- import { TextInputField as f } from "../../Common/Fields/TextInputField/TextInputField.js";
9
- import { NumberInputField as r } from "../../Common/Fields/NumberInputField/NumberInputField.js";
10
- import { useComponentContext as c } from "../../../contexts/ComponentAdapter/useComponentContext.js";
6
+ import { RadioGroupField as u } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
7
+ import { NumberInputField as t } from "../../Common/Fields/NumberInputField/NumberInputField.js";
8
+ import { useComponentContext as d } from "../../../contexts/ComponentAdapter/useComponentContext.js";
11
9
  import "react";
12
- import { SelectField as s } from "../../Common/Fields/SelectField/SelectField.js";
13
- const p = i.object({
14
- w4DataType: i.literal("rev_2020_w4"),
10
+ import { SelectField as c } from "../../Common/Fields/SelectField/SelectField.js";
11
+ const f = i.object({
15
12
  filingStatus: i.string().min(1),
16
13
  twoJobs: i.string().min(1),
17
14
  dependentsAmount: i.number().transform(String),
18
15
  otherIncome: i.number().transform(String),
19
16
  deductions: i.number().transform(String),
20
17
  extraWithholding: i.number().transform(String)
21
- }), h = i.object({
22
- w4DataType: i.literal("pre_2020_w4"),
23
- filingStatus: i.string().min(1),
24
- federalWithholdingAllowance: i.number().int(),
25
- additionalWithholding: i.string()
26
- }), H = i.discriminatedUnion("w4DataType", [p, h]);
27
- function A() {
28
- const { watch: e } = m();
29
- return e("w4DataType") === "rev_2020_w4" ? /* @__PURE__ */ t(b, {}) : /* @__PURE__ */ t(S, {});
30
- }
31
- function b() {
32
- const { t: e } = o("Employee.FederalTaxes"), l = c(), d = [
18
+ }), v = f;
19
+ function M() {
20
+ const { t: e } = s("Employee.FederalTaxes"), o = d(), n = [
33
21
  { value: "Single", label: e("filingStatusSingle") },
34
22
  { value: "Married", label: e("filingStatusMarried") },
35
23
  { value: "Head of Household", label: e("filingStatusHeadOfHousehold") },
36
24
  { value: "Exempt from withholding", label: e("filingStatusExemptFromWithholding") }
37
25
  ];
38
- return /* @__PURE__ */ n(a, { children: [
39
- /* @__PURE__ */ t(
40
- s,
26
+ return /* @__PURE__ */ l(a, { children: [
27
+ /* @__PURE__ */ r(
28
+ c,
41
29
  {
42
30
  name: "filingStatus",
43
31
  label: e("federalFilingStatus1c"),
44
32
  placeholder: e("federalFilingStatusPlaceholder"),
45
33
  description: e("selectWithholdingDescription"),
46
- options: d,
34
+ options: n,
47
35
  isRequired: !0,
48
36
  errorMessage: e("validations.federalFilingStatus")
49
37
  }
50
38
  ),
51
- /* @__PURE__ */ t(
52
- g,
39
+ /* @__PURE__ */ r(
40
+ u,
53
41
  {
54
42
  name: "twoJobs",
55
43
  isRequired: !0,
56
44
  label: e("multipleJobs2c"),
57
45
  errorMessage: e("validations.federalTwoJobs"),
58
- description: /* @__PURE__ */ t(
59
- u,
46
+ description: /* @__PURE__ */ r(
47
+ m,
60
48
  {
61
49
  i18nKey: "includesSpouseExplanation",
62
50
  t: e,
63
51
  components: {
64
- IrsLink: /* @__PURE__ */ t(l.Link, {})
52
+ IrsLink: /* @__PURE__ */ r(o.Link, {})
65
53
  }
66
54
  }
67
55
  ),
@@ -71,8 +59,8 @@ function b() {
71
59
  ]
72
60
  }
73
61
  ),
74
- /* @__PURE__ */ t(
75
- r,
62
+ /* @__PURE__ */ r(
63
+ t,
76
64
  {
77
65
  name: "dependentsAmount",
78
66
  isRequired: !0,
@@ -82,8 +70,8 @@ function b() {
82
70
  errorMessage: e("fieldIsRequired")
83
71
  }
84
72
  ),
85
- /* @__PURE__ */ t(
86
- r,
73
+ /* @__PURE__ */ r(
74
+ t,
87
75
  {
88
76
  name: "otherIncome",
89
77
  isRequired: !0,
@@ -93,8 +81,8 @@ function b() {
93
81
  errorMessage: e("fieldIsRequired")
94
82
  }
95
83
  ),
96
- /* @__PURE__ */ t(
97
- r,
84
+ /* @__PURE__ */ r(
85
+ t,
98
86
  {
99
87
  name: "deductions",
100
88
  isRequired: !0,
@@ -104,8 +92,8 @@ function b() {
104
92
  errorMessage: e("fieldIsRequired")
105
93
  }
106
94
  ),
107
- /* @__PURE__ */ t(
108
- r,
95
+ /* @__PURE__ */ r(
96
+ t,
109
97
  {
110
98
  name: "extraWithholding",
111
99
  isRequired: !0,
@@ -117,51 +105,8 @@ function b() {
117
105
  )
118
106
  ] });
119
107
  }
120
- function S() {
121
- const { t: e } = o("Employee.FederalTaxes"), l = [
122
- { value: "Single", label: e("filingStatusSingle") },
123
- { value: "Married", label: e("filingStatusMarried") },
124
- { value: "Head of Household", label: e("filingStatusHeadOfHousehold") },
125
- { value: "Exempt from withholding", label: e("filingStatusExemptFromWithholding") },
126
- { value: "Married, but withhold as Single", label: e("filingStatusMarriedWithholdAsSingle") }
127
- ];
128
- return /* @__PURE__ */ n(a, { children: [
129
- /* @__PURE__ */ t(
130
- r,
131
- {
132
- name: "federalWithholdingAllowance",
133
- isRequired: !0,
134
- label: e("federalWithholdingAllowance"),
135
- min: 0,
136
- maximumFractionDigits: 0,
137
- errorMessage: e("fieldIsRequired")
138
- }
139
- ),
140
- /* @__PURE__ */ t(
141
- s,
142
- {
143
- name: "filingStatus",
144
- label: e("filingStatus"),
145
- placeholder: e("federalFilingStatusPlaceholder"),
146
- description: e("selectWithholdingDescription"),
147
- options: l,
148
- isRequired: !0,
149
- errorMessage: e("validations.federalFilingStatus")
150
- }
151
- ),
152
- /* @__PURE__ */ t(
153
- f,
154
- {
155
- name: "additionalWithholding",
156
- label: e("additionalWithholding"),
157
- type: "number",
158
- errorMessage: e("fieldIsRequired")
159
- }
160
- )
161
- ] });
162
- }
163
108
  export {
164
- A as FederalForm,
165
- H as FederalFormSchema
109
+ M as FederalForm,
110
+ v as FederalFormSchema
166
111
  };
167
112
  //# sourceMappingURL=FederalForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"FederalForm.js","sources":["../../../../src/components/Employee/FederalTaxes/FederalForm.tsx"],"sourcesContent":["import { Trans, useTranslation } from 'react-i18next'\nimport { useFormContext } from 'react-hook-form'\nimport { z } from 'zod'\nimport { SelectField, RadioGroupField, NumberInputField, TextInputField } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nconst Rev2020Schema = z.object({\n w4DataType: z.literal('rev_2020_w4'),\n filingStatus: z.string().min(1),\n twoJobs: z.string().min(1),\n dependentsAmount: z.number().transform(String),\n otherIncome: z.number().transform(String),\n deductions: z.number().transform(String),\n extraWithholding: z.number().transform(String),\n})\n\nconst Pre2020Schema = z.object({\n w4DataType: z.literal('pre_2020_w4'),\n filingStatus: z.string().min(1),\n federalWithholdingAllowance: z.number().int(),\n additionalWithholding: z.string(),\n})\n\nexport const FederalFormSchema = z.discriminatedUnion('w4DataType', [Rev2020Schema, Pre2020Schema])\n\nexport type FederalFormInputs = z.input<typeof FederalFormSchema>\nexport type FederalFormPayload = z.output<typeof FederalFormSchema>\n\nexport function FederalForm() {\n const { watch } = useFormContext<FederalFormInputs>()\n const w4DataType = watch('w4DataType')\n\n if (w4DataType === 'rev_2020_w4') {\n return <Rev2020Form />\n }\n\n return <Pre2020Form />\n}\n\nfunction Rev2020Form() {\n const { t } = useTranslation('Employee.FederalTaxes')\n const Components = useComponentContext()\n\n const filingStatusOptions = [\n { value: 'Single', label: t('filingStatusSingle') },\n { value: 'Married', label: t('filingStatusMarried') },\n { value: 'Head of Household', label: t('filingStatusHeadOfHousehold') },\n { value: 'Exempt from withholding', label: t('filingStatusExemptFromWithholding') },\n ]\n\n return (\n <>\n <SelectField\n name=\"filingStatus\"\n label={t('federalFilingStatus1c')}\n placeholder={t('federalFilingStatusPlaceholder')}\n description={t('selectWithholdingDescription')}\n options={filingStatusOptions}\n isRequired\n errorMessage={t('validations.federalFilingStatus')}\n />\n <RadioGroupField\n name=\"twoJobs\"\n isRequired\n label={t('multipleJobs2c')}\n errorMessage={t('validations.federalTwoJobs')}\n description={\n <Trans\n i18nKey={'includesSpouseExplanation'}\n t={t}\n components={{\n IrsLink: <Components.Link />,\n }}\n />\n }\n options={[\n { value: 'true', label: t('twoJobYesLabel') },\n { value: 'false', label: t('twoJobNoLabel') },\n ]}\n />\n <NumberInputField\n name=\"dependentsAmount\"\n isRequired\n label={t('dependentsTotalIfApplicable')}\n format=\"currency\"\n min={0}\n errorMessage={t('fieldIsRequired')}\n />\n <NumberInputField\n name=\"otherIncome\"\n isRequired\n label={t('otherIncome')}\n format=\"currency\"\n min={0}\n errorMessage={t('fieldIsRequired')}\n />\n <NumberInputField\n name=\"deductions\"\n isRequired\n label={t('deductions')}\n format=\"currency\"\n min={0}\n errorMessage={t('fieldIsRequired')}\n />\n <NumberInputField\n name=\"extraWithholding\"\n isRequired\n label={t('extraWithholding')}\n format=\"currency\"\n min={0}\n errorMessage={t('fieldIsRequired')}\n />\n </>\n )\n}\n\nfunction Pre2020Form() {\n const { t } = useTranslation('Employee.FederalTaxes')\n\n const filingStatusOptions = [\n { value: 'Single', label: t('filingStatusSingle') },\n { value: 'Married', label: t('filingStatusMarried') },\n { value: 'Head of Household', label: t('filingStatusHeadOfHousehold') },\n { value: 'Exempt from withholding', label: t('filingStatusExemptFromWithholding') },\n { value: 'Married, but withhold as Single', label: t('filingStatusMarriedWithholdAsSingle') },\n ]\n\n return (\n <>\n <NumberInputField\n name=\"federalWithholdingAllowance\"\n isRequired\n label={t('federalWithholdingAllowance')}\n min={0}\n maximumFractionDigits={0}\n errorMessage={t('fieldIsRequired')}\n />\n <SelectField\n name=\"filingStatus\"\n label={t('filingStatus')}\n placeholder={t('federalFilingStatusPlaceholder')}\n description={t('selectWithholdingDescription')}\n options={filingStatusOptions}\n isRequired\n errorMessage={t('validations.federalFilingStatus')}\n />\n <TextInputField\n name=\"additionalWithholding\"\n label={t('additionalWithholding')}\n type=\"number\"\n errorMessage={t('fieldIsRequired')}\n />\n </>\n )\n}\n"],"names":["Rev2020Schema","z","Pre2020Schema","FederalFormSchema","FederalForm","watch","useFormContext","Rev2020Form","Pre2020Form","t","useTranslation","Components","useComponentContext","filingStatusOptions","jsxs","Fragment","jsx","SelectField","RadioGroupField","Trans","NumberInputField","TextInputField"],"m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A,IAEnD,gBAAAO;AAAA,MAACK;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,OAAOZ,EAAE,uBAAuB;AAAA,QAChC,MAAK;AAAA,QACL,cAAcA,EAAE,iBAAiB;AAAA,MAAA;AAAA,IAAA;AAAA,EACnC,GACF;AAEJ;"}
1
+ {"version":3,"file":"FederalForm.js","sources":["../../../../src/components/Employee/FederalTaxes/FederalForm.tsx"],"sourcesContent":["import { Trans, useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { SelectField, RadioGroupField, NumberInputField } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nconst Rev2020Schema = z.object({\n filingStatus: z.string().min(1),\n twoJobs: z.string().min(1),\n dependentsAmount: z.number().transform(String),\n otherIncome: z.number().transform(String),\n deductions: z.number().transform(String),\n extraWithholding: z.number().transform(String),\n})\n\nexport const FederalFormSchema = Rev2020Schema\n\nexport type FederalFormInputs = z.input<typeof FederalFormSchema>\nexport type FederalFormPayload = z.output<typeof FederalFormSchema>\n\nexport function FederalForm() {\n const { t } = useTranslation('Employee.FederalTaxes')\n const Components = useComponentContext()\n\n const filingStatusOptions = [\n { value: 'Single', label: t('filingStatusSingle') },\n { value: 'Married', label: t('filingStatusMarried') },\n { value: 'Head of Household', label: t('filingStatusHeadOfHousehold') },\n { value: 'Exempt from withholding', label: t('filingStatusExemptFromWithholding') },\n ]\n\n return (\n <>\n <SelectField\n name=\"filingStatus\"\n label={t('federalFilingStatus1c')}\n placeholder={t('federalFilingStatusPlaceholder')}\n description={t('selectWithholdingDescription')}\n options={filingStatusOptions}\n isRequired\n errorMessage={t('validations.federalFilingStatus')}\n />\n <RadioGroupField\n name=\"twoJobs\"\n isRequired\n label={t('multipleJobs2c')}\n errorMessage={t('validations.federalTwoJobs')}\n description={\n <Trans\n i18nKey={'includesSpouseExplanation'}\n t={t}\n components={{\n IrsLink: <Components.Link />,\n }}\n />\n }\n options={[\n { value: 'true', label: t('twoJobYesLabel') },\n { value: 'false', label: t('twoJobNoLabel') },\n ]}\n />\n <NumberInputField\n name=\"dependentsAmount\"\n isRequired\n label={t('dependentsTotalIfApplicable')}\n format=\"currency\"\n min={0}\n errorMessage={t('fieldIsRequired')}\n />\n <NumberInputField\n name=\"otherIncome\"\n isRequired\n label={t('otherIncome')}\n format=\"currency\"\n min={0}\n errorMessage={t('fieldIsRequired')}\n />\n <NumberInputField\n name=\"deductions\"\n isRequired\n label={t('deductions')}\n format=\"currency\"\n min={0}\n errorMessage={t('fieldIsRequired')}\n />\n <NumberInputField\n name=\"extraWithholding\"\n isRequired\n label={t('extraWithholding')}\n format=\"currency\"\n min={0}\n errorMessage={t('fieldIsRequired')}\n />\n </>\n )\n}\n"],"names":["Rev2020Schema","z","FederalFormSchema","FederalForm","t","useTranslation","Components","useComponentContext","filingStatusOptions","jsxs","Fragment","jsx","SelectField","RadioGroupField","Trans","NumberInputField"],"mappings":";;;;;;;;;;AAKA,MAAMA,IAAgBC,EAAE,OAAO;AAAA,EAC7B,cAAcA,EAAE,SAAS,IAAI,CAAC;AAAA,EAC9B,SAASA,EAAE,SAAS,IAAI,CAAC;AAAA,EACzB,kBAAkBA,EAAE,SAAS,UAAU,MAAM;AAAA,EAC7C,aAAaA,EAAE,SAAS,UAAU,MAAM;AAAA,EACxC,YAAYA,EAAE,SAAS,UAAU,MAAM;AAAA,EACvC,kBAAkBA,EAAE,OAAA,EAAS,UAAU,MAAM;AAC/C,CAAC,GAEYC,IAAoBF;AAK1B,SAASG,IAAc;AAC5B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,uBAAuB,GAC9CC,IAAaC,EAAA,GAEbC,IAAsB;AAAA,IAC1B,EAAE,OAAO,UAAU,OAAOJ,EAAE,oBAAoB,EAAA;AAAA,IAChD,EAAE,OAAO,WAAW,OAAOA,EAAE,qBAAqB,EAAA;AAAA,IAClD,EAAE,OAAO,qBAAqB,OAAOA,EAAE,6BAA6B,EAAA;AAAA,IACpE,EAAE,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EAAE,iBAAiB;AAAA,MAAA;AAAA,IAAA;AAAA,IAEnC,gBAAAO;AAAA,MAACI;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,YAAU;AAAA,QACV,OAAOX,EAAE,YAAY;AAAA,QACrB,QAAO;AAAA,QACP,KAAK;AAAA,QACL,cAAcA,EAAE,iBAAiB;AAAA,MAAA;AAAA,IAAA;AAAA,IAEnC,gBAAAO;AAAA,MAACI;AAAA,MAAA;AAAA,QACC,MAAK;AAAA,QACL,YAAU;AAAA,QACV,OAAOX,EAAE,kBAAkB;AAAA,QAC3B,QAAO;AAAA,QACP,KAAK;AAAA,QACL,cAAcA,EAAE,iBAAiB;AAAA,MAAA;AAAA,IAAA;AAAA,EACnC,GACF;AAEJ;"}
@@ -1,29 +1,28 @@
1
- import { jsx as o, jsxs as S, Fragment as v } from "react/jsx-runtime";
2
- import { zodResolver as y } from "@hookform/resolvers/zod";
3
- import { useForm as A, FormProvider as D } from "react-hook-form";
1
+ import { jsx as o, jsxs as S, Fragment as g } from "react/jsx-runtime";
2
+ import { zodResolver as v } from "@hookform/resolvers/zod";
3
+ import { useForm as A, FormProvider as w } from "react-hook-form";
4
4
  import { useEffect as _ } from "react";
5
- import { useEmployeeTaxSetupGetFederalTaxesSuspense as b } from "@gusto/embedded-api/react-query/employeeTaxSetupGetFederalTaxes";
6
- import { useEmployeeTaxSetupUpdateFederalTaxesMutation as W } from "@gusto/embedded-api/react-query/employeeTaxSetupUpdateFederalTaxes";
5
+ import { useEmployeeTaxSetupGetFederalTaxesSuspense as N } from "@gusto/embedded-api/react-query/employeeTaxSetupGetFederalTaxes";
6
+ import { useEmployeeTaxSetupUpdateFederalTaxesMutation as D } from "@gusto/embedded-api/react-query/employeeTaxSetupUpdateFederalTaxes";
7
7
  import { FederalFormSchema as I, FederalForm as R } from "./FederalForm.js";
8
- import { Head as N } from "./Head.js";
9
- import { Actions as P } from "./Actions.js";
8
+ import { Head as P } from "./Head.js";
9
+ import { Actions as W } from "./Actions.js";
10
10
  import { FederalTaxesProvider as J } from "./useFederalTaxes.js";
11
11
  import { BaseComponent as L } from "../../Base/Base.js";
12
12
  import { useBase as M } from "../../Base/useBase.js";
13
13
  import { useI18n as U, useComponentDictionary as B } from "../../../i18n/I18n.js";
14
14
  import { normalizeErrorKeyForForm as q } from "../../../helpers/formattedStrings.js";
15
- import { componentEvents as u } from "../../../shared/constants.js";
15
+ import { componentEvents as l } from "../../../shared/constants.js";
16
16
  import { Form as z } from "../../Common/Form/Form.js";
17
- function se(r) {
17
+ function me(r) {
18
18
  return /* @__PURE__ */ o(L, { ...r, children: /* @__PURE__ */ o(C, { ...r }) });
19
19
  }
20
20
  const C = (r) => {
21
- const { employeeId: s, className: c, children: a, dictionary: h } = r, { onEvent: m, fieldErrors: n, baseSubmitHandler: f } = M();
22
- U("Employee.FederalTaxes"), B("Employee.FederalTaxes", h);
23
- const { data: p } = b({
24
- employeeUuid: s
25
- }), e = p.employeeFederalTax, { mutateAsync: E, isPending: g } = W(), T = e.w4DataType === "rev_2020_w4" ? {
26
- w4DataType: "rev_2020_w4",
21
+ const { employeeId: m, className: c, children: i, dictionary: p } = r, { onEvent: a, fieldErrors: n, baseSubmitHandler: f } = M();
22
+ U("Employee.FederalTaxes"), B("Employee.FederalTaxes", p);
23
+ const { data: h } = N({
24
+ employeeUuid: m
25
+ }), e = h.employeeFederalTax, { mutateAsync: E, isPending: x } = D(), F = e.w4DataType === "rev_2020_w4" ? {
27
26
  filingStatus: e.filingStatus ?? "",
28
27
  twoJobs: e.twoJobs ? "true" : "false",
29
28
  deductions: e.deductions ? Number(e.deductions) : 0,
@@ -31,59 +30,55 @@ const C = (r) => {
31
30
  otherIncome: e.otherIncome ? Number(e.otherIncome) : 0,
32
31
  extraWithholding: e.extraWithholding ? Number(e.extraWithholding) : 0
33
32
  } : {
34
- w4DataType: "pre_2020_w4",
35
- filingStatus: e.filingStatus ?? "",
36
- federalWithholdingAllowance: e.federalWithholdingAllowance ?? 0,
37
- additionalWithholding: e.additionalWithholding
33
+ filingStatus: "",
34
+ twoJobs: "false",
35
+ deductions: 0,
36
+ dependentsAmount: 0,
37
+ otherIncome: 0,
38
+ extraWithholding: 0
38
39
  }, d = A({
39
- resolver: y(I),
40
- defaultValues: T
41
- }), { handleSubmit: w, setError: l } = d;
40
+ resolver: v(I),
41
+ defaultValues: F
42
+ }), { handleSubmit: b, setError: u } = d;
42
43
  return _(() => {
43
- n && n.length > 0 && n.forEach((i) => {
44
- const t = q(i.errorKey);
45
- l(t, { type: "custom", message: i.message });
44
+ n && n.length > 0 && n.forEach((s) => {
45
+ const t = q(s.errorKey);
46
+ u(t, { type: "custom", message: s.message });
46
47
  });
47
- }, [n, l]), /* @__PURE__ */ o("section", { className: c, children: /* @__PURE__ */ o(
48
+ }, [n, u]), /* @__PURE__ */ o("section", { className: c, children: /* @__PURE__ */ o(
48
49
  J,
49
50
  {
50
51
  value: {
51
- isPending: g
52
+ isPending: x
52
53
  },
53
- children: /* @__PURE__ */ o(D, { ...d, children: /* @__PURE__ */ o(z, { onSubmit: w(async (i) => {
54
- await f(i, async (t) => {
55
- const F = t.w4DataType === "rev_2020_w4" ? {
54
+ children: /* @__PURE__ */ o(w, { ...d, children: /* @__PURE__ */ o(z, { onSubmit: b(async (s) => {
55
+ await f(s, async (t) => {
56
+ const T = {
56
57
  filingStatus: t.filingStatus,
57
58
  twoJobs: t.twoJobs === "true",
58
- dependentsAmount: t.dependentsAmount,
59
- otherIncome: t.otherIncome,
60
- deductions: t.deductions,
61
- extraWithholding: t.extraWithholding,
62
- w4DataType: t.w4DataType,
63
- version: e.version
64
- } : {
65
- filingStatus: t.filingStatus,
66
- federalWithholdingAllowance: t.federalWithholdingAllowance,
67
- additionalWithholding: t.additionalWithholding,
68
- w4DataType: t.w4DataType,
59
+ dependentsAmount: Number(t.dependentsAmount),
60
+ otherIncome: Number(t.otherIncome),
61
+ deductions: Number(t.deductions),
62
+ extraWithholding: Number(t.extraWithholding),
63
+ w4DataType: "rev_2020_w4",
69
64
  version: e.version
70
- }, x = await E({
65
+ }, y = await E({
71
66
  request: {
72
- employeeUuid: s,
73
- requestBody: F
67
+ employeeUuid: m,
68
+ requestBody: T
74
69
  }
75
70
  });
76
- m(u.EMPLOYEE_FEDERAL_TAXES_UPDATED, x), m(u.EMPLOYEE_FEDERAL_TAXES_DONE);
71
+ a(l.EMPLOYEE_FEDERAL_TAXES_UPDATED, y), a(l.EMPLOYEE_FEDERAL_TAXES_DONE);
77
72
  });
78
- }), children: a || /* @__PURE__ */ S(v, { children: [
79
- /* @__PURE__ */ o(N, {}),
73
+ }), children: i || /* @__PURE__ */ S(g, { children: [
74
+ /* @__PURE__ */ o(P, {}),
80
75
  /* @__PURE__ */ o(R, {}),
81
- /* @__PURE__ */ o(P, {})
76
+ /* @__PURE__ */ o(W, {})
82
77
  ] }) }) })
83
78
  }
84
79
  ) });
85
80
  };
86
81
  export {
87
- se as FederalTaxes
82
+ me as FederalTaxes
88
83
  };
89
84
  //# sourceMappingURL=FederalTaxes.js.map