@gusto/embedded-react-sdk 0.57.2 → 0.57.3
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 +20 -0
- package/dist/components/Common/DateRangeFilter/DateRangeFilter.js +32 -32
- package/dist/components/Common/DateRangeFilter/DateRangeFilter.js.map +1 -1
- package/dist/components/Common/OnboardingStatusBadge/index.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js +34 -14
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.js +106 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.js +136 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js +38 -20
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js +78 -44
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js +45 -37
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js +244 -95
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js +22 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.js +13 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js +48 -43
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/payScheduleAssignmentStateMachine.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.js +57 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.js +83 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.js +84 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.js.map +1 -0
- package/dist/components/Company/PaySchedule/management/PayScheduleManagementComponents.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js +109 -39
- package/dist/components/Company/PaySchedule/management/PayScheduleOverview.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js.map +1 -1
- package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js.map +1 -1
- package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.js.map +1 -1
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js +5 -5
- package/dist/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.js.map +1 -1
- package/dist/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.js +1 -1
- package/dist/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.js.map +1 -1
- package/dist/components/Contractor/Compensation/shared/useContractorCompensationSummary/useContractorCompensationSummary.js +4 -4
- package/dist/components/Contractor/Compensation/shared/useContractorCompensationSummary/useContractorCompensationSummary.js.map +1 -1
- package/dist/components/Contractor/Compensation/shared/useContractorPayForm/useContractorPayForm.js +3 -3
- package/dist/components/Contractor/Compensation/shared/useContractorPayForm/useContractorPayForm.js.map +1 -1
- package/dist/components/Contractor/ContractorList/shared/useContractorList.js +6 -6
- package/dist/components/Contractor/ContractorList/shared/useContractorList.js.map +1 -1
- package/dist/components/Contractor/Dashboard/Dashboard.js +20 -20
- package/dist/components/Contractor/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Contractor/Dismissal/useDismissal/useDismissal.js +10 -10
- package/dist/components/Contractor/Dismissal/useDismissal/useDismissal.js.map +1 -1
- package/dist/components/Contractor/Landing/Landing.js +43 -39
- package/dist/components/Contractor/Landing/Landing.js.map +1 -1
- package/dist/components/Contractor/NewHireReport/NewHireReport.js +3 -3
- package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
- package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js +1 -1
- package/dist/components/Contractor/Payments/CreateHistoricalPayment/CreateHistoricalPayment.js.map +1 -1
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js +10 -10
- package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -1
- package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js +4 -4
- package/dist/components/Contractor/Payments/HistoricalPaymentSummary/HistoricalPaymentSummary.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js +8 -8
- package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js +5 -5
- package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js.map +1 -1
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js +3 -3
- package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js.map +1 -1
- package/dist/components/Contractor/Profile/onboarding/SelfOnboardingContractorProfile.js +1 -1
- package/dist/components/Contractor/Profile/onboarding/SelfOnboardingContractorProfile.js.map +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorDetailsForm/useContractorDetailsForm.js.map +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorProfileSummary/useContractorProfileSummary.js +1 -1
- package/dist/components/Contractor/Profile/shared/useContractorProfileSummary/useContractorProfileSummary.js.map +1 -1
- package/dist/components/Contractor/SelfOnboardingFlow/SelfOnboardingComponents.js +2 -9
- package/dist/components/Contractor/SelfOnboardingFlow/SelfOnboardingComponents.js.map +1 -1
- package/dist/components/Contractor/Submit/Submit.js +18 -18
- package/dist/components/Contractor/Submit/Submit.js.map +1 -1
- package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js +6 -6
- package/dist/components/Contractor/shared/SelectContractors/useSelectContractors.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +25 -25
- package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.js +15 -15
- package/dist/components/Employee/Compensation/shared/useCompensationManagement/useCompensationManagement.js.map +1 -1
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +1 -1
- package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
- package/dist/components/Employee/Dashboard/Dashboard.js +25 -25
- package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js +7 -7
- package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentSigner.js.map +1 -1
- package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js +1 -1
- package/dist/components/Employee/Documents/onboarding/EmployeeDocuments/EmployeeDocuments.js.map +1 -1
- package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js +6 -6
- package/dist/components/Employee/HomeAddress/management/useHomeAddressManagement.js.map +1 -1
- package/dist/components/Employee/Landing/Landing.js +37 -33
- package/dist/components/Employee/Landing/Landing.js.map +1 -1
- package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js +27 -27
- package/dist/components/Employee/OnboardingSummary/OnboardingSummary.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js +6 -6
- package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/useEmployeeDetailsForm.js.map +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.js +1 -1
- package/dist/components/Employee/Profile/shared/useEmployeeProfileSummary/useEmployeeProfileSummary.js.map +1 -1
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.js +8 -15
- package/dist/components/Employee/SelfOnboardingFlow/SelfOnboardingComponents.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js +11 -11
- package/dist/components/Employee/Terminations/TerminateEmployee/TerminateEmployee.js.map +1 -1
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js +12 -12
- package/dist/components/Employee/Terminations/TerminationSummary/TerminationSummary.js.map +1 -1
- package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js +26 -26
- package/dist/components/Employee/WorkAddress/management/useWorkAddressManagement.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js +66 -64
- package/dist/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js +1 -1
- package/dist/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js +6 -6
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js +1 -1
- package/dist/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistory.js.map +1 -1
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js +6 -6
- package/dist/components/Payroll/PayrollHistory/PayrollHistoryPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollList.js.map +1 -1
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js +9 -9
- package/dist/components/Payroll/PayrollList/PayrollListPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollOverview/PayrollOverviewPresentation.js.map +1 -1
- package/dist/components/Payroll/PayrollReceipts/PayrollReceiptsPresentation.js.map +1 -1
- package/dist/components/Payroll/helpers.js +1 -1
- package/dist/components/Payroll/helpers.js.map +1 -1
- package/dist/components/Payroll/payrollTypes.js +1 -1
- package/dist/components/Payroll/payrollTypes.js.map +1 -1
- package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
- package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js +1 -1
- package/dist/contexts/ApiProvider/payrollOffCycleReasonEnumHook.js.map +1 -1
- package/dist/i18n/en/Company.Management.PaySchedule.json.js +31 -13
- package/dist/i18n/en/Company.Management.PaySchedule.json.js.map +1 -1
- package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js +20 -12
- package/dist/i18n/en/Company.Management.PayScheduleAssignment.json.js.map +1 -1
- package/dist/i18n/en/Payroll.PayrollHistory.json.js +1 -1
- package/dist/i18n/en/Payroll.PayrollList.json.js +5 -5
- package/dist/package.json.js +1 -1
- package/dist/shared/constants.js +5 -5
- package/dist/shared/constants.js.map +1 -1
- package/dist/src/components/Common/DateRangeFilter/DateRangeFilter.d.ts +2 -2
- package/dist/src/components/Common/OnboardingStatusBadge/index.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/AutoPilotDialog.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/AutoPilotDialog/useAutoPilotDialog.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentCompensationStepPresentation.d.ts +10 -3
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentDepartmentStepPresentation.d.ts +21 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentEmployeeStepPresentation.d.ts +34 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentScheduleStepPresentation.d.ts +9 -3
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/AssignmentTypeStepPresentation.d.ts +5 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignment.d.ts +10 -10
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/PayScheduleAssignmentComponents.d.ts +12 -4
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/departmentAccess.d.ts +19 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/employeeJob.d.ts +17 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/scheduleLabel.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/useAssignableEmployees.d.ts +34 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleAssignment/usePayScheduleAssignment.d.ts +16 -3
- package/dist/src/components/Company/PaySchedule/management/PayScheduleCompensationOverviewPresentation.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleDepartmentOverviewPresentation.d.ts +23 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleEmployeeOverviewPresentation.d.ts +25 -0
- package/dist/src/components/Company/PaySchedule/management/PayScheduleManagementComponents.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.d.ts +1 -1
- package/dist/src/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.d.ts +1 -1
- package/dist/src/components/Contractor/Landing/Landing.d.ts +5 -2
- package/dist/src/components/Employee/Landing/Landing.d.ts +5 -2
- package/dist/src/components/Payroll/PayrollConfiguration/PayrollConfigurationPresentation.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollConfiguration/usePayrollConfigurationData.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollEditEmployee/shared/usePayrollEditEmployeeForm/usePayrollEditEmployeeForm.d.ts +2 -2
- package/dist/src/components/Payroll/PayrollHistory/PayrollHistoryPresentation.d.ts +1 -1
- package/dist/src/components/Payroll/PayrollList/PayrollListPresentation.d.ts +2 -2
- package/dist/src/components/Payroll/PayrollOverview/PayrollOverviewPresentation.d.ts +1 -1
- package/dist/src/components/Payroll/helpers.d.ts +2 -2
- package/dist/src/components/Payroll/usePreparedPayrollData.d.ts +2 -2
- package/dist/src/i18n/types.d.ts +82 -4
- package/dist/src/models/external.d.ts +63 -48
- package/dist/src/shared/constants.d.ts +1 -1
- package/docs/guides/endpoint-inventory.json +33 -13
- package/package.json +18 -18
|
@@ -1,62 +1,132 @@
|
|
|
1
1
|
import { jsx as p } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { useDepartmentsGetAllSuspense as g } from "@gusto/embedded-api/react-query/departmentsGetAll";
|
|
3
|
+
import { useTranslation as U } from "react-i18next";
|
|
4
|
+
import { usePaySchedulesGetAllSuspense as v } from "@gusto/embedded-api/react-query/paySchedulesGetAll";
|
|
5
|
+
import { usePaySchedulesGetAssignmentsSuspense as w } from "@gusto/embedded-api/react-query/paySchedulesGetAssignments";
|
|
6
|
+
import { PayScheduleAssignmentType as y } from "@gusto/embedded-api/models/components/payscheduleassignment";
|
|
7
|
+
import { PayScheduleEmployeeOverviewPresentation as h } from "./PayScheduleEmployeeOverviewPresentation.js";
|
|
8
|
+
import { useAssignableEmployeesSuspense as D } from "./PayScheduleAssignment/useAssignableEmployees.js";
|
|
9
|
+
import { getCompanyDepartments as O } from "./PayScheduleAssignment/departmentAccess.js";
|
|
10
|
+
import { PayScheduleDepartmentOverviewPresentation as T } from "./PayScheduleDepartmentOverviewPresentation.js";
|
|
5
11
|
import { PayScheduleOverviewPresentation as _ } from "./PayScheduleOverviewPresentation.js";
|
|
6
|
-
import { PayScheduleCompensationOverviewPresentation as
|
|
7
|
-
import { componentEvents as
|
|
8
|
-
import { ensureRequired as
|
|
9
|
-
function
|
|
10
|
-
companyId:
|
|
11
|
-
onEvent:
|
|
12
|
-
enableAutoPilot:
|
|
13
|
-
enableMultipleSchedules:
|
|
12
|
+
import { PayScheduleCompensationOverviewPresentation as M } from "./PayScheduleCompensationOverviewPresentation.js";
|
|
13
|
+
import { componentEvents as f } from "../../../../shared/constants.js";
|
|
14
|
+
import { ensureRequired as C } from "../../../../helpers/ensureRequired.js";
|
|
15
|
+
function Q({
|
|
16
|
+
companyId: s,
|
|
17
|
+
onEvent: n,
|
|
18
|
+
enableAutoPilot: u,
|
|
19
|
+
enableMultipleSchedules: i
|
|
14
20
|
}) {
|
|
15
|
-
const { data:
|
|
16
|
-
|
|
17
|
-
},
|
|
18
|
-
|
|
19
|
-
},
|
|
20
|
-
|
|
21
|
+
const { data: l } = v({ companyId: s }), { data: r } = w({ companyId: s }), o = l.payScheduleShowResponse ?? [], t = r.payScheduleAssignment, e = (c) => {
|
|
22
|
+
n(f.PAY_SCHEDULE_UPDATE, { uuid: c.uuid });
|
|
23
|
+
}, d = (c) => {
|
|
24
|
+
n(f.PAY_SCHEDULE_AUTO_PILOT_EDIT, { schedule: c });
|
|
25
|
+
}, a = () => {
|
|
26
|
+
n(f.PAY_SCHEDULE_MANAGE_ASSIGNMENT);
|
|
21
27
|
};
|
|
22
|
-
if (
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
{
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
28
|
+
if (t?.type === y.ByEmployee)
|
|
29
|
+
return /* @__PURE__ */ p(
|
|
30
|
+
L,
|
|
31
|
+
{
|
|
32
|
+
companyId: s,
|
|
33
|
+
assignment: t,
|
|
34
|
+
schedules: o,
|
|
35
|
+
enableAutoPilot: u,
|
|
36
|
+
enableMultipleSchedules: i,
|
|
37
|
+
onEditSchedule: e,
|
|
38
|
+
onManageAssignment: a,
|
|
39
|
+
onEditAutoPilot: d
|
|
40
|
+
}
|
|
41
|
+
);
|
|
42
|
+
if (t?.type === y.ByDepartment)
|
|
43
|
+
return /* @__PURE__ */ p(
|
|
44
|
+
G,
|
|
45
|
+
{
|
|
46
|
+
companyId: s,
|
|
47
|
+
assignment: t,
|
|
48
|
+
schedules: o,
|
|
49
|
+
enableAutoPilot: u,
|
|
50
|
+
enableMultipleSchedules: i,
|
|
51
|
+
onEditSchedule: e,
|
|
52
|
+
onManageAssignment: a,
|
|
53
|
+
onEditAutoPilot: d
|
|
54
|
+
}
|
|
55
|
+
);
|
|
56
|
+
if (t?.type === y.HourlySalaried) {
|
|
57
|
+
const c = [
|
|
58
|
+
{ compensationType: "salaried", uuid: t.salariedPayScheduleUuid },
|
|
59
|
+
{ compensationType: "hourly", uuid: t.hourlyPayScheduleUuid }
|
|
60
|
+
].flatMap(({ compensationType: P, uuid: E }) => {
|
|
61
|
+
const S = o.find((A) => A.uuid === E);
|
|
62
|
+
return S ? [{ compensationType: P, schedule: S }] : [];
|
|
29
63
|
});
|
|
30
64
|
return /* @__PURE__ */ p(
|
|
31
|
-
|
|
65
|
+
M,
|
|
32
66
|
{
|
|
33
|
-
rows:
|
|
34
|
-
enableAutoPilot:
|
|
35
|
-
enableMultipleSchedules:
|
|
36
|
-
onEditSchedule:
|
|
37
|
-
onManageAssignment:
|
|
38
|
-
onEditAutoPilot:
|
|
67
|
+
rows: c,
|
|
68
|
+
enableAutoPilot: u,
|
|
69
|
+
enableMultipleSchedules: i,
|
|
70
|
+
onEditSchedule: e,
|
|
71
|
+
onManageAssignment: a,
|
|
72
|
+
onEditAutoPilot: d
|
|
39
73
|
}
|
|
40
74
|
);
|
|
41
75
|
}
|
|
42
|
-
const
|
|
76
|
+
const m = C(o.find((c) => c.active) ?? o[0]);
|
|
43
77
|
return /* @__PURE__ */ p(
|
|
44
78
|
_,
|
|
45
79
|
{
|
|
46
|
-
schedule:
|
|
47
|
-
enableAutoPilot:
|
|
48
|
-
enableMultipleSchedules:
|
|
80
|
+
schedule: m,
|
|
81
|
+
enableAutoPilot: u,
|
|
82
|
+
enableMultipleSchedules: i,
|
|
49
83
|
onEditSchedule: () => {
|
|
50
|
-
|
|
84
|
+
e(m);
|
|
51
85
|
},
|
|
52
|
-
onManageAssignment:
|
|
86
|
+
onManageAssignment: a,
|
|
53
87
|
onEditAutoPilot: () => {
|
|
54
|
-
|
|
88
|
+
d(m);
|
|
55
89
|
}
|
|
56
90
|
}
|
|
57
91
|
);
|
|
58
92
|
}
|
|
93
|
+
function G({
|
|
94
|
+
companyId: s,
|
|
95
|
+
assignment: n,
|
|
96
|
+
schedules: u,
|
|
97
|
+
...i
|
|
98
|
+
}) {
|
|
99
|
+
const { data: l } = g({ companyUuid: s }), { t: r } = U("Company.Management.PaySchedule"), o = O(l.departmentList).flatMap(
|
|
100
|
+
(e) => {
|
|
101
|
+
const d = n.departments?.find((m) => m.departmentUuid === e.uuid)?.payScheduleUuid ?? n.defaultPayScheduleUuid, a = u.find((m) => m.uuid === d);
|
|
102
|
+
return a ? [{ departmentName: e.title ?? r("unnamedDepartment"), schedule: a }] : [];
|
|
103
|
+
}
|
|
104
|
+
), t = u.find(
|
|
105
|
+
(e) => e.uuid === n.defaultPayScheduleUuid
|
|
106
|
+
);
|
|
107
|
+
return t && o.push({ departmentName: r("uncategorizedEmployees"), schedule: t }), /* @__PURE__ */ p(T, { rows: o, ...i });
|
|
108
|
+
}
|
|
109
|
+
function L({
|
|
110
|
+
companyId: s,
|
|
111
|
+
assignment: n,
|
|
112
|
+
schedules: u,
|
|
113
|
+
...i
|
|
114
|
+
}) {
|
|
115
|
+
const l = D(s);
|
|
116
|
+
if (l.accessDenied)
|
|
117
|
+
return /* @__PURE__ */ p(h, { rows: [], accessDenied: !0, ...i });
|
|
118
|
+
const r = /* @__PURE__ */ new Map();
|
|
119
|
+
for (const t of l.employees) {
|
|
120
|
+
const e = n.employees?.find((d) => d.employeeUuid === t.uuid)?.payScheduleUuid ?? n.defaultPayScheduleUuid;
|
|
121
|
+
e && r.set(e, (r.get(e) ?? 0) + 1);
|
|
122
|
+
}
|
|
123
|
+
const o = u.flatMap((t) => {
|
|
124
|
+
const e = r.get(t.uuid) ?? 0;
|
|
125
|
+
return e > 0 ? [{ schedule: t, employeeCount: e }] : [];
|
|
126
|
+
});
|
|
127
|
+
return /* @__PURE__ */ p(h, { rows: o, ...i });
|
|
128
|
+
}
|
|
59
129
|
export {
|
|
60
|
-
|
|
130
|
+
Q as PayScheduleOverview
|
|
61
131
|
};
|
|
62
132
|
//# sourceMappingURL=PayScheduleOverview.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayScheduleOverview.js","sources":["../../../../../src/components/Company/PaySchedule/management/PayScheduleOverview.tsx"],"sourcesContent":["import { usePaySchedulesGetAllSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAll'\nimport { usePaySchedulesGetAssignmentsSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAssignments'\nimport { PayScheduleAssignmentType } from '@gusto/embedded-api/models/components/payscheduleassignment'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport { PayScheduleOverviewPresentation } from './PayScheduleOverviewPresentation'\nimport type { PayScheduleCompensationRow } from './PayScheduleCompensationOverviewPresentation'\nimport { PayScheduleCompensationOverviewPresentation } from './PayScheduleCompensationOverviewPresentation'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { ensureRequired } from '@/helpers/ensureRequired'\n\n/** @internal */\nexport interface PayScheduleOverviewProps {\n companyId: string\n onEvent: OnEventType<EventType, unknown>\n enableAutoPilot?: boolean\n enableMultipleSchedules?: boolean\n}\n\n/** @internal */\nexport function PayScheduleOverview({\n companyId,\n onEvent,\n enableAutoPilot,\n enableMultipleSchedules,\n}: PayScheduleOverviewProps) {\n const { data: paySchedules } = usePaySchedulesGetAllSuspense({ companyId })\n const { data: assignments } = usePaySchedulesGetAssignmentsSuspense({ companyId })\n const schedules = paySchedules.payScheduleShowResponse ?? []\n const assignment = assignments.payScheduleAssignment\n\n const editSchedule = (schedule: PayScheduleShow) => {\n onEvent(componentEvents.PAY_SCHEDULE_UPDATE, { uuid: schedule.uuid })\n }\n const editAutoPilot = (schedule: PayScheduleShow) => {\n onEvent(componentEvents.PAY_SCHEDULE_AUTO_PILOT_EDIT, { schedule })\n }\n const manageAssignment = () => {\n onEvent(componentEvents.PAY_SCHEDULE_MANAGE_ASSIGNMENT)\n }\n\n if (assignment?.type === PayScheduleAssignmentType.HourlySalaried) {\n /**\n * A uuid the assignment references but `paySchedulesGetAll` doesn't return has no schedule\n * to name, edit, or hand to the AutoPilot dialog, so its row is dropped rather than\n * rendered half-populated.\n */\n const rows = (\n [\n { compensationType: 'salaried', uuid: assignment.salariedPayScheduleUuid },\n { compensationType: 'hourly', uuid: assignment.hourlyPayScheduleUuid },\n ] as const\n ).flatMap<PayScheduleCompensationRow>(({ compensationType, uuid }) => {\n const schedule = schedules.find(s => s.uuid === uuid)\n return schedule ? [{ compensationType, schedule }] : []\n })\n\n return (\n <PayScheduleCompensationOverviewPresentation\n rows={rows}\n enableAutoPilot={enableAutoPilot}\n enableMultipleSchedules={enableMultipleSchedules}\n onEditSchedule={editSchedule}\n onManageAssignment={manageAssignment}\n onEditAutoPilot={editAutoPilot}\n />\n )\n }\n\n /**\n * Prefer the schedule with employees assigned to it over an unassigned leftover — relevant\n * if enableMultipleSchedules was previously on and is now off, leaving more than one schedule\n * behind. PaySchedule.tsx only routes here once it's confirmed at least one schedule exists.\n */\n const schedule = ensureRequired(schedules.find(s => s.active) ?? schedules[0])\n\n return (\n <PayScheduleOverviewPresentation\n schedule={schedule}\n enableAutoPilot={enableAutoPilot}\n enableMultipleSchedules={enableMultipleSchedules}\n onEditSchedule={() => {\n editSchedule(schedule)\n }}\n onManageAssignment={manageAssignment}\n onEditAutoPilot={() => {\n editAutoPilot(schedule)\n }}\n />\n )\n}\n"],"names":["PayScheduleOverview","companyId","onEvent","enableAutoPilot","enableMultipleSchedules","paySchedules","usePaySchedulesGetAllSuspense","assignments","usePaySchedulesGetAssignmentsSuspense","schedules","assignment","editSchedule","schedule","componentEvents","editAutoPilot","manageAssignment","PayScheduleAssignmentType","rows","compensationType","uuid","s","jsx","PayScheduleCompensationOverviewPresentation","ensureRequired","PayScheduleOverviewPresentation"],"mappings":";;;;;;;;AAoBO,SAASA,EAAoB;AAAA,EAClC,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,yBAAAC;AACF,GAA6B;AAC3B,QAAM,EAAE,MAAMC,EAAA,IAAiBC,EAA8B,EAAE,WAAAL,GAAW,GACpE,EAAE,MAAMM,EAAA,IAAgBC,EAAsC,EAAE,WAAAP,GAAW,GAC3EQ,IAAYJ,EAAa,2BAA2B,CAAA,GACpDK,IAAaH,EAAY,uBAEzBI,IAAe,CAACC,MAA8B;AAClD,IAAAV,EAAQW,EAAgB,qBAAqB,EAAE,MAAMD,EAAS,MAAM;AAAA,EACtE,GACME,IAAgB,CAACF,MAA8B;AACnD,IAAAV,EAAQW,EAAgB,8BAA8B,EAAE,UAAAD,GAAU;AAAA,EACpE,GACMG,IAAmB,MAAM;AAC7B,IAAAb,EAAQW,EAAgB,8BAA8B;AAAA,EACxD;AAEA,MAAIH,GAAY,SAASM,EAA0B,gBAAgB;AAMjE,UAAMC,IACJ;AAAA,MACE,EAAE,kBAAkB,YAAY,MAAMP,EAAW,wBAAA;AAAA,MACjD,EAAE,kBAAkB,UAAU,MAAMA,EAAW,sBAAA;AAAA,IAAsB,EAEvE,QAAoC,CAAC,EAAE,kBAAAQ,GAAkB,MAAAC,QAAW;AACpE,YAAMP,IAAWH,EAAU,KAAK,CAAAW,MAAKA,EAAE,SAASD,CAAI;AACpD,aAAOP,IAAW,CAAC,EAAE,kBAAAM,GAAkB,UAAAN,EAAAA,CAAU,IAAI,CAAA;AAAA,IACvD,CAAC;AAED,WACE,gBAAAS;AAAA,MAACC;AAAA,MAAA;AAAA,QACC,MAAAL;AAAA,QACA,iBAAAd;AAAA,QACA,yBAAAC;AAAA,QACA,gBAAgBO;AAAA,QAChB,oBAAoBI;AAAA,QACpB,iBAAiBD;AAAA,MAAA;AAAA,IAAA;AAAA,EAGvB;AAOA,QAAMF,IAAWW,EAAed,EAAU,KAAK,CAAAW,MAAKA,EAAE,MAAM,KAAKX,EAAU,CAAC,CAAC;AAE7E,SACE,gBAAAY;AAAA,IAACG;AAAA,IAAA;AAAA,MACC,UAAAZ;AAAA,MACA,iBAAAT;AAAA,MACA,yBAAAC;AAAA,MACA,gBAAgB,MAAM;AACpB,QAAAO,EAAaC,CAAQ;AAAA,MACvB;AAAA,MACA,oBAAoBG;AAAA,MACpB,iBAAiB,MAAM;AACrB,QAAAD,EAAcF,CAAQ;AAAA,MACxB;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
|
1
|
+
{"version":3,"file":"PayScheduleOverview.js","sources":["../../../../../src/components/Company/PaySchedule/management/PayScheduleOverview.tsx"],"sourcesContent":["import { useDepartmentsGetAllSuspense } from '@gusto/embedded-api/react-query/departmentsGetAll'\nimport { useTranslation } from 'react-i18next'\nimport type { PayScheduleAssignment } from '@gusto/embedded-api/models/components/payscheduleassignment'\nimport { usePaySchedulesGetAllSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAll'\nimport { usePaySchedulesGetAssignmentsSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAssignments'\nimport { PayScheduleAssignmentType } from '@gusto/embedded-api/models/components/payscheduleassignment'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payschedulelistitem'\nimport { PayScheduleEmployeeOverviewPresentation } from './PayScheduleEmployeeOverviewPresentation'\nimport { useAssignableEmployeesSuspense } from './PayScheduleAssignment/useAssignableEmployees'\nimport { getCompanyDepartments } from './PayScheduleAssignment/departmentAccess'\nimport {\n PayScheduleDepartmentOverviewPresentation,\n type PayScheduleDepartmentRow,\n} from './PayScheduleDepartmentOverviewPresentation'\nimport { PayScheduleOverviewPresentation } from './PayScheduleOverviewPresentation'\nimport type { PayScheduleCompensationRow } from './PayScheduleCompensationOverviewPresentation'\nimport { PayScheduleCompensationOverviewPresentation } from './PayScheduleCompensationOverviewPresentation'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { ensureRequired } from '@/helpers/ensureRequired'\n\n/** @internal */\nexport interface PayScheduleOverviewProps {\n companyId: string\n onEvent: OnEventType<EventType, unknown>\n enableAutoPilot?: boolean\n enableMultipleSchedules?: boolean\n}\n\n/** @internal */\nexport function PayScheduleOverview({\n companyId,\n onEvent,\n enableAutoPilot,\n enableMultipleSchedules,\n}: PayScheduleOverviewProps) {\n const { data: paySchedules } = usePaySchedulesGetAllSuspense({ companyId })\n const { data: assignments } = usePaySchedulesGetAssignmentsSuspense({ companyId })\n const schedules = paySchedules.payScheduleShowResponse ?? []\n const assignment = assignments.payScheduleAssignment\n\n const editSchedule = (schedule: PayScheduleShow) => {\n onEvent(componentEvents.PAY_SCHEDULE_UPDATE, { uuid: schedule.uuid })\n }\n const editAutoPilot = (schedule: PayScheduleShow) => {\n onEvent(componentEvents.PAY_SCHEDULE_AUTO_PILOT_EDIT, { schedule })\n }\n const manageAssignment = () => {\n onEvent(componentEvents.PAY_SCHEDULE_MANAGE_ASSIGNMENT)\n }\n\n if (assignment?.type === PayScheduleAssignmentType.ByEmployee) {\n return (\n <PayScheduleEmployeeOverview\n companyId={companyId}\n assignment={assignment}\n schedules={schedules}\n enableAutoPilot={enableAutoPilot}\n enableMultipleSchedules={enableMultipleSchedules}\n onEditSchedule={editSchedule}\n onManageAssignment={manageAssignment}\n onEditAutoPilot={editAutoPilot}\n />\n )\n }\n\n if (assignment?.type === PayScheduleAssignmentType.ByDepartment) {\n return (\n <PayScheduleDepartmentOverview\n companyId={companyId}\n assignment={assignment}\n schedules={schedules}\n enableAutoPilot={enableAutoPilot}\n enableMultipleSchedules={enableMultipleSchedules}\n onEditSchedule={editSchedule}\n onManageAssignment={manageAssignment}\n onEditAutoPilot={editAutoPilot}\n />\n )\n }\n\n if (assignment?.type === PayScheduleAssignmentType.HourlySalaried) {\n /**\n * A uuid the assignment references but `paySchedulesGetAll` doesn't return has no schedule\n * to name, edit, or hand to the AutoPilot dialog, so its row is dropped rather than\n * rendered half-populated.\n */\n const rows = (\n [\n { compensationType: 'salaried', uuid: assignment.salariedPayScheduleUuid },\n { compensationType: 'hourly', uuid: assignment.hourlyPayScheduleUuid },\n ] as const\n ).flatMap<PayScheduleCompensationRow>(({ compensationType, uuid }) => {\n const schedule = schedules.find(s => s.uuid === uuid)\n return schedule ? [{ compensationType, schedule }] : []\n })\n\n return (\n <PayScheduleCompensationOverviewPresentation\n rows={rows}\n enableAutoPilot={enableAutoPilot}\n enableMultipleSchedules={enableMultipleSchedules}\n onEditSchedule={editSchedule}\n onManageAssignment={manageAssignment}\n onEditAutoPilot={editAutoPilot}\n />\n )\n }\n\n /**\n * Prefer the schedule with employees assigned to it over an unassigned leftover — relevant\n * if enableMultipleSchedules was previously on and is now off, leaving more than one schedule\n * behind. PaySchedule.tsx only routes here once it's confirmed at least one schedule exists.\n */\n const schedule = ensureRequired(schedules.find(s => s.active) ?? schedules[0])\n\n return (\n <PayScheduleOverviewPresentation\n schedule={schedule}\n enableAutoPilot={enableAutoPilot}\n enableMultipleSchedules={enableMultipleSchedules}\n onEditSchedule={() => {\n editSchedule(schedule)\n }}\n onManageAssignment={manageAssignment}\n onEditAutoPilot={() => {\n editAutoPilot(schedule)\n }}\n />\n )\n}\n\nfunction PayScheduleDepartmentOverview({\n companyId,\n assignment,\n schedules,\n ...props\n}: {\n companyId: string\n assignment: PayScheduleAssignment\n schedules: PayScheduleShow[]\n} & Omit<React.ComponentProps<typeof PayScheduleDepartmentOverviewPresentation>, 'rows'>) {\n const { data } = useDepartmentsGetAllSuspense({ companyUuid: companyId })\n const { t } = useTranslation('Company.Management.PaySchedule')\n const rows = getCompanyDepartments(data.departmentList).flatMap<PayScheduleDepartmentRow>(\n department => {\n const uuid =\n assignment.departments?.find(selection => selection.departmentUuid === department.uuid)\n ?.payScheduleUuid ?? assignment.defaultPayScheduleUuid\n const schedule = schedules.find(schedule => schedule.uuid === uuid)\n return schedule\n ? [{ departmentName: department.title ?? t('unnamedDepartment'), schedule }]\n : []\n },\n )\n const defaultSchedule = schedules.find(\n schedule => schedule.uuid === assignment.defaultPayScheduleUuid,\n )\n if (defaultSchedule)\n rows.push({ departmentName: t('uncategorizedEmployees'), schedule: defaultSchedule })\n return <PayScheduleDepartmentOverviewPresentation rows={rows} {...props} />\n}\n\nfunction PayScheduleEmployeeOverview({\n companyId,\n assignment,\n schedules,\n ...props\n}: {\n companyId: string\n assignment: PayScheduleAssignment\n schedules: PayScheduleShow[]\n} & Omit<React.ComponentProps<typeof PayScheduleEmployeeOverviewPresentation>, 'rows'>) {\n const roster = useAssignableEmployeesSuspense(companyId)\n if (roster.accessDenied)\n return <PayScheduleEmployeeOverviewPresentation rows={[]} accessDenied {...props} />\n const counts = new Map<string, number>()\n for (const employee of roster.employees) {\n const uuid =\n assignment.employees?.find(entry => entry.employeeUuid === employee.uuid)?.payScheduleUuid ??\n assignment.defaultPayScheduleUuid\n if (uuid) counts.set(uuid, (counts.get(uuid) ?? 0) + 1)\n }\n const rows = schedules.flatMap(schedule => {\n const employeeCount = counts.get(schedule.uuid) ?? 0\n return employeeCount > 0 ? [{ schedule, employeeCount }] : []\n })\n return <PayScheduleEmployeeOverviewPresentation rows={rows} {...props} />\n}\n"],"names":["PayScheduleOverview","companyId","onEvent","enableAutoPilot","enableMultipleSchedules","paySchedules","usePaySchedulesGetAllSuspense","assignments","usePaySchedulesGetAssignmentsSuspense","schedules","assignment","editSchedule","schedule","componentEvents","editAutoPilot","manageAssignment","PayScheduleAssignmentType","jsx","PayScheduleEmployeeOverview","PayScheduleDepartmentOverview","rows","compensationType","uuid","s","PayScheduleCompensationOverviewPresentation","ensureRequired","PayScheduleOverviewPresentation","props","data","useDepartmentsGetAllSuspense","t","useTranslation","getCompanyDepartments","department","selection","defaultSchedule","PayScheduleDepartmentOverviewPresentation","roster","useAssignableEmployeesSuspense","PayScheduleEmployeeOverviewPresentation","counts","employee","entry","employeeCount"],"mappings":";;;;;;;;;;;;;;AA8BO,SAASA,EAAoB;AAAA,EAClC,WAAAC;AAAA,EACA,SAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,yBAAAC;AACF,GAA6B;AAC3B,QAAM,EAAE,MAAMC,EAAA,IAAiBC,EAA8B,EAAE,WAAAL,GAAW,GACpE,EAAE,MAAMM,EAAA,IAAgBC,EAAsC,EAAE,WAAAP,GAAW,GAC3EQ,IAAYJ,EAAa,2BAA2B,CAAA,GACpDK,IAAaH,EAAY,uBAEzBI,IAAe,CAACC,MAA8B;AAClD,IAAAV,EAAQW,EAAgB,qBAAqB,EAAE,MAAMD,EAAS,MAAM;AAAA,EACtE,GACME,IAAgB,CAACF,MAA8B;AACnD,IAAAV,EAAQW,EAAgB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AjB;AAAA,EACA,YAAAS;AAAA,EACA,WAAAD;AAAA,EACA,GAAGkB;AACL,GAIwF;AACtF,QAAMU,IAASC,EAA+BrC,CAAS;AACvD,MAAIoC,EAAO;AACT,WAAO,gBAAApB,EAACsB,KAAwC,MAAM,CAAA,GAAI,cAAY,IAAE,GAAGZ,GAAO;AACpF,QAAMa,wBAAa,IAAA;AACnB,aAAWC,KAAYJ,EAAO,WAAW;AACvC,UAAMf,IACJZ,EAAW,WAAW,KAAK,CAAAgC,MAASA,EAAM,iBAAiBD,EAAS,IAAI,GAAG,mBAC3E/B,EAAW;AACb,IAAIY,OAAa,IAAIA,IAAOkB,EAAO,IAAIlB,CAAI,KAAK,KAAK,CAAC;AAAA,EACxD;AACA,QAAMF,IAAOX,EAAU,QAAQ,CAAAG,MAAY;AACzC,UAAM+B,IAAgBH,EAAO,IAAI5B,EAAS,IAAI,KAAK;AACnD,WAAO+B,IAAgB,IAAI,CAAC,EAAE,UAAA/B,GAAU,eAAA+B,EAAA,CAAe,IAAI,CAAA;AAAA,EAC7D,CAAC;AACD,SAAO,gBAAA1B,EAACsB,GAAA,EAAwC,MAAAnB,GAAa,GAAGO,EAAA,CAAO;AACzE;"}
|
package/dist/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PayScheduleOverviewPresentation.js","sources":["../../../../../src/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/
|
|
1
|
+
{"version":3,"file":"PayScheduleOverviewPresentation.js","sources":["../../../../../src/components/Company/PaySchedule/management/PayScheduleOverviewPresentation.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payschedulelistitem'\nimport styles from './PayScheduleOverviewPresentation.module.scss'\nimport { Flex } from '@/components/Common/Flex'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\n/** @internal */\nexport interface PayScheduleOverviewPresentationProps {\n /** The company's single pay schedule. */\n schedule: PayScheduleShow\n /** Shows the AutoPilot row and its Edit action when `true`. */\n enableAutoPilot?: boolean\n /** Shows the Manage action when `true`. */\n enableMultipleSchedules?: boolean\n /** Fired when the user clicks Edit on the pay schedule row. */\n onEditSchedule: () => void\n /** Fired when the user clicks Manage. */\n onManageAssignment: () => void\n /** Fired when the user clicks Edit on the AutoPilot row. */\n onEditAutoPilot: () => void\n}\n\nfunction Row({ label, value, action }: { label: ReactNode; value: ReactNode; action?: ReactNode }) {\n const Components = useComponentContext()\n return (\n <div className={styles.row}>\n <Flex justifyContent=\"space-between\" alignItems=\"center\">\n <Flex flexDirection=\"column\" gap={4}>\n <Components.Text weight=\"semibold\">{label}</Components.Text>\n <Components.Text variant=\"supporting\">{value}</Components.Text>\n </Flex>\n {action}\n </Flex>\n </div>\n )\n}\n\n/** @internal */\nexport function PayScheduleOverviewPresentation({\n schedule,\n enableAutoPilot,\n enableMultipleSchedules,\n onEditSchedule,\n onManageAssignment,\n onEditAutoPilot,\n}: PayScheduleOverviewPresentationProps) {\n const { t } = useTranslation('Company.Management.PaySchedule')\n const Components = useComponentContext()\n\n return (\n <Components.Box\n header={\n <Components.BoxHeader\n title={t('title')}\n description={t('description')}\n action={\n enableMultipleSchedules ? (\n <Components.Button variant=\"secondary\" onClick={onManageAssignment}>\n {t('manageCta')}\n </Components.Button>\n ) : undefined\n }\n />\n }\n >\n <div className={styles.rows}>\n <Row\n label={t('labels.name')}\n value={schedule.customName}\n action={\n <Components.Button\n variant=\"secondary\"\n onClick={onEditSchedule}\n aria-label={t('editScheduleAriaLabel')}\n >\n {t('editCta')}\n </Components.Button>\n }\n />\n <Row label={t('labels.frequency')} value={schedule.frequency} />\n {enableAutoPilot ? (\n <Row\n label={t('autoPilot.label')}\n value={schedule.autoPayroll ? t('autoPilot.enabled') : t('autoPilot.disabled')}\n action={\n <Components.Button\n variant=\"secondary\"\n onClick={onEditAutoPilot}\n aria-label={t('editAutoPilotAriaLabel')}\n >\n {t('editCta')}\n </Components.Button>\n }\n />\n ) : null}\n </div>\n </Components.Box>\n )\n}\n"],"names":["Row","label","value","action","Components","useComponentContext","jsx","styles","Flex","jsxs","PayScheduleOverviewPresentation","schedule","enableAutoPilot","enableMultipleSchedules","onEditSchedule","onManageAssignment","onEditAutoPilot","t","useTranslation"],"mappings":";;;;;AAuBA,SAASA,EAAI,EAAE,OAAAC,GAAO,OAAAC,GAAO,QAAAC,KAAsE;AACjG,QAAMC,IAAaC,EAAA;AACnB,SACE,gBAAAC,EAAC,OAAA,EAAI,WAAWC,EAAO,KACrB,4BAACC,GAAA,EAAK,gBAAe,iBAAgB,YAAW,UAC9C,UAAA;AAAA,IAAA,gBAAAC,EAACD,GAAA,EAAK,eAAc,UAAS,KAAK,GAChC,UAAA;AAAA,MAAA,gBAAAF,EAACF,EAAW,MAAX,EAAgB,QAAO,YAAY,UAAAH,GAAM;AAAA,wBACzCG,EAAW,MAAX,EAAgB,SAAQ,cAAc,UAAAF,EAAA,CAAM;AAAA,IAAA,GAC/C;AAAA,IACCC;AAAA,EAAA,EAAA,CACH,EAAA,CACF;AAEJ;AAGO,SAASO,EAAgC;AAAA,EAC9C,UAAAC;AAAA,EACA,iBAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,gBAAAC;AAAA,EACA,oBAAAC;AAAA,EACA,iBAAAC;AACF,GAAyC;AACvC,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,gCAAgC,GACvDd,IAAaC,EAAA;AAEnB,SACE,gBAAAC;AAAA,IAACF,EAAW;AAAA,IAAX;AAAA,MACC,QACE,gBAAAE;AAAA,QAACF,EAAW;AAAA,QAAX;AAAA,UACC,OAAOa,EAAE,OAAO;AAAA,UAChB,aAAaA,EAAE,aAAa;AAAA,UAC5B,QACEJ,IACE,gBAAAP,EAACF,EAAW,QAAX,EAAkB,SAAQ,aAAY,SAASW,GAC7C,UAAAE,EAAE,WAAW,GAChB,IACE;AAAA,QAAA;AAAA,MAAA;AAAA,MAKV,UAAA,gBAAAR,EAAC,OAAA,EAAI,WAAWF,EAAO,MACrB,UAAA;AAAA,QAAA,gBAAAD;AAAA,UAACN;AAAA,UAAA;AAAA,YACC,OAAOiB,EAAE,aAAa;AAAA,YACtB,OAAON,EAAS;AAAA,YAChB,QACE,gBAAAL;AAAA,cAACF,EAAW;AAAA,cAAX;AAAA,gBACC,SAAQ;AAAA,gBACR,SAASU;AAAA,gBACT,cAAYG,EAAE,uBAAuB;AAAA,gBAEpC,YAAE,SAAS;AAAA,cAAA;AAAA,YAAA;AAAA,UACd;AAAA,QAAA;AAAA,QAGJ,gBAAAX,EAACN,KAAI,OAAOiB,EAAE,kBAAkB,GAAG,OAAON,EAAS,WAAW;AAAA,QAC7DC,IACC,gBAAAN;AAAA,UAACN;AAAA,UAAA;AAAA,YACC,OAAOiB,EAAE,iBAAiB;AAAA,YAC1B,OAAON,EAAS,cAAcM,EAAE,mBAAmB,IAAIA,EAAE,oBAAoB;AAAA,YAC7E,QACE,gBAAAX;AAAA,cAACF,EAAW;AAAA,cAAX;AAAA,gBACC,SAAQ;AAAA,gBACR,SAASY;AAAA,gBACT,cAAYC,EAAE,wBAAwB;AAAA,gBAErC,YAAE,SAAS;AAAA,cAAA;AAAA,YAAA;AAAA,UACd;AAAA,QAAA,IAGF;AAAA,MAAA,EAAA,CACN;AAAA,IAAA;AAAA,EAAA;AAGN;"}
|
package/dist/components/Company/PaySchedule/management/payScheduleManagementStateMachine.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payScheduleManagementStateMachine.js","sources":["../../../../../src/components/Company/PaySchedule/management/payScheduleManagementStateMachine.ts"],"sourcesContent":["import { reduce, state, transition } from 'robot3'\nimport type { ComponentType } from 'react'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/
|
|
1
|
+
{"version":3,"file":"payScheduleManagementStateMachine.js","sources":["../../../../../src/components/Company/PaySchedule/management/payScheduleManagementStateMachine.ts"],"sourcesContent":["import { reduce, state, transition } from 'robot3'\nimport type { ComponentType } from 'react'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payschedulelistitem'\nimport type { PayScheduleManagementContextInterface } from './PayScheduleManagementComponents'\nimport {\n PayScheduleOverviewContextual,\n PayScheduleEditFormContextual,\n PayScheduleAssignmentContextual,\n} from './PayScheduleManagementComponents'\nimport { componentEvents } from '@/shared/constants'\nimport type { MachineEventType, MachineTransition } from '@/types/Helpers'\n\ntype EventPayloads = {\n [componentEvents.PAY_SCHEDULE_UPDATE]: { uuid: string }\n [componentEvents.PAY_SCHEDULE_CREATED]: undefined\n [componentEvents.PAY_SCHEDULE_AUTO_PILOT_EDIT]: { schedule: PayScheduleShow }\n}\n\nconst toOverview = reduce(\n (ctx: PayScheduleManagementContextInterface): PayScheduleManagementContextInterface => ({\n ...ctx,\n component: PayScheduleOverviewContextual as ComponentType,\n payScheduleId: undefined,\n autoPilotSchedule: undefined,\n successAlert: null,\n }),\n)\n\nconst toOverviewWithAlert = (alert: PayScheduleManagementContextInterface['successAlert']) =>\n reduce((ctx: PayScheduleManagementContextInterface): PayScheduleManagementContextInterface => ({\n ...ctx,\n component: PayScheduleOverviewContextual as ComponentType,\n payScheduleId: undefined,\n autoPilotSchedule: undefined,\n successAlert: alert,\n }))\n\n/** @internal */\nexport const payScheduleManagementStateMachine = {\n overview: state<MachineTransition>(\n transition(\n componentEvents.PAY_SCHEDULE_UPDATE,\n 'editSchedule',\n reduce(\n (\n ctx: PayScheduleManagementContextInterface,\n ev: MachineEventType<EventPayloads, typeof componentEvents.PAY_SCHEDULE_UPDATE>,\n ): PayScheduleManagementContextInterface => ({\n ...ctx,\n component: PayScheduleEditFormContextual as ComponentType,\n payScheduleId: ev.payload.uuid,\n }),\n ),\n ),\n transition(\n componentEvents.PAY_SCHEDULE_MANAGE_ASSIGNMENT,\n 'manageAssignment',\n reduce(\n (ctx: PayScheduleManagementContextInterface): PayScheduleManagementContextInterface => ({\n ...ctx,\n component: PayScheduleAssignmentContextual as ComponentType,\n successAlert: null,\n }),\n ),\n ),\n transition(componentEvents.PAY_SCHEDULE_MANAGEMENT_ALERT_DISMISSED, 'overview', toOverview),\n transition(\n componentEvents.PAY_SCHEDULE_AUTO_PILOT_EDIT,\n 'overview',\n reduce(\n (\n ctx: PayScheduleManagementContextInterface,\n ev: MachineEventType<EventPayloads, typeof componentEvents.PAY_SCHEDULE_AUTO_PILOT_EDIT>,\n ): PayScheduleManagementContextInterface => ({\n ...ctx,\n autoPilotSchedule: ev.payload.schedule,\n }),\n ),\n ),\n transition(\n componentEvents.PAY_SCHEDULE_AUTO_PILOT_ENABLED,\n 'overview',\n reduce(\n (ctx: PayScheduleManagementContextInterface): PayScheduleManagementContextInterface => ({\n ...ctx,\n autoPilotSchedule: undefined,\n }),\n ),\n ),\n transition(\n componentEvents.PAY_SCHEDULE_AUTO_PILOT_DISABLED,\n 'overview',\n reduce(\n (ctx: PayScheduleManagementContextInterface): PayScheduleManagementContextInterface => ({\n ...ctx,\n autoPilotSchedule: undefined,\n }),\n ),\n ),\n transition(\n componentEvents.PAY_SCHEDULE_AUTO_PILOT_DISMISSED,\n 'overview',\n reduce(\n (ctx: PayScheduleManagementContextInterface): PayScheduleManagementContextInterface => ({\n ...ctx,\n autoPilotSchedule: undefined,\n }),\n ),\n ),\n ),\n editSchedule: state<MachineTransition>(\n transition(componentEvents.PAY_SCHEDULE_UPDATED, 'overview', toOverview),\n transition(componentEvents.CANCEL, 'overview', toOverview),\n ),\n /**\n * Entered directly from PaySchedule.tsx's initial routing when the company has no pay\n * schedules yet — there's no overview to fall back to, so CANCEL isn't handled here; it\n * still bubbles to the host via Flow's onEvent re-emit.\n */\n createSchedule: state<MachineTransition>(\n transition(componentEvents.PAY_SCHEDULE_CREATED, 'overview', toOverview),\n ),\n manageAssignment: state<MachineTransition>(\n transition(componentEvents.PAY_SCHEDULE_ASSIGNMENT_CANCEL, 'overview', toOverview),\n transition(\n componentEvents.PAY_SCHEDULE_ASSIGNED,\n 'overview',\n toOverviewWithAlert('assignmentUpdated'),\n ),\n ),\n}\n"],"names":["toOverview","reduce","ctx","PayScheduleOverviewContextual","toOverviewWithAlert","alert","payScheduleManagementStateMachine","state","transition","componentEvents","ev","PayScheduleEditFormContextual","PayScheduleAssignmentContextual"],"mappings":";;;AAkBA,MAAMA,IAAaC;AAAA,EACjB,CAACC,OAAuF;AAAA,IACtF,GAAGA;AAAA,IACH,WAAWC;AAAA,IACX,eAAe;AAAA,IACf,mBAAmB;AAAA,IACnB,cAAc;AAAA,EAAA;AAElB,GAEMC,IAAsB,CAACC,MAC3BJ,EAAO,CAACC,OAAuF;AAAA,EAC7F,GAAGA;AAAA,EACH,WAAWC;AAAA,EACX,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,cAAcE;AAChB,EAAE,GAGSC,IAAoC;AAAA,EAC/C,UAAUC;AAAA,IACRC;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAR;AAAA,QACE,CACEC,GACAQ,OAC2C;AAAA,UAC3C,GAAGR;AAAA,UACH,WAAWS;AAAA,UACX,eAAeD,EAAG,QAAQ;AAAA,QAAA;AAAA,MAC5B;AAAA,IACF;AAAA,IAEFF;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAR;AAAA,QACE,CAACC,OAAuF;AAAA,UACtF,GAAGA;AAAA,UACH,WAAWU;AAAA,UACX,cAAc;AAAA,QAAA;AAAA,MAChB;AAAA,IACF;AAAA,IAEFJ,EAAWC,EAAgB,yCAAyC,YAAYT,CAAU;AAAA,IAC1FQ;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAR;AAAA,QACE,CACEC,GACAQ,OAC2C;AAAA,UAC3C,GAAGR;AAAA,UACH,mBAAmBQ,EAAG,QAAQ;AAAA,QAAA;AAAA,MAChC;AAAA,IACF;AAAA,IAEFF;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAR;AAAA,QACE,CAACC,OAAuF;AAAA,UACtF,GAAGA;AAAA,UACH,mBAAmB;AAAA,QAAA;AAAA,MACrB;AAAA,IACF;AAAA,IAEFM;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAR;AAAA,QACE,CAACC,OAAuF;AAAA,UACtF,GAAGA;AAAA,UACH,mBAAmB;AAAA,QAAA;AAAA,MACrB;AAAA,IACF;AAAA,IAEFM;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAR;AAAA,QACE,CAACC,OAAuF;AAAA,UACtF,GAAGA;AAAA,UACH,mBAAmB;AAAA,QAAA;AAAA,MACrB;AAAA,IACF;AAAA,EACF;AAAA,EAEF,cAAcK;AAAA,IACZC,EAAWC,EAAgB,sBAAsB,YAAYT,CAAU;AAAA,IACvEQ,EAAWC,EAAgB,QAAQ,YAAYT,CAAU;AAAA,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAO3D,gBAAgBO;AAAA,IACdC,EAAWC,EAAgB,sBAAsB,YAAYT,CAAU;AAAA,EAAA;AAAA,EAEzE,kBAAkBO;AAAA,IAChBC,EAAWC,EAAgB,gCAAgC,YAAYT,CAAU;AAAA,IACjFQ;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAL,EAAoB,mBAAmB;AAAA,IAAA;AAAA,EACzC;AAEJ;"}
|
package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePayScheduleForm.js","sources":["../../../../../../src/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.tsx"],"sourcesContent":["import { useEffect, useMemo } from 'react'\nimport type { ComponentType } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payscheduleshow'\nimport type { PaySchedulePreviewPayPeriod } from '@gusto/embedded-api/models/components/payschedulepreviewpayperiod'\nimport { WorkweekStartDay } from '@gusto/embedded-api/models/components/payschedulecreaterequest'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { usePaySchedulesGetPreview } from '@gusto/embedded-api/react-query/paySchedulesGetPreview'\nimport { usePaySchedulesCreateMutation } from '@gusto/embedded-api/react-query/paySchedulesCreate'\nimport { usePaySchedulesUpdateMutation } from '@gusto/embedded-api/react-query/paySchedulesUpdate'\nimport { usePaymentConfigsGet } from '@gusto/embedded-api/react-query/paymentConfigsGet'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport {\n createPayScheduleSchema,\n type PayScheduleOptionalFieldsToRequire,\n type PayScheduleFormData,\n type PayScheduleFormOutputs,\n type PayScheduleFrequency,\n type PayScheduleWorkweekStartDay,\n} from './payScheduleSchema'\nimport {\n CustomNameField,\n FrequencyField,\n CustomTwicePerMonthField,\n AnchorPayDateField,\n AnchorEndOfPayPeriodField,\n Day1Field,\n Day2Field,\n WorkweekStartDayField,\n} from './fields'\nimport type {\n CustomNameFieldProps,\n FrequencyFieldProps,\n CustomTwicePerMonthFieldProps,\n AnchorPayDateFieldProps,\n AnchorEndOfPayPeriodFieldProps,\n Day1FieldProps,\n Day2FieldProps,\n WorkweekStartDayFieldProps,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { withFlags } from '@/partner-hook-utils/form/withFlags'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { parsePaymentSpeedDays } from '@/hooks/useCompanyPaymentSpeed'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\n\nexport type { PayScheduleOptionalFieldsToRequire } from './payScheduleSchema'\n\n/**\n * Configuration options for {@link usePayScheduleForm}.\n *\n * @remarks\n * Presence or absence of `payScheduleId` selects between update and create mode.\n *\n * @public\n */\nexport interface UsePayScheduleFormProps {\n /** UUID of the company that owns the pay schedule. */\n companyId: string\n /**\n * When set, loads that pay schedule and updates it on submit. When omitted,\n * the form is in create mode and creates a new schedule on submit.\n */\n payScheduleId?: string\n /** Override fields that are optional on a given mode to be required. See `PayScheduleOptionalFieldsToRequire`. */\n optionalFieldsToRequire?: PayScheduleOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence on update. */\n defaultValues?: Partial<PayScheduleFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n /**\n * Renders `Fields.WorkweekStartDay` disabled while still submitting its current value,\n * for partners that compute the workweek start day themselves and don't want end users\n * editing it directly. Defaults to `false`. Has no effect unless the `payrollRegularRateOfPay`\n * unstable feature is enabled.\n *\n * @alpha\n */\n disableWorkweekStartDayEditing?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `usePayScheduleForm().form.Fields`.\n *\n * @remarks\n * `CustomTwicePerMonth`, `Day1`, and `Day2` are conditionally `undefined` based\n * on the selected frequency and twice-per-month strategy — always null-check them\n * before rendering.\n *\n * @public\n */\nexport interface PayScheduleFormFields {\n /** Bound to `customName`. Display name text input. Always available. */\n CustomName: ComponentType<CustomNameFieldProps>\n /** Bound to `frequency`. Frequency selector. Always available. */\n Frequency: ComponentType<FrequencyFieldProps>\n /** Bound to `customTwicePerMonth`. Twice-per-month strategy radio group. Only available when frequency is `'Twice per month'`. */\n CustomTwicePerMonth: ComponentType<CustomTwicePerMonthFieldProps> | undefined\n /** Bound to `anchorPayDate`. First pay date picker. Always available. */\n AnchorPayDate: ComponentType<AnchorPayDateFieldProps>\n /** Bound to `anchorEndOfPayPeriod`. First pay period end date picker. Always available. */\n AnchorEndOfPayPeriod: ComponentType<AnchorEndOfPayPeriodFieldProps>\n /** Bound to `day1`. First-pay-day-of-month number input. Available when frequency is `'Monthly'`, or `'Twice per month'` with `'custom'` strategy. */\n Day1: ComponentType<Day1FieldProps> | undefined\n /** Bound to `day2`. Last-pay-day-of-month number input. Available when frequency is `'Twice per month'` with `'custom'` strategy. */\n Day2: ComponentType<Day2FieldProps> | undefined\n /**\n * Bound to `workweekStartDay`. Workweek start day selector, used for regular rate of pay\n * overtime calculations. `undefined` unless the `payrollRegularRateOfPay` unstable feature\n * is enabled.\n *\n * @alpha\n */\n WorkweekStartDay: ComponentType<WorkweekStartDayFieldProps> | undefined\n}\n\n/**\n * Ready-state shape returned by {@link usePayScheduleForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with the\n * pay-schedule-specific `data`, `status`, `actions`, and `form.Fields` shape.\n *\n * @public\n */\nexport interface UsePayScheduleFormReady extends BaseFormHookReady<\n PayScheduleFieldsMetadata,\n PayScheduleFormData,\n PayScheduleFormFields\n> {\n /** Static entity data resolved from the API. */\n data: {\n /** The pay schedule loaded for update; `null` in create mode. */\n paySchedule: PayScheduleShow | null\n /** Upcoming pay periods previewed from current form values; `null` until the anchor date fields are complete. */\n payPeriodPreview: PaySchedulePreviewPayPeriod[] | null\n /** `true` while the pay period preview request is in flight. */\n payPreviewLoading: boolean\n /** Business days the company needs to process payroll, derived from payment configs; `null` if unavailable. */\n paymentSpeedDays: number | null\n }\n /** Reactive status flags. */\n status: {\n /** `true` while the create or update mutation is in flight. */\n isPending: boolean\n /** Whether the form is creating a new schedule or updating an existing one. */\n mode: 'create' | 'update'\n }\n /** Available actions. */\n actions: {\n /** Validates the form and dispatches the create or update mutation. Returns the saved schedule, or `undefined` if validation failed. */\n onSubmit: () => Promise<HookSubmitResult<PayScheduleShow> | undefined>\n }\n}\n\nconst FREQUENCY_OPTIONS: Array<{ value: PayScheduleFrequency; label: string }> = [\n { value: 'Every week', label: 'Every week' },\n { value: 'Every other week', label: 'Every other week' },\n { value: 'Twice per month', label: 'Twice per month' },\n { value: 'Monthly', label: 'Monthly' },\n]\n\nconst FREQUENCY_ENTRIES: PayScheduleFrequency[] = FREQUENCY_OPTIONS.map(o => o.value)\n\nconst TWICE_PER_MONTH_OPTIONS = [\n { value: '1st15th', label: '15th and Last day of the month' },\n { value: 'custom', label: 'Custom' },\n]\n\nconst TWICE_PER_MONTH_ENTRIES = TWICE_PER_MONTH_OPTIONS.map(o => o.value)\n\nconst WORKWEEK_START_DAY_ENTRIES: PayScheduleWorkweekStartDay[] = Object.values(WorkweekStartDay)\n\nconst WORKWEEK_START_DAY_OPTIONS: Array<{ value: PayScheduleWorkweekStartDay; label: string }> =\n WORKWEEK_START_DAY_ENTRIES.map(value => ({ value, label: value }))\n\nfunction formatWatchedDate(value: unknown): string {\n if (value instanceof Date) return formatDateToStringDate(value) || ''\n if (typeof value === 'string' && value) return value\n return ''\n}\n\nfunction deriveCustomTwicePerMonth(\n frequency: string | undefined,\n day1: number | undefined,\n day2: number | undefined,\n): string {\n if (frequency !== 'Twice per month') return ''\n if (day1 === 15 && day2 === 31) return '1st15th'\n // Only pre-select 'custom' when there are real day values to represent (e.g.\n // editing an existing custom schedule). With no day basis, leave the radio\n // unselected so its required validation prompts an explicit choice rather\n // than silently forcing empty day1/day2 fields into a required state.\n if (day1 != null && day2 != null) return 'custom'\n return ''\n}\n\n/** @internal */\nfunction buildPayScheduleFieldsMetadata(\n base: Record<keyof PayScheduleFormData, FieldMetadata>,\n disableWorkweekStartDayEditing: boolean,\n) {\n return {\n customName: base.customName,\n frequency: withOptions<PayScheduleFrequency>(\n base.frequency,\n FREQUENCY_OPTIONS,\n FREQUENCY_ENTRIES,\n ),\n customTwicePerMonth: withOptions<string>(\n base.customTwicePerMonth,\n TWICE_PER_MONTH_OPTIONS,\n TWICE_PER_MONTH_ENTRIES,\n ),\n anchorPayDate: base.anchorPayDate,\n anchorEndOfPayPeriod: base.anchorEndOfPayPeriod,\n day1: base.day1,\n day2: base.day2,\n workweekStartDay: withOptions<PayScheduleWorkweekStartDay>(\n withFlags(base.workweekStartDay, { isDisabled: disableWorkweekStartDayEditing }),\n WORKWEEK_START_DAY_OPTIONS,\n WORKWEEK_START_DAY_ENTRIES,\n ),\n } satisfies FieldsMetadata\n}\n\n/**\n * Form hook for creating or updating a company pay schedule.\n *\n * @remarks\n * When `payScheduleId` is supplied the hook loads that schedule and issues an\n * update on submit; when omitted it operates in create mode. While both anchor\n * date fields are filled in, the hook fetches a live pay period calendar\n * preview exposed on `data.payPeriodPreview`. `data.paymentSpeedDays` reflects\n * the company's payment configuration and is useful for surfacing UI hints\n * about how far ahead the first pay date must be.\n *\n * @param props - See {@link UsePayScheduleFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UsePayScheduleFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import {\n * usePayScheduleForm,\n * SDKFormProvider,\n * type UsePayScheduleFormReady,\n * } from '@gusto/embedded-react-sdk'\n *\n * function PaySchedulePage({ companyId }: { companyId: string }) {\n * const paySchedule = usePayScheduleForm({ companyId })\n *\n * if (paySchedule.isLoading) return <div>Loading...</div>\n *\n * return <PayScheduleFormReady paySchedule={paySchedule} />\n * }\n *\n * function PayScheduleFormReady({ paySchedule }: { paySchedule: UsePayScheduleFormReady }) {\n * const { Fields } = paySchedule.form\n *\n * return (\n * <SDKFormProvider formHookResult={paySchedule}>\n * <form\n * onSubmit={e => {\n * e.preventDefault()\n * void paySchedule.actions.onSubmit()\n * }}\n * >\n * <Fields.CustomName label=\"Name\" validationMessages={{ REQUIRED: 'Name is required' }} />\n * <Fields.Frequency label=\"Frequency\" validationMessages={{ REQUIRED: 'Frequency is required' }} />\n * {Fields.CustomTwicePerMonth && <Fields.CustomTwicePerMonth label=\"Frequency Options\" />}\n * <Fields.AnchorPayDate label=\"First pay date\" validationMessages={{ REQUIRED: 'Required' }} />\n * <Fields.AnchorEndOfPayPeriod label=\"First pay period end\" validationMessages={{ REQUIRED: 'Required' }} />\n * {Fields.Day1 && (\n * <Fields.Day1\n * label=\"First pay day of the month\"\n * validationMessages={{ REQUIRED: 'Required', DAY_RANGE: 'Must be 1–31' }}\n * />\n * )}\n * {Fields.Day2 && (\n * <Fields.Day2\n * label=\"Last pay day of the month\"\n * validationMessages={{ REQUIRED: 'Required', DAY_RANGE: 'Must be 1–31' }}\n * />\n * )}\n * <button type=\"submit\" disabled={paySchedule.status.isPending}>Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function usePayScheduleForm({\n companyId,\n payScheduleId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n disableWorkweekStartDayEditing = false,\n}: UsePayScheduleFormProps): HookLoadingResult | UsePayScheduleFormReady {\n const isWorkweekStartDayEnabled = useUnstableFeature('payrollRegularRateOfPay')\n const payScheduleQuery = usePaySchedulesGet(\n { companyId, payScheduleId: payScheduleId ?? '' },\n { enabled: !!payScheduleId },\n )\n\n const paymentConfigsQuery = usePaymentConfigsGet({ companyUuid: companyId })\n\n const currentPaySchedule = payScheduleQuery.data?.payScheduleShow ?? null\n const paymentSpeed = paymentConfigsQuery.data?.paymentConfigs?.paymentSpeed\n const paymentSpeedDays = parsePaymentSpeedDays(paymentSpeed)\n\n const isCreateMode = !currentPaySchedule\n const mode = isCreateMode ? 'create' : 'update'\n\n const [schema, metadataConfig] = useMemo(\n () => createPayScheduleSchema({ mode, optionalFieldsToRequire }),\n [mode, optionalFieldsToRequire],\n )\n\n const resolvedDefaults: PayScheduleFormData = {\n customName: currentPaySchedule?.customName ?? partnerDefaults?.customName ?? '',\n frequency: (currentPaySchedule?.frequency ??\n partnerDefaults?.frequency ??\n 'Every week') as PayScheduleFrequency,\n customTwicePerMonth: deriveCustomTwicePerMonth(\n currentPaySchedule?.frequency ?? partnerDefaults?.frequency,\n currentPaySchedule?.day1 ?? partnerDefaults?.day1 ?? undefined,\n currentPaySchedule?.day2 ?? partnerDefaults?.day2 ?? undefined,\n ),\n anchorPayDate:\n currentPaySchedule?.anchorPayDate?.toString() ?? partnerDefaults?.anchorPayDate ?? null,\n anchorEndOfPayPeriod:\n currentPaySchedule?.anchorEndOfPayPeriod?.toString() ??\n partnerDefaults?.anchorEndOfPayPeriod ??\n null,\n day1: currentPaySchedule?.day1 ?? partnerDefaults?.day1 ?? NaN,\n day2: currentPaySchedule?.day2 ?? partnerDefaults?.day2 ?? NaN,\n workweekStartDay:\n currentPaySchedule?.workweekStartDay ?? partnerDefaults?.workweekStartDay ?? null,\n }\n\n const formMethods = useForm<PayScheduleFormData, unknown, PayScheduleFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const watchedFrequency = useWatch({ control: formMethods.control, name: 'frequency' })\n const watchedCustomTwicePerMonth = useWatch({\n control: formMethods.control,\n name: 'customTwicePerMonth',\n })\n const watchedAnchorPayDate = useWatch({ control: formMethods.control, name: 'anchorPayDate' })\n const watchedAnchorEndOfPayPeriod = useWatch({\n control: formMethods.control,\n name: 'anchorEndOfPayPeriod',\n })\n const watchedDay1 = useWatch({ control: formMethods.control, name: 'day1' })\n const watchedDay2 = useWatch({ control: formMethods.control, name: 'day2' })\n\n useEffect(() => {\n if (watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === '1st15th') {\n formMethods.setValue('day1', 15)\n formMethods.setValue('day2', 31)\n }\n }, [watchedFrequency, watchedCustomTwicePerMonth, formMethods.setValue])\n\n const formattedAnchorPayDate = formatWatchedDate(watchedAnchorPayDate)\n const formattedAnchorEndOfPayPeriod = formatWatchedDate(watchedAnchorEndOfPayPeriod)\n\n const previewEnabled = Boolean(formattedAnchorPayDate && formattedAnchorEndOfPayPeriod)\n\n const previewQuery = usePaySchedulesGetPreview(\n {\n companyId,\n frequency: watchedFrequency,\n ...(formattedAnchorPayDate && { anchorPayDate: new RFCDate(formattedAnchorPayDate) }),\n ...(formattedAnchorEndOfPayPeriod && {\n anchorEndOfPayPeriod: new RFCDate(formattedAnchorEndOfPayPeriod),\n }),\n day1: watchedDay1 || undefined,\n day2: watchedDay2 || undefined,\n } as Parameters<typeof usePaySchedulesGetPreview>[0],\n { enabled: previewEnabled },\n )\n\n const payPeriodPreview: PaySchedulePreviewPayPeriod[] | undefined =\n previewQuery.data?.paySchedulePreview?.payPeriods\n const payPreviewLoading = previewQuery.isLoading && previewEnabled\n\n const createPayScheduleMutation = usePaySchedulesCreateMutation()\n const updatePayScheduleMutation = usePaySchedulesUpdateMutation()\n\n const isPending = createPayScheduleMutation.isPending || updatePayScheduleMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('PayScheduleForm')\n\n const queries = payScheduleId ? [payScheduleQuery, paymentConfigsQuery] : [paymentConfigsQuery]\n const errorHandling = composeErrorHandler(queries, { submitError, setSubmitError })\n\n const showCustomTwicePerMonth = watchedFrequency === 'Twice per month'\n const showDay1 =\n watchedFrequency === 'Monthly' ||\n (watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === 'custom')\n const showDay2 = watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === 'custom'\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = buildPayScheduleFieldsMetadata(\n baseMetadata,\n disableWorkweekStartDayEditing,\n )\n\n const onSubmit = async (): Promise<HookSubmitResult<PayScheduleShow> | undefined> => {\n let submitResult: HookSubmitResult<PayScheduleShow> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: PayScheduleFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const anchorPayDate = payload.anchorPayDate ?? ''\n const anchorEndOfPayPeriod = payload.anchorEndOfPayPeriod ?? ''\n\n if (isCreateMode) {\n const result = await createPayScheduleMutation.mutateAsync({\n request: {\n companyId,\n payScheduleCreateRequest: {\n frequency: payload.frequency,\n anchorPayDate: new RFCDate(anchorPayDate),\n anchorEndOfPayPeriod: new RFCDate(anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1 || undefined,\n day2: payload.day2 || undefined,\n workweekStartDay: isWorkweekStartDayEnabled\n ? (payload.workweekStartDay ?? undefined)\n : undefined,\n },\n },\n })\n\n submitResult = { mode: 'create', data: result.payScheduleShow! }\n } else {\n const result = await updatePayScheduleMutation.mutateAsync({\n request: {\n payScheduleId: currentPaySchedule.uuid,\n companyId,\n payScheduleUpdateRequest: {\n frequency: payload.frequency,\n anchorPayDate: new RFCDate(anchorPayDate),\n anchorEndOfPayPeriod: new RFCDate(anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1 || undefined,\n day2: payload.day2 || undefined,\n workweekStartDay: isWorkweekStartDayEnabled\n ? (payload.workweekStartDay ?? undefined)\n : undefined,\n version: currentPaySchedule.version!,\n },\n },\n })\n\n submitResult = { mode: 'update', data: result.payScheduleShow! }\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const isDataLoading =\n paymentConfigsQuery.isLoading || (payScheduleId ? payScheduleQuery.isLoading : false)\n\n if (isDataLoading) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n paySchedule: currentPaySchedule,\n payPeriodPreview: payPeriodPreview ?? null,\n payPreviewLoading,\n paymentSpeedDays,\n },\n status: {\n isPending,\n mode: isCreateMode ? ('create' as const) : ('update' as const),\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n CustomName: CustomNameField,\n Frequency: FrequencyField,\n CustomTwicePerMonth: showCustomTwicePerMonth ? CustomTwicePerMonthField : undefined,\n AnchorPayDate: AnchorPayDateField,\n AnchorEndOfPayPeriod: AnchorEndOfPayPeriodField,\n Day1: showDay1 ? Day1Field : undefined,\n Day2: showDay2 ? Day2Field : undefined,\n WorkweekStartDay: isWorkweekStartDayEnabled ? WorkweekStartDayField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Discriminated union returned by {@link usePayScheduleForm}.\n *\n * @public\n */\nexport type UsePayScheduleFormResult = HookLoadingResult | UsePayScheduleFormReady\n/**\n * Type of `form.fieldsMetadata` returned by {@link usePayScheduleForm}.\n *\n * @public\n */\nexport type PayScheduleFieldsMetadata = ReturnType<typeof buildPayScheduleFieldsMetadata>\n"],"names":["FREQUENCY_OPTIONS","FREQUENCY_ENTRIES","o","TWICE_PER_MONTH_OPTIONS","TWICE_PER_MONTH_ENTRIES","WORKWEEK_START_DAY_ENTRIES","WorkweekStartDay","WORKWEEK_START_DAY_OPTIONS","value","formatWatchedDate","formatDateToStringDate","deriveCustomTwicePerMonth","frequency","day1","day2","buildPayScheduleFieldsMetadata","base","disableWorkweekStartDayEditing","withOptions","withFlags","usePayScheduleForm","companyId","payScheduleId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","isWorkweekStartDayEnabled","useUnstableFeature","payScheduleQuery","usePaySchedulesGet","paymentConfigsQuery","usePaymentConfigsGet","currentPaySchedule","paymentSpeed","paymentSpeedDays","parsePaymentSpeedDays","isCreateMode","mode","schema","metadataConfig","useMemo","createPayScheduleSchema","resolvedDefaults","formMethods","useForm","zodResolver","watchedFrequency","useWatch","watchedCustomTwicePerMonth","watchedAnchorPayDate","watchedAnchorEndOfPayPeriod","watchedDay1","watchedDay2","useEffect","formattedAnchorPayDate","formattedAnchorEndOfPayPeriod","previewEnabled","previewQuery","usePaySchedulesGetPreview","RFCDate","payPeriodPreview","payPreviewLoading","createPayScheduleMutation","usePaySchedulesCreateMutation","updatePayScheduleMutation","usePaySchedulesUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","showCustomTwicePerMonth","showDay1","showDay2","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","onSubmit","submitResult","resolve","data","payload","anchorPayDate","anchorEndOfPayPeriod","hookFormInternals","useHookFormInternals","CustomNameField","FrequencyField","CustomTwicePerMonthField","AnchorPayDateField","AnchorEndOfPayPeriodField","Day1Field","Day2Field","WorkweekStartDayField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2KA,MAAMA,IAA2E;AAAA,EAC/E,EAAE,OAAO,cAAc,OAAO,aAAA;AAAA,EAC9B,EAAE,OAAO,oBAAoB,OAAO,mBAAA;AAAA,EACpC,EAAE,OAAO,mBAAmB,OAAO,kBAAA;AAAA,EACnC,EAAE,OAAO,WAAW,OAAO,UAAA;AAC7B,GAEMC,KAA4CD,EAAkB,IAAI,CAAAE,MAAKA,EAAE,KAAK,GAE9EC,IAA0B;AAAA,EAC9B,EAAE,OAAO,WAAW,OAAO,iCAAA;AAAA,EAC3B,EAAE,OAAO,UAAU,OAAO,SAAA;AAC5B,GAEMC,KAA0BD,EAAwB,IAAI,CAAAD,MAAKA,EAAE,KAAK,GAElEG,IAA4D,OAAO,OAAOC,EAAgB,GAE1FC,KACJF,EAA2B,IAAI,CAAAG,OAAU,EAAE,OAAAA,GAAO,OAAOA,IAAQ;AAEnE,SAASC,EAAkBD,GAAwB;AACjD,SAAIA,aAAiB,OAAaE,GAAuBF,CAAK,KAAK,KAC/D,OAAOA,KAAU,YAAYA,IAAcA,IACxC;AACT;AAEA,SAASG,GACPC,GACAC,GACAC,GACQ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EMD;AAAA,EACT,GAEMM,KAAoBC,GAAqB5C,CAAW;AAK1D,SAFEb,EAAoB,cAAcT,IAAgBO,EAAiB,YAAY,MAGxE,EAAE,WAAW,IAAe,eAAA2C,EAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,aAAavC;AAAA,MACb,kBAAkB4B,KAAoB;AAAA,MACtC,mBAAAC;AAAA,MACA,kBAAA3B;AAAA,IAAA;AAAA,IAEF,QAAQ;AAAA,MACN,WAAAgC;AAAA,MACA,MAAM9B,IAAgB,WAAsB;AAAA,IAAA;AAAA,IAE9C,SAAS,EAAE,UAAA2C,GAAA;AAAA,IACX,eAAAR;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,YAAYiB;AAAA,QACZ,WAAWC;AAAA,QACX,qBAAqBhB,IAA0BiB,KAA2B;AAAA,QAC1E,eAAeC;AAAA,QACf,sBAAsBC;AAAA,QACtB,MAAMlB,IAAWmB,KAAY;AAAA,QAC7B,MAAMlB,IAAWmB,KAAY;AAAA,QAC7B,kBAAkBpE,IAA4BqE,KAAwB;AAAA,MAAA;AAAA,MAExE,gBAAAjB;AAAA,MACA,mBAAAQ;AAAA,MACA,yBAAyBU,GAA8BrD,GAAaL,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"usePayScheduleForm.js","sources":["../../../../../../src/components/Company/PaySchedule/shared/usePayScheduleForm/usePayScheduleForm.tsx"],"sourcesContent":["import { useEffect, useMemo } from 'react'\nimport type { ComponentType } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { PayScheduleShow } from '@gusto/embedded-api/models/components/payschedulelistitem'\nimport type { PaySchedulePreviewPayPeriod } from '@gusto/embedded-api/models/components/payschedulepreviewpayperiod'\nimport { WorkweekStartDay } from '@gusto/embedded-api/models/components/payschedulecreaterequest'\nimport { usePaySchedulesGet } from '@gusto/embedded-api/react-query/paySchedulesGet'\nimport { usePaySchedulesGetPreview } from '@gusto/embedded-api/react-query/paySchedulesGetPreview'\nimport { usePaySchedulesCreateMutation } from '@gusto/embedded-api/react-query/paySchedulesCreate'\nimport { usePaySchedulesUpdateMutation } from '@gusto/embedded-api/react-query/paySchedulesUpdate'\nimport { usePaymentConfigsGet } from '@gusto/embedded-api/react-query/paymentConfigsGet'\nimport { RFCDate } from '@gusto/embedded-api/types/rfcdate'\nimport {\n createPayScheduleSchema,\n type PayScheduleOptionalFieldsToRequire,\n type PayScheduleFormData,\n type PayScheduleFormOutputs,\n type PayScheduleFrequency,\n type PayScheduleWorkweekStartDay,\n} from './payScheduleSchema'\nimport {\n CustomNameField,\n FrequencyField,\n CustomTwicePerMonthField,\n AnchorPayDateField,\n AnchorEndOfPayPeriodField,\n Day1Field,\n Day2Field,\n WorkweekStartDayField,\n} from './fields'\nimport type {\n CustomNameFieldProps,\n FrequencyFieldProps,\n CustomTwicePerMonthFieldProps,\n AnchorPayDateFieldProps,\n AnchorEndOfPayPeriodFieldProps,\n Day1FieldProps,\n Day2FieldProps,\n WorkweekStartDayFieldProps,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { withFlags } from '@/partner-hook-utils/form/withFlags'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { parsePaymentSpeedDays } from '@/hooks/useCompanyPaymentSpeed'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { useUnstableFeature } from '@/contexts/UnstableFeaturesProvider/useUnstableFeature'\n\nexport type { PayScheduleOptionalFieldsToRequire } from './payScheduleSchema'\n\n/**\n * Configuration options for {@link usePayScheduleForm}.\n *\n * @remarks\n * Presence or absence of `payScheduleId` selects between update and create mode.\n *\n * @public\n */\nexport interface UsePayScheduleFormProps {\n /** UUID of the company that owns the pay schedule. */\n companyId: string\n /**\n * When set, loads that pay schedule and updates it on submit. When omitted,\n * the form is in create mode and creates a new schedule on submit.\n */\n payScheduleId?: string\n /** Override fields that are optional on a given mode to be required. See `PayScheduleOptionalFieldsToRequire`. */\n optionalFieldsToRequire?: PayScheduleOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence on update. */\n defaultValues?: Partial<PayScheduleFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n /**\n * Renders `Fields.WorkweekStartDay` disabled while still submitting its current value,\n * for partners that compute the workweek start day themselves and don't want end users\n * editing it directly. Defaults to `false`. Has no effect unless the `payrollRegularRateOfPay`\n * unstable feature is enabled.\n *\n * @alpha\n */\n disableWorkweekStartDayEditing?: boolean\n}\n\n/**\n * Pre-bound field components exposed on `usePayScheduleForm().form.Fields`.\n *\n * @remarks\n * `CustomTwicePerMonth`, `Day1`, and `Day2` are conditionally `undefined` based\n * on the selected frequency and twice-per-month strategy — always null-check them\n * before rendering.\n *\n * @public\n */\nexport interface PayScheduleFormFields {\n /** Bound to `customName`. Display name text input. Always available. */\n CustomName: ComponentType<CustomNameFieldProps>\n /** Bound to `frequency`. Frequency selector. Always available. */\n Frequency: ComponentType<FrequencyFieldProps>\n /** Bound to `customTwicePerMonth`. Twice-per-month strategy radio group. Only available when frequency is `'Twice per month'`. */\n CustomTwicePerMonth: ComponentType<CustomTwicePerMonthFieldProps> | undefined\n /** Bound to `anchorPayDate`. First pay date picker. Always available. */\n AnchorPayDate: ComponentType<AnchorPayDateFieldProps>\n /** Bound to `anchorEndOfPayPeriod`. First pay period end date picker. Always available. */\n AnchorEndOfPayPeriod: ComponentType<AnchorEndOfPayPeriodFieldProps>\n /** Bound to `day1`. First-pay-day-of-month number input. Available when frequency is `'Monthly'`, or `'Twice per month'` with `'custom'` strategy. */\n Day1: ComponentType<Day1FieldProps> | undefined\n /** Bound to `day2`. Last-pay-day-of-month number input. Available when frequency is `'Twice per month'` with `'custom'` strategy. */\n Day2: ComponentType<Day2FieldProps> | undefined\n /**\n * Bound to `workweekStartDay`. Workweek start day selector, used for regular rate of pay\n * overtime calculations. `undefined` unless the `payrollRegularRateOfPay` unstable feature\n * is enabled.\n *\n * @alpha\n */\n WorkweekStartDay: ComponentType<WorkweekStartDayFieldProps> | undefined\n}\n\n/**\n * Ready-state shape returned by {@link usePayScheduleForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with the\n * pay-schedule-specific `data`, `status`, `actions`, and `form.Fields` shape.\n *\n * @public\n */\nexport interface UsePayScheduleFormReady extends BaseFormHookReady<\n PayScheduleFieldsMetadata,\n PayScheduleFormData,\n PayScheduleFormFields\n> {\n /** Static entity data resolved from the API. */\n data: {\n /** The pay schedule loaded for update; `null` in create mode. */\n paySchedule: PayScheduleShow | null\n /** Upcoming pay periods previewed from current form values; `null` until the anchor date fields are complete. */\n payPeriodPreview: PaySchedulePreviewPayPeriod[] | null\n /** `true` while the pay period preview request is in flight. */\n payPreviewLoading: boolean\n /** Business days the company needs to process payroll, derived from payment configs; `null` if unavailable. */\n paymentSpeedDays: number | null\n }\n /** Reactive status flags. */\n status: {\n /** `true` while the create or update mutation is in flight. */\n isPending: boolean\n /** Whether the form is creating a new schedule or updating an existing one. */\n mode: 'create' | 'update'\n }\n /** Available actions. */\n actions: {\n /** Validates the form and dispatches the create or update mutation. Returns the saved schedule, or `undefined` if validation failed. */\n onSubmit: () => Promise<HookSubmitResult<PayScheduleShow> | undefined>\n }\n}\n\nconst FREQUENCY_OPTIONS: Array<{ value: PayScheduleFrequency; label: string }> = [\n { value: 'Every week', label: 'Every week' },\n { value: 'Every other week', label: 'Every other week' },\n { value: 'Twice per month', label: 'Twice per month' },\n { value: 'Monthly', label: 'Monthly' },\n]\n\nconst FREQUENCY_ENTRIES: PayScheduleFrequency[] = FREQUENCY_OPTIONS.map(o => o.value)\n\nconst TWICE_PER_MONTH_OPTIONS = [\n { value: '1st15th', label: '15th and Last day of the month' },\n { value: 'custom', label: 'Custom' },\n]\n\nconst TWICE_PER_MONTH_ENTRIES = TWICE_PER_MONTH_OPTIONS.map(o => o.value)\n\nconst WORKWEEK_START_DAY_ENTRIES: PayScheduleWorkweekStartDay[] = Object.values(WorkweekStartDay)\n\nconst WORKWEEK_START_DAY_OPTIONS: Array<{ value: PayScheduleWorkweekStartDay; label: string }> =\n WORKWEEK_START_DAY_ENTRIES.map(value => ({ value, label: value }))\n\nfunction formatWatchedDate(value: unknown): string {\n if (value instanceof Date) return formatDateToStringDate(value) || ''\n if (typeof value === 'string' && value) return value\n return ''\n}\n\nfunction deriveCustomTwicePerMonth(\n frequency: string | undefined,\n day1: number | undefined,\n day2: number | undefined,\n): string {\n if (frequency !== 'Twice per month') return ''\n if (day1 === 15 && day2 === 31) return '1st15th'\n // Only pre-select 'custom' when there are real day values to represent (e.g.\n // editing an existing custom schedule). With no day basis, leave the radio\n // unselected so its required validation prompts an explicit choice rather\n // than silently forcing empty day1/day2 fields into a required state.\n if (day1 != null && day2 != null) return 'custom'\n return ''\n}\n\n/** @internal */\nfunction buildPayScheduleFieldsMetadata(\n base: Record<keyof PayScheduleFormData, FieldMetadata>,\n disableWorkweekStartDayEditing: boolean,\n) {\n return {\n customName: base.customName,\n frequency: withOptions<PayScheduleFrequency>(\n base.frequency,\n FREQUENCY_OPTIONS,\n FREQUENCY_ENTRIES,\n ),\n customTwicePerMonth: withOptions<string>(\n base.customTwicePerMonth,\n TWICE_PER_MONTH_OPTIONS,\n TWICE_PER_MONTH_ENTRIES,\n ),\n anchorPayDate: base.anchorPayDate,\n anchorEndOfPayPeriod: base.anchorEndOfPayPeriod,\n day1: base.day1,\n day2: base.day2,\n workweekStartDay: withOptions<PayScheduleWorkweekStartDay>(\n withFlags(base.workweekStartDay, { isDisabled: disableWorkweekStartDayEditing }),\n WORKWEEK_START_DAY_OPTIONS,\n WORKWEEK_START_DAY_ENTRIES,\n ),\n } satisfies FieldsMetadata\n}\n\n/**\n * Form hook for creating or updating a company pay schedule.\n *\n * @remarks\n * When `payScheduleId` is supplied the hook loads that schedule and issues an\n * update on submit; when omitted it operates in create mode. While both anchor\n * date fields are filled in, the hook fetches a live pay period calendar\n * preview exposed on `data.payPeriodPreview`. `data.paymentSpeedDays` reflects\n * the company's payment configuration and is useful for surfacing UI hints\n * about how far ahead the first pay date must be.\n *\n * @param props - See {@link UsePayScheduleFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UsePayScheduleFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import {\n * usePayScheduleForm,\n * SDKFormProvider,\n * type UsePayScheduleFormReady,\n * } from '@gusto/embedded-react-sdk'\n *\n * function PaySchedulePage({ companyId }: { companyId: string }) {\n * const paySchedule = usePayScheduleForm({ companyId })\n *\n * if (paySchedule.isLoading) return <div>Loading...</div>\n *\n * return <PayScheduleFormReady paySchedule={paySchedule} />\n * }\n *\n * function PayScheduleFormReady({ paySchedule }: { paySchedule: UsePayScheduleFormReady }) {\n * const { Fields } = paySchedule.form\n *\n * return (\n * <SDKFormProvider formHookResult={paySchedule}>\n * <form\n * onSubmit={e => {\n * e.preventDefault()\n * void paySchedule.actions.onSubmit()\n * }}\n * >\n * <Fields.CustomName label=\"Name\" validationMessages={{ REQUIRED: 'Name is required' }} />\n * <Fields.Frequency label=\"Frequency\" validationMessages={{ REQUIRED: 'Frequency is required' }} />\n * {Fields.CustomTwicePerMonth && <Fields.CustomTwicePerMonth label=\"Frequency Options\" />}\n * <Fields.AnchorPayDate label=\"First pay date\" validationMessages={{ REQUIRED: 'Required' }} />\n * <Fields.AnchorEndOfPayPeriod label=\"First pay period end\" validationMessages={{ REQUIRED: 'Required' }} />\n * {Fields.Day1 && (\n * <Fields.Day1\n * label=\"First pay day of the month\"\n * validationMessages={{ REQUIRED: 'Required', DAY_RANGE: 'Must be 1–31' }}\n * />\n * )}\n * {Fields.Day2 && (\n * <Fields.Day2\n * label=\"Last pay day of the month\"\n * validationMessages={{ REQUIRED: 'Required', DAY_RANGE: 'Must be 1–31' }}\n * />\n * )}\n * <button type=\"submit\" disabled={paySchedule.status.isPending}>Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function usePayScheduleForm({\n companyId,\n payScheduleId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n disableWorkweekStartDayEditing = false,\n}: UsePayScheduleFormProps): HookLoadingResult | UsePayScheduleFormReady {\n const isWorkweekStartDayEnabled = useUnstableFeature('payrollRegularRateOfPay')\n const payScheduleQuery = usePaySchedulesGet(\n { companyId, payScheduleId: payScheduleId ?? '' },\n { enabled: !!payScheduleId },\n )\n\n const paymentConfigsQuery = usePaymentConfigsGet({ companyUuid: companyId })\n\n const currentPaySchedule = payScheduleQuery.data?.payScheduleShow ?? null\n const paymentSpeed = paymentConfigsQuery.data?.paymentConfigs?.paymentSpeed\n const paymentSpeedDays = parsePaymentSpeedDays(paymentSpeed)\n\n const isCreateMode = !currentPaySchedule\n const mode = isCreateMode ? 'create' : 'update'\n\n const [schema, metadataConfig] = useMemo(\n () => createPayScheduleSchema({ mode, optionalFieldsToRequire }),\n [mode, optionalFieldsToRequire],\n )\n\n const resolvedDefaults: PayScheduleFormData = {\n customName: currentPaySchedule?.customName ?? partnerDefaults?.customName ?? '',\n frequency: (currentPaySchedule?.frequency ??\n partnerDefaults?.frequency ??\n 'Every week') as PayScheduleFrequency,\n customTwicePerMonth: deriveCustomTwicePerMonth(\n currentPaySchedule?.frequency ?? partnerDefaults?.frequency,\n currentPaySchedule?.day1 ?? partnerDefaults?.day1 ?? undefined,\n currentPaySchedule?.day2 ?? partnerDefaults?.day2 ?? undefined,\n ),\n anchorPayDate:\n currentPaySchedule?.anchorPayDate?.toString() ?? partnerDefaults?.anchorPayDate ?? null,\n anchorEndOfPayPeriod:\n currentPaySchedule?.anchorEndOfPayPeriod?.toString() ??\n partnerDefaults?.anchorEndOfPayPeriod ??\n null,\n day1: currentPaySchedule?.day1 ?? partnerDefaults?.day1 ?? NaN,\n day2: currentPaySchedule?.day2 ?? partnerDefaults?.day2 ?? NaN,\n workweekStartDay:\n currentPaySchedule?.workweekStartDay ?? partnerDefaults?.workweekStartDay ?? null,\n }\n\n const formMethods = useForm<PayScheduleFormData, unknown, PayScheduleFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const watchedFrequency = useWatch({ control: formMethods.control, name: 'frequency' })\n const watchedCustomTwicePerMonth = useWatch({\n control: formMethods.control,\n name: 'customTwicePerMonth',\n })\n const watchedAnchorPayDate = useWatch({ control: formMethods.control, name: 'anchorPayDate' })\n const watchedAnchorEndOfPayPeriod = useWatch({\n control: formMethods.control,\n name: 'anchorEndOfPayPeriod',\n })\n const watchedDay1 = useWatch({ control: formMethods.control, name: 'day1' })\n const watchedDay2 = useWatch({ control: formMethods.control, name: 'day2' })\n\n useEffect(() => {\n if (watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === '1st15th') {\n formMethods.setValue('day1', 15)\n formMethods.setValue('day2', 31)\n }\n }, [watchedFrequency, watchedCustomTwicePerMonth, formMethods.setValue])\n\n const formattedAnchorPayDate = formatWatchedDate(watchedAnchorPayDate)\n const formattedAnchorEndOfPayPeriod = formatWatchedDate(watchedAnchorEndOfPayPeriod)\n\n const previewEnabled = Boolean(formattedAnchorPayDate && formattedAnchorEndOfPayPeriod)\n\n const previewQuery = usePaySchedulesGetPreview(\n {\n companyId,\n frequency: watchedFrequency,\n ...(formattedAnchorPayDate && { anchorPayDate: new RFCDate(formattedAnchorPayDate) }),\n ...(formattedAnchorEndOfPayPeriod && {\n anchorEndOfPayPeriod: new RFCDate(formattedAnchorEndOfPayPeriod),\n }),\n day1: watchedDay1 || undefined,\n day2: watchedDay2 || undefined,\n } as Parameters<typeof usePaySchedulesGetPreview>[0],\n { enabled: previewEnabled },\n )\n\n const payPeriodPreview: PaySchedulePreviewPayPeriod[] | undefined =\n previewQuery.data?.paySchedulePreview?.payPeriods\n const payPreviewLoading = previewQuery.isLoading && previewEnabled\n\n const createPayScheduleMutation = usePaySchedulesCreateMutation()\n const updatePayScheduleMutation = usePaySchedulesUpdateMutation()\n\n const isPending = createPayScheduleMutation.isPending || updatePayScheduleMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('PayScheduleForm')\n\n const queries = payScheduleId ? [payScheduleQuery, paymentConfigsQuery] : [paymentConfigsQuery]\n const errorHandling = composeErrorHandler(queries, { submitError, setSubmitError })\n\n const showCustomTwicePerMonth = watchedFrequency === 'Twice per month'\n const showDay1 =\n watchedFrequency === 'Monthly' ||\n (watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === 'custom')\n const showDay2 = watchedFrequency === 'Twice per month' && watchedCustomTwicePerMonth === 'custom'\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = buildPayScheduleFieldsMetadata(\n baseMetadata,\n disableWorkweekStartDayEditing,\n )\n\n const onSubmit = async (): Promise<HookSubmitResult<PayScheduleShow> | undefined> => {\n let submitResult: HookSubmitResult<PayScheduleShow> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: PayScheduleFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const anchorPayDate = payload.anchorPayDate ?? ''\n const anchorEndOfPayPeriod = payload.anchorEndOfPayPeriod ?? ''\n\n if (isCreateMode) {\n const result = await createPayScheduleMutation.mutateAsync({\n request: {\n companyId,\n payScheduleCreateRequest: {\n frequency: payload.frequency,\n anchorPayDate: new RFCDate(anchorPayDate),\n anchorEndOfPayPeriod: new RFCDate(anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1 || undefined,\n day2: payload.day2 || undefined,\n workweekStartDay: isWorkweekStartDayEnabled\n ? (payload.workweekStartDay ?? undefined)\n : undefined,\n },\n },\n })\n\n submitResult = { mode: 'create', data: result.payScheduleShow! }\n } else {\n const result = await updatePayScheduleMutation.mutateAsync({\n request: {\n payScheduleId: currentPaySchedule.uuid,\n companyId,\n payScheduleUpdateRequest: {\n frequency: payload.frequency,\n anchorPayDate: new RFCDate(anchorPayDate),\n anchorEndOfPayPeriod: new RFCDate(anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1 || undefined,\n day2: payload.day2 || undefined,\n workweekStartDay: isWorkweekStartDayEnabled\n ? (payload.workweekStartDay ?? undefined)\n : undefined,\n version: currentPaySchedule.version!,\n },\n },\n })\n\n submitResult = { mode: 'update', data: result.payScheduleShow! }\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n const isDataLoading =\n paymentConfigsQuery.isLoading || (payScheduleId ? payScheduleQuery.isLoading : false)\n\n if (isDataLoading) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n paySchedule: currentPaySchedule,\n payPeriodPreview: payPeriodPreview ?? null,\n payPreviewLoading,\n paymentSpeedDays,\n },\n status: {\n isPending,\n mode: isCreateMode ? ('create' as const) : ('update' as const),\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n CustomName: CustomNameField,\n Frequency: FrequencyField,\n CustomTwicePerMonth: showCustomTwicePerMonth ? CustomTwicePerMonthField : undefined,\n AnchorPayDate: AnchorPayDateField,\n AnchorEndOfPayPeriod: AnchorEndOfPayPeriodField,\n Day1: showDay1 ? Day1Field : undefined,\n Day2: showDay2 ? Day2Field : undefined,\n WorkweekStartDay: isWorkweekStartDayEnabled ? WorkweekStartDayField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Discriminated union returned by {@link usePayScheduleForm}.\n *\n * @public\n */\nexport type UsePayScheduleFormResult = HookLoadingResult | UsePayScheduleFormReady\n/**\n * Type of `form.fieldsMetadata` returned by {@link usePayScheduleForm}.\n *\n * @public\n */\nexport type PayScheduleFieldsMetadata = ReturnType<typeof buildPayScheduleFieldsMetadata>\n"],"names":["FREQUENCY_OPTIONS","FREQUENCY_ENTRIES","o","TWICE_PER_MONTH_OPTIONS","TWICE_PER_MONTH_ENTRIES","WORKWEEK_START_DAY_ENTRIES","WorkweekStartDay","WORKWEEK_START_DAY_OPTIONS","value","formatWatchedDate","formatDateToStringDate","deriveCustomTwicePerMonth","frequency","day1","day2","buildPayScheduleFieldsMetadata","base","disableWorkweekStartDayEditing","withOptions","withFlags","usePayScheduleForm","companyId","payScheduleId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","isWorkweekStartDayEnabled","useUnstableFeature","payScheduleQuery","usePaySchedulesGet","paymentConfigsQuery","usePaymentConfigsGet","currentPaySchedule","paymentSpeed","paymentSpeedDays","parsePaymentSpeedDays","isCreateMode","mode","schema","metadataConfig","useMemo","createPayScheduleSchema","resolvedDefaults","formMethods","useForm","zodResolver","watchedFrequency","useWatch","watchedCustomTwicePerMonth","watchedAnchorPayDate","watchedAnchorEndOfPayPeriod","watchedDay1","watchedDay2","useEffect","formattedAnchorPayDate","formattedAnchorEndOfPayPeriod","previewEnabled","previewQuery","usePaySchedulesGetPreview","RFCDate","payPeriodPreview","payPreviewLoading","createPayScheduleMutation","usePaySchedulesCreateMutation","updatePayScheduleMutation","usePaySchedulesUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","showCustomTwicePerMonth","showDay1","showDay2","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","onSubmit","submitResult","resolve","data","payload","anchorPayDate","anchorEndOfPayPeriod","hookFormInternals","useHookFormInternals","CustomNameField","FrequencyField","CustomTwicePerMonthField","AnchorPayDateField","AnchorEndOfPayPeriodField","Day1Field","Day2Field","WorkweekStartDayField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA2KA,MAAMA,IAA2E;AAAA,EAC/E,EAAE,OAAO,cAAc,OAAO,aAAA;AAAA,EAC9B,EAAE,OAAO,oBAAoB,OAAO,mBAAA;AAAA,EACpC,EAAE,OAAO,mBAAmB,OAAO,kBAAA;AAAA,EACnC,EAAE,OAAO,WAAW,OAAO,UAAA;AAC7B,GAEMC,KAA4CD,EAAkB,IAAI,CAAAE,MAAKA,EAAE,KAAK,GAE9EC,IAA0B;AAAA,EAC9B,EAAE,OAAO,WAAW,OAAO,iCAAA;AAAA,EAC3B,EAAE,OAAO,UAAU,OAAO,SAAA;AAC5B,GAEMC,KAA0BD,EAAwB,IAAI,CAAAD,MAAKA,EAAE,KAAK,GAElEG,IAA4D,OAAO,OAAOC,EAAgB,GAE1FC,KACJF,EAA2B,IAAI,CAAAG,OAAU,EAAE,OAAAA,GAAO,OAAOA,IAAQ;AAEnE,SAASC,EAAkBD,GAAwB;AACjD,SAAIA,aAAiB,OAAaE,GAAuBF,CAAK,KAAK,KAC/D,OAAOA,KAAU,YAAYA,IAAcA,IACxC;AACT;AAEA,SAASG,GACPC,GACAC,GACAC,GACQ;AACR,SAAIF,MAAc,oBAA0B,KACxCC,MAAS,MAAMC,MAAS,KAAW,YAKnCD,KAAQ,QAAQC,KAAQ,OAAa,WAClC;AACT;AAGA,SAASC,GACPC,GACAC,GACA;AACA,SAAO;AAAA,IACL,YAAY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AA,IACX,MAAM;AAAA,MACJ,aAAavC;AAAA,MACb,kBAAkB4B,KAAoB;AAAA,MACtC,mBAAAC;AAAA,MACA,kBAAA3B;AAAA,IAAA;AAAA,IAEF,QAAQ;AAAA,MACN,WAAAgC;AAAA,MACA,MAAM9B,IAAgB,WAAsB;AAAA,IAAA;AAAA,IAE9C,SAAS,EAAE,UAAA2C,GAAA;AAAA,IACX,eAAAR;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,YAAYiB;AAAA,QACZ,WAAWC;AAAA,QACX,qBAAqBhB,IAA0BiB,KAA2B;AAAA,QAC1E,eAAeC;AAAA,QACf,sBAAsBC;AAAA,QACtB,MAAMlB,IAAWmB,KAAY;AAAA,QAC7B,MAAMlB,IAAWmB,KAAY;AAAA,QAC7B,kBAAkBpE,IAA4BqE,KAAwB;AAAA,MAAA;AAAA,MAExE,gBAAAjB;AAAA,MACA,mBAAAQ;AAAA,MACA,yBAAyBU,GAA8BrD,GAAaL,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
@@ -32,7 +32,7 @@ function ft({
|
|
|
32
32
|
optionalFieldsToRequire: s,
|
|
33
33
|
defaultValues: r,
|
|
34
34
|
validationMode: C = "onSubmit",
|
|
35
|
-
shouldFocusError:
|
|
35
|
+
shouldFocusError: h = !0
|
|
36
36
|
}) {
|
|
37
37
|
const n = L(
|
|
38
38
|
{ contractorUuid: t },
|
|
@@ -40,7 +40,7 @@ function ft({
|
|
|
40
40
|
), d = Q(
|
|
41
41
|
{ contractorUuid: t },
|
|
42
42
|
{ enabled: !!t }
|
|
43
|
-
), a = n.data?.
|
|
43
|
+
), a = n.data?.contractorShow, v = a?.type, e = d.data?.contractorAddress, [c, b] = A(
|
|
44
44
|
() => T({ optionalFieldsToRequire: s }),
|
|
45
45
|
[s]
|
|
46
46
|
), m = A(
|
|
@@ -55,7 +55,7 @@ function ft({
|
|
|
55
55
|
), i = O({
|
|
56
56
|
resolver: P(c),
|
|
57
57
|
mode: C,
|
|
58
|
-
shouldFocusError:
|
|
58
|
+
shouldFocusError: h,
|
|
59
59
|
defaultValues: m,
|
|
60
60
|
values: m,
|
|
61
61
|
resetOptions: { keepDirtyValues: !0 }
|
|
@@ -66,7 +66,7 @@ function ft({
|
|
|
66
66
|
} = X("ContractorAddressForm"), p = W([n, d], {
|
|
67
67
|
submitError: z,
|
|
68
68
|
setSubmitError: M
|
|
69
|
-
}), E = j(
|
|
69
|
+
}), E = j(b, i.control), U = Y(E), V = async (H) => {
|
|
70
70
|
let l;
|
|
71
71
|
return await new Promise((f) => {
|
|
72
72
|
i.handleSubmit(
|
|
@@ -109,7 +109,7 @@ function ft({
|
|
|
109
109
|
data: {
|
|
110
110
|
contractorAddress: e,
|
|
111
111
|
contractor: a,
|
|
112
|
-
contractorType:
|
|
112
|
+
contractorType: v
|
|
113
113
|
},
|
|
114
114
|
status: {
|
|
115
115
|
isPending: w,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContractorAddressForm.js","sources":["../../../../../../src/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport type { ComponentType } from 'react'\nimport { useForm } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Contractor, ContractorType } from '@gusto/embedded-api/models/components/contractor'\nimport type { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress'\nimport { useContractorsGet } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorsGetAddress } from '@gusto/embedded-api/react-query/contractorsGetAddress'\nimport { useContractorsUpdateAddressMutation } from '@gusto/embedded-api/react-query/contractorsUpdateAddress'\nimport {\n createContractorAddressSchema,\n type ContractorAddressOptionalFieldsToRequire,\n type ContractorAddressFormData,\n type ContractorAddressFormOutputs,\n} from './contractorAddressSchema'\nimport { Street1Field, Street2Field, CityField, StateField, ZipField } from './fields'\nimport type {\n Street1FieldProps,\n Street2FieldProps,\n CityFieldProps,\n StateFieldProps,\n ZipFieldProps,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { STATES_ABBR } from '@/shared/constants'\n\nexport type { ContractorAddressOptionalFieldsToRequire } from './contractorAddressSchema'\n\n/**\n * Optional overrides passed to {@link UseContractorAddressFormReady.actions.onSubmit | onSubmit}.\n *\n * @public\n */\nexport interface ContractorAddressSubmitOptions {\n /** Override the contractor identifier supplied to the hook. */\n contractorId?: string\n}\n\n/**\n * Configuration options for {@link useContractorAddressForm}.\n *\n * @public\n */\nexport interface UseContractorAddressFormProps {\n /** UUID of the contractor whose address is being edited. */\n contractorId: string\n /** Override fields that are optional by default to be required. See `ContractorAddressOptionalFieldsToRequire`. */\n optionalFieldsToRequire?: ContractorAddressOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence. */\n defaultValues?: Partial<ContractorAddressFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Field components exposed by {@link useContractorAddressForm} on `form.Fields`.\n *\n * @public\n */\nexport interface ContractorAddressFormFields {\n /** Bound to `street1`. Text input for the first street address line. Required. */\n Street1: ComponentType<Street1FieldProps>\n /** Bound to `street2`. Text input for the second street address line. Optional. */\n Street2: ComponentType<Street2FieldProps>\n /** Bound to `city`. Text input for the city. Required. */\n City: ComponentType<CityFieldProps>\n /**\n * Bound to `state`. Select whose options are the standard two-letter US state\n * abbreviations. Supply `getOptionLabel` to localize the option labels. Required.\n */\n State: ComponentType<StateFieldProps>\n /**\n * Bound to `zip`. Text input for the ZIP code. Required; also validates ZIP\n * format and emits `INVALID_ZIP` when the value does not match.\n */\n Zip: ComponentType<ZipFieldProps>\n}\n\n/**\n * Ready-state shape returned by {@link useContractorAddressForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with\n * the contractor-address-specific `data`, `status`, `actions`, and `form.Fields` shape.\n *\n * @public\n */\nexport interface UseContractorAddressFormReady extends BaseFormHookReady<\n ContractorAddressFieldsMetadata,\n ContractorAddressFormData,\n ContractorAddressFormFields\n> {\n /** Static entity data resolved from the API. */\n data: {\n /** The contractor address row loaded for update. */\n contractorAddress: ContractorAddress\n /** The full contractor entity loaded alongside the address. */\n contractor: Contractor\n /** The contractor's type — drives whether the address is labelled \"home\" (Individual) or \"business\" (Business). */\n contractorType: ContractorType | undefined\n }\n /** Reactive status flags. */\n status: { isPending: boolean; mode: 'update' }\n /** Available actions. */\n actions: {\n onSubmit: (\n options?: ContractorAddressSubmitOptions,\n ) => Promise<HookSubmitResult<ContractorAddress> | undefined>\n }\n}\n\n/** @internal */\nfunction buildContractorAddressFieldsMetadata(\n base: Record<keyof ContractorAddressFormData, FieldMetadata>,\n) {\n const stateOptions = STATES_ABBR.map(abbr => ({\n value: abbr,\n label: abbr,\n }))\n return {\n street1: base.street1,\n street2: base.street2,\n city: base.city,\n state: withOptions(base.state, stateOptions, STATES_ABBR),\n zip: base.zip,\n } satisfies FieldsMetadata\n}\n\n/**\n * Form hook for editing a contractor's address.\n *\n * @remarks\n * A contractor always has exactly one address (created with the contractor),\n * so this hook operates only in update mode and issues a PUT on submit. The\n * same address is labelled a \"home\" address for Individual contractors and a\n * \"business\" address for Business contractors; the hook exposes `contractorType`\n * so the consuming component can choose the appropriate copy.\n *\n * @param props - See {@link UseContractorAddressFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UseContractorAddressFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import {\n * useContractorAddressForm,\n * SDKFormProvider,\n * type UseContractorAddressFormReady,\n * } from '@gusto/embedded-react-sdk'\n *\n * function ContractorAddressPage({ contractorId }: { contractorId: string }) {\n * const contractorAddress = useContractorAddressForm({ contractorId })\n *\n * if (contractorAddress.isLoading) return <div>Loading...</div>\n *\n * return <ContractorAddressReady contractorAddress={contractorAddress} />\n * }\n *\n * function ContractorAddressReady({\n * contractorAddress,\n * }: {\n * contractorAddress: UseContractorAddressFormReady\n * }) {\n * const { Fields } = contractorAddress.form\n *\n * return (\n * <SDKFormProvider formHookResult={contractorAddress}>\n * <form onSubmit={e => { e.preventDefault(); void contractorAddress.actions.onSubmit() }}>\n * <Fields.Street1 label=\"Street address\" />\n * <Fields.Street2 label=\"Apt, suite, etc. (optional)\" />\n * <Fields.City label=\"City\" />\n * <Fields.State label=\"State\" />\n * <Fields.Zip label=\"ZIP code\" />\n * <button type=\"submit\" disabled={contractorAddress.status.isPending}>Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function useContractorAddressForm({\n contractorId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UseContractorAddressFormProps): HookLoadingResult | UseContractorAddressFormReady {\n const contractorQuery = useContractorsGet(\n { contractorUuid: contractorId },\n { enabled: !!contractorId },\n )\n const addressQuery = useContractorsGetAddress(\n { contractorUuid: contractorId },\n { enabled: !!contractorId },\n )\n\n const contractor = contractorQuery.data?.contractor\n const contractorType = contractor?.type\n const fetchedAddress = addressQuery.data?.contractorAddress\n\n const [schema, metadataConfig] = useMemo(\n () => createContractorAddressSchema({ optionalFieldsToRequire }),\n [optionalFieldsToRequire],\n )\n\n const resolvedDefaults: ContractorAddressFormData = useMemo(\n () => ({\n street1: fetchedAddress?.street1 ?? partnerDefaults?.street1 ?? '',\n street2: fetchedAddress?.street2 ?? partnerDefaults?.street2 ?? '',\n city: fetchedAddress?.city ?? partnerDefaults?.city ?? '',\n state: fetchedAddress?.state ?? partnerDefaults?.state ?? '',\n zip: fetchedAddress?.zip ?? partnerDefaults?.zip ?? '',\n }),\n [fetchedAddress, partnerDefaults],\n )\n\n const formMethods = useForm<ContractorAddressFormData, unknown, ContractorAddressFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const updateAddressMutation = useContractorsUpdateAddressMutation()\n\n const isPending = updateAddressMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('ContractorAddressForm')\n\n const errorHandling = composeErrorHandler([contractorQuery, addressQuery], {\n submitError,\n setSubmitError,\n })\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = buildContractorAddressFieldsMetadata(baseMetadata)\n\n const onSubmit = async (\n options?: ContractorAddressSubmitOptions,\n ): Promise<HookSubmitResult<ContractorAddress> | undefined> => {\n let submitResult: HookSubmitResult<ContractorAddress> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: ContractorAddressFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedContractorId = options?.contractorId ?? contractorId\n\n if (!fetchedAddress?.version) {\n throw new SDKInternalError(\n 'Cannot update contractor address: no matching address on file',\n )\n }\n\n const result = await updateAddressMutation.mutateAsync({\n request: {\n contractorUuid: resolvedContractorId,\n contractorAddressUpdateBody: {\n version: fetchedAddress.version,\n street1: payload.street1,\n street2: payload.street2 || undefined,\n city: payload.city,\n state: payload.state,\n zip: payload.zip,\n },\n },\n })\n\n if (!result.contractorAddress) {\n throw new SDKInternalError('Contractor address update failed')\n }\n\n submitResult = {\n mode: 'update',\n data: result.contractorAddress,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (!contractor || !fetchedAddress) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n contractorAddress: fetchedAddress,\n contractor,\n contractorType,\n },\n status: {\n isPending,\n mode: 'update' as const,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Street1: Street1Field,\n Street2: Street2Field,\n City: CityField,\n State: StateField,\n Zip: ZipField,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Discriminated union returned by {@link useContractorAddressForm}.\n *\n * @public\n */\nexport type UseContractorAddressFormResult = HookLoadingResult | UseContractorAddressFormReady\n/**\n * Type of `form.fieldsMetadata` returned by {@link useContractorAddressForm}.\n *\n * @public\n */\nexport type ContractorAddressFieldsMetadata = ReturnType<\n typeof buildContractorAddressFieldsMetadata\n>\n"],"names":["buildContractorAddressFieldsMetadata","base","stateOptions","STATES_ABBR","abbr","withOptions","useContractorAddressForm","contractorId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","contractorQuery","useContractorsGet","addressQuery","useContractorsGetAddress","contractor","contractorType","fetchedAddress","schema","metadataConfig","useMemo","createContractorAddressSchema","resolvedDefaults","formMethods","useForm","zodResolver","updateAddressMutation","useContractorsUpdateAddressMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","onSubmit","options","submitResult","resolve","data","payload","resolvedContractorId","SDKInternalError","result","hookFormInternals","useHookFormInternals","Street1Field","Street2Field","CityField","StateField","ZipField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;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L,EAAA;AAAA,QACF;AAAA,QACA,MAAM;AACJ,UAAAA,EAAA;AAAA,QACF;AAAA,MAAA,EACF;AAAA,IACF,CAAC,GAEMD;AAAA,EACT,GAEMO,IAAoBC,EAAqBzB,CAAW;AAE1D,SAAI,CAACR,KAAc,CAACE,IACX,EAAE,WAAW,IAAe,eAAAgB,EAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,mBAAmBhB;AAAA,MACnB,YAAAF;AAAA,MACA,gBAAAC;AAAA,IAAA;AAAA,IAEF,QAAQ;AAAA,MACN,WAAAY;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,IAER,SAAS,EAAE,UAAAU,EAAA;AAAA,IACX,eAAAL;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,SAASgB;AAAA,QACT,SAASC;AAAA,QACT,MAAMC;AAAA,QACN,OAAOC;AAAA,QACP,KAAKC;AAAA,MAAA;AAAA,MAEP,gBAAAhB;AAAA,MACA,mBAAAU;AAAA,MACA,yBAAyBO,EAA8B/B,GAAaL,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"useContractorAddressForm.js","sources":["../../../../../../src/components/Contractor/Address/shared/useContractorAddressForm/useContractorAddressForm.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport type { ComponentType } from 'react'\nimport { useForm } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Contractor, ContractorType } from '@gusto/embedded-api/models/components/contractor'\nimport type { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress'\nimport { useContractorsGet } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorsGetAddress } from '@gusto/embedded-api/react-query/contractorsGetAddress'\nimport { useContractorsUpdateAddressMutation } from '@gusto/embedded-api/react-query/contractorsUpdateAddress'\nimport {\n createContractorAddressSchema,\n type ContractorAddressOptionalFieldsToRequire,\n type ContractorAddressFormData,\n type ContractorAddressFormOutputs,\n} from './contractorAddressSchema'\nimport { Street1Field, Street2Field, CityField, StateField, ZipField } from './fields'\nimport type {\n Street1FieldProps,\n Street2FieldProps,\n CityFieldProps,\n StateFieldProps,\n ZipFieldProps,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldMetadata,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { STATES_ABBR } from '@/shared/constants'\n\nexport type { ContractorAddressOptionalFieldsToRequire } from './contractorAddressSchema'\n\n/**\n * Optional overrides passed to {@link UseContractorAddressFormReady.actions.onSubmit | onSubmit}.\n *\n * @public\n */\nexport interface ContractorAddressSubmitOptions {\n /** Override the contractor identifier supplied to the hook. */\n contractorId?: string\n}\n\n/**\n * Configuration options for {@link useContractorAddressForm}.\n *\n * @public\n */\nexport interface UseContractorAddressFormProps {\n /** UUID of the contractor whose address is being edited. */\n contractorId: string\n /** Override fields that are optional by default to be required. See `ContractorAddressOptionalFieldsToRequire`. */\n optionalFieldsToRequire?: ContractorAddressOptionalFieldsToRequire\n /** Pre-fill form values. Server data takes precedence. */\n defaultValues?: Partial<ContractorAddressFormData>\n /** Passed through to react-hook-form. Defaults to `'onSubmit'`. */\n validationMode?: UseFormProps['mode']\n /** Auto-focus the first invalid field on submit. Set to `false` when using `composeSubmitHandler` so submit-time focus is coordinated across multiple forms. Defaults to `true`. */\n shouldFocusError?: boolean\n}\n\n/**\n * Field components exposed by {@link useContractorAddressForm} on `form.Fields`.\n *\n * @public\n */\nexport interface ContractorAddressFormFields {\n /** Bound to `street1`. Text input for the first street address line. Required. */\n Street1: ComponentType<Street1FieldProps>\n /** Bound to `street2`. Text input for the second street address line. Optional. */\n Street2: ComponentType<Street2FieldProps>\n /** Bound to `city`. Text input for the city. Required. */\n City: ComponentType<CityFieldProps>\n /**\n * Bound to `state`. Select whose options are the standard two-letter US state\n * abbreviations. Supply `getOptionLabel` to localize the option labels. Required.\n */\n State: ComponentType<StateFieldProps>\n /**\n * Bound to `zip`. Text input for the ZIP code. Required; also validates ZIP\n * format and emits `INVALID_ZIP` when the value does not match.\n */\n Zip: ComponentType<ZipFieldProps>\n}\n\n/**\n * Ready-state shape returned by {@link useContractorAddressForm} once data has loaded.\n *\n * @remarks\n * Discriminated by `isLoading: false`. Extends {@link BaseFormHookReady} with\n * the contractor-address-specific `data`, `status`, `actions`, and `form.Fields` shape.\n *\n * @public\n */\nexport interface UseContractorAddressFormReady extends BaseFormHookReady<\n ContractorAddressFieldsMetadata,\n ContractorAddressFormData,\n ContractorAddressFormFields\n> {\n /** Static entity data resolved from the API. */\n data: {\n /** The contractor address row loaded for update. */\n contractorAddress: ContractorAddress\n /** The full contractor entity loaded alongside the address. */\n contractor: Contractor\n /** The contractor's type — drives whether the address is labelled \"home\" (Individual) or \"business\" (Business). */\n contractorType: ContractorType | undefined\n }\n /** Reactive status flags. */\n status: { isPending: boolean; mode: 'update' }\n /** Available actions. */\n actions: {\n onSubmit: (\n options?: ContractorAddressSubmitOptions,\n ) => Promise<HookSubmitResult<ContractorAddress> | undefined>\n }\n}\n\n/** @internal */\nfunction buildContractorAddressFieldsMetadata(\n base: Record<keyof ContractorAddressFormData, FieldMetadata>,\n) {\n const stateOptions = STATES_ABBR.map(abbr => ({\n value: abbr,\n label: abbr,\n }))\n return {\n street1: base.street1,\n street2: base.street2,\n city: base.city,\n state: withOptions(base.state, stateOptions, STATES_ABBR),\n zip: base.zip,\n } satisfies FieldsMetadata\n}\n\n/**\n * Form hook for editing a contractor's address.\n *\n * @remarks\n * A contractor always has exactly one address (created with the contractor),\n * so this hook operates only in update mode and issues a PUT on submit. The\n * same address is labelled a \"home\" address for Individual contractors and a\n * \"business\" address for Business contractors; the hook exposes `contractorType`\n * so the consuming component can choose the appropriate copy.\n *\n * @param props - See {@link UseContractorAddressFormProps}.\n * @returns A {@link HookLoadingResult} while loading, or a {@link UseContractorAddressFormReady} once ready.\n * @public\n *\n * @example\n * ```tsx\n * import {\n * useContractorAddressForm,\n * SDKFormProvider,\n * type UseContractorAddressFormReady,\n * } from '@gusto/embedded-react-sdk'\n *\n * function ContractorAddressPage({ contractorId }: { contractorId: string }) {\n * const contractorAddress = useContractorAddressForm({ contractorId })\n *\n * if (contractorAddress.isLoading) return <div>Loading...</div>\n *\n * return <ContractorAddressReady contractorAddress={contractorAddress} />\n * }\n *\n * function ContractorAddressReady({\n * contractorAddress,\n * }: {\n * contractorAddress: UseContractorAddressFormReady\n * }) {\n * const { Fields } = contractorAddress.form\n *\n * return (\n * <SDKFormProvider formHookResult={contractorAddress}>\n * <form onSubmit={e => { e.preventDefault(); void contractorAddress.actions.onSubmit() }}>\n * <Fields.Street1 label=\"Street address\" />\n * <Fields.Street2 label=\"Apt, suite, etc. (optional)\" />\n * <Fields.City label=\"City\" />\n * <Fields.State label=\"State\" />\n * <Fields.Zip label=\"ZIP code\" />\n * <button type=\"submit\" disabled={contractorAddress.status.isPending}>Save</button>\n * </form>\n * </SDKFormProvider>\n * )\n * }\n * ```\n */\nexport function useContractorAddressForm({\n contractorId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n}: UseContractorAddressFormProps): HookLoadingResult | UseContractorAddressFormReady {\n const contractorQuery = useContractorsGet(\n { contractorUuid: contractorId },\n { enabled: !!contractorId },\n )\n const addressQuery = useContractorsGetAddress(\n { contractorUuid: contractorId },\n { enabled: !!contractorId },\n )\n\n const contractor = contractorQuery.data?.contractorShow\n const contractorType = contractor?.type\n const fetchedAddress = addressQuery.data?.contractorAddress\n\n const [schema, metadataConfig] = useMemo(\n () => createContractorAddressSchema({ optionalFieldsToRequire }),\n [optionalFieldsToRequire],\n )\n\n const resolvedDefaults: ContractorAddressFormData = useMemo(\n () => ({\n street1: fetchedAddress?.street1 ?? partnerDefaults?.street1 ?? '',\n street2: fetchedAddress?.street2 ?? partnerDefaults?.street2 ?? '',\n city: fetchedAddress?.city ?? partnerDefaults?.city ?? '',\n state: fetchedAddress?.state ?? partnerDefaults?.state ?? '',\n zip: fetchedAddress?.zip ?? partnerDefaults?.zip ?? '',\n }),\n [fetchedAddress, partnerDefaults],\n )\n\n const formMethods = useForm<ContractorAddressFormData, unknown, ContractorAddressFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const updateAddressMutation = useContractorsUpdateAddressMutation()\n\n const isPending = updateAddressMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('ContractorAddressForm')\n\n const errorHandling = composeErrorHandler([contractorQuery, addressQuery], {\n submitError,\n setSubmitError,\n })\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = buildContractorAddressFieldsMetadata(baseMetadata)\n\n const onSubmit = async (\n options?: ContractorAddressSubmitOptions,\n ): Promise<HookSubmitResult<ContractorAddress> | undefined> => {\n let submitResult: HookSubmitResult<ContractorAddress> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: ContractorAddressFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedContractorId = options?.contractorId ?? contractorId\n\n if (!fetchedAddress?.version) {\n throw new SDKInternalError(\n 'Cannot update contractor address: no matching address on file',\n )\n }\n\n const result = await updateAddressMutation.mutateAsync({\n request: {\n contractorUuid: resolvedContractorId,\n contractorAddressUpdateBody: {\n version: fetchedAddress.version,\n street1: payload.street1,\n street2: payload.street2 || undefined,\n city: payload.city,\n state: payload.state,\n zip: payload.zip,\n },\n },\n })\n\n if (!result.contractorAddress) {\n throw new SDKInternalError('Contractor address update failed')\n }\n\n submitResult = {\n mode: 'update',\n data: result.contractorAddress,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (!contractor || !fetchedAddress) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n contractorAddress: fetchedAddress,\n contractor,\n contractorType,\n },\n status: {\n isPending,\n mode: 'update' as const,\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Street1: Street1Field,\n Street2: Street2Field,\n City: CityField,\n State: StateField,\n Zip: ZipField,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\n/**\n * Discriminated union returned by {@link useContractorAddressForm}.\n *\n * @public\n */\nexport type UseContractorAddressFormResult = HookLoadingResult | UseContractorAddressFormReady\n/**\n * Type of `form.fieldsMetadata` returned by {@link useContractorAddressForm}.\n *\n * @public\n */\nexport type ContractorAddressFieldsMetadata = ReturnType<\n typeof buildContractorAddressFieldsMetadata\n>\n"],"names":["buildContractorAddressFieldsMetadata","base","stateOptions","STATES_ABBR","abbr","withOptions","useContractorAddressForm","contractorId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","contractorQuery","useContractorsGet","addressQuery","useContractorsGetAddress","contractor","contractorType","fetchedAddress","schema","metadataConfig","useMemo","createContractorAddressSchema","resolvedDefaults","formMethods","useForm","zodResolver","updateAddressMutation","useContractorsUpdateAddressMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","onSubmit","options","submitResult","resolve","data","payload","resolvedContractorId","SDKInternalError","result","hookFormInternals","useHookFormInternals","Street1Field","Street2Field","CityField","StateField","ZipField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;AAgIA,SAASA,EACPC,GACA;AACA,QAAMC,IAAeC,EAAY,IAAI,CAAAC,OAAS;AAAA,IAC5C,OAAOA;AAAA,IACP,OAAOA;AAAA,EAAA,EACP;AACF,SAAO;AAAA,IACL,SAASH,EAAK;AAAA,IACd,SAASA,EAAK;AAAA,IACd,MAAMA,EAAK;AAAA,IACX,OAAOI,EAAYJ,EAAK,OAAOC,GAAcC,CAAW;AAAA,IACxD,KAAKF,EAAK;AAAA,EAAA;AAEd;AAsDO,SAASK,GAAyB;AAAA,EACvC,cAAAC;AAAA,EACA,yBAAAC;AAAA,EACA,eAAeC;AAAA,EACf,gBAAAC,IAAiB;AAAA,EACjB,kBAAAC,IAAmB;AACrB,GAAqF;AACnF,QAAMC,IAAkBC;AAAA,IACtB,EAAE,gBAAgBN,EAAA;AAAA,IAClB,EAAE,SAAS,CAAC,CAACA,EAAA;AAAA,EAAa,GAEtBO,IAAeC;AAAA,IACnB,EAAE,gBAAgBR,EAAA;AAAA,IAClB,EAAE,SAAS,CAAC,CAACA,EAAA;AAAA,EAAa,GAGtBS,IAAaJ,EAAgB,MAAM,gBACnCK,IAAiBD,GAAY,MAC7BE,IAAiBJ,EAAa,MAAM,mBAEpC,CAACK,GAAQC,CAAc,IAAIC;AAAA,IAC/B,MAAMC,EAA8B,EAAE,yBAAAd,GAAyB;AAAA,IAC/D,CAACA,CAAuB;AAAA,EAAA,GAGpBe,IAA8CF;AAAA,IAClD,OAAO;AAAA,MACL,SAASH,GAAgB,WAAWT,GAAiB,WAAW;AAAA,MAChE,SAASS,GAAgB,WAAWT,GAAiB,WAAW;AAAA,MAChE,MAAMS,GAAgB,QAAQT,GAAiB,QAAQ;AAAA,MACvD,OAAOS,GAAgB,SAAST,GAAiB,SAAS;AAAA,MAC1D,KAAKS,GAAgB,O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AID,EAAiB,kCAAkC;AAG/D,YAAAL,IAAe;AAAA,cACb,MAAM;AAAA,cACN,MAAMM,EAAO;AAAA,YAAA;AAAA,UAEjB,CAAC,GACDL,EAAA;AAAA,QACF;AAAA,QACA,MAAM;AACJ,UAAAA,EAAA;AAAA,QACF;AAAA,MAAA,EACF;AAAA,IACF,CAAC,GAEMD;AAAA,EACT,GAEMO,IAAoBC,EAAqBzB,CAAW;AAE1D,SAAI,CAACR,KAAc,CAACE,IACX,EAAE,WAAW,IAAe,eAAAgB,EAAA,IAG9B;AAAA,IACL,WAAW;AAAA,IACX,MAAM;AAAA,MACJ,mBAAmBhB;AAAA,MACnB,YAAAF;AAAA,MACA,gBAAAC;AAAA,IAAA;AAAA,IAEF,QAAQ;AAAA,MACN,WAAAY;AAAA,MACA,MAAM;AAAA,IAAA;AAAA,IAER,SAAS,EAAE,UAAAU,EAAA;AAAA,IACX,eAAAL;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,SAASgB;AAAA,QACT,SAASC;AAAA,QACT,MAAMC;AAAA,QACN,OAAOC;AAAA,QACP,KAAKC;AAAA,MAAA;AAAA,MAEP,gBAAAhB;AAAA,MACA,mBAAAU;AAAA,MACA,yBAAyBO,EAA8B/B,GAAaL,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
|
|
@@ -10,7 +10,7 @@ function f({
|
|
|
10
10
|
), r = a(
|
|
11
11
|
{ contractorUuid: o },
|
|
12
12
|
{ staleTime: 1 / 0 }
|
|
13
|
-
), s = c([t, r]), n = r.data?.contractorAddress, e = t.data?.
|
|
13
|
+
), s = c([t, r]), n = r.data?.contractorAddress, e = t.data?.contractorShow?.type;
|
|
14
14
|
return t.isLoading || r.isLoading || !n ? { isLoading: !0, errorHandling: s } : {
|
|
15
15
|
isLoading: !1,
|
|
16
16
|
data: { contractorAddress: n, contractorType: e },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContractorAddressSummary.js","sources":["../../../../../../src/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.tsx"],"sourcesContent":["import { useContractorsGet } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorsGetAddress } from '@gusto/embedded-api/react-query/contractorsGetAddress'\nimport type { ContractorType } from '@gusto/embedded-api/models/components/contractor'\nimport type { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type { BaseHookReady, HookLoadingResult } from '@/partner-hook-utils/types'\n\n/** @internal */\nexport interface UseContractorAddressSummaryParams {\n contractorId: string\n}\n\ntype UseContractorAddressSummaryReady = BaseHookReady<\n {\n contractorAddress: ContractorAddress\n contractorType: ContractorType | undefined\n },\n { isFetching: boolean; isPending: boolean }\n>\n\n/** @internal */\nexport type UseContractorAddressSummaryResult = HookLoadingResult | UseContractorAddressSummaryReady\n\n/** @internal */\nexport function useContractorAddressSummary({\n contractorId,\n}: UseContractorAddressSummaryParams): UseContractorAddressSummaryResult {\n const contractorQuery = useContractorsGet(\n { contractorUuid: contractorId },\n { staleTime: Infinity },\n )\n const addressQuery = useContractorsGetAddress(\n { contractorUuid: contractorId },\n { staleTime: Infinity },\n )\n\n const errorHandling = composeErrorHandler([contractorQuery, addressQuery])\n\n const contractorAddress = addressQuery.data?.contractorAddress\n const contractorType = contractorQuery.data?.
|
|
1
|
+
{"version":3,"file":"useContractorAddressSummary.js","sources":["../../../../../../src/components/Contractor/Address/shared/useContractorAddressSummary/useContractorAddressSummary.tsx"],"sourcesContent":["import { useContractorsGet } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorsGetAddress } from '@gusto/embedded-api/react-query/contractorsGetAddress'\nimport type { ContractorType } from '@gusto/embedded-api/models/components/contractor'\nimport type { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type { BaseHookReady, HookLoadingResult } from '@/partner-hook-utils/types'\n\n/** @internal */\nexport interface UseContractorAddressSummaryParams {\n contractorId: string\n}\n\ntype UseContractorAddressSummaryReady = BaseHookReady<\n {\n contractorAddress: ContractorAddress\n contractorType: ContractorType | undefined\n },\n { isFetching: boolean; isPending: boolean }\n>\n\n/** @internal */\nexport type UseContractorAddressSummaryResult = HookLoadingResult | UseContractorAddressSummaryReady\n\n/** @internal */\nexport function useContractorAddressSummary({\n contractorId,\n}: UseContractorAddressSummaryParams): UseContractorAddressSummaryResult {\n const contractorQuery = useContractorsGet(\n { contractorUuid: contractorId },\n { staleTime: Infinity },\n )\n const addressQuery = useContractorsGetAddress(\n { contractorUuid: contractorId },\n { staleTime: Infinity },\n )\n\n const errorHandling = composeErrorHandler([contractorQuery, addressQuery])\n\n const contractorAddress = addressQuery.data?.contractorAddress\n const contractorType = contractorQuery.data?.contractorShow?.type\n\n if (contractorQuery.isLoading || addressQuery.isLoading || !contractorAddress) {\n return { isLoading: true, errorHandling }\n }\n\n return {\n isLoading: false,\n data: { contractorAddress, contractorType },\n status: {\n isFetching: contractorQuery.isFetching || addressQuery.isFetching,\n isPending: false,\n },\n errorHandling,\n }\n}\n"],"names":["useContractorAddressSummary","contractorId","contractorQuery","useContractorsGet","addressQuery","useContractorsGetAddress","errorHandling","composeErrorHandler","contractorAddress","contractorType"],"mappings":";;;AAwBO,SAASA,EAA4B;AAAA,EAC1C,cAAAC;AACF,GAAyE;AACvE,QAAMC,IAAkBC;AAAA,IACtB,EAAE,gBAAgBF,EAAA;AAAA,IAClB,EAAE,WAAW,MAAA;AAAA,EAAS,GAElBG,IAAeC;AAAA,IACnB,EAAE,gBAAgBJ,EAAA;AAAA,IAClB,EAAE,WAAW,MAAA;AAAA,EAAS,GAGlBK,IAAgBC,EAAoB,CAACL,GAAiBE,CAAY,CAAC,GAEnEI,IAAoBJ,EAAa,MAAM,mBACvCK,IAAiBP,EAAgB,MAAM,gBAAgB;AAE7D,SAAIA,EAAgB,aAAaE,EAAa,aAAa,CAACI,IACnD,EAAE,WAAW,IAAM,eAAAF,EAAA,IAGrB;AAAA,IACL,WAAW;AAAA,IACX,MAAM,EAAE,mBAAAE,GAAmB,gBAAAC,EAAA;AAAA,IAC3B,QAAQ;AAAA,MACN,YAAYP,EAAgB,cAAcE,EAAa;AAAA,MACvD,WAAW;AAAA,IAAA;AAAA,IAEb,eAAAE;AAAA,EAAA;AAEJ;"}
|