@gusto/embedded-react-sdk 0.45.0 → 0.46.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 (113) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js +20 -4
  3. package/dist/components/Company/AssignSignatory/CreateSignatory/useCreateSignatory.js.map +1 -1
  4. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js +20 -4
  5. package/dist/components/Company/AssignSignatory/InviteSignatory/useInviteSignatory.js.map +1 -1
  6. package/dist/components/Company/AssignSignatory/useAssignSignatory.js +22 -6
  7. package/dist/components/Company/AssignSignatory/useAssignSignatory.js.map +1 -1
  8. package/dist/components/Company/BankAccount/BankAccountForm/context.js +20 -4
  9. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  10. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js +20 -4
  11. package/dist/components/Company/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  12. package/dist/components/Company/DocumentSigner/shared/useSignCompanyForm/fields.js +4 -4
  13. package/dist/components/Company/FederalTaxes/useFederalTaxes.js +28 -12
  14. package/dist/components/Company/FederalTaxes/useFederalTaxes.js.map +1 -1
  15. package/dist/components/Company/Industry/Context.js +23 -7
  16. package/dist/components/Company/Industry/Context.js.map +1 -1
  17. package/dist/components/Company/Locations/LocationForm/useLocationForm.js +20 -4
  18. package/dist/components/Company/Locations/LocationForm/useLocationForm.js.map +1 -1
  19. package/dist/components/Company/Locations/LocationsList/useLocationsList.js +20 -4
  20. package/dist/components/Company/Locations/LocationsList/useLocationsList.js.map +1 -1
  21. package/dist/components/Company/OnboardingOverview/context.js +20 -4
  22. package/dist/components/Company/OnboardingOverview/context.js.map +1 -1
  23. package/dist/components/Company/PaySchedule/shared/usePayScheduleForm/fields.js +5 -5
  24. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js +20 -4
  25. package/dist/components/Company/StateTaxes/StateTaxesForm/context.js.map +1 -1
  26. package/dist/components/Company/StateTaxes/StateTaxesList/context.js +20 -4
  27. package/dist/components/Company/StateTaxes/StateTaxesList/context.js.map +1 -1
  28. package/dist/components/Contractor/Address/useAddress.js +22 -6
  29. package/dist/components/Contractor/Address/useAddress.js.map +1 -1
  30. package/dist/components/Contractor/Profile/useContractorProfile.js +52 -42
  31. package/dist/components/Contractor/Profile/useContractorProfile.js.map +1 -1
  32. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.d.ts +11 -0
  33. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js +230 -0
  34. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.js.map +1 -0
  35. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.module.scss.js +8 -0
  36. package/dist/components/Employee/Compensation/management/EditCompensation/EditCompensation.module.scss.js.map +1 -0
  37. package/dist/components/Employee/Compensation/management/EditCompensation/index.d.ts +3 -0
  38. package/dist/components/Employee/Compensation/management/index.d.ts +3 -0
  39. package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js +6 -6
  40. package/dist/components/Employee/Compensation/onboarding/EditCompensation/EditCompensation.js.map +1 -1
  41. package/dist/components/Employee/Compensation/shared/useCompensationForm/fields.js +4 -4
  42. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js +114 -111
  43. package/dist/components/Employee/Compensation/shared/useCompensationForm/useCompensationForm.js.map +1 -1
  44. package/dist/components/Employee/Compensation/shared/useJobForm/fields.js +6 -6
  45. package/dist/components/Employee/Compensation/shared/useJobForm/jobSchema.d.ts +8 -0
  46. package/dist/components/Employee/Compensation/shared/useJobForm/jobSchema.js +22 -17
  47. package/dist/components/Employee/Compensation/shared/useJobForm/jobSchema.js.map +1 -1
  48. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.d.ts +12 -2
  49. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js +115 -110
  50. package/dist/components/Employee/Compensation/shared/useJobForm/useJobForm.js.map +1 -1
  51. package/dist/components/Employee/Dashboard/BasicDetailsView.d.ts +8 -3
  52. package/dist/components/Employee/Dashboard/BasicDetailsView.js +108 -84
  53. package/dist/components/Employee/Dashboard/BasicDetailsView.js.map +1 -1
  54. package/dist/components/Employee/Dashboard/Dashboard.d.ts +2 -0
  55. package/dist/components/Employee/Dashboard/Dashboard.js +64 -58
  56. package/dist/components/Employee/Dashboard/Dashboard.js.map +1 -1
  57. package/dist/components/Employee/Dashboard/DashboardComponents.d.ts +5 -1
  58. package/dist/components/Employee/Dashboard/DashboardComponents.js +82 -65
  59. package/dist/components/Employee/Dashboard/DashboardComponents.js.map +1 -1
  60. package/dist/components/Employee/Dashboard/DocumentsView.js +18 -11
  61. package/dist/components/Employee/Dashboard/DocumentsView.js.map +1 -1
  62. package/dist/components/Employee/Dashboard/JobAndPayView.js +358 -338
  63. package/dist/components/Employee/Dashboard/JobAndPayView.js.map +1 -1
  64. package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js +8 -0
  65. package/dist/components/Employee/Dashboard/JobAndPayView.module.scss.js.map +1 -0
  66. package/dist/components/Employee/Dashboard/TaxesView.d.ts +7 -2
  67. package/dist/components/Employee/Dashboard/TaxesView.js +68 -54
  68. package/dist/components/Employee/Dashboard/TaxesView.js.map +1 -1
  69. package/dist/components/Employee/Dashboard/dashboardStateMachine.js +16 -5
  70. package/dist/components/Employee/Dashboard/dashboardStateMachine.js.map +1 -1
  71. package/dist/components/Employee/Dashboard/hooks/useEmployeeBasicDetails.d.ts +12 -5
  72. package/dist/components/Employee/Dashboard/hooks/useEmployeeBasicDetails.js +21 -21
  73. package/dist/components/Employee/Dashboard/hooks/useEmployeeBasicDetails.js.map +1 -1
  74. package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.d.ts +13 -3
  75. package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js +55 -56
  76. package/dist/components/Employee/Dashboard/hooks/useEmployeeCompensation.js.map +1 -1
  77. package/dist/components/Employee/Dashboard/hooks/useEmployeeForms.d.ts +10 -4
  78. package/dist/components/Employee/Dashboard/hooks/useEmployeeForms.js +10 -12
  79. package/dist/components/Employee/Dashboard/hooks/useEmployeeForms.js.map +1 -1
  80. package/dist/components/Employee/Dashboard/hooks/useEmployeeTaxes.d.ts +10 -3
  81. package/dist/components/Employee/Dashboard/hooks/useEmployeeTaxes.js +19 -14
  82. package/dist/components/Employee/Dashboard/hooks/useEmployeeTaxes.js.map +1 -1
  83. package/dist/components/Employee/Deductions/shared/useChildSupportGarnishmentForm/fields.js +8 -8
  84. package/dist/components/Employee/Deductions/shared/useDeductionForm/fields.js +4 -4
  85. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js +20 -4
  86. package/dist/components/Employee/Documents/onboarding/DocumentSigner/DocumentList/useDocumentList.js.map +1 -1
  87. package/dist/components/Employee/Documents/shared/useSignEmployeeForm/fields.js +1 -1
  88. package/dist/components/Employee/FederalTaxes/shared/useFederalTaxesForm/fields.js +4 -4
  89. package/dist/components/Employee/PaymentMethod/shared/useBankForm/fields.js +1 -1
  90. package/dist/components/Employee/PaymentMethod/shared/useSplitPaymentsForm/splitFieldFactory.js +4 -4
  91. package/dist/components/Employee/Profile/shared/useEmployeeDetailsForm/fields.js +8 -8
  92. package/dist/components/Employee/Profile/shared/useHomeAddressForm/fields.js +5 -5
  93. package/dist/components/Employee/Profile/shared/useWorkAddressForm/fields.js +4 -4
  94. package/dist/components/Employee/StateTaxes/shared/useEmployeeStateTaxesForm/fieldComponents.js +8 -8
  95. package/dist/components/Employee/Taxes/useTaxes.js +20 -4
  96. package/dist/components/Employee/Taxes/useTaxes.js.map +1 -1
  97. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js +34 -26
  98. package/dist/components/Payroll/GrossUpModal/GrossUpModal.js.map +1 -1
  99. package/dist/components/Payroll/usePreparedPayrollData.js +36 -22
  100. package/dist/components/Payroll/usePreparedPayrollData.js.map +1 -1
  101. package/dist/components/TimeOff/PolicySettings/PolicySettingsPresentation.js +52 -40
  102. package/dist/components/TimeOff/PolicySettings/PolicySettingsPresentation.js.map +1 -1
  103. package/dist/i18n/en/Employee.Compensation.json.js +48 -44
  104. package/dist/i18n/en/Employee.Compensation.json.js.map +1 -1
  105. package/dist/i18n/en/Employee.Dashboard.json.js +1 -1
  106. package/dist/i18n/en/Employee.DocumentManager.json.js +1 -1
  107. package/dist/i18n/en/common.json.d.ts +7 -0
  108. package/dist/shared/constants.d.ts +2 -0
  109. package/dist/shared/constants.js +19 -18
  110. package/dist/shared/constants.js.map +1 -1
  111. package/dist/style.css +1 -1
  112. package/dist/types/i18next.d.ts +22 -2
  113. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useAddress.js","sources":["../../../../src/components/Contractor/Address/useAddress.ts"],"sourcesContent":["import type { Contractor, ContractorType } from '@gusto/embedded-api/models/components/contractor'\nimport type { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress'\nimport { z } from 'zod'\nimport { createCompoundContext } from '@/components/Base'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\n\nexport interface AddressContextType {\n contractor?: Contractor\n contractorType?: ContractorType\n address?: ContractorAddress\n isPending: boolean\n}\n\nexport type AddressDefaultValues = RequireAtLeastOne<\n Pick<ContractorAddress, 'street1' | 'street2' | 'city' | 'state' | 'zip'>\n>\n\nexport const AddressFormSchema = z.object({\n street1: z.string().min(1),\n street2: z.string().optional(),\n city: z.string().min(1),\n state: z.string().min(1),\n zip: z.string().min(1),\n})\n\nexport type AddressFormValues = z.infer<typeof AddressFormSchema>\n\nconst [useAddress, AddressProvider] = createCompoundContext<AddressContextType>(\n 'ContractorAddressContext',\n)\n\nexport { useAddress, AddressProvider }\n"],"names":["AddressFormSchema","z","useAddress","AddressProvider","createCompoundContext"],"mappings":";;;AAiBO,MAAMA,IAAoBC,EAAE,OAAO;AAAA,EACxC,SAASA,EAAE,SAAS,IAAI,CAAC;AAAA,EACzB,SAASA,EAAE,OAAA,EAAS,SAAA;AAAA,EACpB,MAAMA,EAAE,SAAS,IAAI,CAAC;AAAA,EACtB,OAAOA,EAAE,SAAS,IAAI,CAAC;AAAA,EACvB,KAAKA,EAAE,OAAA,EAAS,IAAI,CAAC;AACvB,CAAC,GAIK,CAACC,GAAYC,CAAe,IAAIC;AAAA,EACpC;AACF;"}
1
+ {"version":3,"file":"useAddress.js","sources":["../../../../src/components/Contractor/Address/useAddress.ts"],"sourcesContent":["import type { Contractor, ContractorType } from '@gusto/embedded-api/models/components/contractor'\nimport type { ContractorAddress } from '@gusto/embedded-api/models/components/contractoraddress'\nimport { z } from 'zod'\nimport { createCompoundContext } from '@/components/Base'\nimport type { RequireAtLeastOne } from '@/types/Helpers'\n\nexport interface AddressContextType {\n contractor?: Contractor\n contractorType?: ContractorType\n address?: ContractorAddress\n isPending: boolean\n}\n\nexport type AddressDefaultValues = RequireAtLeastOne<\n Pick<ContractorAddress, 'street1' | 'street2' | 'city' | 'state' | 'zip'>\n>\n\nexport const AddressFormSchema = z.object({\n street1: z.string().min(1),\n street2: z.string().optional(),\n city: z.string().min(1),\n state: z.string().min(1),\n zip: z.string().min(1),\n})\n\nexport type AddressFormValues = z.infer<typeof AddressFormSchema>\n\nconst [useAddress, AddressProvider] = createCompoundContext<AddressContextType>(\n 'ContractorAddressContext',\n)\n\nexport { useAddress, AddressProvider }\n"],"names":["AddressFormSchema","z","useAddress","AddressProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;;;;;;;AAiBO,MAAMA,IAAoBC,EAAE,OAAO;AAAA,EACxC,SAASA,EAAE,SAAS,IAAI,CAAC;AAAA,EACzB,SAASA,EAAE,OAAA,EAAS,SAAA;AAAA,EACpB,MAAMA,EAAE,SAAS,IAAI,CAAC;AAAA,EACtB,OAAOA,EAAE,SAAS,IAAI,CAAC;AAAA,EACvB,KAAKA,EAAE,OAAA,EAAS,IAAI,CAAC;AACvB,CAAC,GAIK,CAACC,GAAYC,CAAe,IAAIC;AAAA,EACpC;AACF;"}
@@ -6,21 +6,31 @@ import { z as s } from "zod";
6
6
  import { useContractorsCreateMutation as k } from "@gusto/embedded-api/react-query/contractorsCreate";
7
7
  import { useContractorsUpdateMutation as K } from "@gusto/embedded-api/react-query/contractorsUpdate";
8
8
  import { ContractorWageType as L, ContractorType as J } from "@gusto/embedded-api/models/components/contractor";
9
+ import "react/jsx-runtime";
10
+ import "react-error-boundary";
11
+ import "@tanstack/react-query";
9
12
  import { useBase as Q } from "../../Base/useBase.js";
10
- import { useI18n as Y } from "../../../i18n/I18n.js";
13
+ import "@gusto/embedded-api/models/errors/apierror";
14
+ import "@gusto/embedded-api/models/errors/gustoembeddederror";
15
+ import "@gusto/embedded-api/models/errors/sdkvalidationerror";
16
+ import "@gusto/embedded-api/models/errors/unprocessableentityerror";
17
+ import { SDKInternalError as Y } from "../../../types/sdkError.js";
11
18
  import { ContractorSelfOnboardingStatuses as x, componentEvents as b, ContractorOnboardingStatus as ee } from "../../../shared/constants.js";
12
- import { SSN_REGEX as oe, NAME_REGEX as T } from "../../../helpers/validations.js";
13
- import { removeNonDigits as se } from "../../../helpers/formattedStrings.js";
14
- import { formatDateToStringDate as ae } from "../../../helpers/dateFormatting.js";
15
- import { normalizeEin as te } from "../../../helpers/federalEin.js";
16
- import { SDKInternalError as ne } from "../../../types/sdkError.js";
17
- const i = L, a = J, ie = s.object({
19
+ import "classnames";
20
+ import "../../../contexts/ComponentAdapter/useComponentContext.js";
21
+ import "../../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
22
+ import { useI18n as oe } from "../../../i18n/I18n.js";
23
+ import { SSN_REGEX as se, NAME_REGEX as T } from "../../../helpers/validations.js";
24
+ import { removeNonDigits as ae } from "../../../helpers/formattedStrings.js";
25
+ import { formatDateToStringDate as te } from "../../../helpers/dateFormatting.js";
26
+ import { normalizeEin as ie } from "../../../helpers/federalEin.js";
27
+ const n = L, a = J, ne = s.object({
18
28
  // Self-onboarding toggle
19
29
  selfOnboarding: s.boolean(),
20
30
  email: s.string().email().optional(),
21
31
  // Required contractor fields
22
32
  contractorType: s.enum([a.Individual, a.Business]),
23
- wageType: s.enum([i.Hourly, i.Fixed]),
33
+ wageType: s.enum([n.Hourly, n.Fixed]),
24
34
  startDate: s.date(),
25
35
  // Individual contractor fields
26
36
  firstName: s.string().min(1).regex(T).optional(),
@@ -32,79 +42,79 @@ const i = L, a = J, ie = s.object({
32
42
  ein: s.string().optional(),
33
43
  // Wage fields
34
44
  hourlyRate: s.number().min(0).optional()
35
- }), re = (t, f, u) => ie.superRefine(
36
- (e, n) => {
37
- if (e.selfOnboarding && !e.email && n.addIssue({
45
+ }), re = (t, f, d) => ne.superRefine(
46
+ (e, i) => {
47
+ if (e.selfOnboarding && !e.email && i.addIssue({
38
48
  code: s.ZodIssueCode.custom,
39
49
  path: ["email"],
40
50
  message: t("validations.email")
41
51
  }), e.contractorType === a.Individual)
42
- if (e.firstName || n.addIssue({
52
+ if (e.firstName || i.addIssue({
43
53
  code: s.ZodIssueCode.custom,
44
54
  path: ["firstName"],
45
55
  message: t("validations.firstName")
46
- }), e.lastName || n.addIssue({
56
+ }), e.lastName || i.addIssue({
47
57
  code: s.ZodIssueCode.custom,
48
58
  path: ["lastName"],
49
59
  message: t("validations.lastName")
50
60
  }), !e.ssn)
51
- !f && !e.selfOnboarding && n.addIssue({
61
+ !f && !e.selfOnboarding && i.addIssue({
52
62
  code: s.ZodIssueCode.custom,
53
63
  path: ["ssn"],
54
64
  message: t("validations.ssn")
55
65
  });
56
66
  else {
57
- const l = se(e.ssn);
58
- oe.test(l) || n.addIssue({
67
+ const l = ae(e.ssn);
68
+ se.test(l) || i.addIssue({
59
69
  code: s.ZodIssueCode.custom,
60
70
  path: ["ssn"],
61
71
  message: t("validations.ssnFormat")
62
72
  });
63
73
  }
64
74
  if (e.contractorType === a.Business)
65
- if (e.businessName || n.addIssue({
75
+ if (e.businessName || i.addIssue({
66
76
  code: s.ZodIssueCode.custom,
67
77
  path: ["businessName"],
68
78
  message: t("validations.businessName")
69
79
  }), !e.ein)
70
- !u && !e.selfOnboarding && n.addIssue({
80
+ !d && !e.selfOnboarding && i.addIssue({
71
81
  code: s.ZodIssueCode.custom,
72
82
  path: ["ein"],
73
83
  message: t("validations.ein")
74
84
  });
75
85
  else {
76
- const l = te(e.ein);
77
- /^\d{2}-\d{7}$/.test(l) || n.addIssue({
86
+ const l = ie(e.ein);
87
+ /^\d{2}-\d{7}$/.test(l) || i.addIssue({
78
88
  code: s.ZodIssueCode.custom,
79
89
  path: ["ein"],
80
90
  message: t("validations.einFormat")
81
91
  });
82
92
  }
83
- e.wageType === i.Hourly && (e.hourlyRate === void 0 || e.hourlyRate < 0) && n.addIssue({
93
+ e.wageType === n.Hourly && (e.hourlyRate === void 0 || e.hourlyRate < 0) && i.addIssue({
84
94
  code: s.ZodIssueCode.custom,
85
95
  path: ["hourlyRate"],
86
96
  message: t("validations.hourlyRate")
87
97
  });
88
98
  }
89
99
  );
90
- function Re({
100
+ function He({
91
101
  companyId: t,
92
102
  contractorId: f,
93
- defaultValues: u,
103
+ defaultValues: d,
94
104
  existingContractor: e
95
105
  }) {
96
- Y("Contractor.Profile");
97
- const { t: n } = X("Contractor.Profile"), { onEvent: l, baseSubmitHandler: g } = Q(), S = re(
98
- n,
106
+ oe("Contractor.Profile");
107
+ const { t: i } = X("Contractor.Profile"), { onEvent: l, baseSubmitHandler: g } = Q(), S = re(
108
+ i,
99
109
  e?.hasSsn ?? !1,
100
110
  e?.hasEin ?? !1
101
111
  ), { mutateAsync: R, isPending: w } = k(), { mutateAsync: O, isPending: D } = K(), I = G(
102
112
  () => ({
103
113
  selfOnboarding: !1,
104
114
  contractorType: a.Business,
105
- wageType: i.Fixed,
115
+ wageType: n.Fixed,
106
116
  startDate: /* @__PURE__ */ new Date(),
107
- ...u,
117
+ ...d,
108
118
  // Override with existing contractor data if available
109
119
  ...e && {
110
120
  selfOnboarding: e.onboardingStatus ? (
@@ -112,7 +122,7 @@ function Re({
112
122
  x.has(e.onboardingStatus)
113
123
  ) : !1,
114
124
  contractorType: e.type || a.Business,
115
- wageType: e.wageType || i.Fixed,
125
+ wageType: e.wageType || n.Fixed,
116
126
  startDate: e.startDate ? new Date(e.startDate) : /* @__PURE__ */ new Date(),
117
127
  firstName: e.firstName || void 0,
118
128
  middleInitial: e.middleInitial || void 0,
@@ -125,23 +135,23 @@ function Re({
125
135
  })() : void 0
126
136
  }
127
137
  }),
128
- [e, u]
129
- ), d = j({
138
+ [e, d]
139
+ ), m = j({
130
140
  resolver: $(S),
131
141
  defaultValues: I,
132
142
  ...e && { values: I },
133
143
  resetOptions: { keepDirtyValues: !0 }
134
- }), { handleSubmit: E, formState: F } = d, m = v({ control: d.control, name: "contractorType" }), P = v({ control: d.control, name: "wageType" }), y = v({
135
- control: d.control,
144
+ }), { handleSubmit: E, formState: F } = m, u = v({ control: m.control, name: "contractorType" }), P = v({ control: m.control, name: "wageType" }), y = v({
145
+ control: m.control,
136
146
  name: "selfOnboarding"
137
147
  }), N = (o) => {
138
148
  const r = {
139
149
  type: o.contractorType,
140
150
  wageType: o.wageType,
141
- startDate: ae(o.startDate) || "",
151
+ startDate: te(o.startDate) || "",
142
152
  selfOnboarding: o.selfOnboarding,
143
153
  email: o.selfOnboarding ? o.email : void 0,
144
- hourlyRate: o.wageType === i.Hourly ? String(o.hourlyRate) : void 0,
154
+ hourlyRate: o.wageType === n.Hourly ? String(o.hourlyRate) : void 0,
145
155
  isActive: !0
146
156
  };
147
157
  return o.contractorType === a.Individual ? {
@@ -167,7 +177,7 @@ function Re({
167
177
  let c = e?.uuid;
168
178
  if (e) {
169
179
  if (!e.version)
170
- throw new ne("Contractor version is required for updates");
180
+ throw new Y("Contractor version is required for updates");
171
181
  const h = e.version, p = C(r, h), V = await O({
172
182
  request: {
173
183
  contractorUuid: c,
@@ -189,16 +199,16 @@ function Re({
189
199
  contractorId: c
190
200
  });
191
201
  });
192
- }, A = !!y, H = m === a.Business, Z = m === a.Individual, _ = P === i.Hourly, U = m === a.Individual && !y, M = m === a.Business && !y, q = [
202
+ }, A = !!y, H = u === a.Business, Z = u === a.Individual, _ = P === n.Hourly, U = u === a.Individual && !y, M = u === a.Business && !y, q = [
193
203
  { label: "Individual", value: a.Individual },
194
204
  { label: "Business", value: a.Business }
195
205
  ], W = [
196
- { label: "Hourly", value: i.Hourly },
197
- { label: "Fixed", value: i.Fixed }
206
+ { label: "Hourly", value: n.Hourly },
207
+ { label: "Fixed", value: n.Fixed }
198
208
  ], z = w || D;
199
209
  return {
200
210
  // Form methods and submission
201
- formMethods: d,
211
+ formMethods: m,
202
212
  handleSubmit: E(B),
203
213
  formState: {
204
214
  ...F,
@@ -220,8 +230,8 @@ function Re({
220
230
  }
221
231
  export {
222
232
  a as ContractorType,
223
- i as WageType,
233
+ n as WageType,
224
234
  re as createContractorProfileValidationSchema,
225
- Re as useContractorProfile
235
+ He as useContractorProfile
226
236
  };
227
237
  //# sourceMappingURL=useContractorProfile.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useContractorProfile.js","sources":["../../../../src/components/Contractor/Profile/useContractorProfile.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { useForm, useWatch } from 'react-hook-form'\nimport { z } from 'zod'\nimport { useContractorsCreateMutation } from '@gusto/embedded-api/react-query/contractorsCreate'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api/react-query/contractorsUpdate'\nimport type { ContractorCreateRequestBody } from '@gusto/embedded-api/models/components/contractorcreaterequestbody'\nimport type { ContractorUpdateRequestBody } from '@gusto/embedded-api/models/components/contractorupdaterequestbody'\nimport {\n ContractorWageType as ApiWageType,\n ContractorType as ApiContractorType,\n type Contractor,\n} from '@gusto/embedded-api/models/components/contractor'\nimport { useBase } from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n ContractorOnboardingStatus,\n ContractorSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport { SSN_REGEX, NAME_REGEX } from '@/helpers/validations'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { normalizeEin } from '@/helpers/federalEin'\nimport { SDKInternalError } from '@/types/sdkError'\n\n// Re-export the API types for convenience\nexport const WageType = ApiWageType\nexport const ContractorType = ApiContractorType\n\n// Form schema definition - exported for use in stories and tests\nconst ContractorProfileSchema = z.object({\n // Self-onboarding toggle\n selfOnboarding: z.boolean(),\n email: z.string().email().optional(),\n\n // Required contractor fields\n contractorType: z.enum([ContractorType.Individual, ContractorType.Business]),\n wageType: z.enum([WageType.Hourly, WageType.Fixed]),\n startDate: z.date(),\n\n // Individual contractor fields\n firstName: z.string().min(1).regex(NAME_REGEX).optional(),\n middleInitial: z.string().optional(),\n lastName: z.string().min(1).regex(NAME_REGEX).optional(),\n ssn: z.string().optional(),\n\n // Business contractor fields\n businessName: z.string().optional(),\n ein: z.string().optional(),\n\n // Wage fields\n hourlyRate: z.number().min(0).optional(),\n})\n\nexport type ContractorProfileFormData = z.infer<typeof ContractorProfileSchema>\n\n// Create validation schema - exported for stories\nexport const createContractorProfileValidationSchema = (\n t: (key: string) => string,\n hasSsn: boolean,\n hasEin: boolean,\n) => {\n return ContractorProfileSchema.superRefine(\n (data: ContractorProfileFormData, ctx: z.RefinementCtx) => {\n // Email validation for contractor invitation\n if (data.selfOnboarding && !data.email) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['email'],\n message: t('validations.email'),\n })\n }\n\n // Individual contractor validations\n if (data.contractorType === ContractorType.Individual) {\n if (!data.firstName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['firstName'],\n message: t('validations.firstName'),\n })\n }\n\n if (!data.lastName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['lastName'],\n message: t('validations.lastName'),\n })\n }\n\n if (!data.ssn) {\n if (!hasSsn && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssn'),\n })\n }\n } else {\n // Validate SSN format\n const cleanSSN = removeNonDigits(data.ssn)\n if (!SSN_REGEX.test(cleanSSN)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssnFormat'),\n })\n }\n }\n }\n\n // Business contractor validations\n if (data.contractorType === ContractorType.Business) {\n if (!data.businessName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['businessName'],\n message: t('validations.businessName'),\n })\n }\n\n if (!data.ein) {\n if (!hasEin && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.ein'),\n })\n }\n } else {\n // Validate EIN format after normalization (XX-XXXXXXX)\n const normalizedEin = normalizeEin(data.ein)\n if (!/^\\d{2}-\\d{7}$/.test(normalizedEin)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.einFormat'),\n })\n }\n }\n }\n\n // Hourly rate validation for hourly contractors\n if (data.wageType === WageType.Hourly) {\n if (data.hourlyRate === undefined || data.hourlyRate < 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['hourlyRate'],\n message: t('validations.hourlyRate'),\n })\n }\n }\n },\n )\n}\n\nexport interface UseContractorProfileProps {\n companyId: string\n contractorId?: string\n defaultValues?: Partial<ContractorProfileFormData>\n existingContractor?: Contractor\n}\n\nexport function useContractorProfile({\n companyId,\n contractorId,\n defaultValues,\n existingContractor,\n}: UseContractorProfileProps) {\n useI18n('Contractor.Profile')\n const { t } = useTranslation('Contractor.Profile')\n const { onEvent, baseSubmitHandler } = useBase()\n\n // Create validation schema with translations\n const validationSchema = createContractorProfileValidationSchema(\n t as (key: string) => string,\n existingContractor?.hasSsn ?? false,\n existingContractor?.hasEin ?? false,\n )\n\n // API mutations\n const { mutateAsync: createContractor, isPending: isCreating } = useContractorsCreateMutation()\n const { mutateAsync: updateContractor, isPending: isUpdating } = useContractorsUpdateMutation()\n\n // Prepare default values from existing contractor or provided defaults\n const formDefaultValues = useMemo(\n () => ({\n selfOnboarding: false,\n contractorType: ContractorType.Business,\n wageType: WageType.Fixed,\n startDate: new Date(),\n ...defaultValues,\n // Override with existing contractor data if available\n ...(existingContractor && {\n selfOnboarding: existingContractor.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n ContractorSelfOnboardingStatuses.has(existingContractor.onboardingStatus)\n : false,\n contractorType: existingContractor.type || ContractorType.Business,\n wageType: existingContractor.wageType || WageType.Fixed,\n startDate: existingContractor.startDate\n ? new Date(existingContractor.startDate)\n : new Date(),\n firstName: existingContractor.firstName || undefined,\n middleInitial: existingContractor.middleInitial || undefined,\n lastName: existingContractor.lastName || undefined,\n businessName: existingContractor.businessName || undefined,\n email: existingContractor.email || undefined,\n hourlyRate: existingContractor.hourlyRate\n ? (() => {\n const parsed = parseFloat(existingContractor.hourlyRate)\n return isNaN(parsed) ? undefined : parsed\n })()\n : undefined,\n }),\n }),\n [existingContractor, defaultValues],\n )\n\n // Form setup\n const formMethods = useForm<ContractorProfileFormData, unknown, ContractorProfileFormData>({\n resolver: zodResolver(validationSchema),\n defaultValues: formDefaultValues,\n ...(existingContractor && { values: formDefaultValues }),\n resetOptions: { keepDirtyValues: true },\n })\n\n const { handleSubmit, formState } = formMethods\n\n // Watch form values for conditional rendering\n const watchedType = useWatch({ control: formMethods.control, name: 'contractorType' })\n const watchedWageType = useWatch({ control: formMethods.control, name: 'wageType' })\n const watchedSelfOnboarding = useWatch({\n control: formMethods.control,\n name: 'selfOnboarding',\n })\n\n // Helper function to transform form data to API payload\n const transformFormDataToCreatePayload = (\n data: ContractorProfileFormData,\n ): ContractorCreateRequestBody => {\n const basePayload = {\n type: data.contractorType,\n wageType: data.wageType,\n startDate: formatDateToStringDate(data.startDate) || '',\n selfOnboarding: data.selfOnboarding,\n email: data.selfOnboarding ? data.email : undefined,\n hourlyRate: data.wageType === WageType.Hourly ? String(data.hourlyRate) : undefined,\n isActive: true,\n }\n\n if (data.contractorType === ContractorType.Individual) {\n return {\n ...basePayload,\n firstName: data.firstName,\n middleInitial: data.middleInitial || undefined,\n lastName: data.lastName,\n ssn: data.ssn,\n fileNewHireReport: false, // Default value\n }\n } else {\n return {\n ...basePayload,\n fileNewHireReport: false, // Default value\n businessName: data.businessName,\n ein: data.ein?.replace(/-/g, ''),\n }\n }\n }\n\n const transformFormDataToUpdatePayload = (\n data: ContractorProfileFormData,\n version: string,\n ): ContractorUpdateRequestBody => {\n const createPayload = transformFormDataToCreatePayload(data)\n return {\n ...createPayload,\n version,\n }\n }\n\n // Event handlers\n const onSubmit: SubmitHandler<ContractorProfileFormData> = async data => {\n await baseSubmitHandler(data, async payload => {\n let contractorId = existingContractor?.uuid\n if (existingContractor) {\n // Update existing contractor\n if (!existingContractor.version) {\n throw new SDKInternalError('Contractor version is required for updates')\n }\n const version = existingContractor.version\n const apiPayload = transformFormDataToUpdatePayload(payload, version)\n\n const updateResponse = await updateContractor({\n request: {\n contractorUuid: contractorId!,\n contractorUpdateRequestBody: apiPayload,\n },\n })\n\n onEvent(componentEvents.CONTRACTOR_UPDATED, updateResponse.contractor)\n } else {\n // Create new contractor\n const apiPayload = transformFormDataToCreatePayload(payload)\n\n const createResponse = await createContractor({\n request: {\n companyUuid: companyId,\n contractorCreateRequestBody: apiPayload,\n },\n })\n\n contractorId = createResponse.contractor?.uuid\n onEvent(componentEvents.CONTRACTOR_CREATED, createResponse.contractor)\n }\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n selfOnboarding:\n payload.selfOnboarding &&\n existingContractor?.onboardingStatus !==\n ContractorOnboardingStatus.ADMIN_ONBOARDING_REVIEW,\n contractorId,\n })\n })\n }\n\n // Conditional rendering helpers\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion\n const shouldShowEmailField = !!watchedSelfOnboarding\n const shouldShowBusinessFields = watchedType === ContractorType.Business\n const shouldShowIndividualFields = watchedType === ContractorType.Individual\n const shouldShowHourlyRate = watchedWageType === WageType.Hourly\n const shouldShowSsnField = watchedType === ContractorType.Individual && !watchedSelfOnboarding\n const shouldShowEinField = watchedType === ContractorType.Business && !watchedSelfOnboarding\n\n // Form field options\n const contractorTypeOptions = [\n { label: 'Individual', value: ContractorType.Individual },\n { label: 'Business', value: ContractorType.Business },\n ]\n\n const wageTypeOptions = [\n { label: 'Hourly', value: WageType.Hourly },\n { label: 'Fixed', value: WageType.Fixed },\n ]\n\n // Determine if we're currently submitting (creating or updating)\n const isSubmitting = isCreating || isUpdating\n // Return only what the component actually needs\n return {\n // Form methods and submission\n formMethods,\n handleSubmit: handleSubmit(onSubmit),\n formState: {\n ...formState,\n isSubmitting,\n },\n\n // Conditional rendering flags\n shouldShowEmailField,\n shouldShowBusinessFields,\n shouldShowIndividualFields,\n shouldShowHourlyRate,\n shouldShowSsnField,\n shouldShowEinField,\n\n // Form options\n contractorTypeOptions,\n wageTypeOptions,\n\n // Component state\n isEditing: !!contractorId,\n }\n}\n"],"names":["WageType","ApiWageType","ContractorType","ApiContractorType","ContractorProfileSchema","z","NAME_REGEX","createContractorProfileValidationSchema","hasSsn","hasEin","data","ctx","cleanSSN","removeNonDigits","SSN_REGEX","normalizedEin","normalizeEin","useContractorProfile","companyId","contractorId","defaultValues","existingContractor","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","validationSchema","createContractor","isCreating","useContractorsCreateMutation","updateContractor","isUpdating","useContractorsUpdateMutation","formDefaultValues","useMemo","ContractorSelfOnboardingStatuses","parsed","formMethods","useForm","zodResolver","handleSubmit","formState","watchedType","useWatch","watchedWageType","watchedSelfOnboarding","transformFormDataToCreatePayload","basePayload","formatDateToStringDate","transformFormDataToUpdatePayload","version","onSubmit","payload","SDKInternalError","apiPayload","updateResponse","componentEvents","createResponse","ContractorOnboardingStatus","shouldShowEmailField","shouldShowBusinessFields","shouldShowIndividualFields","shouldShowHourlyRate","shouldShowSsnField","shouldShowEinField","contractorTypeOptions","wageTypeOptions","isSubmitting"],"mappings":";;;;;;;;;;;;;;;;AA6BO,MAAMA,IAAWC,GACXC,IAAiBC,GAGxBC,KAA0BC,EAAE,OAAO;AAAA;AAAA,EAEvC,gBAAgBA,EAAE,QAAA;AAAA,EAClB,OAAOA,EAAE,OAAA,EAAS,MAAA,EAAQ,SAAA;AAAA;AAAA,EAG1B,gBAAgBA,EAAE,KAAK,CAACH,EAAe,YAAYA,EAAe,QAAQ,CAAC;AAAA,EAC3E,UAAUG,EAAE,KAAK,CAACL,EAAS,QAAQA,EAAS,KAAK,CAAC;AAAA,EAClD,WAAWK,EAAE,KAAA;AAAA;AAAA,EAGb,WAAWA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,MAAMC,CAAU,EAAE,SAAA;AAAA,EAC/C,eAAeD,EAAE,OAAA,EAAS,SAAA;AAAA,EAC1B,UAAUA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,MAAMC,CAAU,EAAE,SAAA;AAAA,EAC9C,KAAKD,EAAE,OAAA,EAAS,SAAA;AAAA;AAAA,EAGhB,cAAcA,EAAE,OAAA,EAAS,SAAA;AAAA,EACzB,KAAKA,EAAE,OAAA,EAAS,SAAA;AAAA;AAAA,EAGhB,YAAYA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,SAAA;AAChC,CAAC,GAKYE,KAA0C,CACrD,GACAC,GACAC,MAEOL,GAAwB;AAAA,EAC7B,CAACM,GAAiCC,MAAyB;AAWzD,QATID,EAAK,kBAAkB,CAACA,EAAK,SAC/BC,EAAI,SAAS;AAAA,MACX,MAAMN,EAAE,aAAa;AAAA,MACrB,MAAM,CAAC,OAAO;AAAA,MACd,SAAS,EAAE,mBAAmB;AAAA,IAAA,CAC/B,GAICK,EAAK,mBAAmBR,EAAe;AAiBzC,UAhBKQ,EAAK,aACRC,EAAI,SAAS;AAAA,QACX,MAAMN,EAAE,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uBlB,MAAoB9C,EAAS,QACpDiE,IAAqBrB,MAAgB1C,EAAe,cAAc,CAAC6C,GACnEmB,IAAqBtB,MAAgB1C,EAAe,YAAY,CAAC6C,GAGjEoB,IAAwB;AAAA,IAC5B,EAAE,OAAO,cAAc,OAAOjE,EAAe,WAAA;AAAA,IAC7C,EAAE,OAAO,YAAY,OAAOA,EAAe,SAAA;AAAA,EAAS,GAGhDkE,IAAkB;AAAA,IACtB,EAAE,OAAO,UAAU,OAAOpE,EAAS,OAAA;AAAA,IACnC,EAAE,OAAO,SAAS,OAAOA,EAAS,MAAA;AAAA,EAAM,GAIpCqE,IAAevC,KAAcG;AAEnC,SAAO;AAAA;AAAA,IAEL,aAAAM;AAAA,IACA,cAAcG,EAAaW,CAAQ;AAAA,IACnC,WAAW;AAAA,MACT,GAAGV;AAAA,MACH,cAAA0B;AAAA,IAAA;AAAA;AAAA,IAIF,sBAAAR;AAAA,IACA,0BAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,oBAAAC;AAAA;AAAA,IAGA,uBAAAC;AAAA,IACA,iBAAAC;AAAA;AAAA,IAGA,WAAW,CAAC,CAACjD;AAAA,EAAA;AAEjB;"}
1
+ {"version":3,"file":"useContractorProfile.js","sources":["../../../../src/components/Contractor/Profile/useContractorProfile.ts"],"sourcesContent":["import { useMemo } from 'react'\nimport { useTranslation } from 'react-i18next'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { SubmitHandler } from 'react-hook-form'\nimport { useForm, useWatch } from 'react-hook-form'\nimport { z } from 'zod'\nimport { useContractorsCreateMutation } from '@gusto/embedded-api/react-query/contractorsCreate'\nimport { useContractorsUpdateMutation } from '@gusto/embedded-api/react-query/contractorsUpdate'\nimport type { ContractorCreateRequestBody } from '@gusto/embedded-api/models/components/contractorcreaterequestbody'\nimport type { ContractorUpdateRequestBody } from '@gusto/embedded-api/models/components/contractorupdaterequestbody'\nimport {\n ContractorWageType as ApiWageType,\n ContractorType as ApiContractorType,\n type Contractor,\n} from '@gusto/embedded-api/models/components/contractor'\nimport { useBase } from '@/components/Base'\nimport { useI18n } from '@/i18n'\nimport {\n componentEvents,\n ContractorOnboardingStatus,\n ContractorSelfOnboardingStatuses,\n} from '@/shared/constants'\nimport { SSN_REGEX, NAME_REGEX } from '@/helpers/validations'\nimport { removeNonDigits } from '@/helpers/formattedStrings'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { normalizeEin } from '@/helpers/federalEin'\nimport { SDKInternalError } from '@/types/sdkError'\n\n// Re-export the API types for convenience\nexport const WageType = ApiWageType\nexport const ContractorType = ApiContractorType\n\n// Form schema definition - exported for use in stories and tests\nconst ContractorProfileSchema = z.object({\n // Self-onboarding toggle\n selfOnboarding: z.boolean(),\n email: z.string().email().optional(),\n\n // Required contractor fields\n contractorType: z.enum([ContractorType.Individual, ContractorType.Business]),\n wageType: z.enum([WageType.Hourly, WageType.Fixed]),\n startDate: z.date(),\n\n // Individual contractor fields\n firstName: z.string().min(1).regex(NAME_REGEX).optional(),\n middleInitial: z.string().optional(),\n lastName: z.string().min(1).regex(NAME_REGEX).optional(),\n ssn: z.string().optional(),\n\n // Business contractor fields\n businessName: z.string().optional(),\n ein: z.string().optional(),\n\n // Wage fields\n hourlyRate: z.number().min(0).optional(),\n})\n\nexport type ContractorProfileFormData = z.infer<typeof ContractorProfileSchema>\n\n// Create validation schema - exported for stories\nexport const createContractorProfileValidationSchema = (\n t: (key: string) => string,\n hasSsn: boolean,\n hasEin: boolean,\n) => {\n return ContractorProfileSchema.superRefine(\n (data: ContractorProfileFormData, ctx: z.RefinementCtx) => {\n // Email validation for contractor invitation\n if (data.selfOnboarding && !data.email) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['email'],\n message: t('validations.email'),\n })\n }\n\n // Individual contractor validations\n if (data.contractorType === ContractorType.Individual) {\n if (!data.firstName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['firstName'],\n message: t('validations.firstName'),\n })\n }\n\n if (!data.lastName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['lastName'],\n message: t('validations.lastName'),\n })\n }\n\n if (!data.ssn) {\n if (!hasSsn && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssn'),\n })\n }\n } else {\n // Validate SSN format\n const cleanSSN = removeNonDigits(data.ssn)\n if (!SSN_REGEX.test(cleanSSN)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ssn'],\n message: t('validations.ssnFormat'),\n })\n }\n }\n }\n\n // Business contractor validations\n if (data.contractorType === ContractorType.Business) {\n if (!data.businessName) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['businessName'],\n message: t('validations.businessName'),\n })\n }\n\n if (!data.ein) {\n if (!hasEin && !data.selfOnboarding) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.ein'),\n })\n }\n } else {\n // Validate EIN format after normalization (XX-XXXXXXX)\n const normalizedEin = normalizeEin(data.ein)\n if (!/^\\d{2}-\\d{7}$/.test(normalizedEin)) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['ein'],\n message: t('validations.einFormat'),\n })\n }\n }\n }\n\n // Hourly rate validation for hourly contractors\n if (data.wageType === WageType.Hourly) {\n if (data.hourlyRate === undefined || data.hourlyRate < 0) {\n ctx.addIssue({\n code: z.ZodIssueCode.custom,\n path: ['hourlyRate'],\n message: t('validations.hourlyRate'),\n })\n }\n }\n },\n )\n}\n\nexport interface UseContractorProfileProps {\n companyId: string\n contractorId?: string\n defaultValues?: Partial<ContractorProfileFormData>\n existingContractor?: Contractor\n}\n\nexport function useContractorProfile({\n companyId,\n contractorId,\n defaultValues,\n existingContractor,\n}: UseContractorProfileProps) {\n useI18n('Contractor.Profile')\n const { t } = useTranslation('Contractor.Profile')\n const { onEvent, baseSubmitHandler } = useBase()\n\n // Create validation schema with translations\n const validationSchema = createContractorProfileValidationSchema(\n t as (key: string) => string,\n existingContractor?.hasSsn ?? false,\n existingContractor?.hasEin ?? false,\n )\n\n // API mutations\n const { mutateAsync: createContractor, isPending: isCreating } = useContractorsCreateMutation()\n const { mutateAsync: updateContractor, isPending: isUpdating } = useContractorsUpdateMutation()\n\n // Prepare default values from existing contractor or provided defaults\n const formDefaultValues = useMemo(\n () => ({\n selfOnboarding: false,\n contractorType: ContractorType.Business,\n wageType: WageType.Fixed,\n startDate: new Date(),\n ...defaultValues,\n // Override with existing contractor data if available\n ...(existingContractor && {\n selfOnboarding: existingContractor.onboardingStatus\n ? // @ts-expect-error: onboarding_status during runtime can be one of self onboarding statuses\n ContractorSelfOnboardingStatuses.has(existingContractor.onboardingStatus)\n : false,\n contractorType: existingContractor.type || ContractorType.Business,\n wageType: existingContractor.wageType || WageType.Fixed,\n startDate: existingContractor.startDate\n ? new Date(existingContractor.startDate)\n : new Date(),\n firstName: existingContractor.firstName || undefined,\n middleInitial: existingContractor.middleInitial || undefined,\n lastName: existingContractor.lastName || undefined,\n businessName: existingContractor.businessName || undefined,\n email: existingContractor.email || undefined,\n hourlyRate: existingContractor.hourlyRate\n ? (() => {\n const parsed = parseFloat(existingContractor.hourlyRate)\n return isNaN(parsed) ? undefined : parsed\n })()\n : undefined,\n }),\n }),\n [existingContractor, defaultValues],\n )\n\n // Form setup\n const formMethods = useForm<ContractorProfileFormData, unknown, ContractorProfileFormData>({\n resolver: zodResolver(validationSchema),\n defaultValues: formDefaultValues,\n ...(existingContractor && { values: formDefaultValues }),\n resetOptions: { keepDirtyValues: true },\n })\n\n const { handleSubmit, formState } = formMethods\n\n // Watch form values for conditional rendering\n const watchedType = useWatch({ control: formMethods.control, name: 'contractorType' })\n const watchedWageType = useWatch({ control: formMethods.control, name: 'wageType' })\n const watchedSelfOnboarding = useWatch({\n control: formMethods.control,\n name: 'selfOnboarding',\n })\n\n // Helper function to transform form data to API payload\n const transformFormDataToCreatePayload = (\n data: ContractorProfileFormData,\n ): ContractorCreateRequestBody => {\n const basePayload = {\n type: data.contractorType,\n wageType: data.wageType,\n startDate: formatDateToStringDate(data.startDate) || '',\n selfOnboarding: data.selfOnboarding,\n email: data.selfOnboarding ? data.email : undefined,\n hourlyRate: data.wageType === WageType.Hourly ? String(data.hourlyRate) : undefined,\n isActive: true,\n }\n\n if (data.contractorType === ContractorType.Individual) {\n return {\n ...basePayload,\n firstName: data.firstName,\n middleInitial: data.middleInitial || undefined,\n lastName: data.lastName,\n ssn: data.ssn,\n fileNewHireReport: false, // Default value\n }\n } else {\n return {\n ...basePayload,\n fileNewHireReport: false, // Default value\n businessName: data.businessName,\n ein: data.ein?.replace(/-/g, ''),\n }\n }\n }\n\n const transformFormDataToUpdatePayload = (\n data: ContractorProfileFormData,\n version: string,\n ): ContractorUpdateRequestBody => {\n const createPayload = transformFormDataToCreatePayload(data)\n return {\n ...createPayload,\n version,\n }\n }\n\n // Event handlers\n const onSubmit: SubmitHandler<ContractorProfileFormData> = async data => {\n await baseSubmitHandler(data, async payload => {\n let contractorId = existingContractor?.uuid\n if (existingContractor) {\n // Update existing contractor\n if (!existingContractor.version) {\n throw new SDKInternalError('Contractor version is required for updates')\n }\n const version = existingContractor.version\n const apiPayload = transformFormDataToUpdatePayload(payload, version)\n\n const updateResponse = await updateContractor({\n request: {\n contractorUuid: contractorId!,\n contractorUpdateRequestBody: apiPayload,\n },\n })\n\n onEvent(componentEvents.CONTRACTOR_UPDATED, updateResponse.contractor)\n } else {\n // Create new contractor\n const apiPayload = transformFormDataToCreatePayload(payload)\n\n const createResponse = await createContractor({\n request: {\n companyUuid: companyId,\n contractorCreateRequestBody: apiPayload,\n },\n })\n\n contractorId = createResponse.contractor?.uuid\n onEvent(componentEvents.CONTRACTOR_CREATED, createResponse.contractor)\n }\n\n onEvent(componentEvents.CONTRACTOR_PROFILE_DONE, {\n selfOnboarding:\n payload.selfOnboarding &&\n existingContractor?.onboardingStatus !==\n ContractorOnboardingStatus.ADMIN_ONBOARDING_REVIEW,\n contractorId,\n })\n })\n }\n\n // Conditional rendering helpers\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-conversion\n const shouldShowEmailField = !!watchedSelfOnboarding\n const shouldShowBusinessFields = watchedType === ContractorType.Business\n const shouldShowIndividualFields = watchedType === ContractorType.Individual\n const shouldShowHourlyRate = watchedWageType === WageType.Hourly\n const shouldShowSsnField = watchedType === ContractorType.Individual && !watchedSelfOnboarding\n const shouldShowEinField = watchedType === ContractorType.Business && !watchedSelfOnboarding\n\n // Form field options\n const contractorTypeOptions = [\n { label: 'Individual', value: ContractorType.Individual },\n { label: 'Business', value: ContractorType.Business },\n ]\n\n const wageTypeOptions = [\n { label: 'Hourly', value: WageType.Hourly },\n { label: 'Fixed', value: WageType.Fixed },\n ]\n\n // Determine if we're currently submitting (creating or updating)\n const isSubmitting = isCreating || isUpdating\n // Return only what the component actually needs\n return {\n // Form methods and submission\n formMethods,\n handleSubmit: handleSubmit(onSubmit),\n formState: {\n ...formState,\n isSubmitting,\n },\n\n // Conditional rendering flags\n shouldShowEmailField,\n shouldShowBusinessFields,\n shouldShowIndividualFields,\n shouldShowHourlyRate,\n shouldShowSsnField,\n shouldShowEinField,\n\n // Form options\n contractorTypeOptions,\n wageTypeOptions,\n\n // Component state\n isEditing: !!contractorId,\n }\n}\n"],"names":["WageType","ApiWageType","ContractorType","ApiContractorType","ContractorProfileSchema","z","NAME_REGEX","createContractorProfileValidationSchema","hasSsn","hasEin","data","ctx","cleanSSN","removeNonDigits","SSN_REGEX","normalizedEin","normalizeEin","useContractorProfile","companyId","contractorId","defaultValues","existingContractor","useI18n","t","useTranslation","onEvent","baseSubmitHandler","useBase","validationSchema","createContractor","isCreating","useContractorsCreateMutation","updateContractor","isUpdating","useContractorsUpdateMutation","formDefaultValues","useMemo","ContractorSelfOnboardingStatuses","parsed","formMethods","useForm","zodResolver","handleSubmit","formState","watchedType","useWatch","watchedWageType","watchedSelfOnboarding","transformFormDataToCreatePayload","basePayload","formatDateToStringDate","transformFormDataToUpdatePayload","version","onSubmit","payload","SDKInternalError","apiPayload","updateResponse","componentEvents","createResponse","ContractorOnboardingStatus","shouldShowEmailField","shouldShowBusinessFields","shouldShowIndividualFields","shouldShowHourlyRate","shouldShowSsnField","shouldShowEinField","contractorTypeOptions","wageTypeOptions","isSubmitting"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AA6BO,MAAMA,IAAWC,GACXC,IAAiBC,GAGxBC,KAA0BC,EAAE,OAAO;AAAA;AAAA,EAEvC,gBAAgBA,EAAE,QAAA;AAAA,EAClB,OAAOA,EAAE,OAAA,EAAS,MAAA,EAAQ,SAAA;AAAA;AAAA,EAG1B,gBAAgBA,EAAE,KAAK,CAACH,EAAe,YAAYA,EAAe,QAAQ,CAAC;AAAA,EAC3E,UAAUG,EAAE,KAAK,CAACL,EAAS,QAAQA,EAAS,KAAK,CAAC;AAAA,EAClD,WAAWK,EAAE,KAAA;AAAA;AAAA,EAGb,WAAWA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,MAAMC,CAAU,EAAE,SAAA;AAAA,EAC/C,eAAeD,EAAE,OAAA,EAAS,SAAA;AAAA,EAC1B,UAAUA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,MAAMC,CAAU,EAAE,SAAA;AAAA,EAC9C,KAAKD,EAAE,OAAA,EAAS,SAAA;AAAA;AAAA,EAGhB,cAAcA,EAAE,OAAA,EAAS,SAAA;AAAA,EACzB,KAAKA,EAAE,OAAA,EAAS,SAAA;AAAA;AAAA,EAGhB,YAAYA,EAAE,OAAA,EAAS,IAAI,CAAC,EAAE,SAAA;AAChC,CAAC,GAKYE,KAA0C,CACrD,GACAC,GACAC,MAEOL,GAAwB;AAAA,EAC7B,CAACM,GAAiCC,MAAyB;AAWzD,QATID,EAAK,kBAAkB,CAACA,EAAK,SAC/BC,EAAI,SAAS;AAAA,MACX,MAAMN,EAAE,aAAa;AAAA,MACrB,MAAM,CAAC,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AA,MAAA,CACD;AAAA,IACH,CAAC;AAAA,EACH,GAIM0C,IAAuB,CAAC,CAACd,GACzBe,IAA2BlB,MAAgB1C,EAAe,UAC1D6D,IAA6BnB,MAAgB1C,EAAe,YAC5D8D,IAAuBlB,MAAoB9C,EAAS,QACpDiE,IAAqBrB,MAAgB1C,EAAe,cAAc,CAAC6C,GACnEmB,IAAqBtB,MAAgB1C,EAAe,YAAY,CAAC6C,GAGjEoB,IAAwB;AAAA,IAC5B,EAAE,OAAO,cAAc,OAAOjE,EAAe,WAAA;AAAA,IAC7C,EAAE,OAAO,YAAY,OAAOA,EAAe,SAAA;AAAA,EAAS,GAGhDkE,IAAkB;AAAA,IACtB,EAAE,OAAO,UAAU,OAAOpE,EAAS,OAAA;AAAA,IACnC,EAAE,OAAO,SAAS,OAAOA,EAAS,MAAA;AAAA,EAAM,GAIpCqE,IAAevC,KAAcG;AAEnC,SAAO;AAAA;AAAA,IAEL,aAAAM;AAAA,IACA,cAAcG,EAAaW,CAAQ;AAAA,IACnC,WAAW;AAAA,MACT,GAAGV;AAAA,MACH,cAAA0B;AAAA,IAAA;AAAA;AAAA,IAIF,sBAAAR;AAAA,IACA,0BAAAC;AAAA,IACA,4BAAAC;AAAA,IACA,sBAAAC;AAAA,IACA,oBAAAC;AAAA,IACA,oBAAAC;AAAA;AAAA,IAGA,uBAAAC;AAAA,IACA,iBAAAC;AAAA;AAAA,IAGA,WAAW,CAAC,CAACjD;AAAA,EAAA;AAEjB;"}
@@ -0,0 +1,11 @@
1
+ import { CommonComponentInterface } from '../../../../Base';
2
+ import { OnEventType } from '../../../../Base/useBase';
3
+ import { EventType } from '../../../../../shared/constants';
4
+ export interface EditCompensationProps extends CommonComponentInterface<'Employee.Compensation'> {
5
+ employeeId: string;
6
+ jobId: string;
7
+ onCancel?: () => void;
8
+ /** Called with `EMPLOYEE_COMPENSATION_UPDATED` then `EMPLOYEE_COMPENSATION_DONE` on a successful save. Use `EMPLOYEE_COMPENSATION_DONE` to trigger navigation. */
9
+ onEvent: OnEventType<EventType, unknown>;
10
+ }
11
+ export declare function EditCompensation({ dictionary, ...props }: EditCompensationProps): import("react/jsx-runtime").JSX.Element;
@@ -0,0 +1,230 @@
1
+ import { jsx as t, jsxs as g } from "react/jsx-runtime";
2
+ import v from "classnames";
3
+ import { useTranslation as R, Trans as b } from "react-i18next";
4
+ import { useJobsAndCompensationsGetJobs as L } from "@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs";
5
+ import { useJobForm as h } from "../../shared/useJobForm/useJobForm.js";
6
+ import { useCompensationForm as M } from "../../shared/useCompensationForm/useCompensationForm.js";
7
+ import y from "./EditCompensation.module.scss.js";
8
+ import { BaseBoundaries as W, BaseLayout as p } from "../../../../Base/Base.js";
9
+ import "../../../../Base/useBase.js";
10
+ import { Flex as S } from "../../../../Common/Flex/Flex.js";
11
+ import { componentEvents as f, FLSA_OVERTIME_SALARY_LIMIT as C } from "../../../../../shared/constants.js";
12
+ import { ActionsLayout as T } from "../../../../Common/ActionsLayout/ActionsLayout.js";
13
+ import { Form as k } from "../../../../Common/Form/Form.js";
14
+ import { useComponentContext as H } from "../../../../../contexts/ComponentAdapter/useComponentContext.js";
15
+ import { useComponentDictionary as w, useI18n as F } from "../../../../../i18n/I18n.js";
16
+ import { composeErrorHandler as E } from "../../../../../partner-hook-utils/composeErrorHandler.js";
17
+ import { composeSubmitHandler as O } from "../../../../../partner-hook-utils/form/composeSubmitHandler.js";
18
+ import _ from "../../../../../hooks/useNumberFormatter.js";
19
+ import { addDays as U } from "../../../../../helpers/dateFormatting.js";
20
+ function oe({ dictionary: r, ...i }) {
21
+ return w("Employee.Compensation", r), /* @__PURE__ */ t(W, { componentName: "Employee.Compensation.Management", children: /* @__PURE__ */ t(A, { ...i }) });
22
+ }
23
+ function A({
24
+ employeeId: r,
25
+ jobId: i,
26
+ defaultValues: d,
27
+ ...m
28
+ }) {
29
+ const e = L({ employeeId: r }, { enabled: !!r });
30
+ if (e.isLoading || !e.data) {
31
+ const a = E([e]);
32
+ return /* @__PURE__ */ t(p, { isLoading: !0, error: a.errors });
33
+ }
34
+ const n = e.data.jobs?.find((a) => a.uuid === i), o = n?.compensations?.find((a) => a.uuid === n.currentCompensationUuid), s = o ? {
35
+ title: o.title ?? n?.title ?? void 0,
36
+ flsaStatus: o.flsaStatus ?? void 0,
37
+ rate: Number(o.rate),
38
+ paymentUnit: o.paymentUnit ?? void 0,
39
+ adjustForMinimumWage: o.adjustForMinimumWage ?? !1,
40
+ minimumWageId: o.minimumWages?.[0]?.uuid ?? ""
41
+ // effectiveDate intentionally omitted — user must choose a future date
42
+ } : void 0;
43
+ return /* @__PURE__ */ t(I, { employeeId: r, jobId: i, defaultValues: s, ...m });
44
+ }
45
+ function I({ employeeId: r, jobId: i, defaultValues: d, onCancel: m, className: e, onEvent: n }) {
46
+ F("Employee.Compensation");
47
+ const o = h({
48
+ employeeId: r,
49
+ jobId: i,
50
+ withTitleField: !1,
51
+ withHireDateField: !1,
52
+ shouldFocusError: !1
53
+ }), s = M({
54
+ employeeId: r,
55
+ jobId: i,
56
+ defaultValues: d,
57
+ withEffectiveDateField: !0,
58
+ optionalFieldsToRequire: {
59
+ create: ["title"]
60
+ },
61
+ shouldFocusError: !1
62
+ });
63
+ if (o.isLoading || s.isLoading) {
64
+ const u = E([o, s]);
65
+ return /* @__PURE__ */ t(p, { isLoading: !0, error: u.errors });
66
+ }
67
+ const a = O([o, s], async () => {
68
+ const u = await o.actions.onSubmit();
69
+ if (!u) return;
70
+ n(f.EMPLOYEE_JOB_UPDATED, u.data);
71
+ const c = await s.actions.onSubmit();
72
+ c && (n(f.EMPLOYEE_COMPENSATION_UPDATED, c.data), n(f.EMPLOYEE_COMPENSATION_DONE, c.data));
73
+ }), l = E([a]), D = o.status.isPending || s.status.isPending;
74
+ return /* @__PURE__ */ t("section", { className: v(y.container, e), children: /* @__PURE__ */ t(p, { error: l.errors, children: /* @__PURE__ */ t(k, { onSubmit: a.handleSubmit, children: /* @__PURE__ */ t(
75
+ P,
76
+ {
77
+ jobForm: o,
78
+ compensationForm: s,
79
+ isPending: D,
80
+ onCancel: m
81
+ }
82
+ ) }) }) });
83
+ }
84
+ function P({ jobForm: r, compensationForm: i, isPending: d, onCancel: m }) {
85
+ const { t: e } = R("Employee.Compensation"), n = H(), o = _("currency"), s = r.form.Fields, a = i.form.Fields;
86
+ return /* @__PURE__ */ g(S, { flexDirection: "column", gap: 32, children: [
87
+ /* @__PURE__ */ t(n.Heading, { as: "h2", children: e("management.editCompensationTitle") }),
88
+ i.status.willDeleteSecondaryJobs && /* @__PURE__ */ t(
89
+ n.Alert,
90
+ {
91
+ label: e("management.scheduledClassificationChangeNotification"),
92
+ status: "warning"
93
+ }
94
+ ),
95
+ /* @__PURE__ */ t(
96
+ a.Title,
97
+ {
98
+ label: e("management.jobTitleLabel"),
99
+ validationMessages: { REQUIRED: e("validations.jobTitleSentence") },
100
+ formHookResult: i
101
+ }
102
+ ),
103
+ a.FlsaStatus && /* @__PURE__ */ t(
104
+ a.FlsaStatus,
105
+ {
106
+ label: e("employeeClassification"),
107
+ description: /* @__PURE__ */ t(
108
+ b,
109
+ {
110
+ t: e,
111
+ i18nKey: "classificationLink",
112
+ components: { ClassificationLink: /* @__PURE__ */ t(n.Link, {}) }
113
+ }
114
+ ),
115
+ validationMessages: {
116
+ REQUIRED: e("validations.exemptThreshold", {
117
+ limit: o(C)
118
+ })
119
+ },
120
+ getOptionLabel: (l) => e(`flsaStatusLabels.${l}`),
121
+ formHookResult: i
122
+ }
123
+ ),
124
+ /* @__PURE__ */ t(
125
+ a.Rate,
126
+ {
127
+ label: e("management.wageLabel"),
128
+ validationMessages: {
129
+ REQUIRED: e("validations.rate"),
130
+ RATE_MINIMUM: e("validations.nonZeroRate"),
131
+ RATE_EXEMPT_THRESHOLD: e("validations.rateExemptThreshold", {
132
+ limit: o(C)
133
+ })
134
+ },
135
+ formHookResult: i
136
+ }
137
+ ),
138
+ /* @__PURE__ */ t(
139
+ a.PaymentUnit,
140
+ {
141
+ label: e("management.wageFrequencyLabel"),
142
+ description: e("paymentUnitDescription"),
143
+ validationMessages: { REQUIRED: e("validations.paymentUnit") },
144
+ getOptionLabel: (l) => e(`management.wageFrequencyOptions.${l}`),
145
+ formHookResult: i
146
+ }
147
+ ),
148
+ a.EffectiveDate && /* @__PURE__ */ t(
149
+ a.EffectiveDate,
150
+ {
151
+ label: e("effectiveDateLabel"),
152
+ minDate: U(/* @__PURE__ */ new Date(), 1),
153
+ maxDate: i.data.maximumEffectiveDate ? new Date(i.data.maximumEffectiveDate) : void 0,
154
+ validationMessages: {
155
+ REQUIRED: e("validations.effectiveDate"),
156
+ EFFECTIVE_DATE_BEFORE_HIRE: e("validations.effectiveDateBeforeHire")
157
+ },
158
+ formHookResult: i
159
+ }
160
+ ),
161
+ a.AdjustForMinimumWage && /* @__PURE__ */ t(
162
+ a.AdjustForMinimumWage,
163
+ {
164
+ label: e("adjustForMinimumWage"),
165
+ description: e("adjustForMinimumWageDescription"),
166
+ formHookResult: i
167
+ }
168
+ ),
169
+ a.MinimumWageId && /* @__PURE__ */ t(
170
+ a.MinimumWageId,
171
+ {
172
+ label: e("minimumWageLabel"),
173
+ description: e("minimumWageDescription"),
174
+ validationMessages: { REQUIRED: e("validations.minimumWage") },
175
+ getOptionLabel: (l) => `${o(Number(l.wage))} - ${l.authority}: ${l.notes ?? ""}`,
176
+ formHookResult: i
177
+ }
178
+ ),
179
+ s.TwoPercentShareholder && /* @__PURE__ */ t(
180
+ s.TwoPercentShareholder,
181
+ {
182
+ label: e("management.twoPercentShareholderLabel"),
183
+ formHookResult: r
184
+ }
185
+ ),
186
+ s.StateWcCovered && /* @__PURE__ */ t(
187
+ s.StateWcCovered,
188
+ {
189
+ label: e("stateWcCoveredLabel"),
190
+ description: /* @__PURE__ */ t(
191
+ b,
192
+ {
193
+ t: e,
194
+ i18nKey: "stateWcCoveredDescription",
195
+ components: {
196
+ wcLink: /* @__PURE__ */ t(
197
+ n.Link,
198
+ {
199
+ href: "https://www.lni.wa.gov/insurance/rates-risk-classes/risk-classes-for-workers-compensation/risk-class-lookup#/",
200
+ target: "_blank",
201
+ rel: "noopener noreferrer"
202
+ }
203
+ )
204
+ }
205
+ }
206
+ ),
207
+ getOptionLabel: (l) => e(l ? "stateWcCoveredOptions.yes" : "stateWcCoveredOptions.no"),
208
+ formHookResult: r
209
+ }
210
+ ),
211
+ s.StateWcClassCode && /* @__PURE__ */ t(
212
+ s.StateWcClassCode,
213
+ {
214
+ label: e("stateWcClassCodeLabel"),
215
+ description: e("stateWcClassCodeDescription"),
216
+ placeholder: e("stateWcClassCodeLabel"),
217
+ validationMessages: { REQUIRED: e("validations.stateWcClassCode") },
218
+ formHookResult: r
219
+ }
220
+ ),
221
+ /* @__PURE__ */ g(T, { children: [
222
+ m && /* @__PURE__ */ t(n.Button, { variant: "secondary", onClick: m, isDisabled: d, children: e("cancelCta") }),
223
+ /* @__PURE__ */ t(n.Button, { type: "submit", isLoading: d, children: e("management.saveCta") })
224
+ ] })
225
+ ] });
226
+ }
227
+ export {
228
+ oe as EditCompensation
229
+ };
230
+ //# sourceMappingURL=EditCompensation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditCompensation.js","sources":["../../../../../../src/components/Employee/Compensation/management/EditCompensation/EditCompensation.tsx"],"sourcesContent":["import classNames from 'classnames'\nimport { Trans, useTranslation } from 'react-i18next'\nimport type { PaymentUnit } from '@gusto/embedded-api/models/components/compensation'\nimport type { FlsaStatusType } from '@gusto/embedded-api/models/components/flsastatustype'\nimport type { MinimumWage } from '@gusto/embedded-api/models/components/minimumwage'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobForm, type UseJobFormReady } from '../../shared/useJobForm'\nimport {\n useCompensationForm,\n type UseCompensationFormReady,\n type CompensationFormData,\n} from '../../shared/useCompensationForm'\nimport styles from './EditCompensation.module.scss'\nimport { BaseBoundaries, BaseLayout, type CommonComponentInterface } from '@/components/Base'\nimport type { OnEventType } from '@/components/Base/useBase'\nimport { ActionsLayout, Flex } from '@/components/Common'\nimport { Form } from '@/components/Common/Form'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { useComponentDictionary, useI18n } from '@/i18n'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport { composeSubmitHandler } from '@/partner-hook-utils/form/composeSubmitHandler'\nimport { componentEvents, FLSA_OVERTIME_SALARY_LIMIT, type EventType } from '@/shared/constants'\nimport useNumberFormatter from '@/hooks/useNumberFormatter'\nimport { addDays } from '@/helpers/dateFormatting'\n\nexport interface EditCompensationProps extends CommonComponentInterface<'Employee.Compensation'> {\n employeeId: string\n jobId: string\n onCancel?: () => void\n /** Called with `EMPLOYEE_COMPENSATION_UPDATED` then `EMPLOYEE_COMPENSATION_DONE` on a successful save. Use `EMPLOYEE_COMPENSATION_DONE` to trigger navigation. */\n onEvent: OnEventType<EventType, unknown>\n}\n\nexport function EditCompensation({ dictionary, ...props }: EditCompensationProps) {\n useComponentDictionary('Employee.Compensation', dictionary)\n return (\n <BaseBoundaries componentName=\"Employee.Compensation.Management\">\n <CompensationDefaultsLoader {...props} />\n </BaseBoundaries>\n )\n}\n\ntype LoaderProps = Omit<EditCompensationProps, 'dictionary'>\n\n// Fetches the current job's compensation data to pre-populate the form as\n// defaultValues before rendering Root. Uses the same non-suspense query that\n// useCompensationForm uses internally — React Query dedupes the request so no\n// extra network call is made once Root mounts.\n// defaultValues from CommonComponentInterface (unknown) is excluded from the\n// spread so it doesn't conflict with Root's typed defaultValues prop.\nfunction CompensationDefaultsLoader({\n employeeId,\n jobId,\n defaultValues: _baseDefaults,\n ...rest\n}: LoaderProps) {\n const jobsQuery = useJobsAndCompensationsGetJobs({ employeeId }, { enabled: !!employeeId })\n\n if (jobsQuery.isLoading || !jobsQuery.data) {\n const errorHandling = composeErrorHandler([jobsQuery])\n return <BaseLayout isLoading error={errorHandling.errors} />\n }\n\n const job = jobsQuery.data.jobs?.find(j => j.uuid === jobId)\n const currentComp = job?.compensations?.find(c => c.uuid === job.currentCompensationUuid)\n\n const defaultValues: Partial<CompensationFormData> | undefined = currentComp\n ? {\n title: currentComp.title ?? job?.title ?? undefined,\n flsaStatus: currentComp.flsaStatus ?? undefined,\n rate: Number(currentComp.rate),\n paymentUnit: currentComp.paymentUnit ?? undefined,\n adjustForMinimumWage: currentComp.adjustForMinimumWage ?? false,\n minimumWageId: currentComp.minimumWages?.[0]?.uuid ?? '',\n // effectiveDate intentionally omitted — user must choose a future date\n }\n : undefined\n\n return <Root employeeId={employeeId} jobId={jobId} defaultValues={defaultValues} {...rest} />\n}\n\ninterface RootProps extends LoaderProps {\n defaultValues?: Partial<CompensationFormData>\n}\n\nfunction Root({ employeeId, jobId, defaultValues, onCancel, className, onEvent }: RootProps) {\n useI18n('Employee.Compensation')\n\n // Job form handles the non-effective-dated fields: 2% shareholder + WA WC.\n // Title is suppressed here because the compensation form owns title\n // (effective-dated alongside rate/unit/FLSA on the future-dated row).\n // Hire-date is suppressed because this surface never edits it.\n const jobForm = useJobForm({\n employeeId,\n jobId,\n withTitleField: false,\n withHireDateField: false,\n shouldFocusError: false,\n })\n\n // Compensation form runs in create mode (no compensationId) → POST\n // /v1/jobs/:jobId/compensations, creating a new future-dated compensation.\n // The form is pre-populated with the current comp's values via defaultValues\n // (fetched by CompensationDefaultsLoader) so the user can edit from the\n // current state, and picks a future effectiveDate to schedule the change.\n const compensationForm = useCompensationForm({\n employeeId,\n jobId,\n defaultValues,\n withEffectiveDateField: true,\n optionalFieldsToRequire: {\n create: ['title'],\n },\n shouldFocusError: false,\n })\n\n if (jobForm.isLoading || compensationForm.isLoading) {\n const loadingErrorHandling = composeErrorHandler([jobForm, compensationForm])\n return <BaseLayout isLoading error={loadingErrorHandling.errors} />\n }\n\n // PUT job first (immediate mutation of 2% shareholder / WC), then POST\n // the new compensation (the future-dated change). composeSubmitHandler\n // validates both forms in parallel and short-circuits before any network\n // I/O if either fails.\n const submitResult = composeSubmitHandler([jobForm, compensationForm], async () => {\n const jobResult = await jobForm.actions.onSubmit()\n if (!jobResult) return\n\n onEvent(componentEvents.EMPLOYEE_JOB_UPDATED, jobResult.data)\n\n const compensationResult = await compensationForm.actions.onSubmit()\n if (!compensationResult) return\n\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_UPDATED, compensationResult.data)\n onEvent(componentEvents.EMPLOYEE_COMPENSATION_DONE, compensationResult.data)\n })\n\n const errorHandling = composeErrorHandler([submitResult])\n const isPending = jobForm.status.isPending || compensationForm.status.isPending\n\n return (\n <section className={classNames(styles.container, className)}>\n <BaseLayout error={errorHandling.errors}>\n <Form onSubmit={submitResult.handleSubmit}>\n <FormBody\n jobForm={jobForm}\n compensationForm={compensationForm}\n isPending={isPending}\n onCancel={onCancel}\n />\n </Form>\n </BaseLayout>\n </section>\n )\n}\n\ninterface FormBodyProps {\n jobForm: UseJobFormReady\n compensationForm: UseCompensationFormReady\n isPending: boolean\n onCancel?: () => void\n}\n\nfunction FormBody({ jobForm, compensationForm, isPending, onCancel }: FormBodyProps) {\n const { t } = useTranslation('Employee.Compensation')\n const Components = useComponentContext()\n const format = useNumberFormatter('currency')\n\n const JobFields = jobForm.form.Fields\n const CompFields = compensationForm.form.Fields\n\n return (\n <Flex flexDirection=\"column\" gap={32}>\n <Components.Heading as=\"h2\">{t('management.editCompensationTitle')}</Components.Heading>\n\n {compensationForm.status.willDeleteSecondaryJobs && (\n <Components.Alert\n label={t('management.scheduledClassificationChangeNotification')}\n status=\"warning\"\n />\n )}\n\n <CompFields.Title\n label={t('management.jobTitleLabel')}\n validationMessages={{ REQUIRED: t('validations.jobTitleSentence') }}\n formHookResult={compensationForm}\n />\n\n {CompFields.FlsaStatus && (\n <CompFields.FlsaStatus\n label={t('employeeClassification')}\n description={\n <Trans\n t={t}\n i18nKey=\"classificationLink\"\n components={{ ClassificationLink: <Components.Link /> }}\n />\n }\n validationMessages={{\n REQUIRED: t('validations.exemptThreshold', {\n limit: format(FLSA_OVERTIME_SALARY_LIMIT),\n }),\n }}\n getOptionLabel={(status: FlsaStatusType) => t(`flsaStatusLabels.${status}`)}\n formHookResult={compensationForm}\n />\n )}\n\n <CompFields.Rate\n label={t('management.wageLabel')}\n validationMessages={{\n REQUIRED: t('validations.rate'),\n RATE_MINIMUM: t('validations.nonZeroRate'),\n RATE_EXEMPT_THRESHOLD: t('validations.rateExemptThreshold', {\n limit: format(FLSA_OVERTIME_SALARY_LIMIT),\n }),\n }}\n formHookResult={compensationForm}\n />\n\n <CompFields.PaymentUnit\n label={t('management.wageFrequencyLabel')}\n description={t('paymentUnitDescription')}\n validationMessages={{ REQUIRED: t('validations.paymentUnit') }}\n getOptionLabel={(unit: PaymentUnit) =>\n t(`management.wageFrequencyOptions.${unit}` as const)\n }\n formHookResult={compensationForm}\n />\n\n {CompFields.EffectiveDate && (\n <CompFields.EffectiveDate\n label={t('effectiveDateLabel')}\n minDate={addDays(new Date(), 1)}\n maxDate={\n compensationForm.data.maximumEffectiveDate\n ? new Date(compensationForm.data.maximumEffectiveDate)\n : undefined\n }\n validationMessages={{\n REQUIRED: t('validations.effectiveDate'),\n EFFECTIVE_DATE_BEFORE_HIRE: t('validations.effectiveDateBeforeHire'),\n }}\n formHookResult={compensationForm}\n />\n )}\n\n {CompFields.AdjustForMinimumWage && (\n <CompFields.AdjustForMinimumWage\n label={t('adjustForMinimumWage')}\n description={t('adjustForMinimumWageDescription')}\n formHookResult={compensationForm}\n />\n )}\n\n {CompFields.MinimumWageId && (\n <CompFields.MinimumWageId\n label={t('minimumWageLabel')}\n description={t('minimumWageDescription')}\n validationMessages={{ REQUIRED: t('validations.minimumWage') }}\n getOptionLabel={(wage: MinimumWage) =>\n `${format(Number(wage.wage))} - ${wage.authority}: ${wage.notes ?? ''}`\n }\n formHookResult={compensationForm}\n />\n )}\n\n {JobFields.TwoPercentShareholder && (\n <JobFields.TwoPercentShareholder\n label={t('management.twoPercentShareholderLabel')}\n formHookResult={jobForm}\n />\n )}\n\n {JobFields.StateWcCovered && (\n <JobFields.StateWcCovered\n label={t('stateWcCoveredLabel')}\n description={\n <Trans\n t={t}\n i18nKey=\"stateWcCoveredDescription\"\n components={{\n wcLink: (\n <Components.Link\n href=\"https://www.lni.wa.gov/insurance/rates-risk-classes/risk-classes-for-workers-compensation/risk-class-lookup#/\"\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n />\n ),\n }}\n />\n }\n getOptionLabel={(covered: boolean) =>\n covered ? t('stateWcCoveredOptions.yes') : t('stateWcCoveredOptions.no')\n }\n formHookResult={jobForm}\n />\n )}\n\n {JobFields.StateWcClassCode && (\n <JobFields.StateWcClassCode\n label={t('stateWcClassCodeLabel')}\n description={t('stateWcClassCodeDescription')}\n placeholder={t('stateWcClassCodeLabel')}\n validationMessages={{ REQUIRED: t('validations.stateWcClassCode') }}\n formHookResult={jobForm}\n />\n )}\n\n <ActionsLayout>\n {onCancel && (\n <Components.Button variant=\"secondary\" onClick={onCancel} isDisabled={isPending}>\n {t('cancelCta')}\n </Components.Button>\n )}\n <Components.Button type=\"submit\" isLoading={isPending}>\n {t('management.saveCta')}\n </Components.Button>\n </ActionsLayout>\n </Flex>\n )\n}\n"],"names":["EditCompensation","dictionary","props","useComponentDictionary","jsx","BaseBoundaries","CompensationDefaultsLoader","employeeId","jobId","_baseDefaults","rest","jobsQuery","useJobsAndCompensationsGetJobs","errorHandling","composeErrorHandler","BaseLayout","job","j","currentComp","c","defaultValues","Root","onCancel","className","onEvent","useI18n","jobForm","useJobForm","compensationForm","useCompensationForm","loadingErrorHandling","submitResult","composeSubmitHandler","jobResult","componentEvents","compensationResult","isPending","classNames","styles","Form","FormBody","t","useTranslation","Components","useComponentContext","format","useNumberFormatter","JobFields","CompFields","jsxs","Flex","Trans","FLSA_OVERTIME_SALARY_LIMIT","status","unit","addDays","wage","covered","ActionsLayout"],"mappings":";;;;;;;;;;;;;;;;;;;AAiCO,SAASA,GAAiB,EAAE,YAAAC,GAAY,GAAG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BAAAlB,EAACuC,EAAW,QAAX,EAAkB,SAAQ,aAAY,SAASrB,GAAU,YAAYc,GACnE,UAAAK,EAAE,WAAW,EAAA,CAChB;AAAA,MAEF,gBAAArC,EAACuC,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAWP,GACzC,UAAAK,EAAE,oBAAoB,EAAA,CACzB;AAAA,IAAA,EAAA,CACF;AAAA,EAAA,GACF;AAEJ;"}
@@ -0,0 +1,8 @@
1
+ const n = "_container_18572_1", t = {
2
+ container: n
3
+ };
4
+ export {
5
+ n as container,
6
+ t as default
7
+ };
8
+ //# sourceMappingURL=EditCompensation.module.scss.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EditCompensation.module.scss.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;"}