@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,47 +1,48 @@
1
- import { useMemo as J } from "react";
2
- import { useForm as X, useWatch as Z } from "react-hook-form";
3
- import { zodResolver as ee } from "@hookform/resolvers/zod";
4
- import { useJobsAndCompensationsGetJobs as te } from "@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs";
5
- import { useJobsAndCompensationsCreateJobMutation as oe } from "@gusto/embedded-api/react-query/jobsAndCompensationsCreateJob";
6
- import { useJobsAndCompensationsUpdateMutation as re } from "@gusto/embedded-api/react-query/jobsAndCompensationsUpdate";
7
- import { useEmployeeAddressesGetWorkAddresses as se } from "@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses";
8
- import { useEmployeesGet as ae } from "@gusto/embedded-api/react-query/employeesGet";
9
- import { useFederalTaxDetailsGet as ie } from "@gusto/embedded-api/react-query/federalTaxDetailsGet";
10
- import { createJobSchema as ne } from "./jobSchema.js";
11
- import { StateWcClassCodeField as de, StateWcCoveredField as ce, TwoPercentShareholderField as le, HireDateField as ue, JobTitleField as me } from "./fields.js";
12
- import { useDeriveFieldsMetadata as be } from "../../../../../partner-hook-utils/form/useDeriveFieldsMetadata.js";
13
- import { useHookFormInternals as he } from "../../../../../partner-hook-utils/form/useHookFormInternals.js";
14
- import { createGetFormSubmissionValues as fe } from "../../../../../partner-hook-utils/form/getFormSubmissionValues.js";
15
- import { withOptions as x } from "../../../../../partner-hook-utils/form/withOptions.js";
16
- import { composeErrorHandler as Ce } from "../../../../../partner-hook-utils/composeErrorHandler.js";
17
- import { useBaseSubmit as Se } from "../../../../Base/useBaseSubmit.js";
18
- import { SDKInternalError as u } from "../../../../../types/sdkError.js";
19
- import { WA_RISK_CLASS_CODES as G } from "../../../../../models/WA_RISK_CODES.js";
20
- function ve(e, s) {
1
+ import { useMemo as A } from "react";
2
+ import { useForm as ee, useWatch as te } from "react-hook-form";
3
+ import { zodResolver as oe } from "@hookform/resolvers/zod";
4
+ import { useJobsAndCompensationsGetJobs as re } from "@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs";
5
+ import { useJobsAndCompensationsCreateJobMutation as se } from "@gusto/embedded-api/react-query/jobsAndCompensationsCreateJob";
6
+ import { useJobsAndCompensationsUpdateMutation as ae } from "@gusto/embedded-api/react-query/jobsAndCompensationsUpdate";
7
+ import { useEmployeeAddressesGetWorkAddresses as ie } from "@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses";
8
+ import { useEmployeesGet as ne } from "@gusto/embedded-api/react-query/employeesGet";
9
+ import { useFederalTaxDetailsGet as de } from "@gusto/embedded-api/react-query/federalTaxDetailsGet";
10
+ import { createJobSchema as ce } from "./jobSchema.js";
11
+ import { StateWcClassCodeField as le, StateWcCoveredField as ue, TwoPercentShareholderField as me, HireDateField as be, JobTitleField as fe } from "./fields.js";
12
+ import { useDeriveFieldsMetadata as he } from "../../../../../partner-hook-utils/form/useDeriveFieldsMetadata.js";
13
+ import { useHookFormInternals as Ce } from "../../../../../partner-hook-utils/form/useHookFormInternals.js";
14
+ import { createGetFormSubmissionValues as ve } from "../../../../../partner-hook-utils/form/getFormSubmissionValues.js";
15
+ import { withOptions as O } from "../../../../../partner-hook-utils/form/withOptions.js";
16
+ import { composeErrorHandler as Se } from "../../../../../partner-hook-utils/composeErrorHandler.js";
17
+ import { useBaseSubmit as pe } from "../../../../Base/useBaseSubmit.js";
18
+ import { SDKInternalError as i } from "../../../../../types/sdkError.js";
19
+ import { WA_RISK_CLASS_CODES as V } from "../../../../../models/WA_RISK_CODES.js";
20
+ function we(e, s) {
21
21
  return !e || !s ? null : e.find((m) => m.uuid === s) ?? null;
22
22
  }
23
- function Qe({
23
+ function Ue({
24
24
  employeeId: e,
25
25
  jobId: s,
26
26
  optionalFieldsToRequire: m,
27
27
  defaultValues: a,
28
- validationMode: O = "onSubmit",
29
- shouldFocusError: V = !0,
30
- withHireDateField: i = !0
28
+ validationMode: H = "onSubmit",
29
+ shouldFocusError: Q = !0,
30
+ withHireDateField: n = !0,
31
+ withTitleField: b = !0
31
32
  }) {
32
- const C = te(
33
+ const v = re(
33
34
  { employeeId: e ?? "" },
34
35
  { enabled: !!e }
35
- ), S = se(
36
+ ), S = ie(
36
37
  { employeeId: e ?? "" },
37
38
  { enabled: !!e }
38
- ), v = ae({ employeeId: e ?? "" }, { enabled: !!e }), b = C.data?.jobs, P = S.data?.employeeWorkAddressesList?.find((r) => r.active) ?? null, p = v.data?.employee ?? null, A = p?.companyUuid, g = ie(
39
- { companyId: A ?? "" },
40
- { enabled: !!A }
41
- ), w = g.data?.federalTaxDetails?.taxableAsScorp === !0, n = P?.state === "WA", t = J(() => ve(b, s), [b, s]), h = !s, F = h ? "create" : "update", [j, H] = J(
42
- () => ne({ mode: F, optionalFieldsToRequire: m, withHireDateField: i }),
43
- [F, m, i]
44
- ), y = J(
39
+ ), p = ne({ employeeId: e ?? "" }, { enabled: !!e }), f = v.data?.jobs, g = S.data?.employeeWorkAddressesList?.find((r) => r.active) ?? null, w = p.data?.employee ?? null, j = w?.companyUuid, y = de(
40
+ { companyId: j ?? "" },
41
+ { enabled: !!j }
42
+ ), W = y.data?.federalTaxDetails?.taxableAsScorp === !0, d = g?.state === "WA", t = A(() => we(f, s), [f, s]), h = !s, F = h ? "create" : "update", [E, R] = A(
43
+ () => ce({ mode: F, optionalFieldsToRequire: m, withHireDateField: n, withTitleField: b }),
44
+ [F, m, n, b]
45
+ ), M = A(
45
46
  () => ({
46
47
  title: t?.title ?? a?.title ?? "",
47
48
  hireDate: t?.hireDate ?? a?.hireDate ?? null,
@@ -50,134 +51,138 @@ function Qe({
50
51
  stateWcClassCode: t?.stateWcClassCode ?? a?.stateWcClassCode ?? ""
51
52
  }),
52
53
  [t, a]
53
- ), d = X({
54
- resolver: ee(j),
55
- mode: O,
56
- shouldFocusError: V,
57
- defaultValues: y,
58
- values: y,
54
+ ), c = ee({
55
+ resolver: oe(E),
56
+ mode: H,
57
+ shouldFocusError: Q,
58
+ defaultValues: M,
59
+ values: M,
59
60
  resetOptions: { keepDirtyValues: !0 }
60
- }), Q = Z({ control: d.control, name: "stateWcCovered" }), E = oe(), M = re(), R = E.isPending || M.isPending, {
61
- baseSubmitHandler: U,
62
- error: B,
63
- setError: _
64
- } = Se("JobForm"), k = Ce(e ? [C, S, v, g] : [], { submitError: B, setSubmitError: _ }), K = G.map(({ code: r, description: f }) => ({
61
+ }), U = te({ control: c.control, name: "stateWcCovered" }), q = se(), k = ae(), B = q.isPending || k.isPending, {
62
+ baseSubmitHandler: _,
63
+ error: K,
64
+ setError: $
65
+ } = pe("JobForm"), L = Se(e ? [v, S, p, y] : [], { submitError: K, setSubmitError: $ }), z = V.map(({ code: r, description: C }) => ({
65
66
  value: r,
66
- label: `${r}: ${f}`
67
- })), c = be(H, d.control), $ = {
68
- title: c.title,
69
- hireDate: c.hireDate,
67
+ label: `${r}: ${C}`
68
+ })), l = he(R, c.control), I = {
69
+ title: l.title,
70
+ hireDate: l.hireDate,
70
71
  twoPercentShareholder: {
71
- ...c.twoPercentShareholder,
72
- isDisabled: !w
72
+ ...l.twoPercentShareholder,
73
+ isDisabled: !W
73
74
  },
74
- stateWcCovered: x(
75
- { ...c.stateWcCovered, isDisabled: !n },
75
+ stateWcCovered: O(
76
+ { ...l.stateWcCovered, isDisabled: !d },
76
77
  [
77
78
  { label: "Yes", value: "true" },
78
79
  { label: "No", value: "false" }
79
80
  ],
80
81
  [!0, !1]
81
82
  ),
82
- stateWcClassCode: x(
83
- { ...c.stateWcClassCode, isDisabled: !n },
84
- K,
85
- G
83
+ stateWcClassCode: O(
84
+ { ...l.stateWcClassCode, isDisabled: !d },
85
+ z,
86
+ V
86
87
  )
87
- }, z = async (r) => {
88
- let f;
89
- return await new Promise((q) => {
90
- d.handleSubmit(
91
- async (Y) => {
92
- await U(Y, async (o) => {
93
- const L = r?.employeeId ?? e;
94
- if (!L)
95
- throw new u("employeeId is required to submit a job");
96
- const T = o.stateWcCovered ? o.stateWcClassCode : null, W = i && o.hireDate ? o.hireDate : r?.hireDate ?? t?.hireDate ?? null;
97
- let D;
88
+ }, N = async (r) => {
89
+ let C;
90
+ return await new Promise((x) => {
91
+ c.handleSubmit(
92
+ async (Z) => {
93
+ await _(Z, async (o) => {
94
+ const T = r?.employeeId ?? e;
95
+ if (!T)
96
+ throw new i("employeeId is required to submit a job");
97
+ const G = o.stateWcCovered ? o.stateWcClassCode : null, D = n && o.hireDate ? o.hireDate : r?.hireDate ?? t?.hireDate ?? null, J = b ? o.title : void 0;
98
+ let P;
98
99
  if (h) {
99
- if (!W)
100
- throw new u(
101
- i ? "hireDate is required to create a job" : "hireDate is required to create a job. Pass it via JobSubmitOptions when withHireDateField is false."
100
+ if (!D)
101
+ throw new i(
102
+ n ? "hireDate is required to create a job" : "hireDate is required to create a job. Pass it via JobSubmitOptions when withHireDateField is false."
102
103
  );
103
- const l = await E.mutateAsync({
104
+ if (J === void 0)
105
+ throw new i(
106
+ "title is required to create a job. Set withTitleField: true (the default) on useJobForm for create flows."
107
+ );
108
+ const u = await q.mutateAsync({
104
109
  request: {
105
- employeeId: L,
110
+ employeeId: T,
106
111
  jobsCreateRequestBody: {
107
- title: o.title,
108
- hireDate: W,
112
+ title: J,
113
+ hireDate: D,
109
114
  twoPercentShareholder: o.twoPercentShareholder,
110
115
  stateWcCovered: o.stateWcCovered,
111
- stateWcClassCode: T
116
+ stateWcClassCode: G
112
117
  }
113
118
  }
114
119
  });
115
- if (!l.job)
116
- throw new u("Job creation failed");
117
- D = l.job;
120
+ if (!u.job)
121
+ throw new i("Job creation failed");
122
+ P = u.job;
118
123
  } else {
119
124
  if (!t)
120
- throw new u("Cannot update job: no matching job on file");
121
- const l = await M.mutateAsync({
125
+ throw new i("Cannot update job: no matching job on file");
126
+ const u = await k.mutateAsync({
122
127
  request: {
123
128
  jobId: t.uuid,
124
129
  jobsUpdateRequestBody: {
125
130
  version: t.version,
126
- title: o.title,
127
- hireDate: W ?? void 0,
131
+ title: J,
132
+ hireDate: D ?? void 0,
128
133
  twoPercentShareholder: o.twoPercentShareholder,
129
134
  stateWcCovered: o.stateWcCovered,
130
- stateWcClassCode: T
135
+ stateWcClassCode: G
131
136
  }
132
137
  }
133
138
  });
134
- if (!l.job)
135
- throw new u("Job update failed");
136
- D = l.job;
139
+ if (!u.job)
140
+ throw new i("Job update failed");
141
+ P = u.job;
137
142
  }
138
- f = {
143
+ C = {
139
144
  mode: h ? "create" : "update",
140
- data: D
145
+ data: P
141
146
  };
142
- }), q();
147
+ }), x();
143
148
  },
144
149
  () => {
145
- q();
150
+ x();
146
151
  }
147
152
  )();
148
- }), f;
149
- }, I = e ? C.isLoading || S.isLoading || v.isLoading : !1, N = he(d);
150
- return I || e && (!b || !p) ? { isLoading: !0, errorHandling: k } : {
153
+ }), C;
154
+ }, Y = e ? v.isLoading || S.isLoading || p.isLoading : !1, X = Ce(c);
155
+ return Y || e && (!f || !w) ? { isLoading: !0, errorHandling: L } : {
151
156
  isLoading: !1,
152
157
  data: {
153
158
  currentJob: t,
154
- jobs: b,
155
- employee: p,
156
- currentWorkAddress: P,
157
- showTwoPercentShareholder: w,
158
- showStateWc: n
159
+ jobs: f,
160
+ employee: w,
161
+ currentWorkAddress: g,
162
+ showTwoPercentShareholder: W,
163
+ showStateWc: d
159
164
  },
160
165
  status: {
161
- isPending: R,
166
+ isPending: B,
162
167
  mode: h ? "create" : "update"
163
168
  },
164
- actions: { onSubmit: z },
165
- errorHandling: k,
169
+ actions: { onSubmit: N },
170
+ errorHandling: L,
166
171
  form: {
167
172
  Fields: {
168
- Title: me,
169
- HireDate: i ? ue : void 0,
170
- TwoPercentShareholder: w ? le : void 0,
171
- StateWcCovered: n ? ce : void 0,
172
- StateWcClassCode: n && Q ? de : void 0
173
+ Title: b ? fe : void 0,
174
+ HireDate: n ? be : void 0,
175
+ TwoPercentShareholder: W ? me : void 0,
176
+ StateWcCovered: d ? ue : void 0,
177
+ StateWcClassCode: d && U ? le : void 0
173
178
  },
174
- fieldsMetadata: $,
175
- hookFormInternals: N,
176
- getFormSubmissionValues: fe(d, j)
179
+ fieldsMetadata: I,
180
+ hookFormInternals: X,
181
+ getFormSubmissionValues: ve(c, E)
177
182
  }
178
183
  };
179
184
  }
180
185
  export {
181
- Qe as useJobForm
186
+ Ue as useJobForm
182
187
  };
183
188
  //# sourceMappingURL=useJobForm.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useJobForm.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useJobForm/useJobForm.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobsAndCompensationsCreateJobMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateJob'\nimport { useJobsAndCompensationsUpdateMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdate'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useFederalTaxDetailsGet } from '@gusto/embedded-api/react-query/federalTaxDetailsGet'\nimport {\n createJobSchema,\n type JobOptionalFieldsToRequire,\n type JobFormData,\n type JobFormOutputs,\n} from './jobSchema'\nimport {\n JobTitleField,\n HireDateField,\n TwoPercentShareholderField,\n StateWcCoveredField,\n StateWcClassCodeField,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { WA_RISK_CLASS_CODES, type WARiskClassCode } from '@/models/WA_RISK_CODES'\n\nexport interface JobSubmitOptions {\n /** Override the `employeeId` configured at hook construction. Useful when the employee is created in the same submit chain. */\n employeeId?: string\n /**\n * Supply `hireDate` at submit time rather than via a rendered field. Use\n * with `withHireDateField: false` for screens that derive hireDate from\n * external context (e.g. the employee's `startDate` during onboarding).\n * Falls back to the loaded job's `hireDate` on update mode when omitted;\n * required (or sourced from a partner default) on create mode.\n */\n hireDate?: string\n}\n\nexport interface UseJobFormProps {\n employeeId?: string\n /** Present → update mode (PUT /v1/jobs/:id with `version`). Omitted → create mode (POST /v1/employees/:id/jobs). */\n jobId?: string\n optionalFieldsToRequire?: JobOptionalFieldsToRequire\n defaultValues?: Partial<JobFormData>\n validationMode?: UseFormProps['mode']\n shouldFocusError?: boolean\n /**\n * When `false`, hides `Fields.HireDate` (becomes `undefined`) and removes\n * `hireDate` from schema validation. Partners supply the value via\n * `JobSubmitOptions.hireDate` at submit time, or rely on the loaded job's\n * existing value on update. Use this when the date is driven by external\n * context rather than user input (e.g. the employee's `startDate`).\n * Defaults to `true`.\n */\n withHireDateField?: boolean\n}\n\nexport interface JobFormFields {\n Title: typeof JobTitleField\n HireDate: typeof HireDateField | undefined\n TwoPercentShareholder: typeof TwoPercentShareholderField | undefined\n StateWcCovered: typeof StateWcCoveredField | undefined\n StateWcClassCode: typeof StateWcClassCodeField | undefined\n}\n\nexport interface UseJobFormReady extends BaseFormHookReady<\n FieldsMetadata,\n JobFormData,\n JobFormFields\n> {\n data: {\n /** The job row loaded for update; `null` in create mode. */\n currentJob: Job | null\n /** All jobs for the employee, when employeeId is set. Useful for screen-level cross-checks across jobs. */\n jobs: Job[] | undefined\n employee: Employee | null\n currentWorkAddress: EmployeeWorkAddress | null\n /** True when the company is taxable as an S-Corp; partners use this to decide whether to render `TwoPercentShareholder`. */\n showTwoPercentShareholder: boolean\n /**\n * True when the active work-address state is WA; partners use this to decide whether to render\n * `StateWcCovered`. `Fields.StateWcClassCode` is additionally gated on `stateWcCovered === true`,\n * so partners typically only need to check `Fields.StateWcCovered` / `Fields.StateWcClassCode`\n * truthiness rather than this flag directly.\n */\n showStateWc: boolean\n }\n status: { isPending: boolean; mode: 'create' | 'update' }\n actions: {\n onSubmit: (options?: JobSubmitOptions) => Promise<HookSubmitResult<Job> | undefined>\n }\n}\n\nfunction findJob(jobs: Job[] | undefined, jobId: string | undefined): Job | null {\n if (!jobs || !jobId) return null\n return jobs.find(j => j.uuid === jobId) ?? null\n}\n\nexport function useJobForm({\n employeeId,\n jobId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n withHireDateField = true,\n}: UseJobFormProps): HookLoadingResult | UseJobFormReady {\n const jobsQuery = useJobsAndCompensationsGetJobs(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const addressesQuery = useEmployeeAddressesGetWorkAddresses(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const employeeQuery = useEmployeesGet({ employeeId: employeeId ?? '' }, { enabled: !!employeeId })\n\n const employeeJobs = jobsQuery.data?.jobs\n const workAddresses = addressesQuery.data?.employeeWorkAddressesList\n const currentWorkAddress = workAddresses?.find(address => address.active) ?? null\n const employee = employeeQuery.data?.employee ?? null\n const companyUuid = employee?.companyUuid\n\n const taxQuery = useFederalTaxDetailsGet(\n { companyId: companyUuid ?? '' },\n { enabled: !!companyUuid },\n )\n const federalTaxDetails = taxQuery.data?.federalTaxDetails\n const showTwoPercentShareholder = federalTaxDetails?.taxableAsScorp === true\n const showStateWc = currentWorkAddress?.state === 'WA'\n\n const currentJob = useMemo(() => findJob(employeeJobs, jobId), [employeeJobs, jobId])\n const isCreateMode = !jobId\n const mode = isCreateMode ? 'create' : 'update'\n\n const [schema, metadataConfig] = useMemo(\n () => createJobSchema({ mode, optionalFieldsToRequire, withHireDateField }),\n [mode, optionalFieldsToRequire, withHireDateField],\n )\n\n const resolvedDefaults: JobFormData = useMemo(\n () => ({\n title: currentJob?.title ?? partnerDefaults?.title ?? '',\n hireDate: currentJob?.hireDate ?? partnerDefaults?.hireDate ?? null,\n twoPercentShareholder:\n currentJob?.twoPercentShareholder ?? partnerDefaults?.twoPercentShareholder ?? false,\n stateWcCovered: currentJob?.stateWcCovered ?? partnerDefaults?.stateWcCovered ?? false,\n stateWcClassCode: currentJob?.stateWcClassCode ?? partnerDefaults?.stateWcClassCode ?? '',\n }),\n [currentJob, partnerDefaults],\n )\n\n const formMethods = useForm<JobFormData, unknown, JobFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const watchedStateWcCovered = useWatch({ control: formMethods.control, name: 'stateWcCovered' })\n\n const createJobMutation = useJobsAndCompensationsCreateJobMutation()\n const updateJobMutation = useJobsAndCompensationsUpdateMutation()\n const isPending = createJobMutation.isPending || updateJobMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('JobForm')\n\n const queriesForErrors = employeeId ? [jobsQuery, addressesQuery, employeeQuery, taxQuery] : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const stateWcClassCodeOptions = WA_RISK_CLASS_CODES.map(({ code, description }) => ({\n value: code,\n label: `${code}: ${description}`,\n }))\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = {\n title: baseMetadata.title,\n hireDate: baseMetadata.hireDate,\n twoPercentShareholder: {\n ...baseMetadata.twoPercentShareholder,\n isDisabled: !showTwoPercentShareholder,\n },\n stateWcCovered: withOptions<boolean>(\n { ...baseMetadata.stateWcCovered, isDisabled: !showStateWc },\n [\n { label: 'Yes', value: 'true' },\n { label: 'No', value: 'false' },\n ],\n [true, false],\n ),\n stateWcClassCode: withOptions<WARiskClassCode>(\n { ...baseMetadata.stateWcClassCode, isDisabled: !showStateWc },\n stateWcClassCodeOptions,\n WA_RISK_CLASS_CODES,\n ),\n }\n\n const onSubmit = async (\n options?: JobSubmitOptions,\n ): Promise<HookSubmitResult<Job> | undefined> => {\n let submitResult: HookSubmitResult<Job> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: JobFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedEmployeeId = options?.employeeId ?? employeeId\n if (!resolvedEmployeeId) {\n throw new SDKInternalError('employeeId is required to submit a job')\n }\n\n const stateWcClassCode = payload.stateWcCovered ? payload.stateWcClassCode : null\n\n // Mirror the work/home address pattern: when the field is rendered\n // the payload value wins; when it isn't, fall back to a submit-time\n // override (`options.hireDate`), then to the loaded job's existing\n // value on update mode. Create mode requires a resolved value —\n // hireDate is mandatory on POST /v1/employees/:id/jobs.\n const resolvedHireDate =\n withHireDateField && payload.hireDate\n ? payload.hireDate\n : (options?.hireDate ?? currentJob?.hireDate ?? null)\n\n let updatedJob: Job\n\n if (isCreateMode) {\n if (!resolvedHireDate) {\n throw new SDKInternalError(\n withHireDateField\n ? 'hireDate is required to create a job'\n : 'hireDate is required to create a job. Pass it via JobSubmitOptions when withHireDateField is false.',\n )\n }\n const result = await createJobMutation.mutateAsync({\n request: {\n employeeId: resolvedEmployeeId,\n jobsCreateRequestBody: {\n title: payload.title,\n hireDate: resolvedHireDate,\n twoPercentShareholder: payload.twoPercentShareholder,\n stateWcCovered: payload.stateWcCovered,\n stateWcClassCode,\n },\n },\n })\n if (!result.job) {\n throw new SDKInternalError('Job creation failed')\n }\n updatedJob = result.job\n } else {\n if (!currentJob) {\n throw new SDKInternalError('Cannot update job: no matching job on file')\n }\n const result = await updateJobMutation.mutateAsync({\n request: {\n jobId: currentJob.uuid,\n jobsUpdateRequestBody: {\n version: currentJob.version as string,\n title: payload.title,\n hireDate: resolvedHireDate ?? undefined,\n twoPercentShareholder: payload.twoPercentShareholder,\n stateWcCovered: payload.stateWcCovered,\n stateWcClassCode,\n },\n },\n })\n if (!result.job) {\n throw new SDKInternalError('Job update failed')\n }\n updatedJob = result.job\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: updatedJob,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const isDataLoading = employeeId\n ? jobsQuery.isLoading || addressesQuery.isLoading || employeeQuery.isLoading\n : false\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (isDataLoading || (employeeId && (!employeeJobs || !employee))) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n currentJob,\n jobs: employeeJobs,\n employee,\n currentWorkAddress,\n showTwoPercentShareholder,\n showStateWc,\n },\n status: {\n isPending,\n mode: isCreateMode ? 'create' : 'update',\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Title: JobTitleField,\n HireDate: withHireDateField ? HireDateField : undefined,\n TwoPercentShareholder: showTwoPercentShareholder ? TwoPercentShareholderField : undefined,\n StateWcCovered: showStateWc ? StateWcCoveredField : undefined,\n StateWcClassCode: showStateWc && watchedStateWcCovered ? StateWcClassCodeField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\nexport type UseJobFormResult = HookLoadingResult | UseJobFormReady\nexport type JobFieldsMetadata = UseJobFormReady['form']['fieldsMetadata']\n"],"names":["findJob","jobs","jobId","j","useJobForm","employeeId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","withHireDateField","jobsQuery","useJobsAndCompensationsGetJobs","addressesQuery","useEmployeeAddressesGetWorkAddresses","employeeQuery","useEmployeesGet","employeeJobs","currentWorkAddress","address","employee","companyUuid","taxQuery","useFederalTaxDetailsGet","showTwoPercentShareholder","showStateWc","currentJob","useMemo","isCreateMode","mode","schema","metadataConfig","createJobSchema","resolvedDefaults","formMethods","useForm","zodResolver","watchedStateWcCovered","useWatch","createJobMutation","useJobsAndCompensationsCreateJobMutation","updateJobMutation","useJobsAndCompensationsUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","stateWcClassCodeOptions","WA_RISK_CLASS_CODES","code","description","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","withOptions","onSubmit","options","submitResult","resolve","data","payload","resolvedEmployeeId","SDKInternalError","stateWcClassCode","resolvedHireDate","updatedJob","result","isDataLoading","hookFormInternals","useHookFormInternals","JobTitleField","HireDateField","TwoPercentShareholderField","StateWcCoveredField","StateWcClassCodeField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;AA6GA,SAASA,GAAQC,GAAyBC,GAAuC;AAC/E,SAAI,CAACD,KAAQ,CAACC,IAAc,OACrBD,EAAK,KAAK,CAAAE,MAAKA,EAAE,SAASD,CAAK,KAAK;AAC7C;AAEO,SAASE,GAAW;AAAA,EACzB,YAAAC;AAAA,EACA,OAA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AAgBlD,IAAcmD,KAAsB;AAAA,QACpD,kBAAkBnD,KAAeY,IAAwBwC,KAAwB;AAAA,MAAA;AAAA,MAEnF,gBAAArB;AAAA,MACA,mBAAAe;AAAA,MACA,yBAAyBO,GAA8B5C,GAAaJ,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
1
+ {"version":3,"file":"useJobForm.js","sources":["../../../../../../src/components/Employee/Compensation/shared/useJobForm/useJobForm.tsx"],"sourcesContent":["import { useMemo } from 'react'\nimport { useForm, useWatch } from 'react-hook-form'\nimport type { UseFormProps } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport type { Job } from '@gusto/embedded-api/models/components/job'\nimport type { Employee } from '@gusto/embedded-api/models/components/employee'\nimport type { EmployeeWorkAddress } from '@gusto/embedded-api/models/components/employeeworkaddress'\nimport { useJobsAndCompensationsGetJobs } from '@gusto/embedded-api/react-query/jobsAndCompensationsGetJobs'\nimport { useJobsAndCompensationsCreateJobMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsCreateJob'\nimport { useJobsAndCompensationsUpdateMutation } from '@gusto/embedded-api/react-query/jobsAndCompensationsUpdate'\nimport { useEmployeeAddressesGetWorkAddresses } from '@gusto/embedded-api/react-query/employeeAddressesGetWorkAddresses'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport { useFederalTaxDetailsGet } from '@gusto/embedded-api/react-query/federalTaxDetailsGet'\nimport {\n createJobSchema,\n type JobOptionalFieldsToRequire,\n type JobFormData,\n type JobFormOutputs,\n} from './jobSchema'\nimport {\n JobTitleField,\n HireDateField,\n TwoPercentShareholderField,\n StateWcCoveredField,\n StateWcClassCodeField,\n} from './fields'\nimport { useDeriveFieldsMetadata } from '@/partner-hook-utils/form/useDeriveFieldsMetadata'\nimport { useHookFormInternals } from '@/partner-hook-utils/form/useHookFormInternals'\nimport { createGetFormSubmissionValues } from '@/partner-hook-utils/form/getFormSubmissionValues'\nimport { withOptions } from '@/partner-hook-utils/form/withOptions'\nimport { composeErrorHandler } from '@/partner-hook-utils/composeErrorHandler'\nimport type {\n BaseFormHookReady,\n FieldsMetadata,\n HookLoadingResult,\n HookSubmitResult,\n} from '@/partner-hook-utils/types'\nimport { useBaseSubmit } from '@/components/Base/useBaseSubmit'\nimport { SDKInternalError } from '@/types/sdkError'\nimport { WA_RISK_CLASS_CODES, type WARiskClassCode } from '@/models/WA_RISK_CODES'\n\nexport interface JobSubmitOptions {\n /** Override the `employeeId` configured at hook construction. Useful when the employee is created in the same submit chain. */\n employeeId?: string\n /**\n * Supply `hireDate` at submit time rather than via a rendered field. Use\n * with `withHireDateField: false` for screens that derive hireDate from\n * external context (e.g. the employee's `startDate` during onboarding).\n * Falls back to the loaded job's `hireDate` on update mode when omitted;\n * required (or sourced from a partner default) on create mode.\n */\n hireDate?: string\n}\n\nexport interface UseJobFormProps {\n employeeId?: string\n /** Present → update mode (PUT /v1/jobs/:id with `version`). Omitted → create mode (POST /v1/employees/:id/jobs). */\n jobId?: string\n optionalFieldsToRequire?: JobOptionalFieldsToRequire\n defaultValues?: Partial<JobFormData>\n validationMode?: UseFormProps['mode']\n shouldFocusError?: boolean\n /**\n * When `false`, hides `Fields.HireDate` (becomes `undefined`) and removes\n * `hireDate` from schema validation. Partners supply the value via\n * `JobSubmitOptions.hireDate` at submit time, or rely on the loaded job's\n * existing value on update. Use this when the date is driven by external\n * context rather than user input (e.g. the employee's `startDate`).\n * Defaults to `true`.\n */\n withHireDateField?: boolean\n /**\n * When `false`, hides `Fields.Title` (becomes `undefined`), removes\n * `title` from schema validation, and skips sending `title` on PUT/POST.\n * Use this when another form owns the title field — e.g. steady-state\n * compensation edits render title via `CompFields.Title` so a title\n * change is effective-dated alongside the rest of the compensation\n * change, rather than overwriting the job's current title immediately.\n * Defaults to `true`.\n */\n withTitleField?: boolean\n}\n\nexport interface JobFormFields {\n Title: typeof JobTitleField | undefined\n HireDate: typeof HireDateField | undefined\n TwoPercentShareholder: typeof TwoPercentShareholderField | undefined\n StateWcCovered: typeof StateWcCoveredField | undefined\n StateWcClassCode: typeof StateWcClassCodeField | undefined\n}\n\nexport interface UseJobFormReady extends BaseFormHookReady<\n FieldsMetadata,\n JobFormData,\n JobFormFields\n> {\n data: {\n /** The job row loaded for update; `null` in create mode. */\n currentJob: Job | null\n /** All jobs for the employee, when employeeId is set. Useful for screen-level cross-checks across jobs. */\n jobs: Job[] | undefined\n employee: Employee | null\n currentWorkAddress: EmployeeWorkAddress | null\n /** True when the company is taxable as an S-Corp; partners use this to decide whether to render `TwoPercentShareholder`. */\n showTwoPercentShareholder: boolean\n /**\n * True when the active work-address state is WA; partners use this to decide whether to render\n * `StateWcCovered`. `Fields.StateWcClassCode` is additionally gated on `stateWcCovered === true`,\n * so partners typically only need to check `Fields.StateWcCovered` / `Fields.StateWcClassCode`\n * truthiness rather than this flag directly.\n */\n showStateWc: boolean\n }\n status: { isPending: boolean; mode: 'create' | 'update' }\n actions: {\n onSubmit: (options?: JobSubmitOptions) => Promise<HookSubmitResult<Job> | undefined>\n }\n}\n\nfunction findJob(jobs: Job[] | undefined, jobId: string | undefined): Job | null {\n if (!jobs || !jobId) return null\n return jobs.find(j => j.uuid === jobId) ?? null\n}\n\nexport function useJobForm({\n employeeId,\n jobId,\n optionalFieldsToRequire,\n defaultValues: partnerDefaults,\n validationMode = 'onSubmit',\n shouldFocusError = true,\n withHireDateField = true,\n withTitleField = true,\n}: UseJobFormProps): HookLoadingResult | UseJobFormReady {\n const jobsQuery = useJobsAndCompensationsGetJobs(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const addressesQuery = useEmployeeAddressesGetWorkAddresses(\n { employeeId: employeeId ?? '' },\n { enabled: !!employeeId },\n )\n const employeeQuery = useEmployeesGet({ employeeId: employeeId ?? '' }, { enabled: !!employeeId })\n\n const employeeJobs = jobsQuery.data?.jobs\n const workAddresses = addressesQuery.data?.employeeWorkAddressesList\n const currentWorkAddress = workAddresses?.find(address => address.active) ?? null\n const employee = employeeQuery.data?.employee ?? null\n const companyUuid = employee?.companyUuid\n\n const taxQuery = useFederalTaxDetailsGet(\n { companyId: companyUuid ?? '' },\n { enabled: !!companyUuid },\n )\n const federalTaxDetails = taxQuery.data?.federalTaxDetails\n const showTwoPercentShareholder = federalTaxDetails?.taxableAsScorp === true\n const showStateWc = currentWorkAddress?.state === 'WA'\n\n const currentJob = useMemo(() => findJob(employeeJobs, jobId), [employeeJobs, jobId])\n const isCreateMode = !jobId\n const mode = isCreateMode ? 'create' : 'update'\n\n const [schema, metadataConfig] = useMemo(\n () => createJobSchema({ mode, optionalFieldsToRequire, withHireDateField, withTitleField }),\n [mode, optionalFieldsToRequire, withHireDateField, withTitleField],\n )\n\n const resolvedDefaults: JobFormData = useMemo(\n () => ({\n title: currentJob?.title ?? partnerDefaults?.title ?? '',\n hireDate: currentJob?.hireDate ?? partnerDefaults?.hireDate ?? null,\n twoPercentShareholder:\n currentJob?.twoPercentShareholder ?? partnerDefaults?.twoPercentShareholder ?? false,\n stateWcCovered: currentJob?.stateWcCovered ?? partnerDefaults?.stateWcCovered ?? false,\n stateWcClassCode: currentJob?.stateWcClassCode ?? partnerDefaults?.stateWcClassCode ?? '',\n }),\n [currentJob, partnerDefaults],\n )\n\n const formMethods = useForm<JobFormData, unknown, JobFormOutputs>({\n resolver: zodResolver(schema),\n mode: validationMode,\n shouldFocusError,\n defaultValues: resolvedDefaults,\n values: resolvedDefaults,\n resetOptions: { keepDirtyValues: true },\n })\n\n const watchedStateWcCovered = useWatch({ control: formMethods.control, name: 'stateWcCovered' })\n\n const createJobMutation = useJobsAndCompensationsCreateJobMutation()\n const updateJobMutation = useJobsAndCompensationsUpdateMutation()\n const isPending = createJobMutation.isPending || updateJobMutation.isPending\n\n const {\n baseSubmitHandler,\n error: submitError,\n setError: setSubmitError,\n } = useBaseSubmit('JobForm')\n\n const queriesForErrors = employeeId ? [jobsQuery, addressesQuery, employeeQuery, taxQuery] : []\n const errorHandling = composeErrorHandler(queriesForErrors, { submitError, setSubmitError })\n\n const stateWcClassCodeOptions = WA_RISK_CLASS_CODES.map(({ code, description }) => ({\n value: code,\n label: `${code}: ${description}`,\n }))\n\n const baseMetadata = useDeriveFieldsMetadata(metadataConfig, formMethods.control)\n const fieldsMetadata = {\n title: baseMetadata.title,\n hireDate: baseMetadata.hireDate,\n twoPercentShareholder: {\n ...baseMetadata.twoPercentShareholder,\n isDisabled: !showTwoPercentShareholder,\n },\n stateWcCovered: withOptions<boolean>(\n { ...baseMetadata.stateWcCovered, isDisabled: !showStateWc },\n [\n { label: 'Yes', value: 'true' },\n { label: 'No', value: 'false' },\n ],\n [true, false],\n ),\n stateWcClassCode: withOptions<WARiskClassCode>(\n { ...baseMetadata.stateWcClassCode, isDisabled: !showStateWc },\n stateWcClassCodeOptions,\n WA_RISK_CLASS_CODES,\n ),\n }\n\n const onSubmit = async (\n options?: JobSubmitOptions,\n ): Promise<HookSubmitResult<Job> | undefined> => {\n let submitResult: HookSubmitResult<Job> | undefined\n\n await new Promise<void>(resolve => {\n void formMethods.handleSubmit(\n async (data: JobFormOutputs) => {\n await baseSubmitHandler(data, async payload => {\n const resolvedEmployeeId = options?.employeeId ?? employeeId\n if (!resolvedEmployeeId) {\n throw new SDKInternalError('employeeId is required to submit a job')\n }\n\n const stateWcClassCode = payload.stateWcCovered ? payload.stateWcClassCode : null\n\n // Mirror the work/home address pattern: when the field is rendered\n // the payload value wins; when it isn't, fall back to a submit-time\n // override (`options.hireDate`), then to the loaded job's existing\n // value on update mode. Create mode requires a resolved value —\n // hireDate is mandatory on POST /v1/employees/:id/jobs.\n const resolvedHireDate =\n withHireDateField && payload.hireDate\n ? payload.hireDate\n : (options?.hireDate ?? currentJob?.hireDate ?? null)\n\n // When the title field is suppressed (steady-state edits drive\n // title through useCompensationForm), omit it from the body so\n // the server preserves the existing value rather than clobbering\n // it with whatever sat in form state.\n const titleToSend = withTitleField ? payload.title : undefined\n\n let updatedJob: Job\n\n if (isCreateMode) {\n if (!resolvedHireDate) {\n throw new SDKInternalError(\n withHireDateField\n ? 'hireDate is required to create a job'\n : 'hireDate is required to create a job. Pass it via JobSubmitOptions when withHireDateField is false.',\n )\n }\n if (titleToSend === undefined) {\n throw new SDKInternalError(\n 'title is required to create a job. Set withTitleField: true (the default) on useJobForm for create flows.',\n )\n }\n const result = await createJobMutation.mutateAsync({\n request: {\n employeeId: resolvedEmployeeId,\n jobsCreateRequestBody: {\n title: titleToSend,\n hireDate: resolvedHireDate,\n twoPercentShareholder: payload.twoPercentShareholder,\n stateWcCovered: payload.stateWcCovered,\n stateWcClassCode,\n },\n },\n })\n if (!result.job) {\n throw new SDKInternalError('Job creation failed')\n }\n updatedJob = result.job\n } else {\n if (!currentJob) {\n throw new SDKInternalError('Cannot update job: no matching job on file')\n }\n const result = await updateJobMutation.mutateAsync({\n request: {\n jobId: currentJob.uuid,\n jobsUpdateRequestBody: {\n version: currentJob.version as string,\n title: titleToSend,\n hireDate: resolvedHireDate ?? undefined,\n twoPercentShareholder: payload.twoPercentShareholder,\n stateWcCovered: payload.stateWcCovered,\n stateWcClassCode,\n },\n },\n })\n if (!result.job) {\n throw new SDKInternalError('Job update failed')\n }\n updatedJob = result.job\n }\n\n submitResult = {\n mode: isCreateMode ? 'create' : 'update',\n data: updatedJob,\n }\n })\n resolve()\n },\n () => {\n resolve()\n },\n )()\n })\n\n return submitResult\n }\n\n const isDataLoading = employeeId\n ? jobsQuery.isLoading || addressesQuery.isLoading || employeeQuery.isLoading\n : false\n\n const hookFormInternals = useHookFormInternals(formMethods)\n\n if (isDataLoading || (employeeId && (!employeeJobs || !employee))) {\n return { isLoading: true as const, errorHandling }\n }\n\n return {\n isLoading: false as const,\n data: {\n currentJob,\n jobs: employeeJobs,\n employee,\n currentWorkAddress,\n showTwoPercentShareholder,\n showStateWc,\n },\n status: {\n isPending,\n mode: isCreateMode ? 'create' : 'update',\n },\n actions: { onSubmit },\n errorHandling,\n form: {\n Fields: {\n Title: withTitleField ? JobTitleField : undefined,\n HireDate: withHireDateField ? HireDateField : undefined,\n TwoPercentShareholder: showTwoPercentShareholder ? TwoPercentShareholderField : undefined,\n StateWcCovered: showStateWc ? StateWcCoveredField : undefined,\n StateWcClassCode: showStateWc && watchedStateWcCovered ? StateWcClassCodeField : undefined,\n },\n fieldsMetadata,\n hookFormInternals,\n getFormSubmissionValues: createGetFormSubmissionValues(formMethods, schema),\n },\n }\n}\n\nexport type UseJobFormResult = HookLoadingResult | UseJobFormReady\nexport type JobFieldsMetadata = UseJobFormReady['form']['fieldsMetadata']\n"],"names":["findJob","jobs","jobId","j","useJobForm","employeeId","optionalFieldsToRequire","partnerDefaults","validationMode","shouldFocusError","withHireDateField","withTitleField","jobsQuery","useJobsAndCompensationsGetJobs","addressesQuery","useEmployeeAddressesGetWorkAddresses","employeeQuery","useEmployeesGet","employeeJobs","currentWorkAddress","address","employee","companyUuid","taxQuery","useFederalTaxDetailsGet","showTwoPercentShareholder","showStateWc","currentJob","useMemo","isCreateMode","mode","schema","metadataConfig","createJobSchema","resolvedDefaults","formMethods","useForm","zodResolver","watchedStateWcCovered","useWatch","createJobMutation","useJobsAndCompensationsCreateJobMutation","updateJobMutation","useJobsAndCompensationsUpdateMutation","isPending","baseSubmitHandler","submitError","setSubmitError","useBaseSubmit","errorHandling","composeErrorHandler","stateWcClassCodeOptions","WA_RISK_CLASS_CODES","code","description","baseMetadata","useDeriveFieldsMetadata","fieldsMetadata","withOptions","onSubmit","options","submitResult","resolve","data","payload","resolvedEmployeeId","SDKInternalError","stateWcClassCode","resolvedHireDate","titleToSend","updatedJob","result","isDataLoading","hookFormInternals","useHookFormInternals","JobTitleField","HireDateField","TwoPercentShareholderField","StateWcCoveredField","StateWcClassCodeField","createGetFormSubmissionValues"],"mappings":";;;;;;;;;;;;;;;;;;;AAuHA,SAASA,GAAQC,GAAyBC,GAAuC;AAC/E,SAAI,CAACD,KAAQ,CAACC,IAAc,OACrBD,EAAK,KAAK,CAAAE,MAAKA,EAAE,SAASD,CAAK,KA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A,IAAA;AAAA,IAElC,SAAS,EAAE,UAAA8B,EAAA;AAAA,IACX,eAAAV;AAAA,IACA,MAAM;AAAA,MACJ,QAAQ;AAAA,QACN,OAAOtC,IAAiBgE,KAAgB;AAAA,QACxC,UAAUjE,IAAoBkE,KAAgB;AAAA,QAC9C,uBAAuBnD,IAA4BoD,KAA6B;AAAA,QAChF,gBAAgBnD,IAAcoD,KAAsB;AAAA,QACpD,kBAAkBpD,KAAeY,IAAwByC,KAAwB;AAAA,MAAA;AAAA,MAEnF,gBAAAtB;AAAA,MACA,mBAAAgB;AAAA,MACA,yBAAyBO,GAA8B7C,GAAaJ,CAAM;AAAA,IAAA;AAAA,EAC5E;AAEJ;"}
@@ -5,7 +5,12 @@ export interface BasicDetailsViewProps {
5
5
  employee?: Employee;
6
6
  currentHomeAddress?: EmployeeAddress;
7
7
  currentWorkAddress?: EmployeeWorkAddress;
8
+ /** Loads all three cards. Per-section flags below take precedence
9
+ * when each query resolves independently. */
8
10
  isLoading?: boolean;
11
+ isEmployeeLoading?: boolean;
12
+ isHomeAddressLoading?: boolean;
13
+ isWorkAddressLoading?: boolean;
9
14
  onEditBasicDetails?: () => void;
10
15
  onManageHomeAddress?: () => void;
11
16
  onManageWorkAddress?: () => void;
@@ -19,8 +24,8 @@ export interface BasicDetailsViewWithDataProps {
19
24
  /**
20
25
  * Tab-mounted container for the Basic details tab. Owns the
21
26
  * `useEmployeeBasicDetails` fetch (employee + home address + work address)
22
- * so the requests only fire when the tab is mounted. The presentational
23
- * `BasicDetailsView` stays pure for testing/stories.
27
+ * so the requests only fire when the tab is mounted. Each card paints
28
+ * its own skeleton + content as the underlying query resolves.
24
29
  */
25
30
  export declare function BasicDetailsViewWithData({ employeeId, onEditBasicDetails, onManageHomeAddress, onManageWorkAddress, }: BasicDetailsViewWithDataProps): import("react/jsx-runtime").JSX.Element;
26
- export declare function BasicDetailsView({ employee, currentHomeAddress, currentWorkAddress, isLoading, onEditBasicDetails, onManageHomeAddress, onManageWorkAddress, }: BasicDetailsViewProps): import("react/jsx-runtime").JSX.Element;
31
+ export declare function BasicDetailsView({ employee, currentHomeAddress, currentWorkAddress, isLoading, isEmployeeLoading, isHomeAddressLoading, isWorkAddressLoading, onEditBasicDetails, onManageHomeAddress, onManageWorkAddress, }: BasicDetailsViewProps): import("react/jsx-runtime").JSX.Element;