@gusto/embedded-react-sdk 0.32.0 → 0.34.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (155) hide show
  1. package/CHANGELOG.md +52 -0
  2. package/dist/components/Common/Fields/MultiSelectComboBoxField/MultiSelectComboBoxField.d.ts +5 -0
  3. package/dist/components/Common/Fields/MultiSelectComboBoxField/MultiSelectComboBoxField.js +34 -0
  4. package/dist/components/Common/Fields/MultiSelectComboBoxField/MultiSelectComboBoxField.js.map +1 -0
  5. package/dist/components/Common/Fields/MultiSelectComboBoxField/index.d.ts +2 -0
  6. package/dist/components/Common/SignatureForm/SignatureForm.d.ts +1 -7
  7. package/dist/components/Common/UI/Badge/Badge.js +39 -8
  8. package/dist/components/Common/UI/Badge/Badge.js.map +1 -1
  9. package/dist/components/Common/UI/Badge/Badge.module.scss.js +8 -4
  10. package/dist/components/Common/UI/Badge/Badge.module.scss.js.map +1 -1
  11. package/dist/components/Common/UI/Badge/BadgeTypes.d.ts +12 -0
  12. package/dist/components/Common/UI/Badge/BadgeTypes.js.map +1 -1
  13. package/dist/components/Common/UI/Menu/Menu.js +2 -3
  14. package/dist/components/Common/UI/Menu/Menu.js.map +1 -1
  15. package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.d.ts +2 -0
  16. package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.js +127 -0
  17. package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.js.map +1 -0
  18. package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.module.scss.js +16 -0
  19. package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBox.module.scss.js.map +1 -0
  20. package/dist/components/Common/UI/MultiSelectComboBox/MultiSelectComboBoxTypes.d.ts +17 -0
  21. package/dist/components/Common/UI/MultiSelectComboBox/index.d.ts +3 -0
  22. package/dist/components/Common/index.d.ts +1 -0
  23. package/dist/components/Company/AssignSignatory/CreateSignatory/Schema.d.ts +4 -30
  24. package/dist/components/Company/AssignSignatory/InviteSignatory/InviteSignatoryForm.d.ts +2 -26
  25. package/dist/components/Company/BankAccount/BankAccountForm/Form.d.ts +1 -7
  26. package/dist/components/Company/BankAccount/BankAccountVerify/Form.d.ts +1 -7
  27. package/dist/components/Company/FederalTaxes/useFederalTaxes.d.ts +7 -13
  28. package/dist/components/Company/Locations/LocationForm/Form.d.ts +7 -20
  29. package/dist/components/Company/PaySchedule/usePaySchedule.d.ts +7 -18
  30. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js +40 -46
  31. package/dist/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.js.map +1 -1
  32. package/dist/components/Contractor/Address/useAddress.d.ts +1 -13
  33. package/dist/components/Contractor/ContractorList/useContractorList.js +4 -4
  34. package/dist/components/Contractor/ContractorList/useContractorList.js.map +1 -1
  35. package/dist/components/Contractor/NewHireReport/NewHireReport.d.ts +5 -15
  36. package/dist/components/Contractor/NewHireReport/NewHireReport.js +28 -28
  37. package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
  38. package/dist/components/Contractor/PaymentMethod/PaymentMethod.d.ts +7 -20
  39. package/dist/components/Contractor/PaymentMethod/PaymentTypeForm.d.ts +5 -6
  40. package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js +108 -100
  41. package/dist/components/Contractor/Payments/CreatePayment/CreatePayment.js.map +1 -1
  42. package/dist/components/Contractor/Payments/CreatePayment/CreatePaymentPresentation.d.ts +4 -1
  43. package/dist/components/Contractor/Payments/CreatePayment/CreatePaymentPresentation.js +54 -50
  44. package/dist/components/Contractor/Payments/CreatePayment/CreatePaymentPresentation.js.map +1 -1
  45. package/dist/components/Contractor/Payments/CreatePayment/EditContractorPaymentFormSchema.d.ts +19 -67
  46. package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.js +27 -26
  47. package/dist/components/Contractor/Payments/PaymentFlow/PaymentFlowComponents.js.map +1 -1
  48. package/dist/components/Contractor/Payments/PaymentFlow/paymentStateMachine.js +76 -44
  49. package/dist/components/Contractor/Payments/PaymentFlow/paymentStateMachine.js.map +1 -1
  50. package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js +1 -1
  51. package/dist/components/Contractor/Payments/PaymentHistory/PaymentHistory.js.map +1 -1
  52. package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js +1 -1
  53. package/dist/components/Contractor/Payments/PaymentStatement/PaymentStatement.js.map +1 -1
  54. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.d.ts +3 -1
  55. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js +28 -22
  56. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummary.js.map +1 -1
  57. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummaryPresentation.d.ts +3 -1
  58. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummaryPresentation.js +63 -52
  59. package/dist/components/Contractor/Payments/PaymentSummary/PaymentSummaryPresentation.js.map +1 -1
  60. package/dist/components/Contractor/Profile/useContractorProfile.d.ts +54 -120
  61. package/dist/components/Contractor/Profile/useContractorProfile.js +47 -47
  62. package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
  63. package/dist/components/Employee/Compensation/useCompensation.d.ts +17 -44
  64. package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.d.ts +4 -22
  65. package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js +59 -59
  66. package/dist/components/Employee/Deductions/DeductionsForm/ChildSupportForm.js.map +1 -1
  67. package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.d.ts +4 -22
  68. package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js +33 -33
  69. package/dist/components/Employee/Deductions/DeductionsForm/CustomDeductionForm.js.map +1 -1
  70. package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.d.ts +5 -27
  71. package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js +46 -46
  72. package/dist/components/Employee/Deductions/DeductionsForm/GarnishmentForm.js.map +1 -1
  73. package/dist/components/Employee/Deductions/useDeductions.d.ts +7 -26
  74. package/dist/components/Employee/DocumentSigner/EmploymentEligibility/EmploymentEligibilitySchema.d.ts +5 -29
  75. package/dist/components/Employee/DocumentSigner/EmploymentEligibility/EmploymentEligibilitySchema.js +8 -8
  76. package/dist/components/Employee/DocumentSigner/EmploymentEligibility/EmploymentEligibilitySchema.js.map +1 -1
  77. package/dist/components/Employee/DocumentSigner/I9SignatureForm/I9SignatureForm.d.ts +9 -76
  78. package/dist/components/Employee/EmployeeDocuments/EmployeeDocumentsPresentation.d.ts +1 -5
  79. package/dist/components/Employee/FederalTaxes/FederalForm.d.ts +7 -33
  80. package/dist/components/Employee/PaymentMethod/BankAccount.d.ts +5 -14
  81. package/dist/components/Employee/PaymentMethod/PaymentTypeForm.d.ts +5 -6
  82. package/dist/components/Employee/PaymentMethod/usePaymentMethod.d.ts +12 -68
  83. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js +15 -14
  84. package/dist/components/Employee/PaymentMethod/usePaymentMethod.js.map +1 -1
  85. package/dist/components/Employee/Profile/AdminPersonalDetails.d.ts +17 -82
  86. package/dist/components/Employee/Profile/AdminPersonalDetails.js +38 -33
  87. package/dist/components/Employee/Profile/AdminPersonalDetails.js.map +1 -1
  88. package/dist/components/Employee/Profile/HomeAddress.d.ts +11 -66
  89. package/dist/components/Employee/Profile/PersonalDetailsInputs.d.ts +15 -64
  90. package/dist/components/Employee/Profile/PersonalDetailsInputs.js +23 -19
  91. package/dist/components/Employee/Profile/PersonalDetailsInputs.js.map +1 -1
  92. package/dist/components/Employee/Profile/Profile.js +2 -5
  93. package/dist/components/Employee/Profile/Profile.js.map +1 -1
  94. package/dist/components/Employee/Profile/SelfPersonalDetails.d.ts +8 -37
  95. package/dist/components/Employee/Profile/SelfPersonalDetails.js +22 -19
  96. package/dist/components/Employee/Profile/SelfPersonalDetails.js.map +1 -1
  97. package/dist/components/Employee/StateTaxes/StateForm.d.ts +1 -5
  98. package/dist/components/Employee/Taxes/FederalForm.d.ts +7 -33
  99. package/dist/components/Employee/Taxes/StateForm.d.ts +1 -5
  100. package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.d.ts +1 -11
  101. package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js +1 -1
  102. package/dist/components/Payroll/ConfirmWireDetails/ConfirmWireDetailsForm/ConfirmWireDetailsForm.js.map +1 -1
  103. package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js +6 -9
  104. package/dist/components/Payroll/OffCycle/OffCycleFlowComponents.js.map +1 -1
  105. package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js +84 -56
  106. package/dist/components/Payroll/OffCycleCreation/OffCycleCreation.js.map +1 -1
  107. package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.d.ts +1 -1
  108. package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js +56 -22
  109. package/dist/components/Payroll/OffCycleCreation/OffCycleCreationPresentation.js.map +1 -1
  110. package/dist/components/Payroll/OffCycleCreation/OffCycleCreationTypes.d.ts +5 -0
  111. package/dist/components/Payroll/OffCyclePayPeriodDateForm/OffCyclePayPeriodDateFormTypes.d.ts +2 -22
  112. package/dist/components/Payroll/PayrollBlocker/payrollHelpers.js +22 -18
  113. package/dist/components/Payroll/PayrollBlocker/payrollHelpers.js.map +1 -1
  114. package/dist/components/Payroll/PayrollBlocker/payrollHelpers.test.d.ts +1 -0
  115. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js +12 -8
  116. package/dist/components/Payroll/PayrollConfiguration/PayrollConfiguration.js.map +1 -1
  117. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js +5 -5
  118. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployee.js.map +1 -1
  119. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.d.ts +2 -12
  120. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js +34 -34
  121. package/dist/components/Payroll/PayrollEditEmployee/PayrollEditEmployeePresentation.js.map +1 -1
  122. package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js +38 -35
  123. package/dist/components/Payroll/PayrollExecutionFlow/payrollExecutionMachine.js.map +1 -1
  124. package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.d.ts +1 -0
  125. package/dist/components/Payroll/PayrollFlow/PayrollFlowComponents.js.map +1 -1
  126. package/dist/components/Payroll/usePreparedPayrollData.js +26 -26
  127. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  128. package/dist/contexts/ApiProvider/ApiProvider.js +26 -25
  129. package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
  130. package/dist/contexts/ApiProvider/apiVersionHook.d.ts +2 -0
  131. package/dist/contexts/ApiProvider/apiVersionHook.js +7 -0
  132. package/dist/contexts/ApiProvider/apiVersionHook.js.map +1 -0
  133. package/dist/contexts/ApiProvider/apiVersionHook.test.d.ts +1 -0
  134. package/dist/contexts/ComponentAdapter/adapters/defaultComponentAdapter.js +60 -58
  135. package/dist/contexts/ComponentAdapter/adapters/defaultComponentAdapter.js.map +1 -1
  136. package/dist/contexts/ComponentAdapter/useComponentContext.d.ts +2 -0
  137. package/dist/contexts/ComponentAdapter/useComponentContext.js.map +1 -1
  138. package/dist/contexts/ThemeProvider/ThemeProvider.js +23 -23
  139. package/dist/contexts/ThemeProvider/ThemeProvider.js.map +1 -1
  140. package/dist/helpers/validations.d.ts +2 -2
  141. package/dist/i18n/I18n.js +15 -15
  142. package/dist/i18n/I18n.js.map +1 -1
  143. package/dist/i18n/en/Contractor.Payments.PaymentSummary.json.js +42 -40
  144. package/dist/i18n/en/Contractor.Payments.PaymentSummary.json.js.map +1 -1
  145. package/dist/i18n/en/Contractor.Payments.PaymentsList.json.js +9 -9
  146. package/dist/i18n/en/Payroll.EmployeeSelection.json.js +10 -0
  147. package/dist/i18n/en/Payroll.EmployeeSelection.json.js.map +1 -0
  148. package/dist/i18n/en/Payroll.OffCycleCreation.json.js +10 -8
  149. package/dist/i18n/en/Payroll.OffCycleCreation.json.js.map +1 -1
  150. package/dist/i18n/en/common.json.d.ts +4 -1
  151. package/dist/i18n/en/common.json.js +5 -5
  152. package/dist/style.css +1 -1
  153. package/dist/types/i18next.d.ts +14 -1
  154. package/docs/reference/endpoint-inventory.json +4 -0
  155. package/package.json +13 -12
@@ -1,28 +1,15 @@
1
1
  import { z } from 'zod';
2
2
  export declare const LocationFormSchema: z.ZodObject<{
3
- phoneNumber: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
3
+ phoneNumber: z.ZodPipe<z.ZodString, z.ZodTransform<string, string>>;
4
4
  street1: z.ZodString;
5
5
  street2: z.ZodOptional<z.ZodString>;
6
6
  city: z.ZodString;
7
7
  state: z.ZodString;
8
- zip: z.ZodEffects<z.ZodString, string, string>;
9
- addressType: z.ZodOptional<z.ZodArray<z.ZodEnum<["mailingAddress", "filingAddress"]>, "many">>;
10
- }, "strip", z.ZodTypeAny, {
11
- street1: string;
12
- city: string;
13
- state: string;
14
- zip: string;
15
- phoneNumber: string;
16
- street2?: string | undefined;
17
- addressType?: ("filingAddress" | "mailingAddress")[] | undefined;
18
- }, {
19
- street1: string;
20
- city: string;
21
- state: string;
22
- zip: string;
23
- phoneNumber: string;
24
- street2?: string | undefined;
25
- addressType?: ("filingAddress" | "mailingAddress")[] | undefined;
26
- }>;
8
+ zip: z.ZodString;
9
+ addressType: z.ZodOptional<z.ZodArray<z.ZodEnum<{
10
+ filingAddress: "filingAddress";
11
+ mailingAddress: "mailingAddress";
12
+ }>>>;
13
+ }, z.core.$strip>;
27
14
  export type LocationFormInputs = z.infer<typeof LocationFormSchema>;
28
15
  export declare function Form(): import("react/jsx-runtime").JSX.Element;
@@ -18,30 +18,19 @@ type PayScheduleContextType = {
18
18
  payPreviewLoading?: boolean;
19
19
  };
20
20
  export declare const PayScheduleSchema: z.ZodObject<{
21
- frequency: z.ZodEnum<["Every week", "Every other week", "Twice per month", "Monthly"]>;
21
+ frequency: z.ZodEnum<{
22
+ "Every week": "Every week";
23
+ "Every other week": "Every other week";
24
+ "Twice per month": "Twice per month";
25
+ Monthly: "Monthly";
26
+ }>;
22
27
  anchorPayDate: z.ZodOptional<z.ZodDate>;
23
28
  anchorEndOfPayPeriod: z.ZodOptional<z.ZodDate>;
24
29
  day1: z.ZodOptional<z.ZodNumber>;
25
30
  day2: z.ZodOptional<z.ZodNumber>;
26
31
  customName: z.ZodOptional<z.ZodString>;
27
32
  customTwicePerMonth: z.ZodOptional<z.ZodString>;
28
- }, "strip", z.ZodTypeAny, {
29
- frequency: "Every week" | "Every other week" | "Twice per month" | "Monthly";
30
- anchorPayDate?: Date | undefined;
31
- anchorEndOfPayPeriod?: Date | undefined;
32
- day1?: number | undefined;
33
- day2?: number | undefined;
34
- customName?: string | undefined;
35
- customTwicePerMonth?: string | undefined;
36
- }, {
37
- frequency: "Every week" | "Every other week" | "Twice per month" | "Monthly";
38
- anchorPayDate?: Date | undefined;
39
- anchorEndOfPayPeriod?: Date | undefined;
40
- day1?: number | undefined;
41
- day2?: number | undefined;
42
- customName?: string | undefined;
43
- customTwicePerMonth?: string | undefined;
44
- }>;
33
+ }, z.core.$strip>;
45
34
  export type PayScheduleInputs = z.input<typeof PayScheduleSchema>;
46
35
  export type PayScheduleOutputs = z.output<typeof PayScheduleSchema>;
47
36
  export type PayScheduleDefaultValues = RequireAtLeastOne<Partial<Pick<PayScheduleCreateUpdate, 'anchorPayDate' | 'anchorEndOfPayPeriod' | 'day1' | 'day2' | 'customName' | 'frequency'>>>;
@@ -1,9 +1,9 @@
1
- import { jsx as o, jsxs as U, Fragment as V } from "react/jsx-runtime";
1
+ import { jsx as o, jsxs as V, Fragment as q } from "react/jsx-runtime";
2
2
  import { useForm as B, FormProvider as D } from "react-hook-form";
3
3
  import { zodResolver as K } from "@hookform/resolvers/zod";
4
4
  import { useTaxRequirementsUpdateStateMutation as M } from "@gusto/embedded-api/react-query/taxRequirementsUpdateState";
5
5
  import { useTaxRequirementsGetSuspense as w } from "@gusto/embedded-api/react-query/taxRequirementsGet";
6
- import { z as c } from "zod";
6
+ import { z as m } from "zod";
7
7
  import { useMemo as z } from "react";
8
8
  import { useTranslation as H } from "react-i18next";
9
9
  import { Head as N } from "./Head.js";
@@ -14,75 +14,69 @@ import { BaseComponent as Y } from "../../../Base/Base.js";
14
14
  import { useI18n as $ } from "../../../../i18n/I18n.js";
15
15
  import { Flex as I } from "../../../Common/Flex/Flex.js";
16
16
  import { Form as J } from "../../../Common/Form/Form.js";
17
- import { componentEvents as F } from "../../../../shared/constants.js";
17
+ import { componentEvents as g } from "../../../../shared/constants.js";
18
18
  import { useBase as Q } from "../../../Base/useBase.js";
19
- function Se(a) {
19
+ function he(a) {
20
20
  return /* @__PURE__ */ o(Y, { ...a, children: /* @__PURE__ */ o(W, { ...a, children: a.children }) });
21
21
  }
22
- function W({ companyId: a, state: l, className: g, children: v }) {
22
+ function W({ companyId: a, state: f, className: k, children: y }) {
23
23
  $("Company.StateTaxes");
24
- const { onEvent: S, baseSubmitHandler: k } = Q(), { t: r } = H("Company.StateTaxes", { keyPrefix: "form" }), { data: q } = w({ companyUuid: a, state: l }), d = q.taxRequirementsState, { mutateAsync: b, isPending: P } = M(), { dynamicSchema: _, defaultValues: j } = z(() => {
25
- const u = {}, i = {};
26
- return d.requirementSets?.forEach((t) => {
24
+ const { onEvent: S, baseSubmitHandler: b } = Q(), { t: h } = H("Company.StateTaxes", { keyPrefix: "form" }), { data: P } = w({ companyUuid: a, state: f }), c = P.taxRequirementsState, { mutateAsync: j, isPending: A } = M(), { dynamicSchema: C, defaultValues: E } = z(() => {
25
+ const l = {}, n = {};
26
+ return c.requirementSets?.forEach((t) => {
27
27
  if (!t.key) return;
28
- const n = t.key, s = {}, m = {};
28
+ const r = t.key, i = {}, s = {};
29
29
  t.requirements?.forEach((e) => {
30
30
  if (!e.key) return;
31
- const f = e.key, R = e.metadata?.type === "tax_rate" || e.metadata?.type === "percent";
32
- e.metadata?.type === "radio" ? m[f] = e.value ?? void 0 : m[f] = e.value ? String(e.value) : "";
33
- let p = c.string({
34
- required_error: r("validations.required")
35
- }).min(1, r("validations.required"));
36
- const y = e.metadata?.validation;
37
- if (y && R && y.type === "one_of") {
38
- const T = y.rates;
39
- p = c.string({
40
- required_error: r("validations.required")
41
- }).min(1, r("validations.required")).refine((O) => T.includes(O), {
42
- message: r("validations.oneOf", { values: T.join(", ") })
31
+ const d = e.key, _ = e.metadata?.type === "tax_rate" || e.metadata?.type === "percent";
32
+ e.metadata?.type === "radio" ? s[d] = e.value ?? void 0 : s[d] = e.value ? String(e.value) : "";
33
+ let u = m.string().optional();
34
+ const p = e.metadata?.validation;
35
+ if (p && _ && p.type === "one_of") {
36
+ const T = p.rates;
37
+ u = m.string().optional().refine((F) => !F || T.includes(F), {
38
+ message: h("validations.oneOf", { values: T.join(", ") })
43
39
  });
44
40
  }
45
- e.metadata?.type === "radio" && (p = c.boolean({
46
- required_error: r("validations.required")
47
- })), s[f] = p;
48
- }), Object.keys(s).length > 0 && (u[n] = c.object(s), i[n] = m);
41
+ e.metadata?.type === "radio" && (u = m.boolean().optional()), i[d] = u;
42
+ }), Object.keys(i).length > 0 && (l[r] = m.object(i), n[r] = s);
49
43
  }), {
50
- dynamicSchema: c.object(u),
51
- defaultValues: i
44
+ dynamicSchema: m.object(l),
45
+ defaultValues: n
52
46
  };
53
- }, [d, r]), { control: A, ...h } = B({
54
- resolver: K(_),
55
- defaultValues: j
56
- }), C = async (u) => {
57
- await k(u, async (i) => {
58
- const x = d.requirementSets?.filter((t) => t.key && i[t.key]).map((t) => {
59
- const n = t.key, s = i[n];
47
+ }, [c, h]), { control: R, ...v } = B({
48
+ resolver: K(C),
49
+ defaultValues: E
50
+ }), O = async (l) => {
51
+ await b(l, async (n) => {
52
+ const x = c.requirementSets?.filter((t) => t.key && n[t.key]).map((t) => {
53
+ const r = t.key, i = n[r];
60
54
  return {
61
55
  state: t.state,
62
- key: n,
56
+ key: r,
63
57
  effectiveFrom: t.effectiveFrom,
64
- requirements: Object.entries(s).map(([m, e]) => ({
65
- key: m,
58
+ requirements: Object.entries(i).map(([s, e]) => ({
59
+ key: s,
66
60
  value: String(e)
67
61
  }))
68
62
  };
69
63
  });
70
- await b({
64
+ await j({
71
65
  request: {
72
66
  companyUuid: a,
73
67
  requestBody: { requirementSets: x },
74
- state: l
68
+ state: f
75
69
  }
76
- }), S(F.COMPANY_STATE_TAX_UPDATED);
70
+ }), S(g.COMPANY_STATE_TAX_UPDATED);
77
71
  });
78
- }, E = () => {
79
- S(F.CANCEL);
72
+ }, U = () => {
73
+ S(g.CANCEL);
80
74
  };
81
- return /* @__PURE__ */ o("section", { className: g, children: /* @__PURE__ */ o(D, { ...h, control: A, children: /* @__PURE__ */ o(J, { onSubmit: h.handleSubmit(C), children: /* @__PURE__ */ o(
75
+ return /* @__PURE__ */ o("section", { className: k, children: /* @__PURE__ */ o(D, { ...v, control: R, children: /* @__PURE__ */ o(J, { onSubmit: v.handleSubmit(O), children: /* @__PURE__ */ o(
82
76
  G,
83
77
  {
84
- value: { stateTaxRequirements: d, isPending: P, state: l, handleCancel: E },
85
- children: /* @__PURE__ */ o(I, { flexDirection: "column", gap: 32, children: v || /* @__PURE__ */ U(V, { children: [
78
+ value: { stateTaxRequirements: c, isPending: A, state: f, handleCancel: U },
79
+ children: /* @__PURE__ */ o(I, { flexDirection: "column", gap: 32, children: y || /* @__PURE__ */ V(q, { children: [
86
80
  /* @__PURE__ */ o(N, {}),
87
81
  /* @__PURE__ */ o(L, {}),
88
82
  /* @__PURE__ */ o(X, {})
@@ -91,6 +85,6 @@ function W({ companyId: a, state: l, className: g, children: v }) {
91
85
  ) }) }) });
92
86
  }
93
87
  export {
94
- Se as StateTaxesForm
88
+ he as StateTaxesForm
95
89
  };
96
90
  //# sourceMappingURL=StateTaxesForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"StateTaxesForm.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.tsx"],"sourcesContent":["import { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useTaxRequirementsUpdateStateMutation } from '@gusto/embedded-api/react-query/taxRequirementsUpdateState'\nimport { useTaxRequirementsGetSuspense } from '@gusto/embedded-api/react-query/taxRequirementsGet'\nimport { z } from 'zod'\nimport { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { Head } from './Head'\nimport { StateTaxesFormProvider } from './context'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useI18n } from '@/i18n/I18n'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { Form as HtmlForm } from '@/components/Common/Form'\nimport { componentEvents } from '@/shared/constants'\nimport { useBase } from '@/components/Base'\n\ninterface StateTaxesFormProps extends CommonComponentInterface {\n companyId: string\n state: string\n}\n\nexport function StateTaxesForm(props: StateTaxesFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ companyId, state, className, children }: StateTaxesFormProps) {\n useI18n('Company.StateTaxes')\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const { data } = useTaxRequirementsGetSuspense({ companyUuid: companyId, state })\n const stateTaxRequirements = data.taxRequirementsState!\n\n const { mutateAsync: updateStateTax, isPending: isPendingUpdate } =\n useTaxRequirementsUpdateStateMutation()\n\n // Schema and default value generation\n const { dynamicSchema, defaultValues } = useMemo(() => {\n const schemaShape: Record<string, z.ZodObject<Record<string, z.ZodTypeAny>>> = {}\n const values: Partial<Record<string, Record<string, string | boolean | number | undefined>>> =\n {}\n\n //Looping through each requirement set\n stateTaxRequirements.requirementSets?.forEach(requirementSet => {\n if (!requirementSet.key) return\n\n const requirementSetKey = requirementSet.key\n const requirementShape: Record<string, z.ZodTypeAny> = {}\n const requirementValues: Record<string, string | boolean | number | undefined> = {}\n\n requirementSet.requirements?.forEach(requirement => {\n if (!requirement.key) return\n\n const requirementKey = requirement.key\n\n const isPercentField =\n requirement.metadata?.type === 'tax_rate' || requirement.metadata?.type === 'percent'\n\n if (requirement.metadata?.type === 'radio') {\n requirementValues[requirementKey] = requirement.value ?? undefined\n } else {\n requirementValues[requirementKey] = requirement.value ? String(requirement.value) : ''\n }\n\n let fieldSchema: z.ZodTypeAny = z\n .string({\n required_error: t('validations.required'),\n })\n .min(1, t('validations.required'))\n\n const validation = requirement.metadata?.validation\n\n if (validation) {\n if (isPercentField && validation.type === 'one_of') {\n const oneOfValues = validation.rates as string[]\n fieldSchema = z\n .string({\n required_error: t('validations.required'),\n })\n .min(1, t('validations.required'))\n .refine(val => oneOfValues.includes(val), {\n message: t('validations.oneOf', { values: oneOfValues.join(', ') }),\n })\n }\n }\n\n if (requirement.metadata?.type === 'radio') {\n fieldSchema = z.boolean({\n required_error: t('validations.required'),\n })\n }\n requirementShape[requirementKey] = fieldSchema\n // --- End Schema Logic ---\n })\n\n if (Object.keys(requirementShape).length > 0) {\n schemaShape[requirementSetKey] = z.object(requirementShape)\n values[requirementSetKey] = requirementValues\n }\n })\n\n const finalSchema = z.object(schemaShape)\n\n // Return both the schema and the default values\n return {\n dynamicSchema: finalSchema,\n defaultValues: values as z.infer<typeof finalSchema>,\n }\n }, [stateTaxRequirements, t])\n\n // Infer the type from the schema\n type InferredFormInputs = z.infer<typeof dynamicSchema>\n\n const { control, ...methods } = useForm<InferredFormInputs>({\n resolver: zodResolver(dynamicSchema),\n defaultValues,\n })\n\n const onSubmit = async (formData: InferredFormInputs) => {\n await baseSubmitHandler(formData, async payload => {\n const requirementSets = stateTaxRequirements.requirementSets\n ?.filter(rs => rs.key && payload[rs.key])\n .map(requirementSet => {\n const requirementSetKey = requirementSet.key as string\n const payloadSet = payload[requirementSetKey] as Record<string, unknown>\n\n return {\n state: requirementSet.state,\n key: requirementSetKey,\n effectiveFrom: requirementSet.effectiveFrom,\n requirements: Object.entries(payloadSet).map(([reqKey, value]) => ({\n key: reqKey,\n value: String(value),\n })),\n }\n })\n await updateStateTax({\n request: {\n companyUuid: companyId,\n requestBody: { requirementSets },\n state,\n },\n })\n onEvent(componentEvents.COMPANY_STATE_TAX_UPDATED)\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n return (\n <section className={className}>\n <FormProvider {...methods} control={control}>\n <HtmlForm onSubmit={methods.handleSubmit(onSubmit)}>\n <StateTaxesFormProvider\n value={{ stateTaxRequirements, isPending: isPendingUpdate, state, handleCancel }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </StateTaxesFormProvider>\n </HtmlForm>\n </FormProvider>\n </section>\n )\n}\n"],"names":["StateTaxesForm","props","jsx","BaseComponent","Root","companyId","state","className","children","useI18n","onEvent","baseSubmitHandler","useBase","t","useTranslation","data","useTaxRequirementsGetSuspense","stateTaxRequirements","updateStateTax","isPendingUpdate","useTaxRequirementsUpdateStateMutation","dynamicSchema","defaultValues","useMemo","schemaShape","values","requirementSet","requirementSetKey","requirementShape","requirementValues","requirement","requirementKey","isPercentField","fieldSchema","z","validation","oneOfValues","val","control","methods","useForm","zodResolver","onSubmit","formData","payload","requirementSets","rs","payloadSet","reqKey","value","componentEvents","handleCancel","FormProvider","HtmlForm","StateTaxesFormProvider","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,SAASA,GAAeC,GAAqD;AAClF,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,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CAAK,OAAO;AAAA,YACjE,KAAKD;AAAA,YACL,OAAO,OAAOC,CAAK;AAAA,UAAA,EACnB;AAAA,QAAA;AAAA,MAEN,CAAC;AACH,YAAM/B,EAAe;AAAA,QACnB,SAAS;AAAA,UACP,aAAab;AAAA,UACb,aAAa,EAAE,iBAAAwC,EAAA;AAAA,UACf,OAAAvC;AAAA,QAAA;AAAA,MACF,CACD,GACDI,EAAQwC,EAAgB,yBAAyB;AAAA,IACnD,CAAC;AAAA,EACH,GAEMC,IAAe,MAAM;AACzB,IAAAzC,EAAQwC,EAAgB,MAAM;AAAA,EAChC;AAEA,SACE,gBAAAhD,EAAC,WAAA,EAAQ,WAAAK,GACP,UAAA,gBAAAL,EAACkD,KAAc,GAAGb,GAAS,SAAAD,GACzB,UAAA,gBAAApC,EAACmD,GAAA,EAAS,UAAUd,EAAQ,aAAaG,CAAQ,GAC/C,UAAA,gBAAAxC;AAAA,IAACoD;AAAA,IAAA;AAAA,MACC,OAAO,EAAE,sBAAArC,GAAsB,WAAWE,GAAiB,OAAAb,GAAO,cAAA6C,EAAA;AAAA,MAElE,UAAA,gBAAAjD,EAACqD,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAA/C,KAGC,gBAAAgD,EAAAC,GAAA,EACE,UAAA;AAAA,QAAA,gBAAAvD,EAACwD,GAAA,EAAK;AAAA,0BACLC,GAAA,EAAK;AAAA,0BACLC,GAAA,CAAA,CAAQ;AAAA,MAAA,EAAA,CACX,EAAA,CAEJ;AAAA,IAAA;AAAA,EAAA,EACF,CACF,GACF,GACF;AAEJ;"}
1
+ {"version":3,"file":"StateTaxesForm.js","sources":["../../../../../src/components/Company/StateTaxes/StateTaxesForm/StateTaxesForm.tsx"],"sourcesContent":["import { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useTaxRequirementsUpdateStateMutation } from '@gusto/embedded-api/react-query/taxRequirementsUpdateState'\nimport { useTaxRequirementsGetSuspense } from '@gusto/embedded-api/react-query/taxRequirementsGet'\nimport { z } from 'zod'\nimport { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { Head } from './Head'\nimport { StateTaxesFormProvider } from './context'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useI18n } from '@/i18n/I18n'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { Form as HtmlForm } from '@/components/Common/Form'\nimport { componentEvents } from '@/shared/constants'\nimport { useBase } from '@/components/Base'\n\ninterface StateTaxesFormProps extends CommonComponentInterface {\n companyId: string\n state: string\n}\n\nexport function StateTaxesForm(props: StateTaxesFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ companyId, state, className, children }: StateTaxesFormProps) {\n useI18n('Company.StateTaxes')\n const { onEvent, baseSubmitHandler } = useBase()\n const { t } = useTranslation('Company.StateTaxes', { keyPrefix: 'form' })\n const { data } = useTaxRequirementsGetSuspense({ companyUuid: companyId, state })\n const stateTaxRequirements = data.taxRequirementsState!\n\n const { mutateAsync: updateStateTax, isPending: isPendingUpdate } =\n useTaxRequirementsUpdateStateMutation()\n\n // Schema and default value generation\n const { dynamicSchema, defaultValues } = useMemo(() => {\n const schemaShape: Record<string, z.ZodObject<Record<string, z.ZodType>>> = {}\n const values: Partial<Record<string, Record<string, string | boolean | number | undefined>>> =\n {}\n\n //Looping through each requirement set\n stateTaxRequirements.requirementSets?.forEach(requirementSet => {\n if (!requirementSet.key) return\n\n const requirementSetKey = requirementSet.key\n const requirementShape: Record<string, z.ZodType> = {}\n const requirementValues: Record<string, string | boolean | number | undefined> = {}\n\n requirementSet.requirements?.forEach(requirement => {\n if (!requirement.key) return\n\n const requirementKey = requirement.key\n\n const isPercentField =\n requirement.metadata?.type === 'tax_rate' || requirement.metadata?.type === 'percent'\n\n if (requirement.metadata?.type === 'radio') {\n requirementValues[requirementKey] = requirement.value ?? undefined\n } else {\n requirementValues[requirementKey] = requirement.value ? String(requirement.value) : ''\n }\n\n let fieldSchema: z.ZodType = z.string().optional()\n\n const validation = requirement.metadata?.validation\n\n if (validation) {\n if (isPercentField && validation.type === 'one_of') {\n const oneOfValues = validation.rates as string[]\n fieldSchema = z\n .string()\n .optional()\n .refine(val => !val || oneOfValues.includes(val), {\n message: t('validations.oneOf', { values: oneOfValues.join(', ') }),\n })\n }\n }\n\n if (requirement.metadata?.type === 'radio') {\n fieldSchema = z.boolean().optional()\n }\n requirementShape[requirementKey] = fieldSchema\n // --- End Schema Logic ---\n })\n\n if (Object.keys(requirementShape).length > 0) {\n schemaShape[requirementSetKey] = z.object(requirementShape)\n values[requirementSetKey] = requirementValues\n }\n })\n\n const finalSchema = z.object(schemaShape)\n\n // Return both the schema and the default values\n return {\n dynamicSchema: finalSchema,\n defaultValues: values as z.infer<typeof finalSchema>,\n }\n }, [stateTaxRequirements, t])\n\n // Infer the type from the schema\n type InferredFormInputs = z.infer<typeof dynamicSchema>\n\n const { control, ...methods } = useForm<InferredFormInputs>({\n resolver: zodResolver(dynamicSchema),\n defaultValues,\n })\n\n const onSubmit = async (formData: InferredFormInputs) => {\n await baseSubmitHandler(formData, async payload => {\n const requirementSets = stateTaxRequirements.requirementSets\n ?.filter(rs => rs.key && payload[rs.key])\n .map(requirementSet => {\n const requirementSetKey = requirementSet.key as string\n const payloadSet = payload[requirementSetKey] as Record<string, unknown>\n\n return {\n state: requirementSet.state,\n key: requirementSetKey,\n effectiveFrom: requirementSet.effectiveFrom,\n requirements: Object.entries(payloadSet).map(([reqKey, value]) => ({\n key: reqKey,\n value: String(value),\n })),\n }\n })\n await updateStateTax({\n request: {\n companyUuid: companyId,\n requestBody: { requirementSets },\n state,\n },\n })\n onEvent(componentEvents.COMPANY_STATE_TAX_UPDATED)\n })\n }\n\n const handleCancel = () => {\n onEvent(componentEvents.CANCEL)\n }\n\n return (\n <section className={className}>\n <FormProvider {...methods} control={control}>\n <HtmlForm onSubmit={methods.handleSubmit(onSubmit)}>\n <StateTaxesFormProvider\n value={{ stateTaxRequirements, isPending: isPendingUpdate, state, handleCancel }}\n >\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </StateTaxesFormProvider>\n </HtmlForm>\n </FormProvider>\n </section>\n )\n}\n"],"names":["StateTaxesForm","props","jsx","BaseComponent","Root","companyId","state","className","children","useI18n","onEvent","baseSubmitHandler","useBase","t","useTranslation","data","useTaxRequirementsGetSuspense","stateTaxRequirements","updateStateTax","isPendingUpdate","useTaxRequirementsUpdateStateMutation","dynamicSchema","defaultValues","useMemo","schemaShape","values","requirementSet","requirementSetKey","requirementShape","requirementValues","requirement","requirementKey","isPercentField","fieldSchema","z","validation","oneOfValues","val","control","methods","useForm","zodResolver","onSubmit","formData","payload","requirementSets","rs","payloadSet","reqKey","value","componentEvents","handleCancel","FormProvider","HtmlForm","StateTaxesFormProvider","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":";;;;;;;;;;;;;;;;;;AAwBO,SAASA,GAAeC,GAAqD;AAClF,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAAA,EAAM,SAAA,CAAS,EAAA,CACnC;AAEJ;AAEA,SAASG,EAAK,EAAE,WAAAC,GAAW,OAAAC,GAAO,WAAAC,GAAW,UAAAC,KAAiC;AAC5E,EAAAC,EAAQ,oBAAoB;AAC5B,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAA,IAAsBC,EAAA,GACjC,EAAE,GAAAC,MAAMC,EAAe,sBAAsB,EAAE,WAAW,QAAQ,GAClE,EAAE,MAAAC,MAASC,EAA8B,EAAE,aAAaX,GAAW,OAAAC,GAAO,GAC1EW,IAAuBF,EAAK,sBAE5B,EAAE,aAAaG,GAAgB,W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AAO,EAAE,sBAAArC,GAAsB,WAAWE,GAAiB,OAAAb,GAAO,cAAA6C,EAAA;AAAA,MAElE,UAAA,gBAAAjD,EAACqD,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAA/C,KAGC,gBAAAgD,EAAAC,GAAA,EACE,UAAA;AAAA,QAAA,gBAAAvD,EAACwD,GAAA,EAAK;AAAA,0BACLC,GAAA,EAAK;AAAA,0BACLC,GAAA,CAAA,CAAQ;AAAA,MAAA,EAAA,CACX,EAAA,CAEJ;AAAA,IAAA;AAAA,EAAA,EACF,CACF,GACF,GACF;AAEJ;"}
@@ -15,19 +15,7 @@ export declare const AddressFormSchema: z.ZodObject<{
15
15
  city: z.ZodString;
16
16
  state: z.ZodString;
17
17
  zip: z.ZodString;
18
- }, "strip", z.ZodTypeAny, {
19
- street1: string;
20
- city: string;
21
- state: string;
22
- zip: string;
23
- street2?: string | undefined;
24
- }, {
25
- street1: string;
26
- city: string;
27
- state: string;
28
- zip: string;
29
- street2?: string | undefined;
30
- }>;
18
+ }, z.core.$strip>;
31
19
  export type AddressFormValues = z.infer<typeof AddressFormSchema>;
32
20
  declare const useAddress: () => AddressContextType, AddressProvider: import('react').Provider<AddressContextType | null>;
33
21
  export { useAddress, AddressProvider };
@@ -1,9 +1,9 @@
1
1
  import { useContractorsListSuspense as a } from "@gusto/embedded-api/react-query/contractorsList";
2
- import { usePagination as c } from "../../../hooks/usePagination/usePagination.js";
2
+ import { usePagination as i } from "../../../hooks/usePagination/usePagination.js";
3
3
  function u({ companyUuid: t }) {
4
- const { currentPage: r, itemsPerPage: e, getPaginationProps: o } = c(), {
5
- data: { httpMeta: s, contractorList: n }
6
- } = a({ companyUuid: t, page: r, per: e });
4
+ const { currentPage: e, itemsPerPage: r, getPaginationProps: o } = i(), {
5
+ data: { httpMeta: s, contractors: n }
6
+ } = a({ companyUuid: t, page: e, per: r });
7
7
  return {
8
8
  contractors: n,
9
9
  ...o(s.response.headers)
@@ -1 +1 @@
1
- {"version":3,"file":"useContractorList.js","sources":["../../../../src/components/Contractor/ContractorList/useContractorList.ts"],"sourcesContent":["import { type Contractor } from '@gusto/embedded-api/models/components/contractor'\nimport { useContractorsListSuspense } from '@gusto/embedded-api/react-query/contractorsList'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\n\nexport interface ContractorListContext {\n contractors: Contractor[]\n}\n\nexport interface useContractorsArgs {\n companyUuid: string\n}\n\nexport function useContractors({ companyUuid }: useContractorsArgs) {\n const { currentPage, itemsPerPage, getPaginationProps } = usePagination()\n\n const {\n data: { httpMeta, contractorList: contractors },\n } = useContractorsListSuspense({ companyUuid, page: currentPage, per: itemsPerPage })\n\n return {\n contractors: contractors!,\n ...getPaginationProps(httpMeta.response.headers),\n }\n}\n"],"names":["useContractors","companyUuid","currentPage","itemsPerPage","getPaginationProps","usePagination","httpMeta","contractors","useContractorsListSuspense"],"mappings":";;AAYO,SAASA,EAAe,EAAE,aAAAC,KAAmC;AAClE,QAAM,EAAE,aAAAC,GAAa,cAAAC,GAAc,oBAAAC,EAAA,IAAuBC,EAAA,GAEpD;AAAA,IACJ,MAAM,EAAE,UAAAC,GAAU,gBAAgBC,EAAA;AAAA,EAAY,IAC5CC,EAA2B,EAAE,aAAAP,GAAa,MAAMC,GAAa,KAAKC,GAAc;AAEpF,SAAO;AAAA,IACL,aAAAI;AAAA,IACA,GAAGH,EAAmBE,EAAS,SAAS,OAAO;AAAA,EAAA;AAEnD;"}
1
+ {"version":3,"file":"useContractorList.js","sources":["../../../../src/components/Contractor/ContractorList/useContractorList.ts"],"sourcesContent":["import { type Contractor } from '@gusto/embedded-api/models/components/contractor'\nimport { useContractorsListSuspense } from '@gusto/embedded-api/react-query/contractorsList'\nimport { usePagination } from '@/hooks/usePagination/usePagination'\n\nexport interface ContractorListContext {\n contractors: Contractor[]\n}\n\nexport interface useContractorsArgs {\n companyUuid: string\n}\n\nexport function useContractors({ companyUuid }: useContractorsArgs) {\n const { currentPage, itemsPerPage, getPaginationProps } = usePagination()\n\n const {\n data: { httpMeta, contractors },\n } = useContractorsListSuspense({ companyUuid, page: currentPage, per: itemsPerPage })\n\n return {\n contractors: contractors!,\n ...getPaginationProps(httpMeta.response.headers),\n }\n}\n"],"names":["useContractors","companyUuid","currentPage","itemsPerPage","getPaginationProps","usePagination","httpMeta","contractors","useContractorsListSuspense"],"mappings":";;AAYO,SAASA,EAAe,EAAE,aAAAC,KAAmC;AAClE,QAAM,EAAE,aAAAC,GAAa,cAAAC,GAAc,oBAAAC,EAAA,IAAuBC,EAAA,GAEpD;AAAA,IACJ,MAAM,EAAE,UAAAC,GAAU,aAAAC,EAAA;AAAA,EAAY,IAC5BC,EAA2B,EAAE,aAAAP,GAAa,MAAMC,GAAa,KAAKC,GAAc;AAEpF,SAAO;AAAA,IACL,aAAAI;AAAA,IACA,GAAGH,EAAmBE,EAAS,SAAS,OAAO;AAAA,EAAA;AAEnD;"}
@@ -1,21 +1,11 @@
1
1
  import { default as z } from 'zod';
2
2
  import { NewHireReportProps } from './types';
3
- declare const NewHireReportSchema: z.ZodUnion<[z.ZodObject<{
4
- fileNewHireReport: z.ZodEffects<z.ZodBoolean, boolean, boolean>;
3
+ declare const NewHireReportSchema: z.ZodUnion<readonly [z.ZodObject<{
4
+ fileNewHireReport: z.ZodBoolean;
5
5
  state: z.ZodString;
6
- }, "strip", z.ZodTypeAny, {
7
- state: string;
8
- fileNewHireReport: boolean;
9
- }, {
10
- state: string;
11
- fileNewHireReport: boolean;
12
- }>, z.ZodObject<{
13
- fileNewHireReport: z.ZodEffects<z.ZodBoolean, boolean, boolean>;
14
- }, "strip", z.ZodTypeAny, {
15
- fileNewHireReport: boolean;
16
- }, {
17
- fileNewHireReport: boolean;
18
- }>]>;
6
+ }, z.core.$strip>, z.ZodObject<{
7
+ fileNewHireReport: z.ZodBoolean;
8
+ }, z.core.$strip>]>;
19
9
  export type NewHireReportSchemaInputs = z.input<typeof NewHireReportSchema>;
20
10
  export declare function NewHireReport(props: NewHireReportProps): import("react/jsx-runtime").JSX.Element;
21
11
  export {};
@@ -1,4 +1,4 @@
1
- import { jsx as e, jsxs as c } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as m } from "react/jsx-runtime";
2
2
  import { useTranslation as S } from "react-i18next";
3
3
  import { useForm as E, useWatch as T, FormProvider as y } from "react-hook-form";
4
4
  import { useMemo as O } from "react";
@@ -10,10 +10,10 @@ import { useComponentDictionary as x, useI18n as g } from "../../../i18n/I18n.js
10
10
  import { BaseComponent as A } from "../../Base/Base.js";
11
11
  import { useBase as B } from "../../Base/useBase.js";
12
12
  import { useComponentContext as P } from "../../../contexts/ComponentAdapter/useComponentContext.js";
13
- import { Form as j } from "../../Common/Form/Form.js";
14
- import { STATES_ABBR as L, componentEvents as p } from "../../../shared/constants.js";
15
- import { ActionsLayout as M } from "../../Common/ActionsLayout/ActionsLayout.js";
16
- import { Flex as U } from "../../Common/Flex/Flex.js";
13
+ import { Form as U } from "../../Common/Form/Form.js";
14
+ import { STATES_ABBR as j, componentEvents as p } from "../../../shared/constants.js";
15
+ import { ActionsLayout as L } from "../../Common/ActionsLayout/ActionsLayout.js";
16
+ import { Flex as M } from "../../Common/Flex/Flex.js";
17
17
  import "classnames";
18
18
  import { RadioGroupField as q } from "../../Common/Fields/RadioGroupField/RadioGroupField.js";
19
19
  import { SelectField as W } from "../../Common/Fields/SelectField/SelectField.js";
@@ -26,43 +26,43 @@ const k = r.union([
26
26
  fileNewHireReport: r.boolean().refine((t) => !t)
27
27
  })
28
28
  ]);
29
- function me(t) {
29
+ function ce(t) {
30
30
  return /* @__PURE__ */ e(A, { ...t, children: /* @__PURE__ */ e(z, { ...t, children: t.children }) });
31
31
  }
32
32
  function z({ contractorId: t, className: u, dictionary: d, selfOnboarding: f = !1 }) {
33
33
  x("Contractor.NewHireReport", d), g("Contractor.NewHireReport");
34
- const { t: o } = S("Contractor.NewHireReport"), { onEvent: m, baseSubmitHandler: R } = B(), s = P(), {
34
+ const { t: o } = S("Contractor.NewHireReport"), { onEvent: c, baseSubmitHandler: R } = B(), a = P(), {
35
35
  data: { contractor: h }
36
- } = D({ contractorUuid: t }), i = h, { mutateAsync: H, isPending: w } = F(), N = O(
36
+ } = D({ contractorUuid: t }), n = h, { mutateAsync: H, isPending: w } = F(), N = O(
37
37
  () => ({
38
- fileNewHireReport: i.fileNewHireReport || !1,
39
- state: i.workState || null
38
+ fileNewHireReport: n.fileNewHireReport || !1,
39
+ state: n.workState || null
40
40
  }),
41
- [i]
42
- ), a = E({
41
+ [n]
42
+ ), s = E({
43
43
  resolver: _(k),
44
44
  defaultValues: N
45
- }), b = T({ control: a.control, name: "fileNewHireReport" }), C = async (n) => {
46
- await R(n, async (l) => {
45
+ }), b = T({ control: s.control, name: "fileNewHireReport" }), C = async (i) => {
46
+ await R(i, async (l) => {
47
47
  const v = await H({
48
48
  request: {
49
49
  contractorUuid: t,
50
- requestBody: {
51
- type: i.type,
50
+ contractorUpdateRequestBody: {
51
+ type: n.type,
52
52
  selfOnboarding: f,
53
53
  fileNewHireReport: l.fileNewHireReport,
54
54
  workState: "state" in l ? l.state : null,
55
- version: i.version
55
+ version: n.version
56
56
  }
57
57
  }
58
58
  });
59
- m(p.CONTRACTOR_NEW_HIRE_REPORT_UPDATED, v), m(p.CONTRACTOR_NEW_HIRE_REPORT_DONE);
59
+ c(p.CONTRACTOR_NEW_HIRE_REPORT_UPDATED, v), c(p.CONTRACTOR_NEW_HIRE_REPORT_DONE);
60
60
  });
61
61
  };
62
- return /* @__PURE__ */ e("section", { className: u, children: /* @__PURE__ */ e(y, { ...a, children: /* @__PURE__ */ e(j, { onSubmit: a.handleSubmit(C), children: /* @__PURE__ */ c(U, { flexDirection: "column", children: [
63
- /* @__PURE__ */ c("header", { children: [
64
- /* @__PURE__ */ e(s.Heading, { as: "h2", children: o("title") }),
65
- /* @__PURE__ */ e(s.Text, { children: o("description") })
62
+ return /* @__PURE__ */ e("section", { className: u, children: /* @__PURE__ */ e(y, { ...s, children: /* @__PURE__ */ e(U, { onSubmit: s.handleSubmit(C), children: /* @__PURE__ */ m(M, { flexDirection: "column", children: [
63
+ /* @__PURE__ */ m("header", { children: [
64
+ /* @__PURE__ */ e(a.Heading, { as: "h2", children: o("title") }),
65
+ /* @__PURE__ */ e(a.Text, { children: o("description") })
66
66
  ] }),
67
67
  /* @__PURE__ */ e(
68
68
  q,
@@ -86,9 +86,9 @@ function z({ contractorId: t, className: u, dictionary: d, selfOnboarding: f = !
86
86
  W,
87
87
  {
88
88
  name: "state",
89
- options: L.map((n) => ({
90
- label: o(`statesHash.${n}`, { ns: "common" }),
91
- value: n
89
+ options: j.map((i) => ({
90
+ label: o(`statesHash.${i}`, { ns: "common" }),
91
+ value: i
92
92
  })),
93
93
  label: o("stateSelectionLabel"),
94
94
  placeholder: "",
@@ -96,8 +96,8 @@ function z({ contractorId: t, className: u, dictionary: d, selfOnboarding: f = !
96
96
  isRequired: !0
97
97
  }
98
98
  ),
99
- /* @__PURE__ */ e(M, { children: /* @__PURE__ */ e(
100
- s.Button,
99
+ /* @__PURE__ */ e(L, { children: /* @__PURE__ */ e(
100
+ a.Button,
101
101
  {
102
102
  type: "submit",
103
103
  variant: "primary",
@@ -108,6 +108,6 @@ function z({ contractorId: t, className: u, dictionary: d, selfOnboarding: f = !
108
108
  ] }) }) }) });
109
109
  }
110
110
  export {
111
- me as NewHireReport
111
+ ce as NewHireReport
112
112
  };
113
113
  //# sourceMappingURL=NewHireReport.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NewHireReport.js","sources":["../../../../src/components/Contractor/NewHireReport/NewHireReport.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm, useWatch } from 'react-hook-form'\nimport { useMemo } from 'react'\nimport z from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useContractorsGetSuspense } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api/react-query/contractorsUpdate'\nimport type { NewHireReportProps } from './types'\nimport { useI18n } from '@/i18n'\nimport { BaseComponent, useBase } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { componentEvents, STATES_ABBR } from '@/shared/constants'\nimport { ActionsLayout } from '@/components/Common/ActionsLayout'\nimport { Flex, RadioGroupField, SelectField } from '@/components/Common'\n\nconst NewHireReportSchema = z.union([\n z.object({\n fileNewHireReport: z.boolean().refine(v => v),\n state: z.string().min(1),\n }),\n z.object({\n fileNewHireReport: z.boolean().refine(v => !v),\n }),\n])\n\nexport type NewHireReportSchemaInputs = z.input<typeof NewHireReportSchema>\n\nexport function NewHireReport(props: NewHireReportProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ contractorId, className, dictionary, selfOnboarding = false }: NewHireReportProps) {\n useComponentDictionary('Contractor.NewHireReport', dictionary)\n useI18n('Contractor.NewHireReport')\n const { t } = useTranslation('Contractor.NewHireReport')\n const { onEvent, baseSubmitHandler } = useBase()\n const Components = useComponentContext()\n\n const {\n data: { contractor },\n } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const contractorDetails = contractor!\n\n const { mutateAsync: updateContractor, isPending: updateContractorPending } =\n useContractorsUpdateMutation()\n\n const defaultValues = useMemo(\n () => ({\n fileNewHireReport: contractorDetails.fileNewHireReport || false,\n state: contractorDetails.workState || null,\n }),\n [contractorDetails],\n )\n\n const formMethods = useForm({\n resolver: zodResolver(NewHireReportSchema),\n defaultValues: defaultValues,\n })\n\n const watchedDoFile = useWatch({ control: formMethods.control, name: 'fileNewHireReport' })\n const onSubmit: SubmitHandler<NewHireReportSchemaInputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const contractorResponse = await updateContractor({\n request: {\n contractorUuid: contractorId,\n requestBody: {\n type: contractorDetails.type,\n selfOnboarding: selfOnboarding,\n fileNewHireReport: payload.fileNewHireReport,\n workState: 'state' in payload ? payload.state : null,\n version: contractorDetails.version!,\n },\n },\n })\n onEvent(componentEvents.CONTRACTOR_NEW_HIRE_REPORT_UPDATED, contractorResponse)\n onEvent(componentEvents.CONTRACTOR_NEW_HIRE_REPORT_DONE)\n })\n }\n\n return (\n <section className={className}>\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Flex flexDirection={'column'}>\n <header>\n <Components.Heading as=\"h2\">{t('title')}</Components.Heading>\n <Components.Text>{t('description')}</Components.Text>\n </header>\n <RadioGroupField\n name=\"fileNewHireReport\"\n label={t('doFileLegend')}\n shouldVisuallyHideLabel\n options={[\n {\n value: true,\n label: t('yesOption'),\n },\n {\n value: false,\n label: t('noOption'),\n },\n ]}\n />\n {watchedDoFile && (\n <SelectField\n name=\"state\"\n options={STATES_ABBR.map((stateAbbr: (typeof STATES_ABBR)[number]) => ({\n label: t(`statesHash.${stateAbbr}`, { ns: 'common' }),\n value: stateAbbr,\n }))}\n label={t('stateSelectionLabel')}\n placeholder={''}\n errorMessage={t('validations.state')}\n isRequired\n />\n )}\n <ActionsLayout>\n <Components.Button\n type=\"submit\"\n variant=\"primary\"\n isDisabled={updateContractorPending}\n >\n {t('submitCta')}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n </Form>\n </FormProvider>\n </section>\n )\n}\n"],"names":["NewHireReportSchema","z","v","NewHireReport","props","jsx","BaseComponent","Root","contractorId","className","dictionary","selfOnboarding","useComponentDictionary","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","Components","useComponentContext","contractor","useContractorsGetSuspense","contractorDetails","updateContractor","updateContractorPending","useContractorsUpdateMutation","defaultValues","useMemo","formMethods","useForm","zodResolver","watchedDoFile","useWatch","onSubmit","data","payload","contractorResponse","componentEvents","FormProvider","Form","jsxs","Flex","RadioGroupField","SelectField","STATES_ABBR","stateAbbr","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;;;;AA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C,MAAK;AAAA,QACL,SAASC,EAAY,IAAI,CAACC,OAA6C;AAAA,UACrE,OAAOhC,EAAE,cAAcgC,CAAS,IAAI,EAAE,IAAI,UAAU;AAAA,UACpD,OAAOA;AAAA,QAAA,EACP;AAAA,QACF,OAAOhC,EAAE,qBAAqB;AAAA,QAC9B,aAAa;AAAA,QACb,cAAcA,EAAE,mBAAmB;AAAA,QACnC,YAAU;AAAA,MAAA;AAAA,IAAA;AAAA,sBAGbiC,GAAA,EACC,UAAA,gBAAA1C;AAAA,MAACc,EAAW;AAAA,MAAX;AAAA,QACC,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,YAAYM;AAAA,QAEX,YAAE,WAAW;AAAA,MAAA;AAAA,IAAA,EAChB,CACF;AAAA,EAAA,GACF,EAAA,CACF,GACF,GACF;AAEJ;"}
1
+ {"version":3,"file":"NewHireReport.js","sources":["../../../../src/components/Contractor/NewHireReport/NewHireReport.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm, useWatch } from 'react-hook-form'\nimport { useMemo } from 'react'\nimport z from 'zod'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useContractorsGetSuspense } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api/react-query/contractorsUpdate'\nimport type { NewHireReportProps } from './types'\nimport { useI18n } from '@/i18n'\nimport { BaseComponent, useBase } from '@/components/Base'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentDictionary } from '@/i18n/I18n'\nimport { componentEvents, STATES_ABBR } from '@/shared/constants'\nimport { ActionsLayout } from '@/components/Common/ActionsLayout'\nimport { Flex, RadioGroupField, SelectField } from '@/components/Common'\n\nconst NewHireReportSchema = z.union([\n z.object({\n fileNewHireReport: z.boolean().refine(v => v),\n state: z.string().min(1),\n }),\n z.object({\n fileNewHireReport: z.boolean().refine(v => !v),\n }),\n])\n\nexport type NewHireReportSchemaInputs = z.input<typeof NewHireReportSchema>\n\nexport function NewHireReport(props: NewHireReportProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ contractorId, className, dictionary, selfOnboarding = false }: NewHireReportProps) {\n useComponentDictionary('Contractor.NewHireReport', dictionary)\n useI18n('Contractor.NewHireReport')\n const { t } = useTranslation('Contractor.NewHireReport')\n const { onEvent, baseSubmitHandler } = useBase()\n const Components = useComponentContext()\n\n const {\n data: { contractor },\n } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const contractorDetails = contractor!\n\n const { mutateAsync: updateContractor, isPending: updateContractorPending } =\n useContractorsUpdateMutation()\n\n const defaultValues = useMemo(\n () => ({\n fileNewHireReport: contractorDetails.fileNewHireReport || false,\n state: contractorDetails.workState || null,\n }),\n [contractorDetails],\n )\n\n const formMethods = useForm({\n resolver: zodResolver(NewHireReportSchema),\n defaultValues: defaultValues,\n })\n\n const watchedDoFile = useWatch({ control: formMethods.control, name: 'fileNewHireReport' })\n const onSubmit: SubmitHandler<NewHireReportSchemaInputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const contractorResponse = await updateContractor({\n request: {\n contractorUuid: contractorId,\n contractorUpdateRequestBody: {\n type: contractorDetails.type,\n selfOnboarding: selfOnboarding,\n fileNewHireReport: payload.fileNewHireReport,\n workState: 'state' in payload ? payload.state : null,\n version: contractorDetails.version!,\n },\n },\n })\n onEvent(componentEvents.CONTRACTOR_NEW_HIRE_REPORT_UPDATED, contractorResponse)\n onEvent(componentEvents.CONTRACTOR_NEW_HIRE_REPORT_DONE)\n })\n }\n\n return (\n <section className={className}>\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Flex flexDirection={'column'}>\n <header>\n <Components.Heading as=\"h2\">{t('title')}</Components.Heading>\n <Components.Text>{t('description')}</Components.Text>\n </header>\n <RadioGroupField\n name=\"fileNewHireReport\"\n label={t('doFileLegend')}\n shouldVisuallyHideLabel\n options={[\n {\n value: true,\n label: t('yesOption'),\n },\n {\n value: false,\n label: t('noOption'),\n },\n ]}\n />\n {watchedDoFile && (\n <SelectField\n name=\"state\"\n options={STATES_ABBR.map((stateAbbr: (typeof STATES_ABBR)[number]) => ({\n label: t(`statesHash.${stateAbbr}`, { ns: 'common' }),\n value: stateAbbr,\n }))}\n label={t('stateSelectionLabel')}\n placeholder={''}\n errorMessage={t('validations.state')}\n isRequired\n />\n )}\n <ActionsLayout>\n <Components.Button\n type=\"submit\"\n variant=\"primary\"\n isDisabled={updateContractorPending}\n >\n {t('submitCta')}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n </Form>\n </FormProvider>\n </section>\n )\n}\n"],"names":["NewHireReportSchema","z","v","NewHireReport","props","jsx","BaseComponent","Root","contractorId","className","dictionary","selfOnboarding","useComponentDictionary","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","Components","useComponentContext","contractor","useContractorsGetSuspense","contractorDetails","updateContractor","updateContractorPending","useContractorsUpdateMutation","defaultValues","useMemo","formMethods","useForm","zodResolver","watchedDoFile","useWatch","onSubmit","data","payload","contractorResponse","componentEvents","FormProvider","Form","jsxs","Flex","RadioGroupField","SelectField","STATES_ABBR","stateAbbr","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;;;;AAkBA,MAAMA,IAAsBC,EAAE,MAAM;AAAA,EAClCA,EAAE,OAAO;AAAA,IACP,mBAAmBA,EAAE,QAAA,EAAU,OAAO,OAAKC,CAAC;AAAA,IAC5C,OAAOD,EAAE,OAAA,EAAS,IAAI,CAAC;AAAA,EAAA,CACxB;AAAA,EACDA,EAAE,OAAO;AAAA,IACP,mBAAmBA,EAAE,QAAA,EAAU,OAAO,CAAAC,MAAK,CAACA,CAAC;AAAA,EAAA,CAC9C;AACH,CAAC;AAIM,SAASC,GAAcC,GAA2B;AACvD,SACE,gBAAAC,EAACC,GAAA,EAAe,GAAG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A,QACL,SAAQ;AAAA,QACR,YAAYM;AAAA,QAEX,YAAE,WAAW;AAAA,MAAA;AAAA,IAAA,EAChB,CACF;AAAA,EAAA,GACF,EAAA,CACF,GACF,GACF;AAEJ;"}
@@ -1,30 +1,17 @@
1
1
  import { default as z } from 'zod';
2
2
  import { PaymentMethodProps } from './types';
3
- declare const PaymentMethodSchema: z.ZodDiscriminatedUnion<"type", [z.ZodObject<{
3
+ declare const PaymentMethodSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
4
4
  type: z.ZodLiteral<"Direct Deposit">;
5
5
  name: z.ZodString;
6
6
  routingNumber: z.ZodString;
7
7
  accountNumber: z.ZodAny;
8
- accountType: z.ZodEnum<["Checking", "Savings"]>;
9
- }, "strip", z.ZodTypeAny, {
10
- routingNumber: string;
11
- name: string;
12
- accountType: "Checking" | "Savings";
13
- type: "Direct Deposit";
14
- accountNumber?: any;
15
- }, {
16
- routingNumber: string;
17
- name: string;
18
- accountType: "Checking" | "Savings";
19
- type: "Direct Deposit";
20
- accountNumber?: any;
21
- }>, z.ZodObject<{
8
+ accountType: z.ZodEnum<{
9
+ Checking: "Checking";
10
+ Savings: "Savings";
11
+ }>;
12
+ }, z.core.$strip>, z.ZodObject<{
22
13
  type: z.ZodLiteral<"Check">;
23
- }, "strip", z.ZodTypeAny, {
24
- type: "Check";
25
- }, {
26
- type: "Check";
27
- }>]>;
14
+ }, z.core.$strip>], "type">;
28
15
  export type PaymentMethodSchemaInputs = z.input<typeof PaymentMethodSchema>;
29
16
  export type PaymentMethodSchemaOutputs = z.output<typeof PaymentMethodSchema>;
30
17
  export declare function PaymentMethod(props: PaymentMethodProps): import("react/jsx-runtime").JSX.Element;
@@ -1,11 +1,10 @@
1
1
  import { z } from 'zod';
2
2
  export declare const PaymentTypeSchema: z.ZodObject<{
3
- type: z.ZodEnum<["Check", "Direct Deposit"]>;
4
- }, "strip", z.ZodTypeAny, {
5
- type: "Check" | "Direct Deposit";
6
- }, {
7
- type: "Check" | "Direct Deposit";
8
- }>;
3
+ type: z.ZodEnum<{
4
+ Check: "Check";
5
+ "Direct Deposit": "Direct Deposit";
6
+ }>;
7
+ }, z.core.$strip>;
9
8
  export type PaymentTypeInputs = z.input<typeof PaymentTypeSchema>;
10
9
  export type PaymentTypePayload = z.output<typeof PaymentTypeSchema>;
11
10
  export declare function PaymentTypeForm(): import("react/jsx-runtime").JSX.Element;