@gusto/embedded-react-sdk 0.56.6 → 0.56.7-rc.1

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 (89) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -4
  3. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  4. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -4
  5. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  6. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -6
  7. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  8. package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
  9. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  10. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -4
  11. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  12. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +5 -6
  13. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  14. package/dist/components/Company/Industry/Context.js +6 -7
  15. package/dist/components/Company/Industry/Context.js.map +1 -1
  16. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -4
  17. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  18. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -4
  19. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  20. package/dist/components/Company/OnboardingOverview/context.js +3 -4
  21. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  22. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js +70 -0
  23. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js.map +1 -0
  24. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js +30 -32
  25. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js.map +1 -1
  26. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js +35 -27
  27. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js.map +1 -1
  28. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js +52 -31
  29. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js.map +1 -1
  30. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js +106 -66
  31. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js.map +1 -1
  32. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js +36 -30
  33. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js.map +1 -1
  34. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.js +7 -0
  35. package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.js.map +1 -0
  36. package/dist/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.js +81 -0
  37. package/dist/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.js.map +1 -0
  38. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js +46 -18
  39. package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js.map +1 -1
  40. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -4
  41. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  42. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -4
  43. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  44. package/dist/components/Company/StateTaxes/TaxRateManagement/context.js +3 -4
  45. package/dist/components/Company/StateTaxes/TaxRateManagement/context.js.map +1 -1
  46. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -4
  47. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  48. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/employeeDetailsSchema.js +13 -13
  49. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/employeeDetailsSchema.js.map +1 -1
  50. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +2 -3
  51. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
  52. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +49 -48
  53. package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
  54. package/dist/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.js +49 -47
  55. package/dist/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.js.map +1 -1
  56. package/dist/components/Payroll/usePreparedPayrollData.js +2 -3
  57. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  58. package/dist/contexts/ApiProvider/ApiProvider.js +13 -12
  59. package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
  60. package/dist/contexts/ApiProvider/createSdkQueryClient.js +4 -3
  61. package/dist/contexts/ApiProvider/createSdkQueryClient.js.map +1 -1
  62. package/dist/contexts/ApiProvider/payrollDeductionAmountHook.js +36 -0
  63. package/dist/contexts/ApiProvider/payrollDeductionAmountHook.js.map +1 -0
  64. package/dist/helpers/validations.js +1 -1
  65. package/dist/helpers/validations.js.map +1 -1
  66. package/dist/i18n/en/Company.AssignSignatory.json.js +1 -1
  67. package/dist/i18n/en/Company.Management.PaySchedule.json.js +24 -14
  68. package/dist/i18n/en/Company.Management.PaySchedule.json.js.map +1 -1
  69. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js +12 -10
  70. package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js.map +1 -1
  71. package/dist/package.json.js +1 -1
  72. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.d.ts +15 -0
  73. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.d.ts +3 -3
  74. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.d.ts +7 -3
  75. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.d.ts +20 -4
  76. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.d.ts +3 -0
  77. package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/usePayScheduleAssignment.d.ts +10 -1
  78. package/dist/src/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.d.ts +25 -0
  79. package/dist/src/components/Employee/Profile/shared/useEmployeeDetailsForm/employeeDetailsSchema.test.d.ts +1 -0
  80. package/dist/src/components/Payroll/PayrollList/__fixtures__/payrollListMocks.d.ts +67 -0
  81. package/dist/src/contexts/ApiProvider/createSdkQueryClient.d.ts +2 -0
  82. package/dist/src/contexts/ApiProvider/createSdkQueryClient.test.d.ts +1 -0
  83. package/dist/src/contexts/ApiProvider/payrollDeductionAmountHook.d.ts +12 -0
  84. package/dist/src/contexts/ApiProvider/payrollDeductionAmountHook.test.d.ts +1 -0
  85. package/dist/src/helpers/validations.test.d.ts +1 -0
  86. package/dist/src/i18n/types.d.ts +38 -2
  87. package/dist/src/models/external.d.ts +7 -6
  88. package/docs/guides/endpoint-inventory.json +15 -0
  89. package/package.json +14 -14
@@ -1 +1 @@
1
- {"version":3,"file":"GrossUpModal.js","sources":["../../../../src/components/Payroll/GrossUpModal/GrossUpModal.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { GrossUpModalProps } from './GrossUpModalTypes'\nimport styles from './GrossUpModal.module.scss'\nimport { ActionsLayout, Flex, NumberInputField } from '@/components/Common'\nimport { useBase } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { formatNumberAsCurrency } from '@/helpers/formattedStrings'\n\nconst GrossUpFormSchema = z.object({\n netPay: z.number().positive(),\n})\n\ntype GrossUpFormValues = z.infer<typeof GrossUpFormSchema>\n\n/** @internal */\nexport function GrossUpModal({ isOpen, onCalculateGrossUp, onApply, onCancel }: GrossUpModalProps) {\n useI18n('Payroll.GrossUpModal')\n const { t } = useTranslation('Payroll.GrossUpModal')\n const { Modal, Heading, Text, Button, Alert } = useComponentContext()\n const { baseSubmitHandler } = useBase()\n const modalContainerRef = useRef<HTMLDivElement>(null)\n\n const [calculatedGrossUp, setCalculatedGrossUp] = useState<string | null>(null)\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n const [isCalculating, setIsCalculating] = useState(false)\n const [isApplying, setIsApplying] = useState(false)\n\n const formHandlers = useForm<GrossUpFormValues>({\n resolver: zodResolver(GrossUpFormSchema),\n // Start blank rather than 0: 0 is not a valid net amount, and a leading 0\n // in the field means typing an amount produces values like \"0350\".\n defaultValues: {},\n })\n\n useEffect(() => {\n if (!isOpen) {\n formHandlers.reset()\n setCalculatedGrossUp(null)\n setErrorMessage(null)\n }\n }, [isOpen, formHandlers.reset])\n\n const handleCalculate = async (data: GrossUpFormValues) => {\n setErrorMessage(null)\n setCalculatedGrossUp(null)\n setIsCalculating(true)\n\n await baseSubmitHandler(null, async () => {\n try {\n const result = await onCalculateGrossUp(data.netPay)\n\n if (result) {\n setCalculatedGrossUp(result)\n } else {\n setErrorMessage(t('errorMessage'))\n }\n } finally {\n setIsCalculating(false)\n }\n })\n }\n\n const handleApply = async () => {\n if (calculatedGrossUp) {\n setIsApplying(true)\n await baseSubmitHandler(null, async () => {\n try {\n await onApply(calculatedGrossUp)\n } finally {\n setIsApplying(false)\n }\n })\n }\n }\n\n return (\n <Modal\n isOpen={isOpen}\n onClose={onCancel}\n containerRef={modalContainerRef}\n footer={\n <ActionsLayout>\n <Button\n variant=\"primary\"\n isDisabled={!calculatedGrossUp}\n onClick={handleApply}\n isLoading={isApplying}\n >\n {t('applyCta')}\n </Button>\n <Button variant=\"secondary\" onClick={onCancel}>\n {t('cancelCta')}\n </Button>\n </ActionsLayout>\n }\n >\n <FormProvider {...formHandlers}>\n <div className={styles.header}>\n <Heading as=\"h2\" styledAs=\"h3\">\n {t('title')}\n </Heading>\n <Text variant=\"supporting\" as=\"p\">\n {t('description')}\n </Text>\n </div>\n\n <div className={styles.content}>\n {errorMessage && (\n <div className={styles.alert}>\n <Alert label={errorMessage} status=\"error\" disableScrollIntoView />\n </div>\n )}\n\n <div className={styles.alert}>\n <Alert label={t('warning')} status=\"warning\" disableScrollIntoView />\n </div>\n\n {/* Bottom-align on the row itself: the .calculateButton align-self\n rule below only targets the default (react-aria) adapter, so in\n other adapters the button otherwise falls back to flex-start. */}\n <Flex flexDirection=\"row\" gap={8} alignItems=\"flex-end\">\n <NumberInputField\n name=\"netPay\"\n label={t('netPayLabel')}\n format=\"currency\"\n adornmentStart=\"$\"\n errorMessage={t('validations.netPay')}\n min={0}\n isRequired\n />\n <Button\n variant=\"secondary\"\n className={styles.calculateButton}\n isLoading={isCalculating}\n onClick={formHandlers.handleSubmit(handleCalculate)}\n >\n {t('calculateCta')}\n </Button>\n </Flex>\n\n {calculatedGrossUp ? (\n <div className={styles.result}>\n <Text size=\"sm\" variant=\"supporting\" weight=\"semibold\">\n {t('grossPayResult')}\n </Text>\n <Heading as=\"h3\">{formatNumberAsCurrency(parseFloat(calculatedGrossUp))}</Heading>\n </div>\n ) : (\n <Text size=\"sm\" variant=\"supporting\">\n {t('applyHint')}\n </Text>\n )}\n </div>\n </FormProvider>\n </Modal>\n )\n}\n"],"names":["GrossUpFormSchema","z","GrossUpModal","isOpen","onCalculateGrossUp","onApply","onCancel","useI18n","t","useTranslation","Modal","Heading","Text","Button","Alert","useComponentContext","baseSubmitHandler","useBase","modalContainerRef","useRef","calculatedGrossUp","setCalculatedGrossUp","useState","errorMessage","setErrorMessage","isCalculating","setIsCalculating","isApplying","setIsApplying","formHandlers","useForm","zodResolver","useEffect","handleCalculate","data","result","jsx","ActionsLayout","jsxs","FormProvider","styles","Flex","NumberInputField"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAMA,IAAoBC,EAAE,OAAO;AAAA,EACjC,QAAQA,EAAE,OAAA,EAAS,SAAA;AACrB,CAAC;AAKM,SAASC,GAAa,EAAE,QAAAC,GAAQ,oBAAAC,GAAoB,SAAAC,GAAS,UAAAC,KAA+B;AACjG,EAAAC,EAAQ,sBAAsB;AAC9B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,sBAAsB,GAC7C,EAAE,OAAAC,GAAO,SAAAC,GAAS,MAAAC,GAAM,QAAAC,GAAQ,OAAAC,EAAA,IAAUC,EAAA,GAC1C,EAAE,mBAAAC,EAAA,IAAsBC,EAAA,GACxBC,IAAoBC,EAAuB,IAAI,GAE/C,CAACC,GAAmBC,CAAoB,IAAIC,EAAwB,IAAI,GACxE,CAACC,GAAcC,CAAe,IAAIF,EAAwB,IAAI,GAC9D,CAACG,GAAeC,CAAgB,IAAIJ,EAAS,EAAK,GAClD,CAACK,GAAYC,CAAa,IAAIN,EAAS,EAAK,GAE5CO,IAAeC,EAA2B;AAAA,IAC9C,UAAUC,EAAY/B,CAAiB;AAAA;AAAA;AAAA,IAGvC,eAAe,CAAA;AAAA,EAAC,CACjB;AAED,EAAAgC,EAAU,MAAM;AACd,IAAK7B,MACH0B,EAAa,MAAA,GACbR,EAAqB,IAAI,GACzBG,EAAgB,IAAI;AAAA,EAExB,GAAG,CAACrB,GAAQ0B,EAAa,KAAK,CAAC;AAE/B,QAAMI,IAAkB,OAAOC,MAA4B;AACzD,IAAAV,EAAgB,IAAI,GACpBH,EAAqB,IAA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AAA,QAAA,EAAA,CAEJ;AAAA,MAAA,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
1
+ {"version":3,"file":"GrossUpModal.js","sources":["../../../../src/components/Payroll/GrossUpModal/GrossUpModal.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from 'react'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { GrossUpModalProps } from './GrossUpModalTypes'\nimport styles from './GrossUpModal.module.scss'\nimport { ActionsLayout, Flex, NumberInputField } from '@/components/Common'\nimport { useBase } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useI18n } from '@/i18n'\nimport { formatNumberAsCurrency } from '@/helpers/formattedStrings'\n\nconst GrossUpFormSchema = z.object({\n netPay: z.number().positive(),\n})\n\ntype GrossUpFormValues = z.infer<typeof GrossUpFormSchema>\n\n/** @internal */\nexport function GrossUpModal({ isOpen, onCalculateGrossUp, onApply, onCancel }: GrossUpModalProps) {\n useI18n('Payroll.GrossUpModal')\n const { t } = useTranslation('Payroll.GrossUpModal')\n const { Modal, Heading, Text, Button, Alert } = useComponentContext()\n const { baseSubmitHandler } = useBase()\n const modalContainerRef = useRef<HTMLDivElement>(null)\n\n const [calculatedGrossUp, setCalculatedGrossUp] = useState<string | null>(null)\n const [errorMessage, setErrorMessage] = useState<string | null>(null)\n const [isCalculating, setIsCalculating] = useState(false)\n const [isApplying, setIsApplying] = useState(false)\n\n const formHandlers = useForm<GrossUpFormValues>({\n resolver: zodResolver(GrossUpFormSchema),\n // Start blank rather than 0: 0 is not a valid net amount, and a leading 0\n // in the field means typing an amount produces values like \"0350\".\n defaultValues: {},\n })\n\n useEffect(() => {\n if (!isOpen) {\n formHandlers.reset()\n setCalculatedGrossUp(null)\n setErrorMessage(null)\n }\n }, [isOpen, formHandlers.reset])\n\n const handleCalculate = async (data: GrossUpFormValues) => {\n setErrorMessage(null)\n setCalculatedGrossUp(null)\n setIsCalculating(true)\n\n await baseSubmitHandler(null, async () => {\n try {\n const result = await onCalculateGrossUp(data.netPay)\n\n if (result) {\n setCalculatedGrossUp(result)\n } else {\n setErrorMessage(t('errorMessage'))\n }\n } finally {\n setIsCalculating(false)\n }\n })\n }\n\n const handleApply = async () => {\n if (calculatedGrossUp) {\n setIsApplying(true)\n await baseSubmitHandler(null, async () => {\n try {\n await onApply(calculatedGrossUp)\n } finally {\n setIsApplying(false)\n }\n })\n }\n }\n\n return (\n <Modal\n isOpen={isOpen}\n onClose={onCancel}\n containerRef={modalContainerRef}\n footer={\n <ActionsLayout>\n <Button\n variant=\"primary\"\n isDisabled={!calculatedGrossUp}\n onClick={handleApply}\n isLoading={isApplying}\n >\n {t('applyCta')}\n </Button>\n <Button variant=\"secondary\" onClick={onCancel}>\n {t('cancelCta')}\n </Button>\n </ActionsLayout>\n }\n >\n <FormProvider {...formHandlers}>\n <div className={styles.header}>\n <Heading as=\"h2\" styledAs=\"h3\">\n {t('title')}\n </Heading>\n <Text variant=\"supporting\" as=\"p\">\n {t('description')}\n </Text>\n </div>\n\n <div className={styles.content}>\n {errorMessage && (\n <div className={styles.alert}>\n <Alert label={errorMessage} status=\"error\" disableScrollIntoView />\n </div>\n )}\n\n <div className={styles.alert}>\n <Alert label={t('warning')} status=\"warning\" disableScrollIntoView />\n </div>\n\n {/* Bottom-align on the row itself: the .calculateButton align-self\n rule below only targets the default (react-aria) adapter, so in\n other adapters the button otherwise falls back to flex-start. */}\n <Flex flexDirection=\"row\" gap={8} alignItems=\"flex-end\">\n <NumberInputField\n name=\"netPay\"\n label={t('netPayLabel')}\n format=\"currency\"\n adornmentStart=\"$\"\n errorMessage={t('validations.netPay')}\n min={0}\n isRequired\n />\n <Button\n variant=\"secondary\"\n className={styles.calculateButton}\n isLoading={isCalculating}\n onClick={formHandlers.handleSubmit(handleCalculate)}\n >\n {t('calculateCta')}\n </Button>\n </Flex>\n\n {calculatedGrossUp ? (\n <div className={styles.result}>\n <Text size=\"sm\" variant=\"supporting\" weight=\"semibold\">\n {t('grossPayResult')}\n </Text>\n <Heading as=\"h3\">{formatNumberAsCurrency(parseFloat(calculatedGrossUp))}</Heading>\n </div>\n ) : (\n <Text size=\"sm\" variant=\"supporting\">\n {t('applyHint')}\n </Text>\n )}\n </div>\n </FormProvider>\n </Modal>\n )\n}\n"],"names":["GrossUpFormSchema","z","GrossUpModal","isOpen","onCalculateGrossUp","onApply","onCancel","useI18n","t","useTranslation","Modal","Heading","Text","Button","Alert","useComponentContext","baseSubmitHandler","useBase","modalContainerRef","useRef","calculatedGrossUp","setCalculatedGrossUp","useState","errorMessage","setErrorMessage","isCalculating","setIsCalculating","isApplying","setIsApplying","formHandlers","useForm","zodResolver","useEffect","handleCalculate","data","result","jsx","ActionsLayout","jsxs","FormProvider","styles","Flex","NumberInputField"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAaA,MAAMA,IAAoBC,EAAE,OAAO;AAAA,EACjC,QAAQA,EAAE,OAAA,EAAS,SAAA;AACrB,CAAC;AAKM,SAASC,GAAa,EAAE,QAAAC,GAAQ,oBAAAC,GAAoB,SAAAC,GAAS,UAAAC,KAA+B;AACjG,EAAAC,EAAQ,sBAAsB;AAC9B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,sBAAsB,GAC7C,EAAE,OAAAC,GAAO,SAAAC,GAAS,MAAAC,GAAM,QAAAC,GAAQ,OAAAC,EAAA,IAAUC,EAAA,GAC1C,EAAE,mBAAAC,EAAA,IAAsBC,EAAA,GACxBC,IAAoBC,EAAuB,IAAI,GAE/C,CAACC,GAAmBC,CAAoB,IAAIC,EAAwB,IAAI,GACxE,CAACC,GAAcC,CAAe,IAAIF,EAAwB,IAAI,GAC9D,CAACG,GAAeC,CAAgB,IAAIJ,EAAS,EAAK,GAClD,CAACK,GAAYC,CAAa,IAAIN,EAAS,EAAK,GAE5CO,IAAeC,EAA2B;AAAA,IAC9C,UAAU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;AAAA,YAAA,gBAAAJ,EAACxB,GAAA,EAAK,MAAK,MAAK,SAAQ,cAAa,QAAO,YACzC,UAAAJ,EAAE,gBAAgB,EAAA,CACrB;AAAA,YACA,gBAAA4B,EAACzB,KAAQ,IAAG,MAAM,YAAuB,WAAWS,CAAiB,CAAC,EAAA,CAAE;AAAA,UAAA,EAAA,CAC1E,sBAECR,GAAA,EAAK,MAAK,MAAK,SAAQ,cACrB,UAAAJ,EAAE,WAAW,EAAA,CAChB;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
@@ -1,50 +1,50 @@
1
- import { useState as R, useRef as q, useMemo as y, useEffect as P, useCallback as L } from "react";
1
+ import { useState as q, useRef as L, useMemo as y, useEffect as P, useCallback as F } from "react";
2
2
  import { useEmployeesList as te } from "@gusto/embedded-api/react-query/employeesList";
3
- import { useQueryClient as se, keepPreviousData as F, useQuery as K } from "@tanstack/react-query";
4
- import { usePaySchedulesGet as oe } from "@gusto/embedded-api/react-query/paySchedulesGet";
3
+ import { useQueryClient as oe, keepPreviousData as K, useQuery as _ } from "@tanstack/react-query";
4
+ import { usePaySchedulesGet as se } from "@gusto/embedded-api/react-query/paySchedulesGet";
5
5
  import { useGustoEmbeddedContext as re } from "@gusto/embedded-api/react-query/_context";
6
6
  import { payrollsPrepare as ae } from "@gusto/embedded-api/funcs/payrollsPrepare";
7
7
  import { employeesGet as ne } from "@gusto/embedded-api/funcs/employeesGet";
8
8
  import { UnprocessableEntityError as ie } from "@gusto/embedded-api/models/errors/unprocessableentityerror";
9
9
  import { derivePayrollCategory as le } from "../payrollTypes.js";
10
10
  import { usePagination as ue } from "../../../hooks/usePagination/usePagination.js";
11
- const f = "payroll-prepare", _ = 300 * 1e3, ce = 3, A = (n) => n instanceof ie ? n.errors.some((s) => s.category === "invalid_operation") : !1;
12
- function we({
11
+ const f = "payroll-prepare", A = 300 * 1e3, ce = 3, S = (n) => n instanceof ie ? n.errors.some((o) => o.category === "invalid_operation") : !1;
12
+ function De({
13
13
  companyId: n,
14
- payrollId: s,
14
+ payrollId: o,
15
15
  disablePrepare: d = !1,
16
- excludedEmployeeUuids: S = [],
16
+ excludedEmployeeUuids: w = [],
17
17
  isTransitionPayroll: Q = !1
18
18
  }) {
19
- const D = re(), i = se(), { currentPage: c, itemsPerPage: T, getPaginationProps: k } = ue({
19
+ const D = re(), i = oe(), { currentPage: c, itemsPerPage: T, getPaginationProps: k } = ue({
20
20
  defaultItemsPerPage: 25
21
- }), [x, M] = R([]), [b, h] = R(!1), g = q(!1), { data: l, isFetching: w } = te(
21
+ }), [x, M] = q([]), [b, h] = q(!1), g = L(!1), { data: l, isFetching: U } = te(
22
22
  {
23
23
  companyId: n,
24
- payrollUuid: s,
24
+ payrollUuid: o,
25
25
  per: T,
26
26
  page: c,
27
27
  sortBy: "name"
28
28
  },
29
- { placeholderData: F }
30
- ), U = q(l);
31
- U.current = l;
29
+ { placeholderData: K, throwOnError: !0 }
30
+ ), C = L(l);
31
+ C.current = l;
32
32
  const p = y(() => l?.showEmployees?.map((e) => e.uuid) || [], [l?.showEmployees]), u = y(() => {
33
33
  const e = new Set(p);
34
- return S.filter((t) => !e.has(t));
35
- }, [S, p]), m = y(() => c === 1 ? [...p, ...u] : p, [p, u, c]), B = y(() => m.join(","), [m]), {
34
+ return w.filter((t) => !e.has(t));
35
+ }, [w, p]), m = y(() => c === 1 ? [...p, ...u] : p, [p, u, c]), B = y(() => m.join(","), [m]), {
36
36
  data: r,
37
37
  error: G,
38
38
  isLoading: j,
39
39
  isFetching: I
40
- } = K({
41
- queryKey: [f, s, B],
40
+ } = _({
41
+ queryKey: [f, o, B],
42
42
  queryFn: async ({ signal: e }) => {
43
43
  const t = await ae(
44
44
  D,
45
45
  {
46
46
  companyId: n,
47
- payrollId: s,
47
+ payrollId: o,
48
48
  sortBy: "last_name",
49
49
  requestBody: {
50
50
  employeeUuids: Q ? void 0 : m
@@ -57,55 +57,56 @@ function we({
57
57
  return t.value.payrollPrepared;
58
58
  },
59
59
  enabled: m.length > 0 && !d,
60
- staleTime: _,
61
- placeholderData: F,
60
+ staleTime: A,
61
+ placeholderData: K,
62
+ throwOnError: (e) => !S(e),
62
63
  // An "already processed" prepare failure is terminal — retrying it wastes time. Other
63
64
  // errors (network blips, etc.) still get the standard retry treatment.
64
- retry: (e, t) => !A(t) && e < ce
65
- }), Y = A(G);
65
+ retry: (e, t) => !S(t) && e < ce
66
+ }), O = S(G);
66
67
  P(() => () => {
67
68
  i.cancelQueries({
68
- queryKey: [f, s]
69
+ queryKey: [f, o]
69
70
  });
70
- }, [i, s]), P(() => {
71
+ }, [i, o]), P(() => {
71
72
  d && i.cancelQueries({
72
- queryKey: [f, s]
73
+ queryKey: [f, o]
73
74
  });
74
- }, [d, i, s]);
75
- const H = y(() => u.join(","), [u]), { data: E } = K({
76
- queryKey: ["excluded-employee-details", H],
75
+ }, [d, i, o]);
76
+ const Y = y(() => u.join(","), [u]), { data: E } = _({
77
+ queryKey: ["excluded-employee-details", Y],
77
78
  queryFn: async () => {
78
79
  const e = await Promise.all(
79
- u.map((o) => ne(D, { employeeId: o }))
80
- ), t = e.find((o) => !o.ok);
80
+ u.map((s) => ne(D, { employeeId: s }))
81
+ ), t = e.find((s) => !s.ok);
81
82
  if (t)
82
83
  throw t.error;
83
- return e.filter((o) => o.ok).map((o) => o.value.employee).filter((o) => o != null);
84
+ return e.filter((s) => s.ok).map((s) => s.value.employee).filter((s) => s != null);
84
85
  },
85
86
  enabled: u.length > 0 && !d,
86
- staleTime: _
87
- }), C = L(() => {
88
- const e = U.current;
87
+ staleTime: A
88
+ }), v = F(() => {
89
+ const e = C.current;
89
90
  if (!e?.showEmployees || !r?.employeeCompensations) {
90
91
  h(!1);
91
92
  return;
92
93
  }
93
- const t = e.showEmployees.map((a) => a.uuid), o = new Set(r.employeeCompensations.map((a) => a.employeeUuid));
94
- if (t.length > 0 && t.every((a) => o.has(a))) {
94
+ const t = e.showEmployees.map((a) => a.uuid), s = new Set(r.employeeCompensations.map((a) => a.employeeUuid));
95
+ if (t.length > 0 && t.every((a) => s.has(a))) {
95
96
  const a = [...e.showEmployees];
96
97
  if (c === 1 && E?.length) {
97
98
  const ee = new Set(t);
98
- for (const v of E)
99
- ee.has(v.uuid) || a.push(v);
99
+ for (const R of E)
100
+ ee.has(R.uuid) || a.push(R);
100
101
  }
101
102
  M(a), h(!0), g.current = !0;
102
103
  } else
103
104
  h(!1);
104
105
  }, [r?.employeeCompensations, E, c]);
105
106
  P(() => {
106
- C();
107
- }, [C]);
108
- const { data: N, isLoading: V } = oe(
107
+ v();
108
+ }, [v]);
109
+ const { data: H, isLoading: N } = se(
109
110
  {
110
111
  companyId: n,
111
112
  payScheduleId: r?.payPeriod?.payScheduleUuid || ""
@@ -113,25 +114,25 @@ function we({
113
114
  {
114
115
  enabled: !!r?.payPeriod?.payScheduleUuid
115
116
  }
116
- ), X = L(async () => {
117
+ ), V = F(async () => {
117
118
  await i.invalidateQueries({
118
- queryKey: [f, s]
119
+ queryKey: [f, o]
119
120
  });
120
- }, [i, s]), z = j && !g.current, J = I && g.current, O = w || J || !b, W = z || V || !l && w, Z = l?.httpMeta.response.headers ?? new Headers(), $ = k(Z, O);
121
+ }, [i, o]), X = j && !g.current, z = I && g.current, J = U || z || !b, W = X || N || !l && U, Z = l?.httpMeta.response.headers ?? new Headers(), $ = k(Z, J);
121
122
  return {
122
123
  employeeCompensations: r?.employeeCompensations ?? [],
123
124
  employeeDetails: x,
124
125
  payPeriod: r?.payPeriod,
125
- paySchedule: N?.payScheduleShow,
126
+ paySchedule: H?.payScheduleShow,
126
127
  payrollCategory: le(r ?? {}),
127
128
  pagination: $,
128
129
  isLoading: W,
129
- isAlreadyProcessed: Y,
130
- refetch: X
130
+ isAlreadyProcessed: O,
131
+ refetch: V
131
132
  };
132
133
  }
133
134
  export {
134
135
  f as PREPARE_QUERY_KEY,
135
- we as usePayrollConfigurationData
136
+ De as usePayrollConfigurationData
136
137
  };
137
138
  //# sourceMappingURL=usePayrollConfigurationData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePayrollConfigurationData.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { useEmployeesList } from '@gusto/embedded-api/react-query/employeesList'\nimport { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { useGustoEmbeddedContext } from '@gusto/embedded-api/react-query/_context'\nimport { payrollsPrepare } from '@gusto/embedded-api/funcs/payrollsPrepare'\nimport { employeesGet } from '@gusto/embedded-api/funcs/employeesGet'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport type { PayrollCategory } from '../payrollTypes'\nimport { derivePayrollCategory } from '../payrollTypes'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\n\ninterface UsePayrollConfigurationDataParams {\n companyId: string\n payrollId: string\n /** When true, don't call prepare and cancel any prepare already running. */\n disablePrepare?: boolean\n excludedEmployeeUuids?: string[]\n /**\n * When true, prepare is called without a roster. A transition payroll's roster is fixed by the\n * pay-schedule transition, so the API rejects any `employeeUuids` sent to prepare.\n */\n isTransitionPayroll?: boolean\n}\n\ninterface UsePayrollConfigurationDataReturn {\n employeeCompensations: PayrollEmployeeCompensationsType[]\n employeeDetails: Employee[]\n payPeriod: PayrollPayPeriodType | undefined\n paySchedule: PayScheduleShow | undefined\n payrollCategory: PayrollCategory\n pagination: PaginationControlProps\n isLoading: boolean\n isAlreadyProcessed: boolean\n refetch: () => Promise<void>\n}\n\n/** @internal */\nexport const PREPARE_QUERY_KEY = 'payroll-prepare'\nconst FIVE_MINUTES = 5 * 60 * 1000\nconst PREPARE_MAX_ATTEMPTS = 3\n\nconst isAlreadyProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\n/** @internal */\nexport function usePayrollConfigurationData({\n companyId,\n payrollId,\n disablePrepare = false,\n excludedEmployeeUuids = [],\n isTransitionPayroll = false,\n}: UsePayrollConfigurationDataParams): UsePayrollConfigurationDataReturn {\n const gustoClient = useGustoEmbeddedContext()\n const queryClient = useQueryClient()\n\n const { currentPage, itemsPerPage, getPaginationProps } = usePagination({\n defaultItemsPerPage: 25,\n })\n const [displayedEmployees, setDisplayedEmployees] = useState<Employee[]>([])\n const [isDataInSync, setIsDataInSync] = useState(false)\n const hasInitialDataRef = useRef(false)\n\n const { data: employeeData, isFetching: isFetchingEmployeeData } = useEmployeesList(\n {\n companyId,\n payrollUuid: payrollId,\n per: itemsPerPage,\n page: currentPage,\n sortBy: 'name',\n },\n { placeholderData: keepPreviousData },\n )\n\n const employeeDataRef = useRef(employeeData)\n employeeDataRef.current = employeeData\n\n const listedEmployeeUuids = useMemo(() => {\n return employeeData?.showEmployees?.map(e => e.uuid) || []\n }, [employeeData?.showEmployees])\n\n const missingExcludedUuids = useMemo(() => {\n const listedSet = new Set(listedEmployeeUuids)\n return excludedEmployeeUuids.filter(uuid => !listedSet.has(uuid))\n }, [excludedEmployeeUuids, listedEmployeeUuids])\n\n const employeeUuids = useMemo(() => {\n if (currentPage === 1) {\n return [...listedEmployeeUuids, ...missingExcludedUuids]\n }\n return listedEmployeeUuids\n }, [listedEmployeeUuids, missingExcludedUuids, currentPage])\n\n const employeeUuidsKey = useMemo(() => employeeUuids.join(','), [employeeUuids])\n\n const {\n data: prepareData,\n error: prepareError,\n isLoading: isPrepareLoading,\n isFetching: isPrepareFetching,\n } = useQuery({\n queryKey: [PREPARE_QUERY_KEY, payrollId, employeeUuidsKey],\n queryFn: async ({ signal }) => {\n const result = await payrollsPrepare(\n gustoClient,\n {\n companyId,\n payrollId,\n sortBy: 'last_name',\n requestBody: {\n employeeUuids: isTransitionPayroll ? undefined : employeeUuids,\n },\n },\n { signal },\n )\n\n if (!result.ok) {\n throw result.error\n }\n\n return result.value.payrollPrepared\n },\n enabled: employeeUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n placeholderData: keepPreviousData,\n // An \"already processed\" prepare failure is terminal — retrying it wastes time. Other\n // errors (network blips, etc.) still get the standard retry treatment.\n retry: (failureCount, error) =>\n !isAlreadyProcessedError(error) && failureCount < PREPARE_MAX_ATTEMPTS,\n })\n\n const isAlreadyProcessed = isAlreadyProcessedError(prepareError)\n\n useEffect(() => {\n return () => {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [queryClient, payrollId])\n\n useEffect(() => {\n if (disablePrepare) {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [disablePrepare, queryClient, payrollId])\n\n const excludedUuidsKey = useMemo(() => missingExcludedUuids.join(','), [missingExcludedUuids])\n\n const { data: excludedEmployeeDetails } = useQuery({\n queryKey: ['excluded-employee-details', excludedUuidsKey],\n queryFn: async () => {\n const results = await Promise.all(\n missingExcludedUuids.map(uuid => employeesGet(gustoClient, { employeeId: uuid })),\n )\n const failedResult = results.find(result => !result.ok)\n if (failedResult) {\n throw failedResult.error\n }\n\n return results\n .filter(result => result.ok)\n .map(result => result.value.employee)\n .filter((e): e is Employee => e != null)\n },\n enabled: missingExcludedUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n })\n\n const syncData = useCallback(() => {\n const currentEmployeeData = employeeDataRef.current\n if (!currentEmployeeData?.showEmployees || !prepareData?.employeeCompensations) {\n setIsDataInSync(false)\n return\n }\n\n const currentUuids = currentEmployeeData.showEmployees.map(e => e.uuid)\n const preparedUuids = new Set(prepareData.employeeCompensations.map(c => c.employeeUuid))\n const allListedInSync =\n currentUuids.length > 0 && currentUuids.every(uuid => preparedUuids.has(uuid))\n\n if (allListedInSync) {\n const mergedEmployees = [...currentEmployeeData.showEmployees]\n if (currentPage === 1 && excludedEmployeeDetails?.length) {\n const listedSet = new Set(currentUuids)\n for (const employee of excludedEmployeeDetails) {\n if (!listedSet.has(employee.uuid)) {\n mergedEmployees.push(employee)\n }\n }\n }\n setDisplayedEmployees(mergedEmployees)\n setIsDataInSync(true)\n hasInitialDataRef.current = true\n } else {\n setIsDataInSync(false)\n }\n }, [prepareData?.employeeCompensations, excludedEmployeeDetails, currentPage])\n\n useEffect(() => {\n syncData()\n }, [syncData])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: prepareData?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!prepareData?.payPeriod?.payScheduleUuid,\n },\n )\n\n const handleRefetch = useCallback(async () => {\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }, [queryClient, payrollId])\n\n const isInitialLoading = isPrepareLoading && !hasInitialDataRef.current\n const isPaginating = isPrepareFetching && hasInitialDataRef.current\n const isPaginationFetching = isFetchingEmployeeData || isPaginating || !isDataInSync\n const isLoading =\n isInitialLoading || isPayScheduleLoading || (!employeeData && isFetchingEmployeeData)\n\n const headers = employeeData?.httpMeta.response.headers ?? new Headers()\n const pagination: PaginationControlProps = getPaginationProps(headers, isPaginationFetching)\n\n return {\n employeeCompensations: prepareData?.employeeCompensations ?? [],\n employeeDetails: displayedEmployees,\n payPeriod: prepareData?.payPeriod,\n paySchedule: payScheduleData?.payScheduleShow,\n payrollCategory: derivePayrollCategory(prepareData ?? {}),\n pagination,\n isLoading,\n isAlreadyProcessed,\n refetch: handleRefetch,\n }\n}\n"],"names":["PREPARE_QUERY_KEY","FIVE_MINUTES","PREPARE_MAX_ATTEMPTS","isAlreadyProcessedError","error","UnprocessableEntityError","e","usePayrollConfigurationData","companyId","payrollId","disablePrepare","excludedEmployeeUuids","isTransitionPayroll","gustoClient","useGustoEmbeddedContext","queryClient","useQueryClient","currentPage","itemsPerPage","getPaginationProps","usePagination","displayedEmployees","setDisplayedEmployees","useState","isDataInSync","setIsDataInSync","hasInitialDataRef","useRef","employeeData","isFetchingEmployeeData","useEmployeesList","keepPreviousData","employeeDataRef","listedEmployeeUuids","useMemo","missingExcludedUuids","listedSet","uuid","employeeUuids","employeeUuidsKey","prepareData","prepareError","isPrepareLoading","isPrepareFetching","useQuery","signal","result","payrollsPrepare","failureCount","isAlreadyProcessed","useEffect","excludedUuidsKey","excludedEmployeeDetails","results","employeesGet","failedResult","syncData","useCallback","currentEmployeeData","currentUuids","preparedUuids","c","mergedEmployees","employee","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","handleRefetch","isInitialLoading","isPaginating","isPaginationFetching","isLoading","headers","pagination","derivePayrollCategory"],"mappings":";;;;;;;;;;AA2CO,MAAMA,IAAoB,mBAC3BC,IAAe,MAAS,KACxBC,KAAuB,GAEvBC,IAA0B,CAACC,MACzBA,aAAiBC,KAChBD,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADP;AAKpD,SAASC,GAA4B;AAAA,EAC1C,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,uBAAAC,IAAwB,CAAA;AAAA,EACxB,qBAAAC,IAAsB;AACxB,GAAyE;AACvE,QAAMC,IAAcC,GAAA,GACdC,IAAcC,GAAA,GAEd,EAAE,aAAAC,GAAa,cAAAC,GAAc,oBAAAC,EAAA,IAAuBC,GAAc;AAAA,IACtE,qBAAqB;AAAA,EAAA,CACtB,GACK,CAACC,GAAoBC,CAAqB,IAAIC,EAAqB,CAAA,CAAE,GACrE,CAACC,GAA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AkB;AAAA,MAClC,UAAU,CAACf,GAAmBS,CAAS;AAAA,IAAA,CACxC;AAAA,EACH,GAAG,CAACM,GAAaN,CAAS,CAAC,GAErB2D,IAAmB1B,KAAoB,CAAChB,EAAkB,SAC1D2C,IAAe1B,KAAqBjB,EAAkB,SACtD4C,IAAuBzC,KAA0BwC,KAAgB,CAAC7C,GAClE+C,IACJH,KAAoBH,KAAyB,CAACrC,KAAgBC,GAE1D2C,IAAU5C,GAAc,SAAS,SAAS,WAAW,IAAI,QAAA,GACzD6C,IAAqCtD,EAAmBqD,GAASF,CAAoB;AAE3F,SAAO;AAAA,IACL,uBAAuB9B,GAAa,yBAAyB,CAAA;AAAA,IAC7D,iBAAiBnB;AAAA,IACjB,WAAWmB,GAAa;AAAA,IACxB,aAAawB,GAAiB;AAAA,IAC9B,iBAAiBU,GAAsBlC,KAAe,EAAE;AAAA,IACxD,YAAAiC;AAAA,IACA,WAAAF;AAAA,IACA,oBAAAtB;AAAA,IACA,SAASkB;AAAA,EAAA;AAEb;"}
1
+ {"version":3,"file":"usePayrollConfigurationData.js","sources":["../../../../src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.ts"],"sourcesContent":["import { useCallback, useEffect, useMemo, useRef, useState } from 'react'\nimport { useEmployeesList } from '@gusto/embedded-api/react-query/employeesList'\nimport { keepPreviousData, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { useGustoEmbeddedContext } from '@gusto/embedded-api/react-query/_context'\nimport { payrollsPrepare } from '@gusto/embedded-api/funcs/payrollsPrepare'\nimport { employeesGet } from '@gusto/embedded-api/funcs/employeesGet'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport type { PayrollEmployeeCompensationsType } from '@gusto/embedded-api/models/components/payrollemployeecompensationstype'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport type { PayrollCategory } from '../payrollTypes'\nimport { derivePayrollCategory } from '../payrollTypes'\nimport type { PaginationControlProps } from '@/components/Common/PaginationControl/PaginationControlTypes'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\n\ninterface UsePayrollConfigurationDataParams {\n companyId: string\n payrollId: string\n /** When true, don't call prepare and cancel any prepare already running. */\n disablePrepare?: boolean\n excludedEmployeeUuids?: string[]\n /**\n * When true, prepare is called without a roster. A transition payroll's roster is fixed by the\n * pay-schedule transition, so the API rejects any `employeeUuids` sent to prepare.\n */\n isTransitionPayroll?: boolean\n}\n\ninterface UsePayrollConfigurationDataReturn {\n employeeCompensations: PayrollEmployeeCompensationsType[]\n employeeDetails: Employee[]\n payPeriod: PayrollPayPeriodType | undefined\n paySchedule: PayScheduleShow | undefined\n payrollCategory: PayrollCategory\n pagination: PaginationControlProps\n isLoading: boolean\n isAlreadyProcessed: boolean\n refetch: () => Promise<void>\n}\n\n/** @internal */\nexport const PREPARE_QUERY_KEY = 'payroll-prepare'\nconst FIVE_MINUTES = 5 * 60 * 1000\nconst PREPARE_MAX_ATTEMPTS = 3\n\nconst isAlreadyProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\n/** @internal */\nexport function usePayrollConfigurationData({\n companyId,\n payrollId,\n disablePrepare = false,\n excludedEmployeeUuids = [],\n isTransitionPayroll = false,\n}: UsePayrollConfigurationDataParams): UsePayrollConfigurationDataReturn {\n const gustoClient = useGustoEmbeddedContext()\n const queryClient = useQueryClient()\n\n const { currentPage, itemsPerPage, getPaginationProps } = usePagination({\n defaultItemsPerPage: 25,\n })\n const [displayedEmployees, setDisplayedEmployees] = useState<Employee[]>([])\n const [isDataInSync, setIsDataInSync] = useState(false)\n const hasInitialDataRef = useRef(false)\n\n const { data: employeeData, isFetching: isFetchingEmployeeData } = useEmployeesList(\n {\n companyId,\n payrollUuid: payrollId,\n per: itemsPerPage,\n page: currentPage,\n sortBy: 'name',\n },\n { placeholderData: keepPreviousData, throwOnError: true },\n )\n\n const employeeDataRef = useRef(employeeData)\n employeeDataRef.current = employeeData\n\n const listedEmployeeUuids = useMemo(() => {\n return employeeData?.showEmployees?.map(e => e.uuid) || []\n }, [employeeData?.showEmployees])\n\n const missingExcludedUuids = useMemo(() => {\n const listedSet = new Set(listedEmployeeUuids)\n return excludedEmployeeUuids.filter(uuid => !listedSet.has(uuid))\n }, [excludedEmployeeUuids, listedEmployeeUuids])\n\n const employeeUuids = useMemo(() => {\n if (currentPage === 1) {\n return [...listedEmployeeUuids, ...missingExcludedUuids]\n }\n return listedEmployeeUuids\n }, [listedEmployeeUuids, missingExcludedUuids, currentPage])\n\n const employeeUuidsKey = useMemo(() => employeeUuids.join(','), [employeeUuids])\n\n const {\n data: prepareData,\n error: prepareError,\n isLoading: isPrepareLoading,\n isFetching: isPrepareFetching,\n } = useQuery({\n queryKey: [PREPARE_QUERY_KEY, payrollId, employeeUuidsKey],\n queryFn: async ({ signal }) => {\n const result = await payrollsPrepare(\n gustoClient,\n {\n companyId,\n payrollId,\n sortBy: 'last_name',\n requestBody: {\n employeeUuids: isTransitionPayroll ? undefined : employeeUuids,\n },\n },\n { signal },\n )\n\n if (!result.ok) {\n throw result.error\n }\n\n return result.value.payrollPrepared\n },\n enabled: employeeUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n placeholderData: keepPreviousData,\n throwOnError: error => !isAlreadyProcessedError(error),\n // An \"already processed\" prepare failure is terminal — retrying it wastes time. Other\n // errors (network blips, etc.) still get the standard retry treatment.\n retry: (failureCount, error) =>\n !isAlreadyProcessedError(error) && failureCount < PREPARE_MAX_ATTEMPTS,\n })\n\n const isAlreadyProcessed = isAlreadyProcessedError(prepareError)\n\n useEffect(() => {\n return () => {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [queryClient, payrollId])\n\n useEffect(() => {\n if (disablePrepare) {\n void queryClient.cancelQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }\n }, [disablePrepare, queryClient, payrollId])\n\n const excludedUuidsKey = useMemo(() => missingExcludedUuids.join(','), [missingExcludedUuids])\n\n const { data: excludedEmployeeDetails } = useQuery({\n queryKey: ['excluded-employee-details', excludedUuidsKey],\n queryFn: async () => {\n const results = await Promise.all(\n missingExcludedUuids.map(uuid => employeesGet(gustoClient, { employeeId: uuid })),\n )\n const failedResult = results.find(result => !result.ok)\n if (failedResult) {\n throw failedResult.error\n }\n\n return results\n .filter(result => result.ok)\n .map(result => result.value.employee)\n .filter((e): e is Employee => e != null)\n },\n enabled: missingExcludedUuids.length > 0 && !disablePrepare,\n staleTime: FIVE_MINUTES,\n })\n\n const syncData = useCallback(() => {\n const currentEmployeeData = employeeDataRef.current\n if (!currentEmployeeData?.showEmployees || !prepareData?.employeeCompensations) {\n setIsDataInSync(false)\n return\n }\n\n const currentUuids = currentEmployeeData.showEmployees.map(e => e.uuid)\n const preparedUuids = new Set(prepareData.employeeCompensations.map(c => c.employeeUuid))\n const allListedInSync =\n currentUuids.length > 0 && currentUuids.every(uuid => preparedUuids.has(uuid))\n\n if (allListedInSync) {\n const mergedEmployees = [...currentEmployeeData.showEmployees]\n if (currentPage === 1 && excludedEmployeeDetails?.length) {\n const listedSet = new Set(currentUuids)\n for (const employee of excludedEmployeeDetails) {\n if (!listedSet.has(employee.uuid)) {\n mergedEmployees.push(employee)\n }\n }\n }\n setDisplayedEmployees(mergedEmployees)\n setIsDataInSync(true)\n hasInitialDataRef.current = true\n } else {\n setIsDataInSync(false)\n }\n }, [prepareData?.employeeCompensations, excludedEmployeeDetails, currentPage])\n\n useEffect(() => {\n syncData()\n }, [syncData])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: prepareData?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!prepareData?.payPeriod?.payScheduleUuid,\n },\n )\n\n const handleRefetch = useCallback(async () => {\n await queryClient.invalidateQueries({\n queryKey: [PREPARE_QUERY_KEY, payrollId],\n })\n }, [queryClient, payrollId])\n\n const isInitialLoading = isPrepareLoading && !hasInitialDataRef.current\n const isPaginating = isPrepareFetching && hasInitialDataRef.current\n const isPaginationFetching = isFetchingEmployeeData || isPaginating || !isDataInSync\n const isLoading =\n isInitialLoading || isPayScheduleLoading || (!employeeData && isFetchingEmployeeData)\n\n const headers = employeeData?.httpMeta.response.headers ?? new Headers()\n const pagination: PaginationControlProps = getPaginationProps(headers, isPaginationFetching)\n\n return {\n employeeCompensations: prepareData?.employeeCompensations ?? [],\n employeeDetails: displayedEmployees,\n payPeriod: prepareData?.payPeriod,\n paySchedule: payScheduleData?.payScheduleShow,\n payrollCategory: derivePayrollCategory(prepareData ?? {}),\n pagination,\n isLoading,\n isAlreadyProcessed,\n refetch: handleRefetch,\n }\n}\n"],"names":["PREPARE_QUERY_KEY","FIVE_MINUTES","PREPARE_MAX_ATTEMPTS","isAlreadyProcessedError","error","UnprocessableEntityError","e","usePayrollConfigurationData","companyId","payrollId","disablePrepare","excludedEmployeeUuids","isTransitionPayroll","gustoClient","useGustoEmbeddedContext","queryClient","useQueryClient","currentPage","itemsPerPage","getPaginationProps","usePagination","displayedEmployees","setDisplayedEmployees","useState","isDataInSync","setIsDataInSync","hasInitialDataRef","useRef","employeeData","isFetchingEmployeeData","useEmployeesList","keepPreviousData","employeeDataRef","listedEmployeeUuids","useMemo","missingExcludedUuids","listedSet","uuid","employeeUuids","employeeUuidsKey","prepareData","prepareError","isPrepareLoading","isPrepareFetching","useQuery","signal","result","payrollsPrepare","failureCount","isAlreadyProcessed","useEffect","excludedUuidsKey","excludedEmployeeDetails","results","employeesGet","failedResult","syncData","useCallback","currentEmployeeData","currentUuids","preparedUuids","c","mergedEmployees","employee","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","handleRefetch","isInitialLoading","isPaginating","isPaginationFetching","isLoading","headers","pagination","derivePayrollCategory"],"mappings":";;;;;;;;;;AA2CO,MAAMA,IAAoB,mBAC3BC,IAAe,MAAS,KACxBC,KAAuB,GAEvBC,IAA0B,CAACC,MACzBA,aAAiBC,KAChBD,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADP;AAKpD,SAASC,GAA4B;AAAA,EAC1C,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,gBAAAC,IAAiB;AAAA,EACjB,uBAAAC,IAAwB,CAAA;AAAA,EACxB,qBAAAC,IAAsB;AACxB,GAAyE;AACvE,QAAMC,IAAcC,GAAA,GACdC,IAAcC,GAAA,GAEd,EAAE,aAAAC,GAAa,cAAAC,GAAc,oBAAAC,EAAA,IAAuBC,GAAc;AAAA,IACtE,qBAAqB;AAAA,EAAA,CACtB,GACK,CAACC,GAAoBC,CAAqB,IAAIC,EAAqB,CAAA,CAAE,GACrE,CAACC,GAAcC,CAAe,IAAIF,EAAS,EAAK,GAChDG,IAAoBC,EAAO,EAAK,GAEhC,EAAE,MAAMC,GAAc,YAAYC,MAA2BC;AAAA,IACjE;AAAA,MACE,WAAAtB;AAAA,MACA,aAAaC;AAAA,MACb,KAAKS;AAAA,MACL,MAAMD;AAAA,MACN,QAAQ;AAAA,IAAA;AAAA,IAEV,EAAE,iBAAiBc,GAAkB,cAAc,GAAA;AAAA,EAAK,GAGpDC,IAAkBL,EAAOC,CAAY;AAC3C,EAAAI,EAAgB,UAAUJ;AAE1B,QAAMK,IAAsBC,EAAQ,MAC3BN,GAAc,eAAe,IAAI,OAAK,EAAE,IAAI,KAAK,CAAA,GACvD,CAACA,GAAc,aAAa,CAAC,GAE1BO,IAAuBD,EAAQ,MAAM;AACzC,UAAME,IAAY,IAAI,IAAIH,CAAmB;AAC7C,WAAOtB,EAAsB,OAAO,CAAA0B,MAAQ,CAACD,EAAU,IAAIC,CAAI,CAAC;AAAA,EAClE,GAAG,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ACxD,YAAAiC;AAAA,IACA,WAAAF;AAAA,IACA,oBAAAtB;AAAA,IACA,SAASkB;AAAA,EAAA;AAEb;"}
@@ -1,75 +1,75 @@
1
1
  import { jsx as o, jsxs as p } from "react/jsx-runtime";
2
- import { useForm as v, useWatch as R, FormProvider as _ } from "react-hook-form";
3
- import { zodResolver as T } from "@hookform/resolvers/zod";
2
+ import { useForm as T, useWatch as _, FormProvider as D } from "react-hook-form";
3
+ import { zodResolver as A } from "@hookform/resolvers/zod";
4
4
  import { useTranslation as h } from "react-i18next";
5
5
  import { z as d } from "zod";
6
- import { usePayrollsGeneratePrintableChecksMutation as D } from "@gusto/embedded-api/react-query/payrollsGeneratePrintableChecks";
6
+ import { usePayrollsGeneratePrintableChecksMutation as I } from "@gusto/embedded-api/react-query/payrollsGeneratePrintableChecks";
7
7
  import { PrintingFormat as n } from "@gusto/embedded-api/models/components/printablepayrollchecksbody";
8
- import { useGenerationPoll as A } from "./useGenerationPoll.js";
9
- import { BaseComponent as I } from "../../../Base/Base.js";
10
- import { useBase as G } from "../../../Base/useBase.js";
11
- import { useComponentContext as L } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
12
- import { useComponentDictionary as M, useI18n as b } from "../../../../i18n/I18n.js";
8
+ import { useGenerationPoll as L } from "./useGenerationPoll.js";
9
+ import { BaseComponent as G } from "../../../Base/Base.js";
10
+ import { useBase as H } from "../../../Base/useBase.js";
11
+ import { useComponentContext as b } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
12
+ import { useComponentDictionary as M, useI18n as g } from "../../../../i18n/I18n.js";
13
13
  import { useFlow as x } from "../../../Flow/useFlow.js";
14
14
  import { Flex as B } from "../../../Common/Flex/Flex.js";
15
15
  import { ActionsLayout as w } from "../../../Common/ActionsLayout/ActionsLayout.js";
16
- import { Form as H } from "../../../Common/Form/Form.js";
16
+ import { Form as q } from "../../../Common/Form/Form.js";
17
17
  import { printChecksEvents as m } from "../../../../shared/constants.js";
18
- import { RadioGroupField as q } from "../../../Common/Fields/RadioGroupField/RadioGroupField.js";
19
- import { NumberInputField as K } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
20
- const U = d.object({
18
+ import { RadioGroupField as K } from "../../../Common/Fields/RadioGroupField/RadioGroupField.js";
19
+ import { NumberInputField as U } from "../../../Common/Fields/NumberInputField/NumberInputField.js";
20
+ const j = d.object({
21
21
  printingFormat: d.nativeEnum(n),
22
22
  startingCheckNumber: d.number({ message: "invalidStartingCheckNumber" }).int({ message: "invalidStartingCheckNumber" }).nonnegative({ message: "invalidStartingCheckNumber" }).lt(1e10, { message: "invalidStartingCheckNumber" }).optional()
23
- }), g = "gusto-sdk-print-checks-form", j = (r) => Array.isArray(r) && r.every((e) => typeof e == "object" && e !== null), z = (r) => {
24
- if (r && typeof r == "object" && "errors" in r && j(r.errors)) {
23
+ }), k = "gusto-sdk-print-checks-form", z = (r) => Array.isArray(r) && r.every((e) => typeof e == "object" && e !== null), O = (r) => {
24
+ if (r && typeof r == "object" && "errors" in r && z(r.errors)) {
25
25
  const [e] = r.errors;
26
26
  if (e?.message) return e.message;
27
27
  }
28
28
  return r instanceof Error ? r.message : null;
29
- }, O = (r) => ({
29
+ }, V = (r) => ({
30
30
  printingFormat: r.printingFormat,
31
31
  ...r.printingFormat === n.Bottom && r.startingCheckNumber !== void 0 ? { startingCheckNumber: r.startingCheckNumber } : {}
32
- }), V = (r) => {
32
+ }), W = (r) => {
33
33
  const e = document.createElement("a");
34
34
  e.href = r, e.rel = "noopener noreferrer", document.body.appendChild(e), e.click(), document.body.removeChild(e);
35
35
  };
36
- function W(r) {
37
- return /* @__PURE__ */ o(I, { ...r, children: /* @__PURE__ */ o(J, { ...r, children: r.children }) });
36
+ function J(r) {
37
+ return /* @__PURE__ */ o(G, { ...r, children: /* @__PURE__ */ o(Q, { ...r, children: r.children }) });
38
38
  }
39
- const J = ({ dictionary: r, payrollId: e, isGenerating: i, className: s }) => {
40
- M("Payroll.PrintChecksForm", r), b("Payroll.PrintChecksForm");
41
- const { t } = h("Payroll.PrintChecksForm"), { onEvent: c, baseSubmitHandler: k } = G(), l = v({
42
- resolver: T(U),
39
+ const Q = ({ dictionary: r, payrollId: e, isGenerating: i, className: s }) => {
40
+ M("Payroll.PrintChecksForm", r), g("Payroll.PrintChecksForm");
41
+ const { t } = h("Payroll.PrintChecksForm"), { Heading: f } = b(), { onEvent: c, baseSubmitHandler: E } = H(), l = T({
42
+ resolver: A(j),
43
43
  defaultValues: { printingFormat: n.Top, startingCheckNumber: 0 }
44
- }), f = R({
44
+ }), F = _({
45
45
  name: "printingFormat",
46
46
  control: l.control
47
- }), { mutateAsync: E } = D(), { start: F } = A({
47
+ }), { mutateAsync: N } = I(), { start: y } = L({
48
48
  onSucceeded: (a) => {
49
- c(m.PRINT_CHECKS_GENERATE_SUCCEEDED, { documentUrl: a }), a && V(a);
49
+ c(m.PRINT_CHECKS_GENERATE_SUCCEEDED, { documentUrl: a }), a && W(a);
50
50
  },
51
51
  onFailed: () => {
52
52
  c(m.PRINT_CHECKS_GENERATE_FAILED, { errorMessage: null });
53
53
  }
54
- }), N = async (a) => {
55
- c(m.PRINT_CHECKS_GENERATE_START), await k(a, async (S) => {
54
+ }), P = async (a) => {
55
+ c(m.PRINT_CHECKS_GENERATE_START), await E(a, async (R) => {
56
56
  try {
57
- const C = (await E({
57
+ const C = (await N({
58
58
  request: {
59
59
  payrollUuid: e,
60
- printablePayrollChecksBody: O(S)
60
+ printablePayrollChecksBody: V(R)
61
61
  }
62
62
  })).payrollCheck?.requestUuid;
63
63
  if (!C)
64
64
  throw new Error("Missing requestUuid in generate-printable-checks response");
65
- F(C);
65
+ y(C);
66
66
  } catch (u) {
67
67
  throw c(m.PRINT_CHECKS_GENERATE_FAILED, {
68
- errorMessage: z(u)
68
+ errorMessage: O(u)
69
69
  }), u;
70
70
  }
71
71
  });
72
- }, y = l.formState.errors.startingCheckNumber?.message ? t("validations.startingCheckNumber") : void 0, P = [
72
+ }, S = l.formState.errors.startingCheckNumber?.message ? t("validations.startingCheckNumber") : void 0, v = [
73
73
  {
74
74
  value: n.Top,
75
75
  label: t("customStockLabel"),
@@ -81,30 +81,32 @@ const J = ({ dictionary: r, payrollId: e, isGenerating: i, className: s }) => {
81
81
  description: t("blankStockDescription")
82
82
  }
83
83
  ];
84
- return /* @__PURE__ */ o(_, { ...l, children: /* @__PURE__ */ o(
85
- H,
84
+ return /* @__PURE__ */ o(D, { ...l, children: /* @__PURE__ */ o(
85
+ q,
86
86
  {
87
- id: g,
88
- onSubmit: l.handleSubmit(N),
87
+ id: k,
88
+ onSubmit: l.handleSubmit(P),
89
89
  className: s,
90
90
  children: /* @__PURE__ */ p(B, { flexDirection: "column", gap: 20, children: [
91
+ /* @__PURE__ */ o(f, { as: "h2", children: t("modalTitle") }),
91
92
  /* @__PURE__ */ o(
92
- q,
93
+ K,
93
94
  {
94
95
  name: "printingFormat",
95
96
  label: t("modalTitle"),
96
- options: P,
97
+ shouldVisuallyHideLabel: !0,
98
+ options: v,
97
99
  isRequired: !0,
98
100
  isDisabled: i
99
101
  }
100
102
  ),
101
- f === n.Bottom && /* @__PURE__ */ o(
102
- K,
103
+ F === n.Bottom && /* @__PURE__ */ o(
104
+ U,
103
105
  {
104
106
  name: "startingCheckNumber",
105
107
  label: t("startingCheckNumberLabel"),
106
108
  description: t("startingCheckNumberDescription"),
107
- errorMessage: y,
109
+ errorMessage: S,
108
110
  isDisabled: i,
109
111
  min: 0
110
112
  }
@@ -112,9 +114,9 @@ const J = ({ dictionary: r, payrollId: e, isGenerating: i, className: s }) => {
112
114
  ] })
113
115
  }
114
116
  ) });
115
- }, Q = ({ onEvent: r }) => {
116
- b("Payroll.PrintChecksForm");
117
- const { t: e } = h("Payroll.PrintChecksForm"), { Button: i } = L(), { isGenerating: s } = x();
117
+ }, X = ({ onEvent: r }) => {
118
+ g("Payroll.PrintChecksForm");
119
+ const { t: e } = h("Payroll.PrintChecksForm"), { Button: i } = b(), { isGenerating: s } = x();
118
120
  return /* @__PURE__ */ p(w, { children: [
119
121
  /* @__PURE__ */ o(
120
122
  i,
@@ -127,11 +129,11 @@ const J = ({ dictionary: r, payrollId: e, isGenerating: i, className: s }) => {
127
129
  children: e("cancelCta")
128
130
  }
129
131
  ),
130
- /* @__PURE__ */ o(i, { variant: "primary", type: "submit", form: g, isDisabled: s, children: e(s ? "submitCtaLoading" : "submitCta") })
132
+ /* @__PURE__ */ o(i, { variant: "primary", type: "submit", form: k, isDisabled: s, children: e(s ? "submitCtaLoading" : "submitCta") })
131
133
  ] });
132
134
  };
133
- W.Footer = Q;
135
+ J.Footer = X;
134
136
  export {
135
- W as PrintChecksForm
137
+ J as PrintChecksForm
136
138
  };
137
139
  //# sourceMappingURL=PrintChecksForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PrintChecksForm.js","sources":["../../../../../src/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.tsx"],"sourcesContent":["import { FormProvider, useForm, useWatch } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { usePayrollsGeneratePrintableChecksMutation } from '@gusto/embedded-api/react-query/payrollsGeneratePrintableChecks'\nimport {\n PrintingFormat,\n type PrintablePayrollChecksBody,\n} from '@gusto/embedded-api/models/components/printablepayrollchecksbody'\nimport { useGenerationPoll } from './useGenerationPoll'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { useFlow, type FlowContextInterface } from '@/components/Flow/useFlow'\nimport { ActionsLayout, Flex, NumberInputField, RadioGroupField } from '@/components/Common'\nimport { Form } from '@/components/Common/Form'\nimport { printChecksEvents, type EventType } from '@/shared/constants'\nimport type { RadioGroupOption } from '@/index'\n\ninterface PrintChecksFormProps extends BaseComponentInterface<'Payroll.PrintChecksForm'> {\n payrollId: string\n /** Whether a generate-and-poll cycle is in flight; disables the fields while true. */\n isGenerating?: boolean\n}\n\n// The Footer is rendered by the top-level orchestrator as a sibling of this component (not a\n// child), so it can only read shared state — like whether a generate-and-poll cycle is in\n// flight — via the machine's FlowContext rather than as a prop. This narrow interface describes\n// only the field Footer needs, rather than depending on the orchestrator's full context type.\ninterface PrintChecksFormFlowContext extends FlowContextInterface {\n isGenerating?: boolean\n}\n\nconst PrintChecksFormSchema = z.object({\n printingFormat: z.nativeEnum(PrintingFormat),\n startingCheckNumber: z\n .number({ message: 'invalidStartingCheckNumber' })\n .int({ message: 'invalidStartingCheckNumber' })\n .nonnegative({ message: 'invalidStartingCheckNumber' })\n .lt(10_000_000_000, { message: 'invalidStartingCheckNumber' })\n .optional(),\n})\n\ntype PrintChecksFormValues = z.infer<typeof PrintChecksFormSchema>\n\nconst PRINT_CHECKS_FORM_ID = 'gusto-sdk-print-checks-form'\n\nconst isErrorList = (val: unknown): val is { message?: string }[] =>\n Array.isArray(val) && val.every(entry => typeof entry === 'object' && entry !== null)\n\nconst extractErrorMessage = (err: unknown): string | null => {\n if (err && typeof err === 'object' && 'errors' in err && isErrorList(err.errors)) {\n const [firstError] = err.errors\n if (firstError?.message) return firstError.message\n }\n return err instanceof Error ? err.message : null\n}\n\nconst buildRequestBody = (data: PrintChecksFormValues): PrintablePayrollChecksBody => ({\n printingFormat: data.printingFormat,\n ...(data.printingFormat === PrintingFormat.Bottom && data.startingCheckNumber !== undefined\n ? { startingCheckNumber: data.startingCheckNumber }\n : {}),\n})\n\n// Navigates directly to `url` via a synthetic anchor click rather than `fetch`-ing it into a blob:\n// the generated-document URL is a signed, cross-origin S3 URL with `response-content-disposition:\n// attachment` baked into its query string, so a direct browser-level request downloads it via that\n// response header — but a `fetch()` from JS is subject to CORS, which the bucket doesn't allow, and\n// fails outright. A plain navigation isn't subject to CORS and never opens a new tab or navigates\n// the host page, since the browser intercepts the download instead of rendering a response.\nconst downloadGeneratedChecks = (url: string) => {\n const link = document.createElement('a')\n link.href = url\n link.rel = 'noopener noreferrer'\n document.body.appendChild(link)\n link.click()\n document.body.removeChild(link)\n}\n\n/** @internal */\nexport function PrintChecksForm(props: PrintChecksFormProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ dictionary, payrollId, isGenerating, className }: PrintChecksFormProps) => {\n useComponentDictionary('Payroll.PrintChecksForm', dictionary)\n useI18n('Payroll.PrintChecksForm')\n const { t } = useTranslation('Payroll.PrintChecksForm')\n const { onEvent, baseSubmitHandler } = useBase()\n\n const formMethods = useForm<PrintChecksFormValues>({\n resolver: zodResolver(PrintChecksFormSchema),\n defaultValues: { printingFormat: PrintingFormat.Top, startingCheckNumber: 0 },\n })\n\n const printingFormat = useWatch<PrintChecksFormValues, 'printingFormat'>({\n name: 'printingFormat',\n control: formMethods.control,\n })\n\n const { mutateAsync } = usePayrollsGeneratePrintableChecksMutation()\n\n const { start: startGenerationPoll } = useGenerationPoll({\n onSucceeded: url => {\n onEvent(printChecksEvents.PRINT_CHECKS_GENERATE_SUCCEEDED, { documentUrl: url })\n if (url) {\n downloadGeneratedChecks(url)\n }\n },\n onFailed: () => {\n onEvent(printChecksEvents.PRINT_CHECKS_GENERATE_FAILED, { errorMessage: null })\n },\n })\n\n const onSubmit = async (formData: PrintChecksFormValues) => {\n onEvent(printChecksEvents.PRINT_CHECKS_GENERATE_START)\n\n await baseSubmitHandler(formData, async submittedData => {\n try {\n const result = await mutateAsync({\n request: {\n payrollUuid: payrollId,\n printablePayrollChecksBody: buildRequestBody(submittedData),\n },\n })\n\n const nextRequestUuid = result.payrollCheck?.requestUuid\n if (!nextRequestUuid) {\n throw new Error('Missing requestUuid in generate-printable-checks response')\n }\n\n startGenerationPoll(nextRequestUuid)\n } catch (err) {\n onEvent(printChecksEvents.PRINT_CHECKS_GENERATE_FAILED, {\n errorMessage: extractErrorMessage(err),\n })\n throw err\n }\n })\n }\n\n const startingCheckNumberErrorCode = formMethods.formState.errors.startingCheckNumber?.message\n const startingCheckNumberErrorMessage = startingCheckNumberErrorCode\n ? t('validations.startingCheckNumber')\n : undefined\n\n const printingFormatOptions: RadioGroupOption[] = [\n {\n value: PrintingFormat.Top,\n label: t('customStockLabel'),\n description: t('customStockDescription'),\n },\n {\n value: PrintingFormat.Bottom,\n label: t('blankStockLabel'),\n description: t('blankStockDescription'),\n },\n ]\n\n return (\n <FormProvider {...formMethods}>\n <Form\n id={PRINT_CHECKS_FORM_ID}\n onSubmit={formMethods.handleSubmit(onSubmit)}\n className={className}\n >\n <Flex flexDirection=\"column\" gap={20}>\n <RadioGroupField\n name=\"printingFormat\"\n label={t('modalTitle')}\n options={printingFormatOptions}\n isRequired\n isDisabled={isGenerating}\n />\n {printingFormat === PrintingFormat.Bottom && (\n <NumberInputField\n name=\"startingCheckNumber\"\n label={t('startingCheckNumberLabel')}\n description={t('startingCheckNumberDescription')}\n errorMessage={startingCheckNumberErrorMessage}\n isDisabled={isGenerating}\n min={0}\n />\n )}\n </Flex>\n </Form>\n </FormProvider>\n )\n}\n\nconst Footer = ({ onEvent }: { onEvent: OnEventType<EventType, unknown> }) => {\n useI18n('Payroll.PrintChecksForm')\n const { t } = useTranslation('Payroll.PrintChecksForm')\n const { Button } = useComponentContext()\n const { isGenerating } = useFlow<PrintChecksFormFlowContext>()\n\n return (\n <ActionsLayout>\n <Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(printChecksEvents.PRINT_CHECKS_CANCEL)\n }}\n isDisabled={isGenerating}\n >\n {t('cancelCta')}\n </Button>\n <Button variant=\"primary\" type=\"submit\" form={PRINT_CHECKS_FORM_ID} isDisabled={isGenerating}>\n {isGenerating ? t('submitCtaLoading') : t('submitCta')}\n </Button>\n </ActionsLayout>\n )\n}\nPrintChecksForm.Footer = Footer\n"],"names":["PrintChecksFormSchema","z","PrintingFormat","PRINT_CHECKS_FORM_ID","isErrorList","val","entry","extractErrorMessage","err","firstError","buildRequestBody","data","downloadGeneratedChecks","url","link","PrintChecksForm","props","jsx","BaseComponent","Root","dictionary","payrollId","isGenerating","className","useComponentDictionary","useI18n","useTranslation","onEvent","baseSubmitHandler","useBase","formMethods","useForm","zodResolver","printingFormat","useWatch","mutateAsync","usePayrollsGeneratePrintableChecksMutation","startGenerationPoll","useGenerationPoll","printChecksEvents","onSubmit","formData","submittedData","nextRequestUuid","startingCheckNumberErrorMessage","printingFormatOptions","FormProvider","Form","jsxs","Flex","RadioGroupField","NumberInputField","Footer","t","Button","useComponentContext","useFlow","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,MAAMA,IAAwBC,EAAE,OAAO;AAAA,EACrC,gBAAgBA,EAAE,WAAWC,CAAc;AAAA,EAC3C,qBAAqBD,EAClB,OAAO,EAAE,SAAS,6BAAA,CAA8B,EAChD,IAAI,EAAE,SAAS,6BAAA,CAA8B,EAC7C,YAAY,EAAE,SAAS,6BAAA,CAA8B,EACrD,GAAG,MAAgB,EAAE,SAAS,6BAAA,CAA8B,EAC5D,SAAA;AACL,CAAC,GAIKE,IAAuB,+BAEvBC,IAAc,CAACC,MACnB,MAAM,QAAQA,CAAG,KAAKA,EAAI,MAAM,CAAAC,MAAS,OAAOA,KAAU,YAAYA,MAAU,IAAI,GAEhFC,IAAsB,CAACC,MAAgC;AAC3D,MAAIA,KAAO,OAAOA,KAAQ,YAAY,YAAYA,KAAOJ,EAAYI,EAAI,MAAM,GAAG;AAChF,UAAM,CAACC,CAAU,IAAID,EAAI;AACzB,QAAIC,GAAY,QAAS,QAAOA,EAAW;AAAA,EAC7C;AACA,SAAOD,aAAe,QAAQA,EAAI,UAAU;AAC9C,GAEME,IAAmB,CAACC,OAA6D;AAAA,EACrF,gBAAgBA,EAAK;AAAA,EACrB,GAAIA,EAAK,mBAAmBT,EAAe,UAAUS,EAAK,wBAAwB,SAC9E,EAAE,qBAAqBA,EAAK,oBAAA,IAC5B,CAAA;AACN,IAQMC,IAA0B,CAACC,MAAgB;AAC/C,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,YACL,OAAO,EAAE,0BAA0B;AAAA,YACnC,aAAa,EAAE,gCAAgC;AAAA,YAC/C,cAAcP;AAAA,YACd,YAAYtB;AAAA,YACZ,KAAK;AAAA,UAAA;AAAA,QAAA;AAAA,MACP,EAAA,CAEJ;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ,GAEM8B,IAAS,CAAC,EAAE,SAAAzB,QAA4D;AAC5E,EAAAF,EAAQ,yBAAyB;AACjC,QAAM,EAAE,GAAA4B,EAAA,IAAM3B,EAAe,yBAAyB,GAChD,EAAE,QAAA4B,EAAA,IAAWC,EAAA,GACb,EAAE,cAAAjC,EAAA,IAAiBkC,EAAA;AAEzB,2BACGC,GAAA,EACC,UAAA;AAAA,IAAA,gBAAAxC;AAAA,MAACqC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,SAAS,MAAM;AACb,UAAA3B,EAAQY,EAAkB,mBAAmB;AAAA,QAC/C;AAAA,QACA,YAAYjB;AAAA,QAEX,YAAE,WAAW;AAAA,MAAA;AAAA,IAAA;AAAA,sBAEfgC,GAAA,EAAO,SAAQ,WAAU,MAAK,UAAS,MAAMnD,GAAsB,YAAYmB,GAC7E,UAAe+B,MAAE,qBAAwB,WAAN,EAAiB,CACvD;AAAA,EAAA,GACF;AAEJ;AACAtC,EAAgB,SAASqC;"}
1
+ {"version":3,"file":"PrintChecksForm.js","sources":["../../../../../src/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.tsx"],"sourcesContent":["import { FormProvider, useForm, useWatch } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useTranslation } from 'react-i18next'\nimport { z } from 'zod'\nimport { usePayrollsGeneratePrintableChecksMutation } from '@gusto/embedded-api/react-query/payrollsGeneratePrintableChecks'\nimport {\n PrintingFormat,\n type PrintablePayrollChecksBody,\n} from '@gusto/embedded-api/models/components/printablepayrollchecksbody'\nimport { useGenerationPoll } from './useGenerationPoll'\nimport { BaseComponent, useBase, type BaseComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { useFlow, type FlowContextInterface } from '@/components/Flow/useFlow'\nimport { ActionsLayout, Flex, NumberInputField, RadioGroupField } from '@/components/Common'\nimport { Form } from '@/components/Common/Form'\nimport { printChecksEvents, type EventType } from '@/shared/constants'\nimport type { RadioGroupOption } from '@/index'\n\ninterface PrintChecksFormProps extends BaseComponentInterface<'Payroll.PrintChecksForm'> {\n payrollId: string\n /** Whether a generate-and-poll cycle is in flight; disables the fields while true. */\n isGenerating?: boolean\n}\n\n// The Footer is rendered by the top-level orchestrator as a sibling of this component (not a\n// child), so it can only read shared state — like whether a generate-and-poll cycle is in\n// flight — via the machine's FlowContext rather than as a prop. This narrow interface describes\n// only the field Footer needs, rather than depending on the orchestrator's full context type.\ninterface PrintChecksFormFlowContext extends FlowContextInterface {\n isGenerating?: boolean\n}\n\nconst PrintChecksFormSchema = z.object({\n printingFormat: z.nativeEnum(PrintingFormat),\n startingCheckNumber: z\n .number({ message: 'invalidStartingCheckNumber' })\n .int({ message: 'invalidStartingCheckNumber' })\n .nonnegative({ message: 'invalidStartingCheckNumber' })\n .lt(10_000_000_000, { message: 'invalidStartingCheckNumber' })\n .optional(),\n})\n\ntype PrintChecksFormValues = z.infer<typeof PrintChecksFormSchema>\n\nconst PRINT_CHECKS_FORM_ID = 'gusto-sdk-print-checks-form'\n\nconst isErrorList = (val: unknown): val is { message?: string }[] =>\n Array.isArray(val) && val.every(entry => typeof entry === 'object' && entry !== null)\n\nconst extractErrorMessage = (err: unknown): string | null => {\n if (err && typeof err === 'object' && 'errors' in err && isErrorList(err.errors)) {\n const [firstError] = err.errors\n if (firstError?.message) return firstError.message\n }\n return err instanceof Error ? err.message : null\n}\n\nconst buildRequestBody = (data: PrintChecksFormValues): PrintablePayrollChecksBody => ({\n printingFormat: data.printingFormat,\n ...(data.printingFormat === PrintingFormat.Bottom && data.startingCheckNumber !== undefined\n ? { startingCheckNumber: data.startingCheckNumber }\n : {}),\n})\n\n// Navigates directly to `url` via a synthetic anchor click rather than `fetch`-ing it into a blob:\n// the generated-document URL is a signed, cross-origin S3 URL with `response-content-disposition:\n// attachment` baked into its query string, so a direct browser-level request downloads it via that\n// response header — but a `fetch()` from JS is subject to CORS, which the bucket doesn't allow, and\n// fails outright. A plain navigation isn't subject to CORS and never opens a new tab or navigates\n// the host page, since the browser intercepts the download instead of rendering a response.\nconst downloadGeneratedChecks = (url: string) => {\n const link = document.createElement('a')\n link.href = url\n link.rel = 'noopener noreferrer'\n document.body.appendChild(link)\n link.click()\n document.body.removeChild(link)\n}\n\n/** @internal */\nexport function PrintChecksForm(props: PrintChecksFormProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ dictionary, payrollId, isGenerating, className }: PrintChecksFormProps) => {\n useComponentDictionary('Payroll.PrintChecksForm', dictionary)\n useI18n('Payroll.PrintChecksForm')\n const { t } = useTranslation('Payroll.PrintChecksForm')\n const { Heading } = useComponentContext()\n const { onEvent, baseSubmitHandler } = useBase()\n\n const formMethods = useForm<PrintChecksFormValues>({\n resolver: zodResolver(PrintChecksFormSchema),\n defaultValues: { printingFormat: PrintingFormat.Top, startingCheckNumber: 0 },\n })\n\n const printingFormat = useWatch<PrintChecksFormValues, 'printingFormat'>({\n name: 'printingFormat',\n control: formMethods.control,\n })\n\n const { mutateAsync } = usePayrollsGeneratePrintableChecksMutation()\n\n const { start: startGenerationPoll } = useGenerationPoll({\n onSucceeded: url => {\n onEvent(printChecksEvents.PRINT_CHECKS_GENERATE_SUCCEEDED, { documentUrl: url })\n if (url) {\n downloadGeneratedChecks(url)\n }\n },\n onFailed: () => {\n onEvent(printChecksEvents.PRINT_CHECKS_GENERATE_FAILED, { errorMessage: null })\n },\n })\n\n const onSubmit = async (formData: PrintChecksFormValues) => {\n onEvent(printChecksEvents.PRINT_CHECKS_GENERATE_START)\n\n await baseSubmitHandler(formData, async submittedData => {\n try {\n const result = await mutateAsync({\n request: {\n payrollUuid: payrollId,\n printablePayrollChecksBody: buildRequestBody(submittedData),\n },\n })\n\n const nextRequestUuid = result.payrollCheck?.requestUuid\n if (!nextRequestUuid) {\n throw new Error('Missing requestUuid in generate-printable-checks response')\n }\n\n startGenerationPoll(nextRequestUuid)\n } catch (err) {\n onEvent(printChecksEvents.PRINT_CHECKS_GENERATE_FAILED, {\n errorMessage: extractErrorMessage(err),\n })\n throw err\n }\n })\n }\n\n const startingCheckNumberErrorCode = formMethods.formState.errors.startingCheckNumber?.message\n const startingCheckNumberErrorMessage = startingCheckNumberErrorCode\n ? t('validations.startingCheckNumber')\n : undefined\n\n const printingFormatOptions: RadioGroupOption[] = [\n {\n value: PrintingFormat.Top,\n label: t('customStockLabel'),\n description: t('customStockDescription'),\n },\n {\n value: PrintingFormat.Bottom,\n label: t('blankStockLabel'),\n description: t('blankStockDescription'),\n },\n ]\n\n return (\n <FormProvider {...formMethods}>\n <Form\n id={PRINT_CHECKS_FORM_ID}\n onSubmit={formMethods.handleSubmit(onSubmit)}\n className={className}\n >\n <Flex flexDirection=\"column\" gap={20}>\n <Heading as=\"h2\">{t('modalTitle')}</Heading>\n <RadioGroupField\n name=\"printingFormat\"\n label={t('modalTitle')}\n shouldVisuallyHideLabel\n options={printingFormatOptions}\n isRequired\n isDisabled={isGenerating}\n />\n {printingFormat === PrintingFormat.Bottom && (\n <NumberInputField\n name=\"startingCheckNumber\"\n label={t('startingCheckNumberLabel')}\n description={t('startingCheckNumberDescription')}\n errorMessage={startingCheckNumberErrorMessage}\n isDisabled={isGenerating}\n min={0}\n />\n )}\n </Flex>\n </Form>\n </FormProvider>\n )\n}\n\nconst Footer = ({ onEvent }: { onEvent: OnEventType<EventType, unknown> }) => {\n useI18n('Payroll.PrintChecksForm')\n const { t } = useTranslation('Payroll.PrintChecksForm')\n const { Button } = useComponentContext()\n const { isGenerating } = useFlow<PrintChecksFormFlowContext>()\n\n return (\n <ActionsLayout>\n <Button\n variant=\"secondary\"\n onClick={() => {\n onEvent(printChecksEvents.PRINT_CHECKS_CANCEL)\n }}\n isDisabled={isGenerating}\n >\n {t('cancelCta')}\n </Button>\n <Button variant=\"primary\" type=\"submit\" form={PRINT_CHECKS_FORM_ID} isDisabled={isGenerating}>\n {isGenerating ? t('submitCtaLoading') : t('submitCta')}\n </Button>\n </ActionsLayout>\n )\n}\nPrintChecksForm.Footer = Footer\n"],"names":["PrintChecksFormSchema","z","PrintingFormat","PRINT_CHECKS_FORM_ID","isErrorList","val","entry","extractErrorMessage","err","firstError","buildRequestBody","data","downloadGeneratedChecks","url","link","PrintChecksForm","props","jsx","BaseComponent","Root","dictionary","payrollId","isGenerating","className","useComponentDictionary","useI18n","useTranslation","Heading","useComponentContext","onEvent","baseSubmitHandler","useBase","formMethods","useForm","zodResolver","printingFormat","useWatch","mutateAsync","usePayrollsGeneratePrintableChecksMutation","startGenerationPoll","useGenerationPoll","printChecksEvents","onSubmit","formData","submittedData","nextRequestUuid","startingCheckNumberErrorMessage","printingFormatOptions","FormProvider","Form","jsxs","Flex","RadioGroupField","NumberInputField","Footer","t","Button","useFlow","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;;;;AAkCA,MAAMA,IAAwBC,EAAE,OAAO;AAAA,EACrC,gBAAgBA,EAAE,WAAWC,CAAc;AAAA,EAC3C,qBAAqBD,EAClB,OAAO,EAAE,SAAS,6BAAA,CAA8B,EAChD,IAAI,EAAE,SAAS,6BAAA,CAA8B,EAC7C,YAAY,EAAE,SAAS,6BAAA,CAA8B,EACrD,GAAG,MAAgB,EAAE,SAAS,6BAAA,CAA8B,EAC5D,SAAA;AACL,CAAC,GAIKE,IAAuB,+BAEvBC,IAAc,CAACC,MACnB,MAAM,QAAQA,CAAG,KAAKA,EAAI,MAAM,CAAAC,MAAS,OAAOA,KAAU,YAAYA,MAAU,IAAI,GAEhFC,IAAs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C,GAAA,EAAO,SAAQ,WAAU,MAAK,UAAS,MAAMrD,GAAsB,YAAYmB,GAC7E,UAAeiC,MAAE,qBAAwB,WAAN,EAAiB,CACvD;AAAA,EAAA,GACF;AAEJ;AACAxC,EAAgB,SAASuC;"}
@@ -13,9 +13,8 @@ import "@gusto/embedded-api/models/errors/sdkvalidationerror";
13
13
  import "@gusto/embedded-api/models/errors/httpclienterrors";
14
14
  import "../../shared/constants.js";
15
15
  import "../../contexts/ComponentAdapter/useComponentContext.js";
16
- import "../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
17
16
  import { retryAsync as T } from "../../helpers/retryAsync.js";
18
- const U = 4, q = 1500, B = (e) => e instanceof w ? e.errors.some((r) => r.category === "invalid_operation") : !1, Z = ({
17
+ const U = 4, q = 1500, B = (e) => e instanceof w ? e.errors.some((r) => r.category === "invalid_operation") : !1, W = ({
19
18
  companyId: e,
20
19
  payrollId: r,
21
20
  employeeUuids: a,
@@ -75,6 +74,6 @@ const U = 4, q = 1500, B = (e) => e instanceof w ? e.errors.some((r) => r.catego
75
74
  };
76
75
  };
77
76
  export {
78
- Z as usePreparedPayrollData
77
+ W as usePreparedPayrollData
79
78
  };
80
79
  //# sourceMappingURL=usePreparedPayrollData.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"usePreparedPayrollData.js","sources":["../../../src/components/Payroll/usePreparedPayrollData.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from 'react'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/payrollshow'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport { useBase } from '../Base'\nimport { retryAsync } from '@/helpers/retryAsync'\n\ninterface UsePreparedPayrollDataParams {\n companyId: string\n payrollId: string\n employeeUuids?: string[]\n sortBy?: string\n onDataReady?: (preparedPayroll: PayrollPrepared) => void\n /**\n * When true, prepare is called without a roster. A transition payroll's roster is fixed by the\n * pay-schedule transition, so the API rejects any `employeeUuids` sent to prepare.\n */\n isTransitionPayroll?: boolean\n}\n\ninterface UsePreparedPayrollDataReturn {\n handlePreparePayroll: () => Promise<void>\n preparedPayroll: PayrollPrepared | undefined\n paySchedule: PayScheduleShow | undefined\n isLoading: boolean\n isPaginating: boolean\n hasInitialData: boolean\n}\n\nconst PREPARE_MAX_ATTEMPTS = 4\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst isPayrollBeingProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\n/**\n * Wraps the prepare-payroll mutation and pay-schedule fetch, retrying while the payroll is still being processed.\n *\n * @remarks\n * Fires the prepare call once on mount, then exposes `handlePreparePayroll` for callers that need to re-prepare\n * (e.g. after sort or pagination changes). Distinguishes initial loading from subsequent pagination via\n * `isLoading` and `isPaginating`, and surfaces the pay schedule for the prepared payroll's pay period.\n *\n * @param params - The company and payroll identifiers, plus optional employee filter, sort, and ready callback.\n * @returns The prepared payroll, its pay schedule, loading flags, and a `handlePreparePayroll` callback to re-run.\n * @internal\n */\nexport const usePreparedPayrollData = ({\n companyId,\n payrollId,\n employeeUuids,\n sortBy,\n onDataReady,\n isTransitionPayroll = false,\n}: UsePreparedPayrollDataParams): UsePreparedPayrollDataReturn => {\n const { mutateAsync: preparePayroll, isPending: isPreparePayrollPending } =\n usePayrollsPrepareMutation()\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const hasInitialDataRef = useRef(false)\n const hasFiredRef = useRef(false)\n const { baseSubmitHandler } = useBase()\n\n const employeeUuidsKey = useMemo(() => employeeUuids?.join(',') ?? '', [employeeUuids])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid,\n },\n )\n\n const executePrepare = useCallback(async () => {\n const result = await preparePayroll({\n request: {\n companyId,\n payrollId,\n sortBy,\n requestBody: {\n employeeUuids: isTransitionPayroll ? undefined : employeeUuids,\n },\n },\n })\n setPreparedPayroll(result.payrollPrepared)\n if (result.payrollPrepared) {\n hasInitialDataRef.current = true\n onDataReady?.(result.payrollPrepared)\n }\n }, [\n companyId,\n payrollId,\n preparePayroll,\n employeeUuidsKey,\n sortBy,\n onDataReady,\n isTransitionPayroll,\n ])\n\n const handlePreparePayroll = useCallback(async () => {\n await baseSubmitHandler(null, () =>\n retryAsync(executePrepare, {\n maxAttempts: PREPARE_MAX_ATTEMPTS,\n delayMs: PREPARE_RETRY_DELAY_MS,\n shouldRetry: isPayrollBeingProcessedError,\n }),\n )\n }, [baseSubmitHandler, executePrepare])\n\n useEffect(() => {\n if (hasFiredRef.current) return\n hasFiredRef.current = true\n void handlePreparePayroll()\n }, [handlePreparePayroll])\n\n const isInitialLoading = isPreparePayrollPending && !hasInitialDataRef.current\n const isPaginating = isPreparePayrollPending && hasInitialDataRef.current\n const isLoading = isInitialLoading || isPayScheduleLoading\n\n return {\n handlePreparePayroll,\n preparedPayroll,\n paySchedule: payScheduleData?.payScheduleShow,\n isLoading,\n isPaginating,\n hasInitialData: hasInitialDataRef.current,\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityError","e","usePreparedPayrollData","companyId","payrollId","employeeUuids","sortBy","onDataReady","isTransitionPayroll","preparePayroll","isPreparePayrollPending","usePayrollsPrepareMutation","preparedPayroll","setPreparedPayroll","useState","hasInitialDataRef","useRef","hasFiredRef","baseSubmitHandler","useBase","employeeUuidsKey","useMemo","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","executePrepare","useCallback","result","handlePreparePayroll","retryAsync","useEffect","isInitialLoading","isPaginating","isLoading"],"mappings":";;;;;;;;;;;;;;;;;AA+BA,MAAMA,IAAuB,GACvBC,IAAyB,MAEzBC,IAA+B,CAACC,MAC9BA,aAAiBC,IAChBD,EAAM,OAAO,KAAK,CAAAE,MAAKA,EAAE,aAAa,mBAAmB,IADP,IAgB9CC,IAAyB,CAAC;AAAA,EACrC,WAAAC;AAAA,EACA,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,QAAAC;AAAA,EACA,aAAAC;AAAA,EACA,qBAAAC,IAAsB;AACxB,MAAkE;AAChE,QAAM,EAAE,aAAaC,GAAgB,WAAWC,EAAA,IAC9CC,EAAA,GACI,CAACC,GAAiBC,CAAkB,IAAIC,EAAA,GACxCC,IAAoBC,EAAO,EAAK,GAChCC,IAAcD,EAAO,EAAK,GAC1B,EAAE,mBAAAE,EAAA,IAAsBC,EAAA,GAExBC,IAAmBC,EAAQ,MAAMhB,GAAe,KAAK,GAAG,KAAK,IAAI,CAACA,CAAa,CAAC,GAEhF,EAAE,MAAMiB,GAAiB,WAAWC,MAAyBC;AAAA,IACjE;AAAA,MACE,WAAArB;AAAA,MACA,eAAeS,GAAiB,WAAW,mBAAmB;AAAA,IAAA;AAAA,IAEhE;AAAA,MACE,SAAS,CAAC,CAACA,GAAiB,WAAW;AAAA,IAAA;AAAA,EACzC,GAGIa,IAAiBC,EAAY,YAAY;AAC7C,UAAMC,IAAS,MAAMlB,EAAe;AAAA,MAClC,SAAS;AAAA,QACP,WAAAN;AAAA,QACA,WAAAC;AAAA,QACA,QAAAE;AAAA,QACA,aAAa;AAAA,UACX,eAAeE,IAAsB,SAAYH;AAAA,QAAA;AAAA,MACnD;AAAA,IACF,CACD;AACD,IAAAQ,EAAmBc,EAAO,eAAe,GACrCA,EAAO,oBACTZ,EAAkB,UAAU,IAC5BR,IAAcoB,EAAO,eAAe;AAAA,EAExC,GAAG;AAAA,IACDxB;AAAA,IACAC;AAAA,IACAK;AAAA,IACAW;AAAA,IACAd;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA,CACD,GAEKoB,IAAuBF,EAAY,YAAY;AACnD,UAAMR;AAAA,MAAkB;AAAA,MAAM,MAC5BW,EAAWJ,GAAgB;AAAA,QACzB,aAAa7B;AAAA,QACb,SAASC;AAAA,QACT,aAAaC;AAAA,MAAA,CACd;AAAA,IAAA;AAAA,EAEL,GAAG,CAACoB,GAAmBO,CAAc,CAAC;AAEtC,EAAAK,EAAU,MAAM;AACd,IAAIb,EAAY,YAChBA,EAAY,UAAU,IACjBW,EAAA;AAAA,EACP,GAAG,CAACA,CAAoB,CAAC;AAEzB,QAAMG,IAAmBrB,KAA2B,CAACK,EAAkB,SACjEiB,IAAetB,KAA2BK,EAAkB,SAC5DkB,IAAYF,KAAoBR;AAEtC,SAAO;AAAA,IACL,sBAAAK;AAAA,IACA,iBAAAhB;AAAA,IACA,aAAaU,GAAiB;AAAA,IAC9B,WAAAW;AAAA,IACA,cAAAD;AAAA,IACA,gBAAgBjB,EAAkB;AAAA,EAAA;AAEtC;"}
1
+ {"version":3,"file":"usePreparedPayrollData.js","sources":["../../../src/components/Payroll/usePreparedPayrollData.ts"],"sourcesContent":["import { useState, useEffect, useCallback, useRef, useMemo } from 'react'\nimport { usePayrollsPrepareMutation } from '@gusto/embedded-api/react-query/payrollsPrepare'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport type { PayrollPrepared } from '@gusto/embedded-api/models/components/payrollshow'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { UnprocessableEntityError } from '@gusto/embedded-api/models/errors/unprocessableentityerror'\nimport { useBase } from '../Base'\nimport { retryAsync } from '@/helpers/retryAsync'\n\ninterface UsePreparedPayrollDataParams {\n companyId: string\n payrollId: string\n employeeUuids?: string[]\n sortBy?: string\n onDataReady?: (preparedPayroll: PayrollPrepared) => void\n /**\n * When true, prepare is called without a roster. A transition payroll's roster is fixed by the\n * pay-schedule transition, so the API rejects any `employeeUuids` sent to prepare.\n */\n isTransitionPayroll?: boolean\n}\n\ninterface UsePreparedPayrollDataReturn {\n handlePreparePayroll: () => Promise<void>\n preparedPayroll: PayrollPrepared | undefined\n paySchedule: PayScheduleShow | undefined\n isLoading: boolean\n isPaginating: boolean\n hasInitialData: boolean\n}\n\nconst PREPARE_MAX_ATTEMPTS = 4\nconst PREPARE_RETRY_DELAY_MS = 1500\n\nconst isPayrollBeingProcessedError = (error: unknown): boolean => {\n if (!(error instanceof UnprocessableEntityError)) return false\n return error.errors.some(e => e.category === 'invalid_operation')\n}\n\n/**\n * Wraps the prepare-payroll mutation and pay-schedule fetch, retrying while the payroll is still being processed.\n *\n * @remarks\n * Fires the prepare call once on mount, then exposes `handlePreparePayroll` for callers that need to re-prepare\n * (e.g. after sort or pagination changes). Distinguishes initial loading from subsequent pagination via\n * `isLoading` and `isPaginating`, and surfaces the pay schedule for the prepared payroll's pay period.\n *\n * @param params - The company and payroll identifiers, plus optional employee filter, sort, and ready callback.\n * @returns The prepared payroll, its pay schedule, loading flags, and a `handlePreparePayroll` callback to re-run.\n * @internal\n */\nexport const usePreparedPayrollData = ({\n companyId,\n payrollId,\n employeeUuids,\n sortBy,\n onDataReady,\n isTransitionPayroll = false,\n}: UsePreparedPayrollDataParams): UsePreparedPayrollDataReturn => {\n const { mutateAsync: preparePayroll, isPending: isPreparePayrollPending } =\n usePayrollsPrepareMutation()\n const [preparedPayroll, setPreparedPayroll] = useState<PayrollPrepared | undefined>()\n const hasInitialDataRef = useRef(false)\n const hasFiredRef = useRef(false)\n const { baseSubmitHandler } = useBase()\n\n const employeeUuidsKey = useMemo(() => employeeUuids?.join(',') ?? '', [employeeUuids])\n\n const { data: payScheduleData, isLoading: isPayScheduleLoading } = usePaySchedulesGet(\n {\n companyId,\n payScheduleId: preparedPayroll?.payPeriod?.payScheduleUuid || '',\n },\n {\n enabled: !!preparedPayroll?.payPeriod?.payScheduleUuid,\n },\n )\n\n const executePrepare = useCallback(async () => {\n const result = await preparePayroll({\n request: {\n companyId,\n payrollId,\n sortBy,\n requestBody: {\n employeeUuids: isTransitionPayroll ? undefined : employeeUuids,\n },\n },\n })\n setPreparedPayroll(result.payrollPrepared)\n if (result.payrollPrepared) {\n hasInitialDataRef.current = true\n onDataReady?.(result.payrollPrepared)\n }\n }, [\n companyId,\n payrollId,\n preparePayroll,\n employeeUuidsKey,\n sortBy,\n onDataReady,\n isTransitionPayroll,\n ])\n\n const handlePreparePayroll = useCallback(async () => {\n await baseSubmitHandler(null, () =>\n retryAsync(executePrepare, {\n maxAttempts: PREPARE_MAX_ATTEMPTS,\n delayMs: PREPARE_RETRY_DELAY_MS,\n shouldRetry: isPayrollBeingProcessedError,\n }),\n )\n }, [baseSubmitHandler, executePrepare])\n\n useEffect(() => {\n if (hasFiredRef.current) return\n hasFiredRef.current = true\n void handlePreparePayroll()\n }, [handlePreparePayroll])\n\n const isInitialLoading = isPreparePayrollPending && !hasInitialDataRef.current\n const isPaginating = isPreparePayrollPending && hasInitialDataRef.current\n const isLoading = isInitialLoading || isPayScheduleLoading\n\n return {\n handlePreparePayroll,\n preparedPayroll,\n paySchedule: payScheduleData?.payScheduleShow,\n isLoading,\n isPaginating,\n hasInitialData: hasInitialDataRef.current,\n }\n}\n"],"names":["PREPARE_MAX_ATTEMPTS","PREPARE_RETRY_DELAY_MS","isPayrollBeingProcessedError","error","UnprocessableEntityError","e","usePreparedPayrollData","companyId","payrollId","employeeUuids","sortBy","onDataReady","isTransitionPayroll","preparePayroll","isPreparePayrollPending","usePayrollsPrepareMutation","preparedPayroll","setPreparedPayroll","useState","hasInitialDataRef","useRef","hasFiredRef","baseSubmitHandler","useBase","employeeUuidsKey","useMemo","payScheduleData","isPayScheduleLoading","usePaySchedulesGet","executePrepare","useCallback","result","handlePreparePayroll","retryAsync","useEffect","isInitialLoading","isPaginating","isLoading"],"mappings":";;;;;;;;;;;;;;;;AA+BA,MAAMA,IAAuB,GACvBC,IAA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