@gusto/embedded-react-sdk 0.56.5 → 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.
- package/CHANGELOG.md +24 -0
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +3 -6
- package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +3 -6
- package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js +5 -8
- package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
- package/dist/components/Company/BankAccount/BankAccountForm/context.js +3 -6
- package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +3 -6
- package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js +8 -11
- package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
- package/dist/components/Company/Industry/Context.js +6 -9
- package/dist/components/Company/Industry/Context.js.map +1 -1
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js +3 -6
- package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js +3 -6
- package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
- package/dist/components/Company/OnboardingOverview/context.js +3 -6
- package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.js +39 -0
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialogPresentation.js +54 -0
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialogPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.js +56 -0
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PaySchedule.js +54 -39
- package/dist/components/Company/PaySchedule/management/PaySchedule.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js +70 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js +30 -32
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js +35 -27
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js +52 -31
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js +106 -66
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js +36 -30
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.js +7 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.js +81 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js +48 -32
- package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js +47 -19
- package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js +74 -32
- package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +3 -6
- package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js +3 -6
- package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
- package/dist/components/Company/StateTaxes/TaxRateManagement/context.js +3 -6
- package/dist/components/Company/StateTaxes/TaxRateManagement/context.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentFlow/paymentStateMachine.js +17 -14
- package/dist/components/Contractor/Payments/PaymentFlow/paymentStateMachine.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +3 -6
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js +27 -16
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlow.js.map +1 -1
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.js +25 -17
- package/dist/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/employeeDetailsSchema.js +13 -13
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/employeeDetailsSchema.js.map +1 -1
- package/dist/components/Payroll/ConfirmWireDetails/confirmWireDetailsStateMachine.js +6 -5
- package/dist/components/Payroll/ConfirmWireDetails/confirmWireDetailsStateMachine.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/PayrollConfiguration/usePayrollConfigurationData.js +49 -48
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js +55 -57
- package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js.map +1 -1
- package/dist/components/Payroll/PayrollFlow/payrollStateMachine.js +25 -18
- package/dist/components/Payroll/PayrollFlow/payrollStateMachine.js.map +1 -1
- package/dist/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.js +49 -47
- package/dist/components/Payroll/PrintChecks/PrintChecksForm/PrintChecksForm.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js +7 -10
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/contexts/ApiProvider/ApiProvider.js +13 -12
- package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
- package/dist/contexts/ApiProvider/createSdkQueryClient.js +4 -3
- package/dist/contexts/ApiProvider/createSdkQueryClient.js.map +1 -1
- package/dist/contexts/ApiProvider/payrollDeductionAmountHook.js +36 -0
- package/dist/contexts/ApiProvider/payrollDeductionAmountHook.js.map +1 -0
- package/dist/helpers/validations.js +1 -1
- package/dist/helpers/validations.js.map +1 -1
- package/dist/i18n/I18n.js +1 -0
- package/dist/i18n/I18n.js.map +1 -1
- package/dist/i18n/en/Company.AssignSignatory.json.js +1 -1
- package/dist/i18n/en/Company.Management.AutoPilotDialog.json.js +22 -0
- package/dist/i18n/en/Company.Management.AutoPilotDialog.json.js.map +1 -0
- package/dist/i18n/en/Company.Management.PaySchedule.json.js +24 -14
- package/dist/i18n/en/Company.Management.PaySchedule.json.js.map +1 -1
- package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js +12 -10
- package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js.map +1 -1
- package/dist/package.json.js +1 -1
- package/dist/shared/constants.js +18 -15
- package/dist/shared/constants.js.map +1 -1
- package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.d.ts +11 -0
- package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialogPresentation.d.ts +17 -0
- package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/index.d.ts +1 -0
- package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.d.ts +22 -0
- package/dist/src/components/Company/PaySchedule/management/PaySchedule.d.ts +17 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.d.ts +15 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.d.ts +3 -3
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.d.ts +7 -3
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.d.ts +20 -4
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.d.ts +3 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/usePayScheduleAssignment.d.ts +10 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.d.ts +25 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleManagementComponents.d.ts +2 -0
- package/dist/src/components/Company/PaySchedule/management/index.d.ts +1 -1
- package/dist/src/components/Company/exports/companyManagement.d.ts +1 -1
- package/dist/src/components/Employee/EmployeeListFlow/EmployeeListFlow.d.ts +1 -1
- package/dist/src/components/Employee/EmployeeListFlow/EmployeeListFlowComponents.d.ts +6 -0
- package/dist/src/components/Employee/Profile/shared/useEmployeeDetailsForm/employeeDetailsSchema.test.d.ts +1 -0
- package/dist/src/components/Payroll/ConfirmWireDetails/confirmWireDetailsStateMachine.test.d.ts +1 -0
- package/dist/src/components/Payroll/PayrollList/__fixtures__/payrollListMocks.d.ts +67 -0
- package/dist/src/contexts/ApiProvider/createSdkQueryClient.d.ts +2 -0
- package/dist/src/contexts/ApiProvider/createSdkQueryClient.test.d.ts +1 -0
- package/dist/src/contexts/ApiProvider/payrollDeductionAmountHook.d.ts +12 -0
- package/dist/src/contexts/ApiProvider/payrollDeductionAmountHook.test.d.ts +1 -0
- package/dist/src/helpers/validations.test.d.ts +1 -0
- package/dist/src/i18n/types.d.ts +119 -2
- package/dist/src/models/external.d.ts +7 -6
- package/dist/src/shared/constants.d.ts +6 -0
- package/docs/guides/endpoint-inventory.json +27 -1
- package/package.json +14 -14
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { state as
|
|
2
|
-
import { PayrollReceiptsContextual as
|
|
1
|
+
import { state as r, transition as t, reduce as o, guard as v } from "robot3";
|
|
2
|
+
import { PayrollReceiptsContextual as L, PayrollBlockerContextual as R, PayrollLandingContextual as b, PayrollOverviewContextual as C } from "./PayrollFlowComponents.js";
|
|
3
3
|
import { PayrollExecutionFlowContextual as g } from "./PayrollExecutionFlowContextual.js";
|
|
4
4
|
import { TransitionFlowContextual as _ } from "./TransitionFlowContextual.js";
|
|
5
5
|
import { OffCycleFlowContextual as E } from "./OffCycleFlowContextual.js";
|
|
@@ -16,6 +16,7 @@ const I = {
|
|
|
16
16
|
onNavigate: ((e) => ({
|
|
17
17
|
...c(e, { currentBreadcrumbId: void 0 }),
|
|
18
18
|
component: b,
|
|
19
|
+
alerts: void 0,
|
|
19
20
|
payrollUuid: void 0,
|
|
20
21
|
executionInitialState: void 0
|
|
21
22
|
}))
|
|
@@ -50,6 +51,7 @@ function y(e) {
|
|
|
50
51
|
return {
|
|
51
52
|
...c(e, { currentBreadcrumbId: void 0 }),
|
|
52
53
|
component: b,
|
|
54
|
+
alerts: void 0,
|
|
53
55
|
payrollUuid: void 0,
|
|
54
56
|
payPeriod: void 0,
|
|
55
57
|
executionInitialState: void 0
|
|
@@ -59,6 +61,7 @@ function P(e, a, i) {
|
|
|
59
61
|
return {
|
|
60
62
|
...e,
|
|
61
63
|
component: g,
|
|
64
|
+
alerts: void 0,
|
|
62
65
|
payrollUuid: a.payload.payrollUuid,
|
|
63
66
|
showPayrollCancelledAlert: !1,
|
|
64
67
|
executionInitialState: i
|
|
@@ -67,11 +70,11 @@ function P(e, a, i) {
|
|
|
67
70
|
const u = t(
|
|
68
71
|
l.BREADCRUMB_NAVIGATE,
|
|
69
72
|
"landing",
|
|
70
|
-
|
|
73
|
+
v(
|
|
71
74
|
(e, a) => a.payload.key === "landing"
|
|
72
75
|
),
|
|
73
76
|
o(y)
|
|
74
|
-
),
|
|
77
|
+
), n = t(
|
|
75
78
|
l.PAYROLL_EXIT_FLOW,
|
|
76
79
|
"landing",
|
|
77
80
|
o(y)
|
|
@@ -94,6 +97,7 @@ const u = t(
|
|
|
94
97
|
endDate: i?.endDate ?? ""
|
|
95
98
|
}),
|
|
96
99
|
component: C,
|
|
100
|
+
alerts: void 0,
|
|
97
101
|
payrollUuid: a.payload.payrollUuid ?? e.payrollUuid,
|
|
98
102
|
payPeriod: i,
|
|
99
103
|
executionInitialState: void 0,
|
|
@@ -105,7 +109,7 @@ const u = t(
|
|
|
105
109
|
}
|
|
106
110
|
)
|
|
107
111
|
), B = {
|
|
108
|
-
landing:
|
|
112
|
+
landing: r(
|
|
109
113
|
t(
|
|
110
114
|
l.RUN_PAYROLL_SELECTED,
|
|
111
115
|
"execution",
|
|
@@ -125,7 +129,8 @@ const u = t(
|
|
|
125
129
|
"blockers",
|
|
126
130
|
o((e) => ({
|
|
127
131
|
...m("blockers", e),
|
|
128
|
-
component:
|
|
132
|
+
component: R,
|
|
133
|
+
alerts: void 0,
|
|
129
134
|
showPayrollCancelledAlert: !1,
|
|
130
135
|
ctaConfig: {
|
|
131
136
|
labelKey: "exitFlowCta",
|
|
@@ -148,6 +153,7 @@ const u = t(
|
|
|
148
153
|
(e, a) => ({
|
|
149
154
|
...c(e, { currentBreadcrumbId: void 0 }),
|
|
150
155
|
component: _,
|
|
156
|
+
alerts: void 0,
|
|
151
157
|
transitionStartDate: a.payload.startDate,
|
|
152
158
|
transitionEndDate: a.payload.endDate,
|
|
153
159
|
transitionPayScheduleUuid: a.payload.payScheduleUuid,
|
|
@@ -161,18 +167,19 @@ const u = t(
|
|
|
161
167
|
o((e) => ({
|
|
162
168
|
...c(e, { currentBreadcrumbId: void 0 }),
|
|
163
169
|
component: E,
|
|
170
|
+
alerts: void 0,
|
|
164
171
|
showPayrollCancelledAlert: !1
|
|
165
172
|
}))
|
|
166
173
|
)
|
|
167
174
|
),
|
|
168
|
-
execution:
|
|
175
|
+
execution: r(
|
|
169
176
|
u,
|
|
170
|
-
|
|
177
|
+
n,
|
|
171
178
|
d,
|
|
172
179
|
p
|
|
173
180
|
),
|
|
174
|
-
blockers:
|
|
175
|
-
submittedOverview:
|
|
181
|
+
blockers: r(s("landing"), n),
|
|
182
|
+
submittedOverview: r(
|
|
176
183
|
s("landing"),
|
|
177
184
|
t(
|
|
178
185
|
l.RUN_PAYROLL_RECEIPT_GET,
|
|
@@ -182,7 +189,7 @@ const u = t(
|
|
|
182
189
|
startDate: e.payPeriod?.startDate ?? "",
|
|
183
190
|
endDate: e.payPeriod?.endDate ?? ""
|
|
184
191
|
}),
|
|
185
|
-
component:
|
|
192
|
+
component: L,
|
|
186
193
|
alerts: void 0,
|
|
187
194
|
ctaConfig: {
|
|
188
195
|
labelKey: "exitFlowCta",
|
|
@@ -191,21 +198,21 @@ const u = t(
|
|
|
191
198
|
}))
|
|
192
199
|
),
|
|
193
200
|
d,
|
|
194
|
-
|
|
201
|
+
n
|
|
195
202
|
),
|
|
196
|
-
submittedReceipts:
|
|
203
|
+
submittedReceipts: r(
|
|
197
204
|
s("landing"),
|
|
198
|
-
|
|
205
|
+
n
|
|
199
206
|
),
|
|
200
|
-
transition:
|
|
207
|
+
transition: r(
|
|
201
208
|
u,
|
|
202
|
-
|
|
209
|
+
n,
|
|
203
210
|
d,
|
|
204
211
|
p
|
|
205
212
|
),
|
|
206
|
-
offCycle:
|
|
213
|
+
offCycle: r(
|
|
207
214
|
u,
|
|
208
|
-
|
|
215
|
+
n,
|
|
209
216
|
d,
|
|
210
217
|
p
|
|
211
218
|
)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payrollStateMachine.js","sources":["../../../../src/components/Payroll/PayrollFlow/payrollStateMachine.ts"],"sourcesContent":["import { state, transition, reduce, guard } from 'robot3'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayrollExecutionInitialState } from '../PayrollExecutionFlow'\nimport {\n PayrollLandingContextual,\n PayrollBlockerContextual,\n PayrollOverviewContextual,\n PayrollReceiptsContextual,\n type PayrollFlowContextInterface,\n} from './PayrollFlowComponents'\nimport { PayrollExecutionFlowContextual } from './PayrollExecutionFlowContextual'\nimport { TransitionFlowContextual } from './TransitionFlowContextual'\nimport { OffCycleFlowContextual } from './OffCycleFlowContextual'\nimport { componentEvents } from '@/shared/constants'\nimport type { MachineEventType, MachineTransition } from '@/types/Helpers'\nimport { patchBreadcrumbsHeader, updateBreadcrumbs } from '@/helpers/breadcrumbHelpers'\nimport type { BreadcrumbNodes } from '@/components/Common/FlowBreadcrumbs/FlowBreadcrumbsTypes'\nimport { createBreadcrumbNavigateTransition } from '@/components/Common/FlowBreadcrumbs/breadcrumbTransitionHelpers'\n\ntype PayrollFlowEventPayloads = {\n [componentEvents.RUN_PAYROLL_SELECTED]: {\n payrollUuid: string\n }\n [componentEvents.REVIEW_PAYROLL]: {\n payrollUuid: string\n }\n [componentEvents.RUN_PAYROLL_PROCESSED]: {\n payPeriod?: PayrollPayPeriodType\n payrollUuid?: string\n }\n [componentEvents.RUN_TRANSITION_PAYROLL]: {\n startDate: string\n endDate: string\n payScheduleUuid: string\n }\n}\n\n/** @internal */\nexport const payrollFlowBreadcrumbsNodes: BreadcrumbNodes = {\n landing: {\n parent: null,\n item: {\n id: 'landing',\n label: 'breadcrumbs.landing',\n namespace: 'Payroll.PayrollLanding',\n onNavigate: ((ctx: PayrollFlowContextInterface) => ({\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: undefined }),\n component: PayrollLandingContextual,\n payrollUuid: undefined,\n executionInitialState: undefined,\n })) as (context: unknown) => unknown,\n },\n },\n blockers: {\n parent: 'landing',\n item: {\n id: 'blockers',\n label: 'breadcrumbLabel',\n namespace: 'Payroll.PayrollBlocker',\n },\n },\n submittedOverview: {\n parent: 'landing',\n item: {\n id: 'submittedOverview',\n label: 'breadcrumbs.overview',\n namespace: 'Payroll.PayrollLanding',\n },\n },\n submittedReceipts: {\n parent: 'landing',\n item: {\n id: 'submittedReceipts',\n label: 'breadcrumbs.receipt',\n namespace: 'Payroll.PayrollLanding',\n },\n },\n}\n\nconst breadcrumbNavigateTransition =\n createBreadcrumbNavigateTransition<PayrollFlowContextInterface>()\n\nfunction toLandingReducer(ctx: PayrollFlowContextInterface): PayrollFlowContextInterface {\n return {\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: undefined }),\n component: PayrollLandingContextual,\n payrollUuid: undefined,\n payPeriod: undefined,\n executionInitialState: undefined,\n }\n}\n\nfunction toExecutionReducer(\n ctx: PayrollFlowContextInterface,\n ev: { payload: { payrollUuid: string } },\n executionInitialState: PayrollExecutionInitialState,\n): PayrollFlowContextInterface {\n return {\n ...ctx,\n component: PayrollExecutionFlowContextual,\n payrollUuid: ev.payload.payrollUuid,\n showPayrollCancelledAlert: false,\n executionInitialState,\n }\n}\n\nconst landingBreadcrumbNavigateTransition = transition(\n componentEvents.BREADCRUMB_NAVIGATE,\n 'landing',\n guard(\n (_ctx: PayrollFlowContextInterface, ev: { payload: { key: string } }) =>\n ev.payload.key === 'landing',\n ),\n reduce(toLandingReducer),\n)\n\nconst exitFlowTransition = transition(\n componentEvents.PAYROLL_EXIT_FLOW,\n 'landing',\n reduce(toLandingReducer),\n)\n\nconst cancelledToLandingTransition = transition(\n componentEvents.RUN_PAYROLL_CANCELLED,\n 'landing',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...toLandingReducer(ctx),\n showPayrollCancelledAlert: true,\n })),\n)\n\nconst processedToSubmittedOverviewTransition = transition(\n componentEvents.RUN_PAYROLL_PROCESSED,\n 'submittedOverview',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<PayrollFlowEventPayloads, typeof componentEvents.RUN_PAYROLL_PROCESSED>,\n ): PayrollFlowContextInterface => {\n const payPeriod = ev.payload.payPeriod ?? ctx.payPeriod\n return {\n ...updateBreadcrumbs('submittedOverview', ctx, {\n startDate: payPeriod?.startDate ?? '',\n endDate: payPeriod?.endDate ?? '',\n }),\n component: PayrollOverviewContextual,\n payrollUuid: ev.payload.payrollUuid ?? ctx.payrollUuid,\n payPeriod,\n executionInitialState: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollOverview',\n },\n }\n },\n ),\n)\n\n/** @internal */\nexport const payrollFlowMachine = {\n landing: state<MachineTransition>(\n transition(\n componentEvents.RUN_PAYROLL_SELECTED,\n 'execution',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<\n PayrollFlowEventPayloads,\n typeof componentEvents.RUN_PAYROLL_SELECTED\n >,\n ) => toExecutionReducer(ctx, ev, 'configuration'),\n ),\n ),\n transition(\n componentEvents.REVIEW_PAYROLL,\n 'execution',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<PayrollFlowEventPayloads, typeof componentEvents.REVIEW_PAYROLL>,\n ) => toExecutionReducer(ctx, ev, 'overview'),\n ),\n ),\n transition(\n componentEvents.RUN_PAYROLL_BLOCKERS_VIEW_ALL,\n 'blockers',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...updateBreadcrumbs('blockers', ctx),\n component: PayrollBlockerContextual,\n showPayrollCancelledAlert: false,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollBlocker',\n },\n })),\n ),\n transition(\n componentEvents.RUN_PAYROLL_CANCELLED_ALERT_DISMISSED,\n 'landing',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...ctx,\n showPayrollCancelledAlert: false,\n })),\n ),\n transition(\n componentEvents.RUN_TRANSITION_PAYROLL,\n 'transition',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<\n PayrollFlowEventPayloads,\n typeof componentEvents.RUN_TRANSITION_PAYROLL\n >,\n ): PayrollFlowContextInterface => ({\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: undefined }),\n component: TransitionFlowContextual,\n transitionStartDate: ev.payload.startDate,\n transitionEndDate: ev.payload.endDate,\n transitionPayScheduleUuid: ev.payload.payScheduleUuid,\n showPayrollCancelledAlert: false,\n }),\n ),\n ),\n transition(\n componentEvents.RUN_OFF_CYCLE_PAYROLL,\n 'offCycle',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: undefined }),\n component: OffCycleFlowContextual,\n showPayrollCancelledAlert: false,\n })),\n ),\n ),\n execution: state<MachineTransition>(\n landingBreadcrumbNavigateTransition,\n exitFlowTransition,\n cancelledToLandingTransition,\n processedToSubmittedOverviewTransition,\n ),\n blockers: state<MachineTransition>(breadcrumbNavigateTransition('landing'), exitFlowTransition),\n submittedOverview: state<MachineTransition>(\n breadcrumbNavigateTransition('landing'),\n transition(\n componentEvents.RUN_PAYROLL_RECEIPT_GET,\n 'submittedReceipts',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...updateBreadcrumbs('submittedReceipts', ctx, {\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollReceiptsContextual,\n alerts: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollReceipts',\n },\n })),\n ),\n cancelledToLandingTransition,\n exitFlowTransition,\n ),\n submittedReceipts: state<MachineTransition>(\n breadcrumbNavigateTransition('landing'),\n exitFlowTransition,\n ),\n transition: state<MachineTransition>(\n landingBreadcrumbNavigateTransition,\n exitFlowTransition,\n cancelledToLandingTransition,\n processedToSubmittedOverviewTransition,\n ),\n offCycle: state<MachineTransition>(\n landingBreadcrumbNavigateTransition,\n exitFlowTransition,\n cancelledToLandingTransition,\n processedToSubmittedOverviewTransition,\n ),\n}\n"],"names":["payrollFlowBreadcrumbsNodes","ctx","patchBreadcrumbsHeader","PayrollLandingContextual","breadcrumbNavigateTransition","createBreadcrumbNavigateTransition","toLandingReducer","toExecutionReducer","ev","executionInitialState","PayrollExecutionFlowContextual","landingBreadcrumbNavigateTransition","transition","componentEvents","guard","_ctx","reduce","exitFlowTransition","cancelledToLandingTransition","processedToSubmittedOverviewTransition","payPeriod","updateBreadcrumbs","PayrollOverviewContextual","payrollFlowMachine","state","PayrollBlockerContextual","TransitionFlowContextual","OffCycleFlowContextual","PayrollReceiptsContextual"],"mappings":";;;;;;;;AAsCO,MAAMA,IAA+C;AAAA,EAC1D,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,WAAW;AAAA,MACX,aAAa,CAACC,OAAsC;AAAA,QAClD,GAAGC,EAAuBD,GAAK,EAAE,qBAAqB,QAAW;AAAA,QACjE,WAAWE;AAAA,QACX,aAAa;AAAA,QACb,uBAAuB;AAAA,MAAA;AAAA,IACzB;AAAA,EACF;AAAA,EAEF,UAAU;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,WAAW;AAAA,IAAA;AAAA,EACb;AAAA,EAEF,mBAAmB;AAAA,IACjB,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,WAAW;AAAA,IAAA;AAAA,EACb;AAAA,EAE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gB;AAAA,MAChB;AAAA,MACAG,EAAO,CAACf,OAAmE;AAAA,QACzE,GAAGC,EAAuBD,GAAK,EAAE,qBAAqB,QAAW;AAAA,QACjE,WAAW0B;AAAA,QACX,2BAA2B;AAAA,MAAA,EAC3B;AAAA,IAAA;AAAA,EACJ;AAAA,EAEF,WAAWH;AAAA,IACTb;AAAA,IACAM;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA;AAAA,EAEF,UAAUK,EAAyBpB,EAA6B,SAAS,GAAGa,CAAkB;AAAA,EAC9F,mBAAmBO;AAAA,IACjBpB,EAA6B,SAAS;AAAA,IACtCQ;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAG,EAAO,CAACf,OAAmE;AAAA,QACzE,GAAGoB,EAAkB,qBAAqBpB,GAAK;AAAA,UAC7C,WAAWA,EAAI,WAAW,aAAa;AAAA,UACvC,SAASA,EAAI,WAAW,WAAW;AAAA,QAAA,CACpC;AAAA,QACD,WAAW2B;AAAA,QACX,QAAQ;AAAA,QACR,WAAW;AAAA,UACT,UAAU;AAAA,UACV,WAAW;AAAA,QAAA;AAAA,MACb,EACA;AAAA,IAAA;AAAA,IAEJV;AAAA,IACAD;AAAA,EAAA;AAAA,EAEF,mBAAmBO;AAAA,IACjBpB,EAA6B,SAAS;AAAA,IACtCa;AAAA,EAAA;AAAA,EAEF,YAAYO;AAAA,IACVb;AAAA,IACAM;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA;AAAA,EAEF,UAAUK;AAAA,IACRb;AAAA,IACAM;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"payrollStateMachine.js","sources":["../../../../src/components/Payroll/PayrollFlow/payrollStateMachine.ts"],"sourcesContent":["import { state, transition, reduce, guard } from 'robot3'\nimport type { PayrollPayPeriodType } from '@gusto/embedded-api/models/components/payrollpayperiodtype'\nimport type { PayrollExecutionInitialState } from '../PayrollExecutionFlow'\nimport {\n PayrollLandingContextual,\n PayrollBlockerContextual,\n PayrollOverviewContextual,\n PayrollReceiptsContextual,\n type PayrollFlowContextInterface,\n} from './PayrollFlowComponents'\nimport { PayrollExecutionFlowContextual } from './PayrollExecutionFlowContextual'\nimport { TransitionFlowContextual } from './TransitionFlowContextual'\nimport { OffCycleFlowContextual } from './OffCycleFlowContextual'\nimport { componentEvents } from '@/shared/constants'\nimport type { MachineEventType, MachineTransition } from '@/types/Helpers'\nimport { patchBreadcrumbsHeader, updateBreadcrumbs } from '@/helpers/breadcrumbHelpers'\nimport type { BreadcrumbNodes } from '@/components/Common/FlowBreadcrumbs/FlowBreadcrumbsTypes'\nimport { createBreadcrumbNavigateTransition } from '@/components/Common/FlowBreadcrumbs/breadcrumbTransitionHelpers'\n\ntype PayrollFlowEventPayloads = {\n [componentEvents.RUN_PAYROLL_SELECTED]: {\n payrollUuid: string\n }\n [componentEvents.REVIEW_PAYROLL]: {\n payrollUuid: string\n }\n [componentEvents.RUN_PAYROLL_PROCESSED]: {\n payPeriod?: PayrollPayPeriodType\n payrollUuid?: string\n }\n [componentEvents.RUN_TRANSITION_PAYROLL]: {\n startDate: string\n endDate: string\n payScheduleUuid: string\n }\n}\n\n/** @internal */\nexport const payrollFlowBreadcrumbsNodes: BreadcrumbNodes = {\n landing: {\n parent: null,\n item: {\n id: 'landing',\n label: 'breadcrumbs.landing',\n namespace: 'Payroll.PayrollLanding',\n onNavigate: ((ctx: PayrollFlowContextInterface) => ({\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: undefined }),\n component: PayrollLandingContextual,\n alerts: undefined,\n payrollUuid: undefined,\n executionInitialState: undefined,\n })) as (context: unknown) => unknown,\n },\n },\n blockers: {\n parent: 'landing',\n item: {\n id: 'blockers',\n label: 'breadcrumbLabel',\n namespace: 'Payroll.PayrollBlocker',\n },\n },\n submittedOverview: {\n parent: 'landing',\n item: {\n id: 'submittedOverview',\n label: 'breadcrumbs.overview',\n namespace: 'Payroll.PayrollLanding',\n },\n },\n submittedReceipts: {\n parent: 'landing',\n item: {\n id: 'submittedReceipts',\n label: 'breadcrumbs.receipt',\n namespace: 'Payroll.PayrollLanding',\n },\n },\n}\n\nconst breadcrumbNavigateTransition =\n createBreadcrumbNavigateTransition<PayrollFlowContextInterface>()\n\nfunction toLandingReducer(ctx: PayrollFlowContextInterface): PayrollFlowContextInterface {\n return {\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: undefined }),\n component: PayrollLandingContextual,\n alerts: undefined,\n payrollUuid: undefined,\n payPeriod: undefined,\n executionInitialState: undefined,\n }\n}\n\nfunction toExecutionReducer(\n ctx: PayrollFlowContextInterface,\n ev: { payload: { payrollUuid: string } },\n executionInitialState: PayrollExecutionInitialState,\n): PayrollFlowContextInterface {\n return {\n ...ctx,\n component: PayrollExecutionFlowContextual,\n alerts: undefined,\n payrollUuid: ev.payload.payrollUuid,\n showPayrollCancelledAlert: false,\n executionInitialState,\n }\n}\n\nconst landingBreadcrumbNavigateTransition = transition(\n componentEvents.BREADCRUMB_NAVIGATE,\n 'landing',\n guard(\n (_ctx: PayrollFlowContextInterface, ev: { payload: { key: string } }) =>\n ev.payload.key === 'landing',\n ),\n reduce(toLandingReducer),\n)\n\nconst exitFlowTransition = transition(\n componentEvents.PAYROLL_EXIT_FLOW,\n 'landing',\n reduce(toLandingReducer),\n)\n\nconst cancelledToLandingTransition = transition(\n componentEvents.RUN_PAYROLL_CANCELLED,\n 'landing',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...toLandingReducer(ctx),\n showPayrollCancelledAlert: true,\n })),\n)\n\nconst processedToSubmittedOverviewTransition = transition(\n componentEvents.RUN_PAYROLL_PROCESSED,\n 'submittedOverview',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<PayrollFlowEventPayloads, typeof componentEvents.RUN_PAYROLL_PROCESSED>,\n ): PayrollFlowContextInterface => {\n const payPeriod = ev.payload.payPeriod ?? ctx.payPeriod\n return {\n ...updateBreadcrumbs('submittedOverview', ctx, {\n startDate: payPeriod?.startDate ?? '',\n endDate: payPeriod?.endDate ?? '',\n }),\n component: PayrollOverviewContextual,\n alerts: undefined,\n payrollUuid: ev.payload.payrollUuid ?? ctx.payrollUuid,\n payPeriod,\n executionInitialState: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollOverview',\n },\n }\n },\n ),\n)\n\n/** @internal */\nexport const payrollFlowMachine = {\n landing: state<MachineTransition>(\n transition(\n componentEvents.RUN_PAYROLL_SELECTED,\n 'execution',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<\n PayrollFlowEventPayloads,\n typeof componentEvents.RUN_PAYROLL_SELECTED\n >,\n ) => toExecutionReducer(ctx, ev, 'configuration'),\n ),\n ),\n transition(\n componentEvents.REVIEW_PAYROLL,\n 'execution',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<PayrollFlowEventPayloads, typeof componentEvents.REVIEW_PAYROLL>,\n ) => toExecutionReducer(ctx, ev, 'overview'),\n ),\n ),\n transition(\n componentEvents.RUN_PAYROLL_BLOCKERS_VIEW_ALL,\n 'blockers',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...updateBreadcrumbs('blockers', ctx),\n component: PayrollBlockerContextual,\n alerts: undefined,\n showPayrollCancelledAlert: false,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollBlocker',\n },\n })),\n ),\n transition(\n componentEvents.RUN_PAYROLL_CANCELLED_ALERT_DISMISSED,\n 'landing',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...ctx,\n showPayrollCancelledAlert: false,\n })),\n ),\n transition(\n componentEvents.RUN_TRANSITION_PAYROLL,\n 'transition',\n reduce(\n (\n ctx: PayrollFlowContextInterface,\n ev: MachineEventType<\n PayrollFlowEventPayloads,\n typeof componentEvents.RUN_TRANSITION_PAYROLL\n >,\n ): PayrollFlowContextInterface => ({\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: undefined }),\n component: TransitionFlowContextual,\n alerts: undefined,\n transitionStartDate: ev.payload.startDate,\n transitionEndDate: ev.payload.endDate,\n transitionPayScheduleUuid: ev.payload.payScheduleUuid,\n showPayrollCancelledAlert: false,\n }),\n ),\n ),\n transition(\n componentEvents.RUN_OFF_CYCLE_PAYROLL,\n 'offCycle',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...patchBreadcrumbsHeader(ctx, { currentBreadcrumbId: undefined }),\n component: OffCycleFlowContextual,\n alerts: undefined,\n showPayrollCancelledAlert: false,\n })),\n ),\n ),\n execution: state<MachineTransition>(\n landingBreadcrumbNavigateTransition,\n exitFlowTransition,\n cancelledToLandingTransition,\n processedToSubmittedOverviewTransition,\n ),\n blockers: state<MachineTransition>(breadcrumbNavigateTransition('landing'), exitFlowTransition),\n submittedOverview: state<MachineTransition>(\n breadcrumbNavigateTransition('landing'),\n transition(\n componentEvents.RUN_PAYROLL_RECEIPT_GET,\n 'submittedReceipts',\n reduce((ctx: PayrollFlowContextInterface): PayrollFlowContextInterface => ({\n ...updateBreadcrumbs('submittedReceipts', ctx, {\n startDate: ctx.payPeriod?.startDate ?? '',\n endDate: ctx.payPeriod?.endDate ?? '',\n }),\n component: PayrollReceiptsContextual,\n alerts: undefined,\n ctaConfig: {\n labelKey: 'exitFlowCta',\n namespace: 'Payroll.PayrollReceipts',\n },\n })),\n ),\n cancelledToLandingTransition,\n exitFlowTransition,\n ),\n submittedReceipts: state<MachineTransition>(\n breadcrumbNavigateTransition('landing'),\n exitFlowTransition,\n ),\n transition: state<MachineTransition>(\n landingBreadcrumbNavigateTransition,\n exitFlowTransition,\n cancelledToLandingTransition,\n processedToSubmittedOverviewTransition,\n ),\n offCycle: state<MachineTransition>(\n landingBreadcrumbNavigateTransition,\n exitFlowTransition,\n cancelledToLandingTransition,\n processedToSubmittedOverviewTransition,\n ),\n}\n"],"names":["payrollFlowBreadcrumbsNodes","ctx","patchBreadcrumbsHeader","PayrollLandingContextual","breadcrumbNavigateTransition","createBreadcrumbNavigateTransition","toLandingReducer","toExecutionReducer","ev","executionInitialState","PayrollExecutionFlowContextual","landingBreadcrumbNavigateTransition","transition","componentEvents","guard","_ctx","reduce","exitFlowTransition","cancelledToLandingTransition","processedToSubmittedOverviewTransition","payPeriod","updateBreadcrumbs","PayrollOverviewContextual","payrollFlowMachine","state","PayrollBlockerContextual","TransitionFlowContextual","OffCycleFlowContextual","PayrollReceiptsContextual"],"mappings":";;;;;;;;AAsCO,MAAMA,IAA+C;AAAA,EAC1D,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,WAAW;AAAA,MACX,aAAa,CAACC,OAAsC;AAAA,QAClD,GAAGC,EAAuBD,GAAK,EAAE,qBAAqB,QAAW;AAAA,QACjE,WAAWE;AAAA,QACX,QAAQ;AAAA,QACR,aAAa;AAAA,QACb,uBAAuB;AAAA,MAAA;AAAA,IACzB;AAAA,EACF;AAAA,EAEF,UAAU;AAAA,IACR,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,WAAW;AAAA,IAAA;AAAA,EACb;AAAA,EAEF,mBAAmB;AAAA,IACjB,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,WAAW;AAAA,IAAA;AAAA,EACb;AAAA,EAEF,mBAAmB;AAAA,IACjB,QAAQ;AAAA,IACR,MAAM;AAAA,MACJ,IAAI;AAAA,MACJ,OAAO;AAAA,MACP,WAAW;AAAA,IAAA;AAAA,EACb;AAEJ,GAEMC,IACJC,EAAA;AAEF,SAASC,EAAiBL,GAA+D;AACvF,SAAO;AAAA,IACL,GAAGC,EAAuBD,GAAK,EAAE,qBAAqB,QAAW;AAAA,IACjE,WAAWE;AAAA,IACX,QAAQ;AAAA,IACR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J;AAAA,EAEF,WAAWH;AAAA,IACTb;AAAA,IACAM;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA;AAAA,EAEF,UAAUK,EAAyBpB,EAA6B,SAAS,GAAGa,CAAkB;AAAA,EAC9F,mBAAmBO;AAAA,IACjBpB,EAA6B,SAAS;AAAA,IACtCQ;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAG,EAAO,CAACf,OAAmE;AAAA,QACzE,GAAGoB,EAAkB,qBAAqBpB,GAAK;AAAA,UAC7C,WAAWA,EAAI,WAAW,aAAa;AAAA,UACvC,SAASA,EAAI,WAAW,WAAW;AAAA,QAAA,CACpC;AAAA,QACD,WAAW2B;AAAA,QACX,QAAQ;AAAA,QACR,WAAW;AAAA,UACT,UAAU;AAAA,UACV,WAAW;AAAA,QAAA;AAAA,MACb,EACA;AAAA,IAAA;AAAA,IAEJV;AAAA,IACAD;AAAA,EAAA;AAAA,EAEF,mBAAmBO;AAAA,IACjBpB,EAA6B,SAAS;AAAA,IACtCa;AAAA,EAAA;AAAA,EAEF,YAAYO;AAAA,IACVb;AAAA,IACAM;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA;AAAA,EAEF,UAAUK;AAAA,IACRb;AAAA,IACAM;AAAA,IACAC;AAAA,IACAC;AAAA,EAAA;AAEJ;"}
|
|
@@ -1,75 +1,75 @@
|
|
|
1
1
|
import { jsx as o, jsxs as p } from "react/jsx-runtime";
|
|
2
|
-
import { useForm as
|
|
3
|
-
import { zodResolver as
|
|
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
|
|
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
|
|
9
|
-
import { BaseComponent as
|
|
10
|
-
import { useBase as
|
|
11
|
-
import { useComponentContext as
|
|
12
|
-
import { useComponentDictionary as M, useI18n as
|
|
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
|
|
16
|
+
import { Form as q } from "../../../Common/Form/Form.js";
|
|
17
17
|
import { printChecksEvents as m } from "../../../../shared/constants.js";
|
|
18
|
-
import { RadioGroupField as
|
|
19
|
-
import { NumberInputField as
|
|
20
|
-
const
|
|
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
|
-
}),
|
|
24
|
-
if (r && typeof r == "object" && "errors" in r &&
|
|
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
|
-
},
|
|
29
|
+
}, V = (r) => ({
|
|
30
30
|
printingFormat: r.printingFormat,
|
|
31
31
|
...r.printingFormat === n.Bottom && r.startingCheckNumber !== void 0 ? { startingCheckNumber: r.startingCheckNumber } : {}
|
|
32
|
-
}),
|
|
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
|
|
37
|
-
return /* @__PURE__ */ o(
|
|
36
|
+
function J(r) {
|
|
37
|
+
return /* @__PURE__ */ o(G, { ...r, children: /* @__PURE__ */ o(Q, { ...r, children: r.children }) });
|
|
38
38
|
}
|
|
39
|
-
const
|
|
40
|
-
M("Payroll.PrintChecksForm", r),
|
|
41
|
-
const { t } = h("Payroll.PrintChecksForm"), { onEvent: c, baseSubmitHandler:
|
|
42
|
-
resolver:
|
|
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
|
-
}),
|
|
44
|
+
}), F = _({
|
|
45
45
|
name: "printingFormat",
|
|
46
46
|
control: l.control
|
|
47
|
-
}), { mutateAsync:
|
|
47
|
+
}), { mutateAsync: N } = I(), { start: y } = L({
|
|
48
48
|
onSucceeded: (a) => {
|
|
49
|
-
c(m.PRINT_CHECKS_GENERATE_SUCCEEDED, { documentUrl: a }), 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
|
-
}),
|
|
55
|
-
c(m.PRINT_CHECKS_GENERATE_START), await
|
|
54
|
+
}), P = async (a) => {
|
|
55
|
+
c(m.PRINT_CHECKS_GENERATE_START), await E(a, async (R) => {
|
|
56
56
|
try {
|
|
57
|
-
const C = (await
|
|
57
|
+
const C = (await N({
|
|
58
58
|
request: {
|
|
59
59
|
payrollUuid: e,
|
|
60
|
-
printablePayrollChecksBody:
|
|
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
|
-
|
|
65
|
+
y(C);
|
|
66
66
|
} catch (u) {
|
|
67
67
|
throw c(m.PRINT_CHECKS_GENERATE_FAILED, {
|
|
68
|
-
errorMessage:
|
|
68
|
+
errorMessage: O(u)
|
|
69
69
|
}), u;
|
|
70
70
|
}
|
|
71
71
|
});
|
|
72
|
-
},
|
|
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(
|
|
85
|
-
|
|
84
|
+
return /* @__PURE__ */ o(D, { ...l, children: /* @__PURE__ */ o(
|
|
85
|
+
q,
|
|
86
86
|
{
|
|
87
|
-
id:
|
|
88
|
-
onSubmit: l.handleSubmit(
|
|
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
|
-
|
|
93
|
+
K,
|
|
93
94
|
{
|
|
94
95
|
name: "printingFormat",
|
|
95
96
|
label: t("modalTitle"),
|
|
96
|
-
|
|
97
|
+
shouldVisuallyHideLabel: !0,
|
|
98
|
+
options: v,
|
|
97
99
|
isRequired: !0,
|
|
98
100
|
isDisabled: i
|
|
99
101
|
}
|
|
100
102
|
),
|
|
101
|
-
|
|
102
|
-
|
|
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:
|
|
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
|
-
},
|
|
116
|
-
|
|
117
|
-
const { t: e } = h("Payroll.PrintChecksForm"), { Button: i } =
|
|
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:
|
|
132
|
+
/* @__PURE__ */ o(i, { variant: "primary", type: "submit", form: k, isDisabled: s, children: e(s ? "submitCtaLoading" : "submitCta") })
|
|
131
133
|
] });
|
|
132
134
|
};
|
|
133
|
-
|
|
135
|
+
J.Footer = X;
|
|
134
136
|
export {
|
|
135
|
-
|
|
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,QAAMC,IAAO,SAAS,cAAc,GAAG;AACvC,EAAAA,EAAK,OAAOD,GACZC,EAAK,MAAM,uBACX,SAAS,KAAK,YAAYA,CAAI,GAC9BA,EAAK,MA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AAA;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,IAAsB,CAACC,MAAgC;AAC3D,MAAIA,KAAO,OAAOA,KAAQ,YAAY,YAAYA,KAAOJ,EAAYI,EAAI,MAAM,GAAG;AAChF,UAAM,CAACC,C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A,EAAA,GACF;AAEJ;AACAxC,EAAgB,SAASuC;"}
|
|
@@ -11,13 +11,10 @@ import "@gusto/embedded-api/models/errors/apierror";
|
|
|
11
11
|
import "@gusto/embedded-api/models/errors/gustoembeddederror";
|
|
12
12
|
import "@gusto/embedded-api/models/errors/sdkvalidationerror";
|
|
13
13
|
import "@gusto/embedded-api/models/errors/httpclienterrors";
|
|
14
|
-
import "dompurify";
|
|
15
|
-
import "../../contexts/LocaleProvider/useLocale.js";
|
|
16
14
|
import "../../shared/constants.js";
|
|
17
15
|
import "../../contexts/ComponentAdapter/useComponentContext.js";
|
|
18
|
-
import "../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
|
|
19
16
|
import { retryAsync as T } from "../../helpers/retryAsync.js";
|
|
20
|
-
const U = 4, q = 1500, B = (e) => e instanceof w ? e.errors.some((r) => r.category === "invalid_operation") : !1,
|
|
17
|
+
const U = 4, q = 1500, B = (e) => e instanceof w ? e.errors.some((r) => r.category === "invalid_operation") : !1, W = ({
|
|
21
18
|
companyId: e,
|
|
22
19
|
payrollId: r,
|
|
23
20
|
employeeUuids: a,
|
|
@@ -25,7 +22,7 @@ const U = 4, q = 1500, B = (e) => e instanceof w ? e.errors.some((r) => r.catego
|
|
|
25
22
|
onDataReady: l,
|
|
26
23
|
isTransitionPayroll: p = !1
|
|
27
24
|
}) => {
|
|
28
|
-
const { mutateAsync: c, isPending: u } = D(), [o, h] = _(), t = y(!1), d = y(!1), { baseSubmitHandler:
|
|
25
|
+
const { mutateAsync: c, isPending: u } = D(), [o, h] = _(), t = y(!1), d = y(!1), { baseSubmitHandler: P } = x(), S = b(() => a?.join(",") ?? "", [a]), { data: E, isLoading: g } = v(
|
|
29
26
|
{
|
|
30
27
|
companyId: e,
|
|
31
28
|
payScheduleId: o?.payPeriod?.payScheduleUuid || ""
|
|
@@ -33,7 +30,7 @@ const U = 4, q = 1500, B = (e) => e instanceof w ? e.errors.some((r) => r.catego
|
|
|
33
30
|
{
|
|
34
31
|
enabled: !!o?.payPeriod?.payScheduleUuid
|
|
35
32
|
}
|
|
36
|
-
),
|
|
33
|
+
), m = f(async () => {
|
|
37
34
|
const i = await c({
|
|
38
35
|
request: {
|
|
39
36
|
companyId: e,
|
|
@@ -54,15 +51,15 @@ const U = 4, q = 1500, B = (e) => e instanceof w ? e.errors.some((r) => r.catego
|
|
|
54
51
|
l,
|
|
55
52
|
p
|
|
56
53
|
]), s = f(async () => {
|
|
57
|
-
await
|
|
54
|
+
await P(
|
|
58
55
|
null,
|
|
59
|
-
() => T(
|
|
56
|
+
() => T(m, {
|
|
60
57
|
maxAttempts: U,
|
|
61
58
|
delayMs: q,
|
|
62
59
|
shouldRetry: B
|
|
63
60
|
})
|
|
64
61
|
);
|
|
65
|
-
}, [
|
|
62
|
+
}, [P, m]);
|
|
66
63
|
L(() => {
|
|
67
64
|
d.current || (d.current = !0, s());
|
|
68
65
|
}, [s]);
|
|
@@ -77,6 +74,6 @@ const U = 4, q = 1500, B = (e) => e instanceof w ? e.errors.some((r) => r.catego
|
|
|
77
74
|
};
|
|
78
75
|
};
|
|
79
76
|
export {
|
|
80
|
-
|
|
77
|
+
W as usePreparedPayrollData
|
|
81
78
|
};
|
|
82
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":"
|
|
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,M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15 @@
|
|
|
1
1
|
import { jsx as u } from "react/jsx-runtime";
|
|
2
2
|
import { QueryClientProvider as E } from "@tanstack/react-query";
|
|
3
|
-
import { GustoEmbeddedProvider as
|
|
4
|
-
import { GustoEmbeddedCore as
|
|
3
|
+
import { GustoEmbeddedProvider as g } from "@gusto/embedded-api/react-query/_context";
|
|
4
|
+
import { GustoEmbeddedCore as R } from "@gusto/embedded-api/core";
|
|
5
5
|
import { SDKHooks as q } from "@gusto/embedded-api/hooks/hooks";
|
|
6
6
|
import { useMemo as m } from "react";
|
|
7
|
-
import { apiVersionHook as
|
|
7
|
+
import { apiVersionHook as l } from "./apiVersionHook.js";
|
|
8
8
|
import { apiVersionMismatchHook as a } from "./apiVersionMismatchHook.js";
|
|
9
|
-
import { informationRequestEnumHook as
|
|
10
|
-
import {
|
|
11
|
-
|
|
9
|
+
import { informationRequestEnumHook as A } from "./informationRequestEnumHook.js";
|
|
10
|
+
import { payrollDeductionAmountHook as C } from "./payrollDeductionAmountHook.js";
|
|
11
|
+
import { createSdkQueryClient as S } from "./createSdkQueryClient.js";
|
|
12
|
+
function Q({
|
|
12
13
|
url: s,
|
|
13
14
|
headers: i,
|
|
14
15
|
hooks: r,
|
|
@@ -16,12 +17,12 @@ function P({
|
|
|
16
17
|
queryClient: f
|
|
17
18
|
}) {
|
|
18
19
|
const p = m(() => {
|
|
19
|
-
const t = new
|
|
20
|
+
const t = new R({
|
|
20
21
|
serverURL: s
|
|
21
22
|
}), e = t._options.hooks || new q();
|
|
22
|
-
if (e.registerBeforeRequestHook(
|
|
23
|
+
if (e.registerBeforeRequestHook(l), e.registerAfterSuccessHook(a), e.registerAfterErrorHook(a), e.registerAfterSuccessHook(A), e.registerAfterSuccessHook(C), i) {
|
|
23
24
|
const o = {
|
|
24
|
-
beforeRequest: (
|
|
25
|
+
beforeRequest: (b, n) => (new Headers(i).forEach((c, k) => {
|
|
25
26
|
c && n.headers.set(k, c);
|
|
26
27
|
}), n)
|
|
27
28
|
};
|
|
@@ -36,10 +37,10 @@ function P({
|
|
|
36
37
|
}), r?.afterError && r.afterError.forEach((o) => {
|
|
37
38
|
e.registerAfterErrorHook(o);
|
|
38
39
|
}), t._options.hooks || (t._options.hooks = e), t;
|
|
39
|
-
}, [s, i, r]), d = m(() => f ??
|
|
40
|
-
return /* @__PURE__ */ u(E, { client: d, children: /* @__PURE__ */ u(
|
|
40
|
+
}, [s, i, r]), d = m(() => f ?? S(), [f]);
|
|
41
|
+
return /* @__PURE__ */ u(E, { client: d, children: /* @__PURE__ */ u(g, { client: p, children: H }) });
|
|
41
42
|
}
|
|
42
43
|
export {
|
|
43
|
-
|
|
44
|
+
Q as ApiProvider
|
|
44
45
|
};
|
|
45
46
|
//# sourceMappingURL=ApiProvider.js.map
|