@gusto/embedded-react-sdk 0.55.2 → 0.55.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +41 -0
- package/dist/components/Common/DataView/DataCards/DataCards.d.ts +2 -1
- package/dist/components/Common/DataView/DataCards/DataCards.js +63 -54
- package/dist/components/Common/DataView/DataCards/DataCards.js.map +1 -1
- package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js +14 -12
- package/dist/components/Common/DataView/DataCards/DataCards.module.scss.js.map +1 -1
- package/dist/components/Common/DataView/DataTable/DataTable.d.ts +2 -1
- package/dist/components/Common/DataView/DataTable/DataTable.js +75 -66
- package/dist/components/Common/DataView/DataTable/DataTable.js.map +1 -1
- package/dist/components/Common/DataView/DataTable/DataTable.module.scss.js +8 -4
- package/dist/components/Common/DataView/DataTable/DataTable.module.scss.js.map +1 -1
- package/dist/components/Common/DataView/DataView.js +18 -17
- package/dist/components/Common/DataView/DataView.js.map +1 -1
- package/dist/components/Common/FieldLayout/FieldLayout.js +6 -6
- package/dist/components/Common/Fieldset/Fieldset.js +6 -6
- package/dist/components/Common/HorizontalFieldLayout/HorizontalFieldLayout.js +6 -6
- package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.js +58 -49
- package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.js.map +1 -1
- package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.module.scss.js +14 -10
- package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.module.scss.js.map +1 -1
- package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBoxTypes.d.ts +4 -0
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -4
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -6
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -4
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.d.ts +4 -0
- package/dist/components/Company/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/List.js +11 -8
- package/dist/components/Company/DocumentSigner/DocumentList/List.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +5 -6
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +6 -7
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -4
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/List.js +27 -25
- package/dist/components/Company/Locations/LocationsList/List.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/LocationsList.js +41 -36
- package/dist/components/Company/Locations/LocationsList/LocationsList.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.d.ts +1 -0
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -4
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +3 -4
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.d.ts +9 -2
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js +19 -18
- package/dist/components/Company/StateTaxes/StateTaxesForm/Form.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +63 -62
- package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -4
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/TaxRateManagement/AddTaxRateDialog.js +69 -65
- package/dist/components/Company/StateTaxes/TaxRateManagement/AddTaxRateDialog.js.map +1 -1
- package/dist/components/Company/StateTaxes/TaxRateManagement/context.js +3 -4
- package/dist/components/Company/StateTaxes/TaxRateManagement/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/TaxRateManagement/toHistoryRows.js +30 -23
- package/dist/components/Company/StateTaxes/TaxRateManagement/toHistoryRows.js.map +1 -1
- package/dist/components/Company/StateTaxes/shared/RequirementFields.d.ts +8 -4
- package/dist/components/Company/StateTaxes/shared/RequirementFields.js +13 -12
- package/dist/components/Company/StateTaxes/shared/RequirementFields.js.map +1 -1
- package/dist/components/Company/StateTaxes/shared/prepareRequirements.d.ts +29 -0
- package/dist/components/Company/StateTaxes/shared/prepareRequirements.js +24 -0
- package/dist/components/Company/StateTaxes/shared/prepareRequirements.js.map +1 -0
- package/dist/components/Company/StateTaxes/shared/prepareRequirements.test.d.ts +1 -0
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsList.js +68 -55
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsList.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.js +36 -35
- package/dist/components/Contractor/Payments/PaymentsList/PaymentsListPresentation.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +116 -116
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/DocumentList.d.ts +4 -0
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/DocumentList.js +19 -19
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/DocumentList.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/List.js +16 -13
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/List.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -4
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.d.ts +4 -0
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js.map +1 -1
- package/dist/components/Employee/Paystubs/management/PaystubsCard/PaystubsCard.js +84 -96
- package/dist/components/Employee/Paystubs/management/PaystubsCard/PaystubsCard.js.map +1 -1
- package/dist/components/Flow/Flow.js +22 -22
- package/dist/components/Flow/Flow.js.map +1 -1
- package/dist/components/Flow/useFlow.js +3 -3
- package/dist/components/InformationRequests/InformationRequests.d.ts +1 -1
- package/dist/components/InformationRequests/InformationRequests.js +68 -53
- package/dist/components/InformationRequests/InformationRequests.js.map +1 -1
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +2 -3
- package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +87 -81
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.d.ts +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js +86 -67
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleCreation/OffCycleCreationTypes.d.ts +4 -0
- package/dist/components/Payroll/OffCycleDeductionsSetting/OffCycleDeductionsSetting.d.ts +1 -1
- package/dist/components/Payroll/OffCycleDeductionsSetting/OffCycleDeductionsSetting.js +26 -21
- package/dist/components/Payroll/OffCycleDeductionsSetting/OffCycleDeductionsSetting.js.map +1 -1
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.d.ts +8 -1
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js +29 -17
- package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormPresentation.js.map +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.js +21 -18
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.js.map +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.module.scss.js +9 -7
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTable.module.scss.js.map +1 -1
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.d.ts +2 -0
- package/dist/components/Payroll/OffCycleTaxWithholdingTable/OffCycleTaxWithholdingTableTypes.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +200 -199
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.d.ts +3 -2
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +32 -32
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +254 -243
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistory.js +83 -76
- package/dist/components/Payroll/PayrollHistory/PayrollHistory.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +23 -22
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollList.js +108 -97
- package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js +38 -37
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.d.ts +8 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js +196 -174
- package/dist/components/Payroll/PayrollOverview/PayrollOverview.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.d.ts +3 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js +173 -163
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/helpers.d.ts +0 -15
- package/dist/components/Payroll/helpers.js +13 -18
- package/dist/components/Payroll/helpers.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +8 -9
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/helpers/openPdfInNewTab.d.ts +15 -0
- package/dist/helpers/openPdfInNewTab.js +28 -0
- package/dist/helpers/openPdfInNewTab.js.map +1 -0
- package/dist/i18n/en/Company.DocumentList.json.js +34 -32
- package/dist/i18n/en/Company.DocumentList.json.js.map +1 -1
- package/dist/i18n/en/Company.StateTaxes.json.js +1 -1
- package/dist/i18n/en/Employee.DocumentSigner.json.js +24 -22
- package/dist/i18n/en/Employee.DocumentSigner.json.js.map +1 -1
- package/dist/i18n/en/Payroll.OffCycleCreation.json.js +11 -9
- package/dist/i18n/en/Payroll.OffCycleCreation.json.js.map +1 -1
- package/dist/i18n/en/Payroll.OffCycleTaxWithholding.json.js +7 -7
- package/dist/i18n/en/Payroll.PayrollEditEmployee.json.js +29 -27
- package/dist/i18n/en/Payroll.PayrollEditEmployee.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollOverview.json.js +41 -39
- package/dist/i18n/en/Payroll.PayrollOverview.json.js.map +1 -1
- package/dist/i18n/types.d.ts +331 -1
- package/dist/style.css +1 -1
- package/package.json +21 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Flow.js","sources":["../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import { Suspense } from 'react'\nimport { useMachine } from 'react-robot'\nimport { type Machine, type SendFunction } from 'robot3'\nimport type { OnEventType } from '../Base/useBase'\nimport { Flex } from '../Common/Flex'\nimport type { FlowContextInterface } from './useFlow'\nimport { FlowContext } from './useFlow'\nimport { FlowHeader } from './FlowHeader'\nimport { useLoadingIndicator } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\nimport { type EventType } from '@/shared/constants'\n\n/**\n * Header chrome is short (a back-button row is the only header that can suspend),\n * so the header fallback matches its height rather than the full content loader —\n * this keeps the step body at the same level, avoiding a layout shift.\n */\nconst HEADER_LOADER_HEIGHT = 40\n\n/**\n * Fallback for the {@link FlowHeader} Suspense boundary. FlowHeader calls\n * `useTranslation` and renders above the active step's own boundary, so a\n * first-time i18n namespace load during a synchronous transition would otherwise\n * throw React #426. Reuses the SDK loading indicator sized to the header height\n * so the placeholder matches the header chrome and the step body doesn't shift.\n * (Step components manage their own loading via `BaseComponent`/`BaseBoundaries`.)\n */\nfunction FlowHeaderFallback() {\n const { LoadingIndicator } = useLoadingIndicator()\n return <LoadingIndicator height={HEADER_LOADER_HEIGHT} />\n}\n\ntype FlowProps<M extends Machine> = {\n machine: M\n onEvent: OnEventType<EventType, unknown>\n}\n\n/**\n * Drives a robot3 state machine that orchestrates a multi-step SDK flow, rendering the active\n * step component inside a {@link FlowContext} provider with optional header chrome above it.\n *\n * @remarks\n * Re-emits every event produced by the state machine (or the active child machine, when one is\n * nested) to the upstream `onEvent` callback, so the consuming flow component (e.g. `PayrollFlow`,\n * `OnboardingFlow`) can forward them to partner code. The set of event types is defined by the\n * machine itself rather than a fixed catalogue.\n *\n * @typeParam M - The robot3 {@link Machine} type whose context extends {@link FlowContextInterface}.\n * @param props - Component props: the `machine` instance to run and an `onEvent` handler that\n * receives every event the machine emits.\n * @returns A React element rendering the machine's current `component` inside the flow context,\n * with a {@link FlowHeader} above it.\n * @internal\n */\nexport const Flow = <M extends Machine<object, FlowContextInterface>>({\n onEvent,\n machine,\n}: FlowProps<M>) => {\n const [current, send, service] = useMachine(machine, {\n onEvent: handleEvent,\n component: null,\n })\n\n function handleEvent(type: EventType, data: unknown): void {\n const event = { type, payload: data }\n const sendFn = send as SendFunction<string>\n //When dealing with nested state machine, correct machine needs to recieve an event\n if (service.child) {\n ;(service.child.send as SendFunction<string>)(event)\n } else {\n sendFn(event)\n }\n // Pass event upstream - onEvent can be optional on Flow component\n onEvent(type, data)\n }\n\n const Component = current.context.component\n\n return (\n <Flex>\n <FlowContext.Provider\n value={{\n ...current.context,\n }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n <Suspense fallback={<FlowHeaderFallback />}>\n <FlowHeader />\n </Suspense>\n {Component && <Component />}
|
|
1
|
+
{"version":3,"file":"Flow.js","sources":["../../../src/components/Flow/Flow.tsx"],"sourcesContent":["import { Suspense } from 'react'\nimport { useMachine } from 'react-robot'\nimport { type Machine, type SendFunction } from 'robot3'\nimport type { OnEventType } from '../Base/useBase'\nimport { Flex } from '../Common/Flex'\nimport type { FlowContextInterface } from './useFlow'\nimport { FlowContext } from './useFlow'\nimport { FlowHeader } from './FlowHeader'\nimport { useLoadingIndicator } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\nimport { type EventType } from '@/shared/constants'\n\n/**\n * Header chrome is short (a back-button row is the only header that can suspend),\n * so the header fallback matches its height rather than the full content loader —\n * this keeps the step body at the same level, avoiding a layout shift.\n */\nconst HEADER_LOADER_HEIGHT = 40\n\n/**\n * Fallback for the {@link FlowHeader} Suspense boundary. FlowHeader calls\n * `useTranslation` and renders above the active step's own boundary, so a\n * first-time i18n namespace load during a synchronous transition would otherwise\n * throw React #426. Reuses the SDK loading indicator sized to the header height\n * so the placeholder matches the header chrome and the step body doesn't shift.\n * (Step components manage their own loading via `BaseComponent`/`BaseBoundaries`.)\n */\nfunction FlowHeaderFallback() {\n const { LoadingIndicator } = useLoadingIndicator()\n return <LoadingIndicator height={HEADER_LOADER_HEIGHT} />\n}\n\ntype FlowProps<M extends Machine> = {\n machine: M\n onEvent: OnEventType<EventType, unknown>\n}\n\n/**\n * Drives a robot3 state machine that orchestrates a multi-step SDK flow, rendering the active\n * step component inside a {@link FlowContext} provider with optional header chrome above it.\n *\n * @remarks\n * Re-emits every event produced by the state machine (or the active child machine, when one is\n * nested) to the upstream `onEvent` callback, so the consuming flow component (e.g. `PayrollFlow`,\n * `OnboardingFlow`) can forward them to partner code. The set of event types is defined by the\n * machine itself rather than a fixed catalogue.\n *\n * @typeParam M - The robot3 {@link Machine} type whose context extends {@link FlowContextInterface}.\n * @param props - Component props: the `machine` instance to run and an `onEvent` handler that\n * receives every event the machine emits.\n * @returns A React element rendering the machine's current `component` inside the flow context,\n * with a {@link FlowHeader} above it.\n * @internal\n */\nexport const Flow = <M extends Machine<object, FlowContextInterface>>({\n onEvent,\n machine,\n}: FlowProps<M>) => {\n const { LoadingIndicator } = useLoadingIndicator()\n const [current, send, service] = useMachine(machine, {\n onEvent: handleEvent,\n component: null,\n })\n\n function handleEvent(type: EventType, data: unknown): void {\n const event = { type, payload: data }\n const sendFn = send as SendFunction<string>\n //When dealing with nested state machine, correct machine needs to recieve an event\n if (service.child) {\n ;(service.child.send as SendFunction<string>)(event)\n } else {\n sendFn(event)\n }\n // Pass event upstream - onEvent can be optional on Flow component\n onEvent(type, data)\n }\n\n const Component = current.context.component\n\n return (\n <Flex>\n <FlowContext.Provider\n value={{\n ...current.context,\n }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n <Suspense fallback={<FlowHeaderFallback />}>\n <FlowHeader />\n </Suspense>\n <Suspense fallback={<LoadingIndicator />}>{Component && <Component />}</Suspense>\n </Flex>\n </FlowContext.Provider>\n </Flex>\n )\n}\n"],"names":["HEADER_LOADER_HEIGHT","FlowHeaderFallback","LoadingIndicator","useLoadingIndicator","jsx","Flow","onEvent","machine","current","send","service","useMachine","handleEvent","type","data","event","sendFn","Component","Flex","FlowContext","jsxs","Suspense","FlowHeader"],"mappings":";;;;;;;AAgBA,MAAMA,IAAuB;AAU7B,SAASC,IAAqB;AAC5B,QAAM,EAAE,kBAAAC,EAAA,IAAqBC,EAAA;AAC7B,SAAO,gBAAAC,EAACF,GAAA,EAAiB,QAAQF,EAAA,CAAsB;AACzD;AAwBO,MAAMK,IAAO,CAAkD;AAAA,EACpE,SAAAC;AAAA,EACA,SAAAC;AACF,MAAoB;AAClB,QAAM,EAAE,kBAAAL,EAAA,IAAqBC,EAAA,GACvB,CAACK,GAASC,GAAMC,CAAO,IAAIC,EAAWJ,GAAS;AAAA,IACnD,SAASK;AAAA,IACT,WAAW;AAAA,EAAA,CACZ;AAED,WAASA,EAAYC,GAAiBC,GAAqB;AACzD,UAAMC,IAAQ,EAAE,MAAAF,GAAM,SAASC,EAAA,GACzBE,IAASP;AAEf,IAAIC,EAAQ,QACRA,EAAQ,MAAM,KAA8BK,CAAK,IAEnDC,EAAOD,CAAK,GAGdT,EAAQO,GAAMC,CAAI;AAAA,EACpB;AAEA,QAAMG,IAAYT,EAAQ,QAAQ;AAElC,2BACGU,GAAA,EACC,UAAA,gBAAAd;AAAA,IAACe,EAAY;AAAA,IAAZ;AAAA,MACC,OAAO;AAAA,QACL,GAAGX,EAAQ;AAAA,MAAA;AAAA,MAGb,UAAA,gBAAAY,EAACF,GAAA,EAAK,eAAc,UAAS,KAAK,IAChC,UAAA;AAAA,QAAA,gBAAAd,EAACiB,KAAS,UAAU,gBAAAjB,EAACH,KAAmB,GACtC,UAAA,gBAAAG,EAACkB,KAAW,EAAA,CACd;AAAA,QACA,gBAAAlB,EAACiB,KAAS,UAAU,gBAAAjB,EAACF,KAAiB,GAAK,UAAAe,KAAa,gBAAAb,EAACa,GAAA,CAAA,CAAU,EAAA,CAAG;AAAA,MAAA,EAAA,CACxE;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
const r =
|
|
1
|
+
import { useContext as e, createContext as t } from "react";
|
|
2
|
+
const r = t(null);
|
|
3
3
|
function u() {
|
|
4
|
-
const o =
|
|
4
|
+
const o = e(r);
|
|
5
5
|
if (!o)
|
|
6
6
|
throw new Error("useFlow used outside provider");
|
|
7
7
|
return o;
|
|
@@ -60,4 +60,4 @@ export interface InformationRequestsFlowProps extends Omit<BaseComponentInterfac
|
|
|
60
60
|
* }
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
|
-
export declare function InformationRequestsFlow({
|
|
63
|
+
export declare function InformationRequestsFlow({ FallbackComponent, LoaderComponent, ...props }: InformationRequestsFlowProps): import("react").JSX.Element;
|
|
@@ -1,94 +1,109 @@
|
|
|
1
|
-
import { jsx as t, jsxs as
|
|
2
|
-
import { createMachine as
|
|
3
|
-
import { useMachine as
|
|
4
|
-
import { useState as
|
|
5
|
-
import { useTranslation as
|
|
6
|
-
import { informationRequestsMachine as
|
|
7
|
-
import { BaseBoundaries as
|
|
1
|
+
import { jsx as t, jsxs as Q } from "react/jsx-runtime";
|
|
2
|
+
import { createMachine as U } from "robot3";
|
|
3
|
+
import { useMachine as k } from "react-robot";
|
|
4
|
+
import { useState as I, useCallback as p, useMemo as P, Suspense as O } from "react";
|
|
5
|
+
import { useTranslation as g } from "react-i18next";
|
|
6
|
+
import { informationRequestsMachine as j } from "./informationRequestsStateMachine.js";
|
|
7
|
+
import { BaseBoundaries as h } from "../Base/Base.js";
|
|
8
8
|
import "../Base/useBase.js";
|
|
9
|
-
import { Flex as
|
|
10
|
-
import { useComponentContext as
|
|
9
|
+
import { Flex as w } from "../Common/Flex/Flex.js";
|
|
10
|
+
import { useComponentContext as B } from "../../contexts/ComponentAdapter/useComponentContext.js";
|
|
11
11
|
import { FlowContext as $ } from "../Flow/useFlow.js";
|
|
12
|
-
import { useComponentDictionary as
|
|
13
|
-
import { informationRequestEvents as
|
|
12
|
+
import { useComponentDictionary as z, useI18n as L } from "../../i18n/I18n.js";
|
|
13
|
+
import { informationRequestEvents as l } from "../../shared/constants.js";
|
|
14
14
|
import { InformationRequestList as Y } from "./InformationRequestList/InformationRequestList.js";
|
|
15
|
-
const
|
|
16
|
-
function
|
|
17
|
-
companyId:
|
|
18
|
-
dictionary:
|
|
19
|
-
withAlert:
|
|
20
|
-
onEvent:
|
|
15
|
+
const M = "informationRequestResponded";
|
|
16
|
+
function G({
|
|
17
|
+
companyId: o,
|
|
18
|
+
dictionary: s,
|
|
19
|
+
withAlert: r = !0,
|
|
20
|
+
onEvent: x = () => {
|
|
21
21
|
},
|
|
22
|
-
LoaderComponent:
|
|
22
|
+
LoaderComponent: a
|
|
23
23
|
}) {
|
|
24
|
-
|
|
25
|
-
const { t:
|
|
24
|
+
z("InformationRequests", s), L("InformationRequests");
|
|
25
|
+
const { t: f } = g("InformationRequests"), { Modal: A, LoadingSpinner: u, Alert: F, Text: N } = B(), [T, m] = I(!1), [_, d] = I({
|
|
26
26
|
nextAlertId: 0,
|
|
27
27
|
alerts: []
|
|
28
|
-
}),
|
|
29
|
-
|
|
30
|
-
...
|
|
31
|
-
alerts:
|
|
28
|
+
}), q = p((e) => {
|
|
29
|
+
d((n) => ({
|
|
30
|
+
...n,
|
|
31
|
+
alerts: n.alerts.filter((b) => b.id !== e)
|
|
32
32
|
}));
|
|
33
33
|
}, []), S = p(() => {
|
|
34
|
-
|
|
34
|
+
d((e) => ({
|
|
35
35
|
nextAlertId: e.nextAlertId + 1,
|
|
36
36
|
alerts: [{ id: e.nextAlertId }, ...e.alerts]
|
|
37
37
|
}));
|
|
38
|
-
}, []),
|
|
39
|
-
() =>
|
|
38
|
+
}, []), C = P(
|
|
39
|
+
() => U(
|
|
40
40
|
"list",
|
|
41
|
-
|
|
41
|
+
j,
|
|
42
42
|
() => ({
|
|
43
43
|
component: null,
|
|
44
|
-
companyId:
|
|
45
|
-
onEvent:
|
|
46
|
-
LoaderComponent:
|
|
44
|
+
companyId: o,
|
|
45
|
+
onEvent: i,
|
|
46
|
+
LoaderComponent: a
|
|
47
47
|
})
|
|
48
48
|
),
|
|
49
|
-
[
|
|
50
|
-
), [
|
|
51
|
-
function
|
|
52
|
-
|
|
49
|
+
[o, a]
|
|
50
|
+
), [R, D] = k(C);
|
|
51
|
+
function i(e, n) {
|
|
52
|
+
D({ type: e, payload: n }), e === l.INFORMATION_REQUEST_RESPOND && m(!0), (e === l.INFORMATION_REQUEST_FORM_CANCEL || e === l.INFORMATION_REQUEST_FORM_DONE) && m(!1), e === l.INFORMATION_REQUEST_FORM_DONE && r && S(), x(e, n);
|
|
53
53
|
}
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
},
|
|
54
|
+
const v = () => {
|
|
55
|
+
m(!1);
|
|
56
|
+
}, c = R.context.component, E = c?.Footer || void 0;
|
|
57
57
|
return /* @__PURE__ */ t(
|
|
58
58
|
$.Provider,
|
|
59
59
|
{
|
|
60
60
|
value: {
|
|
61
|
-
...
|
|
62
|
-
onEvent:
|
|
61
|
+
...R.context,
|
|
62
|
+
onEvent: i
|
|
63
63
|
},
|
|
64
|
-
children: /* @__PURE__ */
|
|
65
|
-
|
|
66
|
-
|
|
64
|
+
children: /* @__PURE__ */ Q(w, { flexDirection: "column", gap: 32, children: [
|
|
65
|
+
r && _.alerts.map((e) => /* @__PURE__ */ t(
|
|
66
|
+
F,
|
|
67
67
|
{
|
|
68
68
|
status: "success",
|
|
69
|
-
label:
|
|
69
|
+
label: f(`alerts.${M}.title`),
|
|
70
70
|
onDismiss: () => {
|
|
71
|
-
|
|
71
|
+
q(e.id);
|
|
72
72
|
},
|
|
73
|
-
children: /* @__PURE__ */ t(
|
|
73
|
+
children: /* @__PURE__ */ t(N, { children: f(`alerts.${M}.description`) })
|
|
74
74
|
},
|
|
75
75
|
e.id
|
|
76
76
|
)),
|
|
77
|
-
/* @__PURE__ */ t(
|
|
77
|
+
/* @__PURE__ */ t(O, { fallback: /* @__PURE__ */ t(u, {}), children: /* @__PURE__ */ t(Y, { companyId: o, onEvent: i }) }),
|
|
78
78
|
/* @__PURE__ */ t(
|
|
79
|
-
|
|
79
|
+
A,
|
|
80
80
|
{
|
|
81
|
-
isOpen:
|
|
82
|
-
onClose:
|
|
83
|
-
footer:
|
|
84
|
-
children:
|
|
81
|
+
isOpen: T,
|
|
82
|
+
onClose: v,
|
|
83
|
+
footer: E && /* @__PURE__ */ t(h, { LoaderComponent: a, children: /* @__PURE__ */ t(O, { fallback: /* @__PURE__ */ t(u, { size: "sm" }), children: /* @__PURE__ */ t(E, { onEvent: i }) }) }),
|
|
84
|
+
children: c && /* @__PURE__ */ t(c, {})
|
|
85
85
|
}
|
|
86
86
|
)
|
|
87
87
|
] })
|
|
88
88
|
}
|
|
89
89
|
);
|
|
90
90
|
}
|
|
91
|
+
function ie({
|
|
92
|
+
FallbackComponent: o,
|
|
93
|
+
LoaderComponent: s,
|
|
94
|
+
...r
|
|
95
|
+
}) {
|
|
96
|
+
return /* @__PURE__ */ t(
|
|
97
|
+
h,
|
|
98
|
+
{
|
|
99
|
+
componentName: "InformationRequests",
|
|
100
|
+
FallbackComponent: o,
|
|
101
|
+
LoaderComponent: s,
|
|
102
|
+
children: /* @__PURE__ */ t(G, { LoaderComponent: s, ...r })
|
|
103
|
+
}
|
|
104
|
+
);
|
|
105
|
+
}
|
|
91
106
|
export {
|
|
92
|
-
|
|
107
|
+
ie as InformationRequestsFlow
|
|
93
108
|
};
|
|
94
109
|
//# sourceMappingURL=InformationRequests.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InformationRequests.js","sources":["../../../src/components/InformationRequests/InformationRequests.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMachine } from 'react-robot'\nimport { Suspense, useCallback, useMemo, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { InformationRequestList } from './InformationRequestList'\nimport { informationRequestsMachine } from './informationRequestsStateMachine'\nimport { type InformationRequestsContextInterface } from './InformationRequestsComponents'\nimport { BaseBoundaries, type BaseComponentInterface } from '@/components/Base'\nimport { Flex } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { FlowContext } from '@/components/Flow/useFlow'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { informationRequestEvents, type EventType } from '@/shared/constants'\n\ninterface SubmissionAlert {\n id: number\n}\n\ninterface SubmissionAlertState {\n nextAlertId: number\n alerts: SubmissionAlert[]\n}\n\n/**\n * Props for {@link InformationRequestsFlow}.\n *\n * @public\n */\nexport interface InformationRequestsFlowProps extends Omit<\n BaseComponentInterface<'InformationRequests'>,\n 'onEvent'\n> {\n /** The associated company identifier. */\n companyId: string\n /**\n * When `true` (default), the submission success alert is rendered at the top of this component.\n * Set to `false` when embedding in a parent that renders the alert elsewhere.\n */\n withAlert?: boolean\n /** Callback invoked when the flow or its blocks emit an event. */\n onEvent?: BaseComponentInterface['onEvent']\n}\n\nconst ALERT_TYPE = 'informationRequestResponded' as const\n\n/**\n * Hub for viewing and responding to outstanding information requests from Gusto.\n *\n * @remarks\n * Renders the list of open and submitted information requests for a company and hosts the response form in a modal.\n * On successful submit, a dismissible success alert appears at the top of the list (when `withAlert` is `true`) and the modal closes.\n *\n * Information requests can also block payroll processing; in that case they are surfaced inline within\n * `Payroll.PayrollBlockerList`, which embeds this flow with `withAlert={false}` so the blocker list owns the alert UX.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `informationRequest/respond` | Fired when the user clicks \"Respond\" on a request and the form modal opens | `{ requestId: string }` |\n * | `informationRequest/form/done` | Fired when an information request is successfully submitted | Response from the Submit information request endpoint |\n * | `informationRequest/form/cancel` | Fired when the user cancels the response form (closes the modal without submitting) | — |\n *\n * Each piece is also exported as a standalone block (see the Blocks\n * table) for composing a custom workflow when this orchestration is the wrong\n * fit. See the\n * {@link https://sdk.gusto.com/docs/guides/integration-guide/composition | Composition guide}\n * for how to recompose these blocks into your own flow.\n *\n * @components\n * - {@link InformationRequestList}\n * - {@link InformationRequestForm}\n *\n * @param props - See {@link InformationRequestsFlowProps}.\n * @returns The information requests flow surface.\n * @public\n *\n * @example\n * ```tsx title=\"App.tsx\"\n * import { InformationRequests } from '@gusto/embedded-react-sdk'\n *\n * function MyApp() {\n * return (\n * <InformationRequests.InformationRequestsFlow\n * companyId=\"a007e1ab-3595-43c2-ab4b-af7a5af2e365\"\n * onEvent={() => {}}\n * />\n * )\n * }\n * ```\n */\nexport function InformationRequestsFlow({\n companyId,\n dictionary,\n withAlert = true,\n onEvent = () => {},\n LoaderComponent,\n}: InformationRequestsFlowProps) {\n useComponentDictionary('InformationRequests', dictionary)\n useI18n('InformationRequests')\n const { t } = useTranslation('InformationRequests')\n const { Modal, LoadingSpinner, Alert, Text } = useComponentContext()\n const [isModalOpen, setIsModalOpen] = useState(false)\n const [alertState, setAlertState] = useState<SubmissionAlertState>({\n nextAlertId: 0,\n alerts: [],\n })\n\n const handleDismissAlert = useCallback((alertId: number) => {\n setAlertState(prev => ({\n ...prev,\n alerts: prev.alerts.filter(alert => alert.id !== alertId),\n }))\n }, [])\n\n const addSubmissionAlert = useCallback(() => {\n setAlertState(prev => ({\n nextAlertId: prev.nextAlertId + 1,\n alerts: [{ id: prev.nextAlertId }, ...prev.alerts],\n }))\n }, [])\n\n const informationRequestsMachineInstance = useMemo(\n () =>\n createMachine(\n 'list',\n informationRequestsMachine,\n (): InformationRequestsContextInterface => ({\n component: null,\n companyId,\n onEvent: handleEvent,\n LoaderComponent,\n }),\n ),\n [companyId, LoaderComponent],\n )\n const [current, send] = useMachine(informationRequestsMachineInstance)\n\n function handleEvent(type: EventType, data?: unknown) {\n send({ type, payload: data })\n\n if (type === informationRequestEvents.INFORMATION_REQUEST_RESPOND) {\n setIsModalOpen(true)\n }\n\n if (\n type === informationRequestEvents.INFORMATION_REQUEST_FORM_CANCEL ||\n type === informationRequestEvents.INFORMATION_REQUEST_FORM_DONE\n ) {\n setIsModalOpen(false)\n }\n\n if (type === informationRequestEvents.INFORMATION_REQUEST_FORM_DONE && withAlert) {\n addSubmissionAlert()\n }\n\n onEvent(type, data)\n }\n\n const handleCloseModal = () => {\n setIsModalOpen(false)\n }\n\n const CurrentComponent = current.context.component\n const Footer = CurrentComponent?.Footer || undefined\n\n return (\n <FlowContext.Provider\n value={{\n ...current.context,\n onEvent: handleEvent,\n }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {withAlert &&\n alertState.alerts.map(alert => (\n <Alert\n key={alert.id}\n status=\"success\"\n label={t(`alerts.${ALERT_TYPE}.title`)}\n onDismiss={() => {\n handleDismissAlert(alert.id)\n }}\n >\n <Text>{t(`alerts.${ALERT_TYPE}.description`)}</Text>\n </Alert>\n ))}\n\n <Suspense fallback={<LoadingSpinner />}>\n <InformationRequestList companyId={companyId} onEvent={handleEvent} />\n </Suspense>\n <Modal\n isOpen={isModalOpen}\n onClose={handleCloseModal}\n footer={\n Footer && (\n <BaseBoundaries LoaderComponent={LoaderComponent}>\n <Suspense fallback={<LoadingSpinner size=\"sm\" />}>\n <Footer onEvent={handleEvent} />\n </Suspense>\n </BaseBoundaries>\n )\n }\n >\n {CurrentComponent && <CurrentComponent />}\n </Modal>\n </Flex>\n </FlowContext.Provider>\n )\n}\n"],"names":["ALERT_TYPE","InformationRequestsFlow","companyId","dictionary","withAlert","onEvent","LoaderComponent","useComponentDictionary","useI18n","t","useTranslation","Modal","LoadingSpinner","Alert","Text","useComponentContext","isModalOpen","setIsModalOpen","useState","alertState","setAlertState","handleDismissAlert","useCallback","alertId","prev","alert","addSubmissionAlert","informationRequestsMachineInstance","useMemo","createMachine","informationRequestsMachine","handleEvent","current","send","useMachine","type","data","informationRequestEvents","handleCloseModal","CurrentComponent","Footer","jsx","FlowContext","jsxs","Flex","Suspense","InformationRequestList","BaseBoundaries"],"mappings":";;;;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,KAAe,iBAAAzC,GACd,UAAA,gBAAAmC,EAACI,KAAS,UAAU,gBAAAJ,EAAC7B,GAAA,EAAe,MAAK,MAAK,GAC5C,UAAA,gBAAA6B,EAACD,KAAO,SAAST,GAAa,GAChC,EAAA,CACF;AAAA,YAIH,UAAAQ,uBAAqBA,GAAA,CAAA,CAAiB;AAAA,UAAA;AAAA,QAAA;AAAA,MACzC,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"InformationRequests.js","sources":["../../../src/components/InformationRequests/InformationRequests.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMachine } from 'react-robot'\nimport { Suspense, useCallback, useMemo, useState } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { InformationRequestList } from './InformationRequestList'\nimport { informationRequestsMachine } from './informationRequestsStateMachine'\nimport { type InformationRequestsContextInterface } from './InformationRequestsComponents'\nimport { BaseBoundaries, type BaseComponentInterface } from '@/components/Base'\nimport { Flex } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { FlowContext } from '@/components/Flow/useFlow'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { informationRequestEvents, type EventType } from '@/shared/constants'\n\ninterface SubmissionAlert {\n id: number\n}\n\ninterface SubmissionAlertState {\n nextAlertId: number\n alerts: SubmissionAlert[]\n}\n\nconst ALERT_TYPE = 'informationRequestResponded' as const\n\nfunction InformationRequestsFlowRoot({\n companyId,\n dictionary,\n withAlert = true,\n onEvent = () => {},\n LoaderComponent,\n}: InformationRequestsFlowProps) {\n useComponentDictionary('InformationRequests', dictionary)\n useI18n('InformationRequests')\n const { t } = useTranslation('InformationRequests')\n const { Modal, LoadingSpinner, Alert, Text } = useComponentContext()\n const [isModalOpen, setIsModalOpen] = useState(false)\n const [alertState, setAlertState] = useState<SubmissionAlertState>({\n nextAlertId: 0,\n alerts: [],\n })\n\n const handleDismissAlert = useCallback((alertId: number) => {\n setAlertState(prev => ({\n ...prev,\n alerts: prev.alerts.filter(alert => alert.id !== alertId),\n }))\n }, [])\n\n const addSubmissionAlert = useCallback(() => {\n setAlertState(prev => ({\n nextAlertId: prev.nextAlertId + 1,\n alerts: [{ id: prev.nextAlertId }, ...prev.alerts],\n }))\n }, [])\n\n const informationRequestsMachineInstance = useMemo(\n () =>\n createMachine(\n 'list',\n informationRequestsMachine,\n (): InformationRequestsContextInterface => ({\n component: null,\n companyId,\n onEvent: handleEvent,\n LoaderComponent,\n }),\n ),\n [companyId, LoaderComponent],\n )\n const [current, send] = useMachine(informationRequestsMachineInstance)\n\n function handleEvent(type: EventType, data?: unknown) {\n send({ type, payload: data })\n\n if (type === informationRequestEvents.INFORMATION_REQUEST_RESPOND) {\n setIsModalOpen(true)\n }\n\n if (\n type === informationRequestEvents.INFORMATION_REQUEST_FORM_CANCEL ||\n type === informationRequestEvents.INFORMATION_REQUEST_FORM_DONE\n ) {\n setIsModalOpen(false)\n }\n\n if (type === informationRequestEvents.INFORMATION_REQUEST_FORM_DONE && withAlert) {\n addSubmissionAlert()\n }\n\n onEvent(type, data)\n }\n\n const handleCloseModal = () => {\n setIsModalOpen(false)\n }\n\n const CurrentComponent = current.context.component\n const Footer = CurrentComponent?.Footer || undefined\n\n return (\n <FlowContext.Provider\n value={{\n ...current.context,\n onEvent: handleEvent,\n }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {withAlert &&\n alertState.alerts.map(alert => (\n <Alert\n key={alert.id}\n status=\"success\"\n label={t(`alerts.${ALERT_TYPE}.title`)}\n onDismiss={() => {\n handleDismissAlert(alert.id)\n }}\n >\n <Text>{t(`alerts.${ALERT_TYPE}.description`)}</Text>\n </Alert>\n ))}\n\n <Suspense fallback={<LoadingSpinner />}>\n <InformationRequestList companyId={companyId} onEvent={handleEvent} />\n </Suspense>\n <Modal\n isOpen={isModalOpen}\n onClose={handleCloseModal}\n footer={\n Footer && (\n <BaseBoundaries LoaderComponent={LoaderComponent}>\n <Suspense fallback={<LoadingSpinner size=\"sm\" />}>\n <Footer onEvent={handleEvent} />\n </Suspense>\n </BaseBoundaries>\n )\n }\n >\n {CurrentComponent && <CurrentComponent />}\n </Modal>\n </Flex>\n </FlowContext.Provider>\n )\n}\n\n/**\n * Props for {@link InformationRequestsFlow}.\n *\n * @public\n */\nexport interface InformationRequestsFlowProps extends Omit<\n BaseComponentInterface<'InformationRequests'>,\n 'onEvent'\n> {\n /** The associated company identifier. */\n companyId: string\n /**\n * When `true` (default), the submission success alert is rendered at the top of this component.\n * Set to `false` when embedding in a parent that renders the alert elsewhere.\n */\n withAlert?: boolean\n /** Callback invoked when the flow or its blocks emit an event. */\n onEvent?: BaseComponentInterface['onEvent']\n}\n\n/**\n * Hub for viewing and responding to outstanding information requests from Gusto.\n *\n * @remarks\n * Renders the list of open and submitted information requests for a company and hosts the response form in a modal.\n * On successful submit, a dismissible success alert appears at the top of the list (when `withAlert` is `true`) and the modal closes.\n *\n * Information requests can also block payroll processing; in that case they are surfaced inline within\n * `Payroll.PayrollBlockerList`, which embeds this flow with `withAlert={false}` so the blocker list owns the alert UX.\n *\n * @events\n * | Event | Description | Data |\n * | ----- | ----------- | ---- |\n * | `informationRequest/respond` | Fired when the user clicks \"Respond\" on a request and the form modal opens | `{ requestId: string }` |\n * | `informationRequest/form/done` | Fired when an information request is successfully submitted | Response from the Submit information request endpoint |\n * | `informationRequest/form/cancel` | Fired when the user cancels the response form (closes the modal without submitting) | — |\n *\n * Each piece is also exported as a standalone block (see the Blocks\n * table) for composing a custom workflow when this orchestration is the wrong\n * fit. See the\n * {@link https://sdk.gusto.com/docs/guides/integration-guide/composition | Composition guide}\n * for how to recompose these blocks into your own flow.\n *\n * @components\n * - {@link InformationRequestList}\n * - {@link InformationRequestForm}\n *\n * @param props - See {@link InformationRequestsFlowProps}.\n * @returns The information requests flow surface.\n * @public\n *\n * @example\n * ```tsx title=\"App.tsx\"\n * import { InformationRequests } from '@gusto/embedded-react-sdk'\n *\n * function MyApp() {\n * return (\n * <InformationRequests.InformationRequestsFlow\n * companyId=\"a007e1ab-3595-43c2-ab4b-af7a5af2e365\"\n * onEvent={() => {}}\n * />\n * )\n * }\n * ```\n */\nexport function InformationRequestsFlow({\n FallbackComponent,\n LoaderComponent,\n ...props\n}: InformationRequestsFlowProps) {\n return (\n <BaseBoundaries\n componentName=\"InformationRequests\"\n FallbackComponent={FallbackComponent}\n LoaderComponent={LoaderComponent}\n >\n <InformationRequestsFlowRoot LoaderComponent={LoaderComponent} {...props} />\n </BaseBoundaries>\n )\n}\n"],"names":["ALERT_TYPE","InformationRequestsFlowRoot","companyId","dictionary","withAlert","onEvent","LoaderComponent","useComponentDictionary","useI18n","t","useTranslation","Modal","LoadingSpinner","Alert","Text","useComponentContext","isModalOpen","setIsModalOpen","useState","alertState","setAlertState","handleDismissAlert","useCallback","alertId","prev","alert","addSubmissionAlert","informationRequestsMachineInstance","useMemo","createMachine","informationRequestsMachine","handleEvent","current","send","useMachine","type","data","informationRequestEvents","handleCloseModal","CurrentComponent","Footer","jsx","FlowContext","jsxs","Flex","Suspense","InformationRequestList","BaseBoundaries","InformationRequestsFlow","FallbackComponent","props"],"mappings":";;;;;;;;;;;;;;AAuBA,MAAMA,IAAa;AAEnB,SAASC,EAA4B;AAAA,EACnC,WAAAC;AAAA,EACA,YAAAC;AAAA,EACA,WAAAC,IAAY;AAAA,EACZ,SAAAC,IAAU,MAAM;AAAA,EAAC;AAAA,EACjB,iBAAAC;AACF,GAAiC;AAC/B,EAAAC,EAAuB,uBAAuBJ,CAAU,GACxDK,EAAQ,qBAAqB;AAC7B,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB,GAC5C,EAAE,OAAAC,GAAO,gBAAAC,GAAgB,OAAAC,GAAO,MAAAC,EAAA,IAASC,EAAA,GACzC,CAACC,GAAaC,CAAc,IAAIC,EAAS,EAAK,GAC9C,CAACC,GAAYC,CAAa,IAAIF,EAA+B;AAAA,IACjE,aAAa;AAAA,IACb,QAAQ,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EAACxC,GAAA,EAA4B,iBAAAK,GAAmC,GAAG4C,EAAA,CAAO;AAAA,IAAA;AAAA,EAAA;AAGhF;"}
|
|
@@ -18,13 +18,12 @@ import "@gusto/embedded-api/models/errors/httpclienterrors";
|
|
|
18
18
|
import { formatNumberAsCurrency as L } from "../../../helpers/formattedStrings.js";
|
|
19
19
|
import "../../../shared/constants.js";
|
|
20
20
|
import { useComponentContext as V } from "../../../contexts/ComponentAdapter/useComponentContext.js";
|
|
21
|
-
import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
22
21
|
import { useI18n as E } from "../../../i18n/I18n.js";
|
|
23
22
|
import { NumberInputField as T } from "../../Common/Fields/NumberInputField/NumberInputField.js";
|
|
24
23
|
const q = P.object({
|
|
25
24
|
netPay: P.number().positive()
|
|
26
25
|
});
|
|
27
|
-
function
|
|
26
|
+
function pe({ isOpen: n, onCalculateGrossUp: w, onApply: A, onCancel: d }) {
|
|
28
27
|
E("Payroll.GrossUpModal");
|
|
29
28
|
const { t: r } = k("Payroll.GrossUpModal"), { Modal: M, Heading: u, Text: p, Button: i, Alert: f } = V(), { baseSubmitHandler: y } = H(), N = R(null), [l, c] = o(null), [h, m] = o(null), [g, b] = o(!1), [x, v] = o(!1), s = U({
|
|
30
29
|
resolver: z(q),
|
|
@@ -111,6 +110,6 @@ function fe({ isOpen: n, onCalculateGrossUp: w, onApply: A, onCancel: d }) {
|
|
|
111
110
|
);
|
|
112
111
|
}
|
|
113
112
|
export {
|
|
114
|
-
|
|
113
|
+
pe as GrossUpModal
|
|
115
114
|
};
|
|
116
115
|
//# sourceMappingURL=GrossUpModal.js.map
|
|
@@ -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 defaultValues: { netPay: 0 },\n })\n\n useEffect(() => {\n if (!isOpen) {\n formHandlers.reset({ netPay: 0 })\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 <Flex flexDirection=\"row\" gap={8}>\n <NumberInputField\n name=\"netPay\"\n label={t('netPayLabel')}\n format=\"currency\"\n errorMessage={t('validations.netPay')}\n min={0}\n isRequired\n />\n <Button\n variant=\"secondary\"\n className={styles.calculateButton}\n isDisabled={isCalculating}\n onClick={formHandlers.handleSubmit(handleCalculate)}\n >\n {isCalculating ? t('calculatingCta') : t('calculateCta')}\n </Button>\n </Flex>\n\n {calculatedGrossUp && (\n <>\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 )}\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","Fragment"],"mappings":"
|
|
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 defaultValues: { netPay: 0 },\n })\n\n useEffect(() => {\n if (!isOpen) {\n formHandlers.reset({ netPay: 0 })\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 <Flex flexDirection=\"row\" gap={8}>\n <NumberInputField\n name=\"netPay\"\n label={t('netPayLabel')}\n format=\"currency\"\n errorMessage={t('validations.netPay')}\n min={0}\n isRequired\n />\n <Button\n variant=\"secondary\"\n className={styles.calculateButton}\n isDisabled={isCalculating}\n onClick={formHandlers.handleSubmit(handleCalculate)}\n >\n {isCalculating ? t('calculatingCta') : t('calculateCta')}\n </Button>\n </Flex>\n\n {calculatedGrossUp && (\n <>\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 )}\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","Fragment"],"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,IACvC,eAAe,EAAE,QAAQ,EAAA;AAAA,EAAE,CAC5B;AAED,EAAAgC,EAAU,MAAM;AACd,IAAK7B,MACH0B,EAAa,MAAM,EAAE,QAAQ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,YACzC,UAAAJ,EAAE,gBAAgB,EAAA,CACrB;AAAA,YACA,gBAAA4B,EAACzB,KAAQ,IAAG,MAAM,YAAuB,WAAWS,CAAiB,CAAC,EAAA,CAAE;AAAA,UAAA,EAAA,CAC1E,EAAA,CACF;AAAA,QAAA,EAAA,CAEJ;AAAA,MAAA,EAAA,CACF;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { useState as
|
|
3
|
-
import { useForm as H, FormProvider as
|
|
4
|
-
import { zodResolver as
|
|
5
|
-
import { z as
|
|
6
|
-
import { useTranslation as
|
|
7
|
-
import { usePayrollsCreateOffCycleMutation as
|
|
8
|
-
import { WithholdingPayPeriod as
|
|
9
|
-
import { RFCDate as
|
|
1
|
+
import { jsx as c } from "react/jsx-runtime";
|
|
2
|
+
import { useState as v, useCallback as D, useMemo as z, useEffect as Y } from "react";
|
|
3
|
+
import { useForm as H, FormProvider as J } from "react-hook-form";
|
|
4
|
+
import { zodResolver as K } from "@hookform/resolvers/zod";
|
|
5
|
+
import { z as l } from "zod";
|
|
6
|
+
import { useTranslation as x } from "react-i18next";
|
|
7
|
+
import { usePayrollsCreateOffCycleMutation as Z } from "@gusto/embedded-api/react-query/payrollsCreateOffCycle";
|
|
8
|
+
import { WithholdingPayPeriod as G, OffCycleReason as W } from "@gusto/embedded-api/models/operations/postv1companiescompanyidpayrolls";
|
|
9
|
+
import { RFCDate as P } from "@gusto/embedded-api/types/rfcdate";
|
|
10
10
|
import { useEmployeesListSuspense as Q } from "@gusto/embedded-api/react-query/employeesList";
|
|
11
11
|
import { createOffCyclePayPeriodDateFormSchema as X } from "../OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormTypes.js";
|
|
12
12
|
import { useOffCyclePayPeriodDateValidation as $ } from "../OffCyclePayPeriodDateForm/useOffCyclePayPeriodDateValidation.js";
|
|
@@ -14,117 +14,123 @@ import { OffCycleCreationPresentation as ee } from "./OffCycleCreationPresentati
|
|
|
14
14
|
import { useCompanyPaymentSpeed as oe } from "../../../hooks/useCompanyPaymentSpeed.js";
|
|
15
15
|
import { BaseComponent as te } from "../../Base/Base.js";
|
|
16
16
|
import { useBase as ne } from "../../Base/useBase.js";
|
|
17
|
-
import { useComponentDictionary as le, useI18n as
|
|
17
|
+
import { useComponentDictionary as le, useI18n as a } from "../../../i18n/I18n.js";
|
|
18
18
|
import { componentEvents as se } from "../../../shared/constants.js";
|
|
19
|
-
import { SDKInternalError as
|
|
20
|
-
import { Form as
|
|
21
|
-
import { OFF_CYCLE_REASON_DEFAULTS as
|
|
19
|
+
import { SDKInternalError as ie } from "../../../types/sdkError.js";
|
|
20
|
+
import { Form as re } from "../../Common/Form/Form.js";
|
|
21
|
+
import { OFF_CYCLE_REASON_DEFAULTS as f } from "../OffCycleReasonSelection/types.js";
|
|
22
22
|
const ae = {
|
|
23
|
-
bonus:
|
|
24
|
-
correction:
|
|
23
|
+
bonus: W.Bonus,
|
|
24
|
+
correction: W.Correction
|
|
25
25
|
};
|
|
26
|
-
function Ae(
|
|
27
|
-
return /* @__PURE__ */
|
|
26
|
+
function Ae(m) {
|
|
27
|
+
return /* @__PURE__ */ c(te, { ...m, children: /* @__PURE__ */ c(ce, { ...m }) });
|
|
28
28
|
}
|
|
29
|
-
function ce({ dictionary:
|
|
30
|
-
le("Payroll.OffCycleCreation",
|
|
31
|
-
const { t:
|
|
32
|
-
withholdingPayPeriod:
|
|
33
|
-
withholdingRate:
|
|
34
|
-
}), [M,
|
|
35
|
-
|
|
36
|
-
}, []),
|
|
37
|
-
|
|
38
|
-
}, []),
|
|
39
|
-
|
|
40
|
-
}, []), { data:
|
|
41
|
-
companyId:
|
|
29
|
+
function ce({ dictionary: m, companyId: y, payrollType: d = "bonus" }) {
|
|
30
|
+
le("Payroll.OffCycleCreation", m), a("Payroll.OffCycleCreation"), a("Payroll.OffCycleReasonSelection"), a("Payroll.OffCyclePayPeriodDateForm"), a("Payroll.OffCycleDeductionsSetting"), a("Payroll.EmployeeSelection");
|
|
31
|
+
const { t: A } = x("Payroll.OffCyclePayPeriodDateForm"), { t: g } = x("Payroll.OffCycleCreation"), { onEvent: F, baseSubmitHandler: U } = ne(), { paymentSpeedDays: O } = oe(y), { minCheckDate: E, today: k } = $(O), { mutateAsync: N, isPending: L } = Z(), [h, R] = v({
|
|
32
|
+
withholdingPayPeriod: G.EveryOtherWeek,
|
|
33
|
+
withholdingRate: f[d].withholdingType
|
|
34
|
+
}), [M, p] = v(!1), _ = D(() => {
|
|
35
|
+
p(!0);
|
|
36
|
+
}, []), j = D((e) => {
|
|
37
|
+
R(e), p(!1);
|
|
38
|
+
}, []), B = D(() => {
|
|
39
|
+
p(!1);
|
|
40
|
+
}, []), { data: w } = Q({
|
|
41
|
+
companyId: y,
|
|
42
42
|
onboardedActive: !0
|
|
43
|
-
}),
|
|
44
|
-
const
|
|
45
|
-
return
|
|
46
|
-
}).map((o) =>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
}), S = z(() => [...w.showEmployees ?? []].sort((o, t) => {
|
|
44
|
+
const n = o.lastName.localeCompare(t.lastName);
|
|
45
|
+
return n !== 0 ? n : o.firstName.localeCompare(t.firstName);
|
|
46
|
+
}).map((o) => {
|
|
47
|
+
const t = [o.firstName, o.lastName].filter(Boolean).join(" "), n = o.jobs?.find((r) => r.primary) ?? o.jobs?.[0];
|
|
48
|
+
return {
|
|
49
|
+
label: t,
|
|
50
|
+
value: o.uuid,
|
|
51
|
+
description: n?.title || void 0
|
|
52
|
+
};
|
|
53
|
+
}), [w]), I = (e, o) => (
|
|
50
54
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
51
|
-
|
|
52
|
-
),
|
|
55
|
+
A(e, o)
|
|
56
|
+
), i = H({
|
|
53
57
|
resolver: (e, o, t) => {
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
),
|
|
60
|
-
reason:
|
|
61
|
-
skipRegularDeductions:
|
|
62
|
-
includeAllEmployees:
|
|
63
|
-
selectedEmployeeUuids:
|
|
64
|
-
}).and(s).superRefine((
|
|
65
|
-
!
|
|
66
|
-
code:
|
|
58
|
+
const n = e.reason, r = e.isCheckOnly, s = X(
|
|
59
|
+
I,
|
|
60
|
+
n === "correction" ? "correction" : d,
|
|
61
|
+
r ? k : E,
|
|
62
|
+
O
|
|
63
|
+
), u = l.object({
|
|
64
|
+
reason: l.enum(["bonus", "correction"]),
|
|
65
|
+
skipRegularDeductions: l.boolean(),
|
|
66
|
+
includeAllEmployees: l.boolean(),
|
|
67
|
+
selectedEmployeeUuids: l.array(l.string())
|
|
68
|
+
}).and(s).superRefine((T, q) => {
|
|
69
|
+
!T.includeAllEmployees && T.selectedEmployeeUuids.length === 0 && q.addIssue({
|
|
70
|
+
code: l.ZodIssueCode.custom,
|
|
67
71
|
path: ["selectedEmployeeUuids"],
|
|
68
|
-
message:
|
|
72
|
+
message: g("errors.noEmployeesSelected")
|
|
69
73
|
});
|
|
70
74
|
});
|
|
71
|
-
return
|
|
75
|
+
return K(u)(e, o, t);
|
|
72
76
|
},
|
|
73
77
|
defaultValues: {
|
|
74
|
-
reason:
|
|
78
|
+
reason: d,
|
|
75
79
|
isCheckOnly: !1,
|
|
76
80
|
startDate: null,
|
|
77
81
|
endDate: null,
|
|
78
82
|
checkDate: null,
|
|
79
|
-
skipRegularDeductions:
|
|
83
|
+
skipRegularDeductions: f[d].skipDeductions,
|
|
80
84
|
includeAllEmployees: !1,
|
|
81
85
|
selectedEmployeeUuids: []
|
|
82
86
|
}
|
|
83
|
-
}),
|
|
87
|
+
}), C = i.watch("reason");
|
|
84
88
|
Y(() => {
|
|
85
|
-
|
|
89
|
+
i.setValue(
|
|
86
90
|
"skipRegularDeductions",
|
|
87
|
-
|
|
88
|
-
),
|
|
91
|
+
f[C].skipDeductions
|
|
92
|
+
), R((e) => ({
|
|
89
93
|
...e,
|
|
90
|
-
withholdingRate:
|
|
94
|
+
withholdingRate: f[C].withholdingType
|
|
91
95
|
}));
|
|
92
|
-
}, [
|
|
93
|
-
const
|
|
94
|
-
const o = e.reason, t = e.checkDate,
|
|
95
|
-
await
|
|
96
|
+
}, [C, i]);
|
|
97
|
+
const V = async (e) => {
|
|
98
|
+
const o = e.reason, t = e.checkDate, n = e.startDate, r = e.endDate, b = e.includeAllEmployees ? S.map((s) => s.value) : e.selectedEmployeeUuids.length > 0 ? e.selectedEmployeeUuids : void 0;
|
|
99
|
+
await U(e, async () => {
|
|
96
100
|
const s = await N({
|
|
97
101
|
request: {
|
|
98
|
-
companyId:
|
|
102
|
+
companyId: y,
|
|
99
103
|
requestBody: {
|
|
100
104
|
offCycle: !0,
|
|
101
105
|
offCycleReason: ae[o],
|
|
102
|
-
startDate: new
|
|
103
|
-
endDate: new
|
|
104
|
-
checkDate: new
|
|
106
|
+
startDate: new P(n),
|
|
107
|
+
endDate: new P(r),
|
|
108
|
+
checkDate: new P(t),
|
|
105
109
|
skipRegularDeductions: e.skipRegularDeductions,
|
|
106
110
|
isCheckOnlyPayroll: e.isCheckOnly,
|
|
107
|
-
employeeUuids:
|
|
108
|
-
withholdingPayPeriod:
|
|
109
|
-
fixedWithholdingRate:
|
|
111
|
+
employeeUuids: b,
|
|
112
|
+
withholdingPayPeriod: h.withholdingPayPeriod,
|
|
113
|
+
fixedWithholdingRate: h.withholdingRate === "supplemental"
|
|
110
114
|
}
|
|
111
115
|
}
|
|
112
|
-
}),
|
|
113
|
-
if (!
|
|
114
|
-
throw new
|
|
115
|
-
|
|
116
|
+
}), u = s.payrollUnprocessed?.payrollUuid ?? s.payrollUnprocessed?.uuid;
|
|
117
|
+
if (!u)
|
|
118
|
+
throw new ie(g("errors.missingPayrollId"));
|
|
119
|
+
F(se.OFF_CYCLE_CREATED, { payrollUuid: u });
|
|
116
120
|
});
|
|
117
121
|
};
|
|
118
|
-
return /* @__PURE__ */
|
|
122
|
+
return /* @__PURE__ */ c(J, { ...i, children: /* @__PURE__ */ c(re, { onSubmit: i.handleSubmit(V), children: /* @__PURE__ */ c(
|
|
119
123
|
ee,
|
|
120
124
|
{
|
|
121
|
-
employees:
|
|
125
|
+
employees: S,
|
|
122
126
|
isPending: L,
|
|
123
|
-
|
|
127
|
+
minCheckDate: E,
|
|
128
|
+
minCheckOnlyDate: k,
|
|
129
|
+
taxWithholdingConfig: h,
|
|
124
130
|
isTaxWithholdingModalOpen: M,
|
|
125
131
|
onTaxWithholdingEditClick: _,
|
|
126
|
-
onTaxWithholdingModalDone:
|
|
127
|
-
onTaxWithholdingModalCancel:
|
|
132
|
+
onTaxWithholdingModalDone: j,
|
|
133
|
+
onTaxWithholdingModalCancel: B
|
|
128
134
|
}
|
|
129
135
|
) }) });
|
|
130
136
|
}
|