@gusto/embedded-react-sdk 0.10.2 → 0.10.3-rc.2

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 (74) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/components/Base/Base.d.ts +3 -2
  3. package/dist/components/Base/Base.js +31 -31
  4. package/dist/components/Base/Base.js.map +1 -1
  5. package/dist/components/Company/BankAccount/BankAccountComponents.js +16 -9
  6. package/dist/components/Company/BankAccount/BankAccountComponents.js.map +1 -1
  7. package/dist/components/Company/BankAccount/BankAccountForm/Actions.js +22 -8
  8. package/dist/components/Company/BankAccount/BankAccountForm/Actions.js.map +1 -1
  9. package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.d.ts +1 -0
  10. package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.js +23 -25
  11. package/dist/components/Company/BankAccount/BankAccountForm/BankAccountForm.js.map +1 -1
  12. package/dist/components/Company/BankAccount/BankAccountForm/context.d.ts +4 -0
  13. package/dist/components/Company/BankAccount/BankAccountForm/context.js.map +1 -1
  14. package/dist/components/Company/BankAccount/BankAccountList/AccountView.js +14 -13
  15. package/dist/components/Company/BankAccount/BankAccountList/AccountView.js.map +1 -1
  16. package/dist/components/Company/BankAccount/stateMachine.d.ts +1 -1
  17. package/dist/components/Company/BankAccount/stateMachine.js +13 -5
  18. package/dist/components/Company/BankAccount/stateMachine.js.map +1 -1
  19. package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js +41 -42
  20. package/dist/components/Company/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
  21. package/dist/components/Company/FederalTaxes/Head.js +11 -11
  22. package/dist/components/Company/FederalTaxes/Head.js.map +1 -1
  23. package/dist/components/Company/Industry/Industry.js +30 -31
  24. package/dist/components/Company/Industry/Industry.js.map +1 -1
  25. package/dist/components/Company/Locations/LocationForm/LocationForm.js +34 -37
  26. package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
  27. package/dist/components/Company/Locations/Locations.d.ts +1 -1
  28. package/dist/components/Company/Locations/Locations.js +19 -17
  29. package/dist/components/Company/Locations/Locations.js.map +1 -1
  30. package/dist/components/Company/Locations/LocationsList/List.js +5 -2
  31. package/dist/components/Company/Locations/LocationsList/List.js.map +1 -1
  32. package/dist/components/Company/PaySchedule/PaySchedule.js +70 -71
  33. package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
  34. package/dist/components/Contractor/Address/Address.js +37 -38
  35. package/dist/components/Contractor/Address/Address.js.map +1 -1
  36. package/dist/components/Contractor/List/index.js +47 -50
  37. package/dist/components/Contractor/List/index.js.map +1 -1
  38. package/dist/components/Contractor/NewHireReport/NewHireReport.js +57 -58
  39. package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
  40. package/dist/components/Employee/Compensation/Compensation.js +123 -132
  41. package/dist/components/Employee/Compensation/Compensation.js.map +1 -1
  42. package/dist/components/Employee/Deductions/Deductions.js +74 -79
  43. package/dist/components/Employee/Deductions/Deductions.js.map +1 -1
  44. package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js +36 -42
  45. package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
  46. package/dist/components/Employee/EmployeeList/EmployeeList.js +57 -58
  47. package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
  48. package/dist/components/Employee/PaymentMethod/PaymentMethod.js +95 -97
  49. package/dist/components/Employee/PaymentMethod/PaymentMethod.js.map +1 -1
  50. package/dist/components/Employee/Profile/Profile.js +118 -124
  51. package/dist/components/Employee/Profile/Profile.js.map +1 -1
  52. package/dist/components/Employee/Taxes/FederalForm.js +4 -4
  53. package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
  54. package/dist/components/Employee/Taxes/Taxes.js +59 -60
  55. package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
  56. package/dist/contexts/ApiProvider/ApiProvider.js +16 -14
  57. package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
  58. package/dist/contexts/ComponentAdapter/componentAdapterTypes.d.ts +5 -0
  59. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +2 -0
  60. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +19 -17
  61. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
  62. package/dist/contexts/LoadingIndicatorProvider/LoadingIndicatorProvider.d.ts +7 -0
  63. package/dist/contexts/LoadingIndicatorProvider/LoadingIndicatorProvider.js +10 -0
  64. package/dist/contexts/LoadingIndicatorProvider/LoadingIndicatorProvider.js.map +1 -0
  65. package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.d.ts +6 -0
  66. package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.js +11 -0
  67. package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.js.map +1 -0
  68. package/dist/i18n/en/Company.Locations.json.js +2 -2
  69. package/dist/shared/constants.d.ts +2 -0
  70. package/dist/shared/constants.js +10 -9
  71. package/dist/shared/constants.js.map +1 -1
  72. package/dist/style.css +1 -1
  73. package/dist/types/i18next.d.ts +1 -1
  74. package/package.json +8 -1
@@ -1,40 +1,39 @@
1
1
  import { jsx as t, jsxs as k } from "react/jsx-runtime";
2
- import { useForm as z, FormProvider as Q } from "react-hook-form";
2
+ import { useForm as G, FormProvider as z } from "react-hook-form";
3
3
  import { zodResolver as J } from "@hookform/resolvers/zod";
4
4
  import { useState as p, useEffect as w } from "react";
5
5
  import { usePaySchedulesGetPreview as K } from "@gusto/embedded-api/react-query/paySchedulesGetPreview";
6
- import { usePaySchedulesUpdateMutation as W } from "@gusto/embedded-api/react-query/paySchedulesUpdate";
7
- import { usePaySchedulesGetAllSuspense as X, invalidateAllPaySchedulesGetAll as Z } from "@gusto/embedded-api/react-query/paySchedulesGetAll";
8
- import { usePaySchedulesCreateMutation as $ } from "@gusto/embedded-api/react-query/paySchedulesCreate";
9
- import { useQueryClient as V } from "@tanstack/react-query";
10
- import { PayScheduleSchema as ee, PayScheduleProvider as oe } from "./usePaySchedule.js";
11
- import { Form as ae } from "../../Common/Form/Form.js";
12
- import { BaseComponent as re } from "../../Base/Base.js";
13
- import { useBase as te } from "../../Base/useBase.js";
14
- import { Flex as ne } from "../../Common/Flex/Flex.js";
15
- import { useI18n as ce, useComponentDictionary as ie } from "../../../i18n/I18n.js";
16
- import { componentEvents as A } from "../../../shared/constants.js";
17
- import { formatDateToStringDate as de } from "../../../helpers/dateFormatting.js";
18
- import { Head as C } from "./_parts/Head.js";
19
- import { List as _ } from "./_parts/List.js";
6
+ import { usePaySchedulesUpdateMutation as Q } from "@gusto/embedded-api/react-query/paySchedulesUpdate";
7
+ import { usePaySchedulesGetAllSuspense as W } from "@gusto/embedded-api/react-query/paySchedulesGetAll";
8
+ import { usePaySchedulesCreateMutation as X } from "@gusto/embedded-api/react-query/paySchedulesCreate";
9
+ import { PayScheduleSchema as Z, PayScheduleProvider as $ } from "./usePaySchedule.js";
10
+ import { Form as V } from "../../Common/Form/Form.js";
11
+ import { BaseComponent as ee } from "../../Base/Base.js";
12
+ import { useBase as oe } from "../../Base/useBase.js";
13
+ import { Flex as re } from "../../Common/Flex/Flex.js";
14
+ import { useI18n as ae, useComponentDictionary as te } from "../../../i18n/I18n.js";
15
+ import { componentEvents as q } from "../../../shared/constants.js";
16
+ import { formatDateToStringDate as ne } from "../../../helpers/dateFormatting.js";
17
+ import { Head as _ } from "./_parts/Head.js";
18
+ import { List as C } from "./_parts/List.js";
20
19
  import { Edit as L } from "./_parts/Edit.js";
21
20
  import { Actions as O } from "./_parts/Actions.js";
22
21
  const f = ({
23
22
  companyId: n,
24
23
  defaultValues: P,
25
- dictionary: r,
24
+ dictionary: a,
26
25
  ...m
27
- }) => (ce("Company.PaySchedule"), ie("Company.PaySchedule", r), /* @__PURE__ */ t(re, { ...m, children: /* @__PURE__ */ t(ye, { companyId: n, defaultValues: P, children: m.children }) })), ye = ({ companyId: n, children: P, defaultValues: r }) => {
28
- const m = V(), { baseSubmitHandler: T, onEvent: E, fieldErrors: D } = te(), [S, u] = p("LIST_PAY_SCHEDULES"), [i, H] = p(null), M = {
29
- frequency: r?.frequency ?? "Every week",
30
- anchorPayDate: r?.anchorPayDate ? new Date(r.anchorPayDate) : void 0,
31
- anchorEndOfPayPeriod: r?.anchorEndOfPayPeriod ? new Date(r.anchorEndOfPayPeriod) : void 0,
32
- day1: r?.day1 ?? void 0,
33
- day2: r?.day2 ?? void 0,
34
- customName: r?.customName ?? "",
26
+ }) => (ae("Company.PaySchedule"), te("Company.PaySchedule", a), /* @__PURE__ */ t(ee, { ...m, children: /* @__PURE__ */ t(ce, { companyId: n, defaultValues: P, children: m.children }) })), ce = ({ companyId: n, children: P, defaultValues: a }) => {
27
+ const { baseSubmitHandler: m, onEvent: E, fieldErrors: D } = oe(), [S, u] = p("LIST_PAY_SCHEDULES"), [i, T] = p(null), H = {
28
+ frequency: a?.frequency ?? "Every week",
29
+ anchorPayDate: a?.anchorPayDate ? new Date(a.anchorPayDate) : void 0,
30
+ anchorEndOfPayPeriod: a?.anchorEndOfPayPeriod ? new Date(a.anchorEndOfPayPeriod) : void 0,
31
+ day1: a?.day1 ?? void 0,
32
+ day2: a?.day2 ?? void 0,
33
+ customName: a?.customName ?? "",
35
34
  customTwicePerMonth: "false",
36
35
  payPeriodPreviewRange: 0
37
- }, [d, y] = p(null), { data: U, isLoading: Y } = K(
36
+ }, [d, y] = p(null), { data: M, isLoading: U } = K(
38
37
  {
39
38
  companyId: n,
40
39
  frequency: d?.frequency,
@@ -47,18 +46,18 @@ const f = ({
47
46
  enabled: !0
48
47
  }
49
48
  // Casting to non-null because we know it's not null from the enabled prop
50
- ), { data: N } = X({
49
+ ), { data: Y } = W({
51
50
  companyId: n
52
- }), g = $(), b = W(), l = z({
53
- resolver: J(ee),
54
- defaultValues: M
55
- }), { watch: R, setValue: v, reset: s, setError: q } = l;
51
+ }), N = X(), g = Q(), l = G({
52
+ resolver: J(Z),
53
+ defaultValues: H
54
+ }), { watch: b, setValue: v, reset: s, setError: A } = l;
56
55
  w(() => {
57
56
  D && D.forEach((o) => {
58
- q(o.key, { message: o.message });
57
+ A(o.key, { message: o.message });
59
58
  });
60
- }, [q, D]);
61
- const e = R();
59
+ }, [A, D]);
60
+ const e = b();
62
61
  w(() => {
63
62
  e.frequency === "Twice per month" && e.day1 === 15 && e.day2 === 31 && e.customTwicePerMonth === void 0 ? v("customTwicePerMonth", "1st15th") : e.frequency === "Twice per month" && e.customTwicePerMonth === void 0 && v("customTwicePerMonth", "custom");
64
63
  }, [e.frequency, e.day1, e.day2, v, e.customTwicePerMonth]), w(() => {
@@ -81,11 +80,11 @@ const f = ({
81
80
  i?.version,
82
81
  y
83
82
  ]);
84
- const x = () => {
83
+ const R = () => {
85
84
  u("ADD_PAY_SCHEDULE"), s({});
86
- }, B = () => {
85
+ }, x = () => {
87
86
  u("LIST_PAY_SCHEDULES"), s({}), y(null);
88
- }, F = (o) => {
87
+ }, B = (o) => {
89
88
  s({
90
89
  frequency: o.frequency,
91
90
  anchorPayDate: o.anchorPayDate ? new Date(o.anchorPayDate) : void 0,
@@ -93,74 +92,74 @@ const f = ({
93
92
  day1: o.day1 ?? void 0,
94
93
  day2: o.day2 ?? void 0,
95
94
  customName: o.customName ?? ""
96
- }), H(o), u("EDIT_PAY_SCHEDULE");
97
- }, j = () => {
98
- E(A.PAY_SCHEDULE_DONE);
99
- }, G = async (o) => {
100
- await T(o, async (a) => {
101
- const h = (c) => c && de(c) || "";
95
+ }), T(o), u("EDIT_PAY_SCHEDULE");
96
+ }, F = () => {
97
+ E(q.PAY_SCHEDULE_DONE);
98
+ }, j = async (o) => {
99
+ await m(o, async (r) => {
100
+ const h = (c) => c && ne(c) || "";
102
101
  if (S === "ADD_PAY_SCHEDULE") {
103
- const c = await g.mutateAsync({
102
+ const c = await N.mutateAsync({
104
103
  request: {
105
104
  companyId: n,
106
105
  requestBody: {
107
- frequency: a.frequency,
108
- anchorPayDate: h(a.anchorPayDate),
109
- anchorEndOfPayPeriod: h(a.anchorEndOfPayPeriod),
110
- customName: a.customName,
111
- day1: a.day1,
112
- day2: a.day2
106
+ frequency: r.frequency,
107
+ anchorPayDate: h(r.anchorPayDate),
108
+ anchorEndOfPayPeriod: h(r.anchorEndOfPayPeriod),
109
+ customName: r.customName,
110
+ day1: r.day1,
111
+ day2: r.day2
113
112
  }
114
113
  }
115
114
  });
116
- E(A.PAY_SCHEDULE_CREATED, c), s(), y(null);
115
+ E(q.PAY_SCHEDULE_CREATED, c), s(), y(null);
117
116
  } else if (S === "EDIT_PAY_SCHEDULE") {
118
- const c = i?.version, I = await b.mutateAsync({
117
+ const c = i?.version, I = await g.mutateAsync({
119
118
  request: {
120
119
  payScheduleId: i?.uuid,
121
120
  companyId: n,
122
121
  requestBody: {
123
- frequency: a.frequency,
124
- anchorPayDate: h(a.anchorPayDate),
125
- anchorEndOfPayPeriod: h(a.anchorEndOfPayPeriod),
126
- customName: a.customName,
127
- day1: a.day1,
128
- day2: a.day2,
122
+ frequency: r.frequency,
123
+ anchorPayDate: h(r.anchorPayDate),
124
+ anchorEndOfPayPeriod: h(r.anchorEndOfPayPeriod),
125
+ customName: r.customName,
126
+ day1: r.day1,
127
+ day2: r.day2,
129
128
  version: c
130
129
  }
131
130
  }
132
131
  });
133
- E(A.PAY_SCHEDULE_UPDATED, I), s(), y(null);
132
+ E(q.PAY_SCHEDULE_UPDATED, I), s(), y(null);
134
133
  }
135
- await Z(m), u("LIST_PAY_SCHEDULES");
134
+ u("LIST_PAY_SCHEDULES");
136
135
  });
137
136
  };
138
137
  return /* @__PURE__ */ t(
139
- oe,
138
+ $,
140
139
  {
141
140
  value: {
142
141
  companyId: n,
143
- handleAdd: x,
144
- handleEdit: F,
145
- handleCancel: B,
146
- handleContinue: j,
142
+ handleAdd: R,
143
+ handleEdit: B,
144
+ handleCancel: x,
145
+ handleContinue: F,
147
146
  mode: S,
148
- paySchedules: N.payScheduleList,
149
- payPeriodPreview: U?.object?.payPeriods,
150
- payPreviewLoading: Y,
147
+ paySchedules: Y.payScheduleList,
148
+ payPeriodPreview: M?.object?.payPeriods,
149
+ payPreviewLoading: U,
151
150
  currentPaySchedule: i
152
151
  },
153
- children: /* @__PURE__ */ t("span", { "data-testid": "pay-schedule-edit-form", children: /* @__PURE__ */ t(Q, { ...l, children: /* @__PURE__ */ t(ae, { onSubmit: l.handleSubmit(G), children: P || /* @__PURE__ */ k(ne, { flexDirection: "column", children: [
154
- /* @__PURE__ */ t(C, {}),
152
+ children: /* @__PURE__ */ t("span", { "data-testid": "pay-schedule-edit-form", children: /* @__PURE__ */ t(z, { ...l, children: /* @__PURE__ */ t(V, { onSubmit: l.handleSubmit(j), children: P || /* @__PURE__ */ k(re, { flexDirection: "column", children: [
155
153
  /* @__PURE__ */ t(_, {}),
154
+ /* @__PURE__ */ t(C, {}),
156
155
  /* @__PURE__ */ t(L, {}),
157
156
  /* @__PURE__ */ t(O, {})
158
157
  ] }) }) }) })
159
158
  }
160
159
  );
161
160
  };
162
- f.Head = C;
163
- f.List = _;
161
+ f.Head = _;
162
+ f.List = C;
164
163
  f.Edit = L;
165
164
  f.Actions = O;
166
165
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"PaySchedule.js","sources":["../../../../src/components/Company/PaySchedule/PaySchedule.tsx"],"sourcesContent":["import type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useEffect, useState } from 'react'\nimport { usePaySchedulesGetPreview } from '@gusto/embedded-api/react-query/paySchedulesGetPreview'\nimport { usePaySchedulesUpdateMutation } from '@gusto/embedded-api/react-query/paySchedulesUpdate'\nimport {\n usePaySchedulesGetAllSuspense,\n invalidateAllPaySchedulesGetAll,\n} from '@gusto/embedded-api/react-query/paySchedulesGetAll'\nimport { usePaySchedulesCreateMutation } from '@gusto/embedded-api/react-query/paySchedulesCreate'\nimport type { PayScheduleObject as PayScheduleType } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport { useQueryClient } from '@tanstack/react-query'\nimport type { Frequency } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayschedules'\nimport type { MODE, PayScheduleInputs, PayScheduleOutputs } from './usePaySchedule'\nimport {\n PayScheduleProvider,\n PayScheduleSchema,\n type PayScheduleDefaultValues,\n} from './usePaySchedule'\nimport { Actions, Edit, Head, List } from './_parts'\nimport { Form } from '@/components/Common/Form'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base'\nimport { BaseComponent, useBase } from '@/components/Base'\nimport { Flex } from '@/components/Common'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\ninterface PayScheduleProps extends CommonComponentInterface<'Company.PaySchedule'> {\n companyId: string\n defaultValues?: PayScheduleDefaultValues\n}\n\nexport const PaySchedule = ({\n companyId,\n defaultValues,\n dictionary,\n ...props\n}: PayScheduleProps & BaseComponentInterface) => {\n useI18n('Company.PaySchedule')\n useComponentDictionary('Company.PaySchedule', dictionary)\n return (\n <BaseComponent {...props}>\n <Root companyId={companyId} defaultValues={defaultValues}>\n {props.children}\n </Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ companyId, children, defaultValues }: PayScheduleProps) => {\n const queryClient = useQueryClient()\n const { baseSubmitHandler, onEvent, fieldErrors } = useBase()\n const [mode, setMode] = useState<MODE>('LIST_PAY_SCHEDULES')\n const [currentPaySchedule, setCurrentPaySchedule] = useState<PayScheduleType | null>(null)\n const transformedDefaultValues: PayScheduleInputs = {\n frequency: defaultValues?.frequency ?? 'Every week',\n anchorPayDate: defaultValues?.anchorPayDate ? new Date(defaultValues.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: defaultValues?.anchorEndOfPayPeriod\n ? new Date(defaultValues.anchorEndOfPayPeriod)\n : undefined,\n day1: defaultValues?.day1 ?? undefined,\n day2: defaultValues?.day2 ?? undefined,\n customName: defaultValues?.customName ?? '',\n customTwicePerMonth: 'false',\n payPeriodPreviewRange: 0,\n }\n\n const [payScheduleDraft, setPayScheduleDraft] = useState<PayScheduleType | null>(null)\n const { data: payPreviewData, isLoading } = usePaySchedulesGetPreview(\n {\n companyId,\n frequency: payScheduleDraft?.frequency as Frequency,\n anchorPayDate: payScheduleDraft?.anchorPayDate ?? '',\n anchorEndOfPayPeriod: payScheduleDraft?.anchorEndOfPayPeriod ?? '',\n day1: payScheduleDraft?.day1 ?? undefined,\n day2: payScheduleDraft?.day2 ?? undefined,\n },\n {\n enabled: true,\n }, // Casting to non-null because we know it's not null from the enabled prop\n )\n\n const { data: paySchedules } = usePaySchedulesGetAllSuspense({\n companyId,\n })\n\n const createPayScheduleMutation = usePaySchedulesCreateMutation()\n const updatePayScheduleMutation = usePaySchedulesUpdateMutation()\n\n const formMethods = useForm<PayScheduleInputs, unknown, PayScheduleOutputs>({\n resolver: zodResolver(PayScheduleSchema),\n defaultValues: transformedDefaultValues,\n })\n const { watch, setValue, reset, setError } = formMethods\n\n useEffect(() => {\n if (fieldErrors) {\n // TODO: These error messages are not being localized correctly\n fieldErrors.forEach(error => {\n setError(error.key as keyof PayScheduleInputs, { message: error.message })\n })\n }\n }, [setError, fieldErrors])\n\n const allValues = watch()\n\n // Set the custom_twice_per_month value based on the frequency and day_1 and day_2 values as it is not set by the API call\n useEffect(() => {\n if (\n allValues.frequency === 'Twice per month' &&\n allValues.day1 === 15 &&\n allValues.day2 === 31 &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `1st15th`)\n } else if (\n allValues.frequency === 'Twice per month' &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `custom`)\n }\n }, [allValues.frequency, allValues.day1, allValues.day2, setValue, allValues.customTwicePerMonth])\n\n useEffect(() => {\n // Don't update if dates are not set\n if (!allValues.anchorPayDate || !allValues.anchorEndOfPayPeriod) {\n return\n }\n\n setPayScheduleDraft({\n frequency: allValues.frequency,\n anchorPayDate: allValues.anchorPayDate.toString(),\n anchorEndOfPayPeriod: allValues.anchorEndOfPayPeriod.toString(),\n day1: allValues.day1 || undefined,\n day2: allValues.day2 || undefined,\n uuid: '',\n version: currentPaySchedule?.version || '', //TODO: This needs to be set to something\n })\n }, [\n allValues.anchorEndOfPayPeriod,\n allValues.anchorPayDate,\n allValues.day1,\n allValues.day2,\n allValues.frequency,\n currentPaySchedule?.version,\n setPayScheduleDraft,\n ])\n\n // Custom effect to show/hide pay schedule preview errors\n\n const handleAdd = () => {\n setMode('ADD_PAY_SCHEDULE')\n reset({})\n }\n const handleCancel = () => {\n setMode('LIST_PAY_SCHEDULES')\n reset({})\n setPayScheduleDraft(null)\n }\n const handleEdit = (schedule: PayScheduleType) => {\n reset({\n frequency: schedule.frequency as Frequency,\n anchorPayDate: schedule.anchorPayDate ? new Date(schedule.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: schedule.anchorEndOfPayPeriod\n ? new Date(schedule.anchorEndOfPayPeriod)\n : undefined,\n day1: schedule.day1 ?? undefined,\n day2: schedule.day2 ?? undefined,\n customName: schedule.customName ?? '',\n })\n setCurrentPaySchedule(schedule)\n setMode('EDIT_PAY_SCHEDULE')\n }\n const handleContinue = () => {\n onEvent(componentEvents.PAY_SCHEDULE_DONE)\n }\n const onSubmit: SubmitHandler<PayScheduleOutputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const formatPayloadDate = (date: Date | undefined): string => {\n return date ? formatDateToStringDate(date) || '' : ''\n }\n\n if (mode === 'ADD_PAY_SCHEDULE') {\n const createPayScheduleResponse = await createPayScheduleMutation.mutateAsync({\n request: {\n companyId: companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_CREATED, createPayScheduleResponse)\n reset()\n setPayScheduleDraft(null)\n } else if (mode === 'EDIT_PAY_SCHEDULE') {\n const version = currentPaySchedule?.version\n const updatePayScheduleResponse = await updatePayScheduleMutation.mutateAsync({\n request: {\n payScheduleId: currentPaySchedule?.uuid as string,\n companyId: companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n version: version as string,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_UPDATED, updatePayScheduleResponse)\n reset()\n setPayScheduleDraft(null)\n }\n await invalidateAllPaySchedulesGetAll(queryClient)\n setMode('LIST_PAY_SCHEDULES')\n })\n }\n\n return (\n <PayScheduleProvider\n value={{\n companyId,\n handleAdd,\n handleEdit,\n handleCancel,\n handleContinue,\n mode,\n paySchedules: paySchedules.payScheduleList,\n payPeriodPreview: payPreviewData?.object?.payPeriods,\n payPreviewLoading: isLoading,\n currentPaySchedule,\n }}\n >\n <span data-testid=\"pay-schedule-edit-form\">\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <Flex flexDirection=\"column\">\n <Head />\n <List />\n <Edit />\n <Actions />\n </Flex>\n )}\n </Form>\n </FormProvider>\n </span>\n </PayScheduleProvider>\n )\n}\n\nPaySchedule.Head = Head\nPaySchedule.List = List\nPaySchedule.Edit = Edit\nPaySchedule.Actions = Actions\n"],"names":["PaySchedule","companyId","defaultValues","dictionary","props","useI18n","useComponentDictionary","jsx","BaseComponent","Root","children","queryClient","useQueryClient","baseSubmitHandler","onEvent","fieldErrors","useBase","mode","setMode","useState","currentPaySchedule","setCurrentPaySchedule","transformedDefaultValues","payScheduleDraft","setPayScheduleDraft","payPreviewData","isLoading","usePaySchedulesGetPreview","paySchedules","usePaySchedulesGetAllSuspense","createPayScheduleMutation","usePaySchedulesCreateMutation","updatePayScheduleMutation","usePaySchedulesUpdateMutation","formMethods","useForm","zodResolver","PayScheduleSchema","watch","setValue","reset","setError","useEffect","error","allValues","handleAdd","handleCancel","handleEdit","schedule","handleContinue","componentEvents","onSubmit","data","payload","formatPayloadDate","date","formatDateToStringDate","createPayScheduleResponse","version","updatePayScheduleResponse","invalidateAllPaySchedulesGetAll","PayScheduleProvider","FormProvider","Form","jsxs","Flex","Head","List","Edit","Actions"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAmCO,MAAMA,IAAc,CAAC;AAAA,EAC1B,WAAAC;AAAA,EACA,eAAAC;AAAA,EACA,YAAAC;AAAA,EACA,GAAGC;AACL,OACEC,GAAQ,qBAAqB,GAC7BC,GAAuB,uBAAuBH,CAAU,GAEtD,gBAAAI,EAACC,IAAe,EAAA,GAAGJ,GACjB,UAAA,gBAAAG,EAACE,MAAK,WAAAR,GAAsB,eAAAC,GACzB,UAAME,EAAA,SAAA,CACT,EACF,CAAA,IAIEK,KAAO,CAAC,EAAE,WAAAR,GAAW,UAAAS,GAAU,eAAAR,QAAsC;AACzE,QAAMS,IAAcC,EAAe,GAC7B,EAAE,mBAAAC,GAAmB,SAAAC,GAAS,aAAAC,EAAA,IAAgBC,GAAQ,GACtD,CAACC,GAAMC,CAAO,IAAIC,EAAe,oBAAoB,GACrD,CAACC,GAAoBC,CAAqB,IAAIF,EAAiC,IAAI,GACnFG,IAA8C;AAAA,IAClD,WAAWpB,GAAe,aAAa;AAAA,IACvC,eAAeA,GAAe,gBAAgB,IAAI,KAAKA,EAAc,aAAa,IAAI;AAAA,IACtF,sBAAsBA,GAAe,uBACjC,IAAI,KAAKA,EAAc,oBAAoB,IAC3C;AAAA,IACJ,MAAMA,GAAe,QAAQ;AAAA,IAC7B,MAAMA,GAAe,QAAQ;AAAA,IAC7B,YAAYA,GAAe,cAAc;AAAA,IACzC,qBAAqB;AAAA,IACrB,uBAAuB;AAAA,EACzB,GAEM,CAACqB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AcW,EAAa;AAAA,QAC3B,kBAAkBH,GAAgB,QAAQ;AAAA,QAC1C,mBAAmBC;AAAA,QACnB,oBAAAN;AAAA,MACF;AAAA,MAEA,UAAA,gBAAAb,EAAC,UAAK,eAAY,0BAChB,4BAACuD,GAAc,EAAA,GAAG5B,GAChB,UAAC,gBAAA3B,EAAAwD,IAAA,EAAK,UAAU7B,EAAY,aAAaiB,CAAQ,GAC9C,UAAAzC,KAGE,gBAAAsD,EAAAC,IAAA,EAAK,eAAc,UAClB,UAAA;AAAA,QAAA,gBAAA1D,EAAC2D,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,GACX,EAAA,CAEJ,GACF,EACF,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;AAEArE,EAAY,OAAOkE;AACnBlE,EAAY,OAAOmE;AACnBnE,EAAY,OAAOoE;AACnBpE,EAAY,UAAUqE;"}
1
+ {"version":3,"file":"PaySchedule.js","sources":["../../../../src/components/Company/PaySchedule/PaySchedule.tsx"],"sourcesContent":["import type { SubmitHandler } from 'react-hook-form'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { useEffect, useState } from 'react'\nimport { usePaySchedulesGetPreview } from '@gusto/embedded-api/react-query/paySchedulesGetPreview'\nimport { usePaySchedulesUpdateMutation } from '@gusto/embedded-api/react-query/paySchedulesUpdate'\nimport { usePaySchedulesGetAllSuspense } from '@gusto/embedded-api/react-query/paySchedulesGetAll'\nimport { usePaySchedulesCreateMutation } from '@gusto/embedded-api/react-query/paySchedulesCreate'\nimport type { PayScheduleObject as PayScheduleType } from '@gusto/embedded-api/models/components/payscheduleobject'\nimport type { Frequency } from '@gusto/embedded-api/models/operations/postv1companiescompanyidpayschedules'\nimport type { MODE, PayScheduleInputs, PayScheduleOutputs } from './usePaySchedule'\nimport {\n PayScheduleProvider,\n PayScheduleSchema,\n type PayScheduleDefaultValues,\n} from './usePaySchedule'\nimport { Actions, Edit, Head, List } from './_parts'\nimport { Form } from '@/components/Common/Form'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base'\nimport { BaseComponent, useBase } from '@/components/Base'\nimport { Flex } from '@/components/Common'\nimport { useI18n } from '@/i18n'\nimport { componentEvents } from '@/shared/constants'\nimport { formatDateToStringDate } from '@/helpers/dateFormatting'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\ninterface PayScheduleProps extends CommonComponentInterface<'Company.PaySchedule'> {\n companyId: string\n defaultValues?: PayScheduleDefaultValues\n}\n\nexport const PaySchedule = ({\n companyId,\n defaultValues,\n dictionary,\n ...props\n}: PayScheduleProps & BaseComponentInterface) => {\n useI18n('Company.PaySchedule')\n useComponentDictionary('Company.PaySchedule', dictionary)\n return (\n <BaseComponent {...props}>\n <Root companyId={companyId} defaultValues={defaultValues}>\n {props.children}\n </Root>\n </BaseComponent>\n )\n}\n\nconst Root = ({ companyId, children, defaultValues }: PayScheduleProps) => {\n const { baseSubmitHandler, onEvent, fieldErrors } = useBase()\n const [mode, setMode] = useState<MODE>('LIST_PAY_SCHEDULES')\n const [currentPaySchedule, setCurrentPaySchedule] = useState<PayScheduleType | null>(null)\n const transformedDefaultValues: PayScheduleInputs = {\n frequency: defaultValues?.frequency ?? 'Every week',\n anchorPayDate: defaultValues?.anchorPayDate ? new Date(defaultValues.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: defaultValues?.anchorEndOfPayPeriod\n ? new Date(defaultValues.anchorEndOfPayPeriod)\n : undefined,\n day1: defaultValues?.day1 ?? undefined,\n day2: defaultValues?.day2 ?? undefined,\n customName: defaultValues?.customName ?? '',\n customTwicePerMonth: 'false',\n payPeriodPreviewRange: 0,\n }\n\n const [payScheduleDraft, setPayScheduleDraft] = useState<PayScheduleType | null>(null)\n const { data: payPreviewData, isLoading } = usePaySchedulesGetPreview(\n {\n companyId,\n frequency: payScheduleDraft?.frequency as Frequency,\n anchorPayDate: payScheduleDraft?.anchorPayDate ?? '',\n anchorEndOfPayPeriod: payScheduleDraft?.anchorEndOfPayPeriod ?? '',\n day1: payScheduleDraft?.day1 ?? undefined,\n day2: payScheduleDraft?.day2 ?? undefined,\n },\n {\n enabled: true,\n }, // Casting to non-null because we know it's not null from the enabled prop\n )\n\n const { data: paySchedules } = usePaySchedulesGetAllSuspense({\n companyId,\n })\n\n const createPayScheduleMutation = usePaySchedulesCreateMutation()\n const updatePayScheduleMutation = usePaySchedulesUpdateMutation()\n\n const formMethods = useForm<PayScheduleInputs, unknown, PayScheduleOutputs>({\n resolver: zodResolver(PayScheduleSchema),\n defaultValues: transformedDefaultValues,\n })\n const { watch, setValue, reset, setError } = formMethods\n\n useEffect(() => {\n if (fieldErrors) {\n // TODO: These error messages are not being localized correctly\n fieldErrors.forEach(error => {\n setError(error.key as keyof PayScheduleInputs, { message: error.message })\n })\n }\n }, [setError, fieldErrors])\n\n const allValues = watch()\n\n // Set the custom_twice_per_month value based on the frequency and day_1 and day_2 values as it is not set by the API call\n useEffect(() => {\n if (\n allValues.frequency === 'Twice per month' &&\n allValues.day1 === 15 &&\n allValues.day2 === 31 &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `1st15th`)\n } else if (\n allValues.frequency === 'Twice per month' &&\n allValues.customTwicePerMonth === undefined\n ) {\n setValue('customTwicePerMonth', `custom`)\n }\n }, [allValues.frequency, allValues.day1, allValues.day2, setValue, allValues.customTwicePerMonth])\n\n useEffect(() => {\n // Don't update if dates are not set\n if (!allValues.anchorPayDate || !allValues.anchorEndOfPayPeriod) {\n return\n }\n\n setPayScheduleDraft({\n frequency: allValues.frequency,\n anchorPayDate: allValues.anchorPayDate.toString(),\n anchorEndOfPayPeriod: allValues.anchorEndOfPayPeriod.toString(),\n day1: allValues.day1 || undefined,\n day2: allValues.day2 || undefined,\n uuid: '',\n version: currentPaySchedule?.version || '', //TODO: This needs to be set to something\n })\n }, [\n allValues.anchorEndOfPayPeriod,\n allValues.anchorPayDate,\n allValues.day1,\n allValues.day2,\n allValues.frequency,\n currentPaySchedule?.version,\n setPayScheduleDraft,\n ])\n\n // Custom effect to show/hide pay schedule preview errors\n\n const handleAdd = () => {\n setMode('ADD_PAY_SCHEDULE')\n reset({})\n }\n const handleCancel = () => {\n setMode('LIST_PAY_SCHEDULES')\n reset({})\n setPayScheduleDraft(null)\n }\n const handleEdit = (schedule: PayScheduleType) => {\n reset({\n frequency: schedule.frequency as Frequency,\n anchorPayDate: schedule.anchorPayDate ? new Date(schedule.anchorPayDate) : undefined,\n anchorEndOfPayPeriod: schedule.anchorEndOfPayPeriod\n ? new Date(schedule.anchorEndOfPayPeriod)\n : undefined,\n day1: schedule.day1 ?? undefined,\n day2: schedule.day2 ?? undefined,\n customName: schedule.customName ?? '',\n })\n setCurrentPaySchedule(schedule)\n setMode('EDIT_PAY_SCHEDULE')\n }\n const handleContinue = () => {\n onEvent(componentEvents.PAY_SCHEDULE_DONE)\n }\n const onSubmit: SubmitHandler<PayScheduleOutputs> = async data => {\n await baseSubmitHandler(data, async payload => {\n const formatPayloadDate = (date: Date | undefined): string => {\n return date ? formatDateToStringDate(date) || '' : ''\n }\n\n if (mode === 'ADD_PAY_SCHEDULE') {\n const createPayScheduleResponse = await createPayScheduleMutation.mutateAsync({\n request: {\n companyId: companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_CREATED, createPayScheduleResponse)\n reset()\n setPayScheduleDraft(null)\n } else if (mode === 'EDIT_PAY_SCHEDULE') {\n const version = currentPaySchedule?.version\n const updatePayScheduleResponse = await updatePayScheduleMutation.mutateAsync({\n request: {\n payScheduleId: currentPaySchedule?.uuid as string,\n companyId: companyId,\n requestBody: {\n frequency: payload.frequency,\n anchorPayDate: formatPayloadDate(payload.anchorPayDate),\n anchorEndOfPayPeriod: formatPayloadDate(payload.anchorEndOfPayPeriod),\n customName: payload.customName,\n day1: payload.day1,\n day2: payload.day2,\n version: version as string,\n },\n },\n })\n onEvent(componentEvents.PAY_SCHEDULE_UPDATED, updatePayScheduleResponse)\n reset()\n setPayScheduleDraft(null)\n }\n setMode('LIST_PAY_SCHEDULES')\n })\n }\n\n return (\n <PayScheduleProvider\n value={{\n companyId,\n handleAdd,\n handleEdit,\n handleCancel,\n handleContinue,\n mode,\n paySchedules: paySchedules.payScheduleList,\n payPeriodPreview: payPreviewData?.object?.payPeriods,\n payPreviewLoading: isLoading,\n currentPaySchedule,\n }}\n >\n <span data-testid=\"pay-schedule-edit-form\">\n <FormProvider {...formMethods}>\n <Form onSubmit={formMethods.handleSubmit(onSubmit)}>\n {children ? (\n children\n ) : (\n <Flex flexDirection=\"column\">\n <Head />\n <List />\n <Edit />\n <Actions />\n </Flex>\n )}\n </Form>\n </FormProvider>\n </span>\n </PayScheduleProvider>\n )\n}\n\nPaySchedule.Head = Head\nPaySchedule.List = List\nPaySchedule.Edit = Edit\nPaySchedule.Actions = Actions\n"],"names":["PaySchedule","companyId","defaultValues","dictionary","props","useI18n","useComponentDictionary","jsx","BaseComponent","Root","children","baseSubmitHandler","onEvent","fieldErrors","useBase","mode","setMode","useState","currentPaySchedule","setCurrentPaySchedule","transformedDefaultValues","payScheduleDraft","setPayScheduleDraft","payPreviewData","isLoading","usePaySchedulesGetPreview","paySchedules","usePaySchedulesGetAllSuspense","createPayScheduleMutation","usePaySchedulesCreateMutation","updatePayScheduleMutation","usePaySchedulesUpdateMutation","formMethods","useForm","zodResolver","PayScheduleSchema","watch","setValue","reset","setError","useEffect","error","allValues","handleAdd","handleCancel","handleEdit","schedule","handleContinue","componentEvents","onSubmit","data","payload","formatPayloadDate","date","formatDateToStringDate","createPayScheduleResponse","version","updatePayScheduleResponse","PayScheduleProvider","FormProvider","Form","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A;AAAA,QAAA,gBAAAvD,EAACwD,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,GACX,EAAA,CAEJ,GACF,EACF,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;AAEAlE,EAAY,OAAO+D;AACnB/D,EAAY,OAAOgE;AACnBhE,EAAY,OAAOiE;AACnBjE,EAAY,UAAUkE;"}
@@ -1,41 +1,40 @@
1
- import { jsx as t, jsxs as P, Fragment as T } from "react/jsx-runtime";
2
- import { useContractorsGetSuspense as U } from "@gusto/embedded-api/react-query/contractorsGet";
3
- import { useContractorsGetAddressSuspense as b, invalidateContractorsGetAddress as x } from "@gusto/embedded-api/react-query/contractorsGetAddress";
4
- import { useContractorsUpdateAddressMutation as O } from "@gusto/embedded-api/react-query/contractorsUpdateAddress";
5
- import { useQueryClient as _ } from "@tanstack/react-query";
6
- import { useForm as q, FormProvider as w } from "react-hook-form";
7
- import { zodResolver as B } from "@hookform/resolvers/zod";
8
- import { AddressFormSchema as G, AddressProvider as H } from "./useAddress.js";
9
- import { Head as u } from "./Head.js";
10
- import { Form as p } from "./Form.js";
1
+ import { jsx as t, jsxs as E, Fragment as P } from "react/jsx-runtime";
2
+ import { useContractorsGetSuspense as T } from "@gusto/embedded-api/react-query/contractorsGet";
3
+ import { useContractorsGetAddressSuspense as U } from "@gusto/embedded-api/react-query/contractorsGetAddress";
4
+ import { useContractorsUpdateAddressMutation as b } from "@gusto/embedded-api/react-query/contractorsUpdateAddress";
5
+ import { useForm as x, FormProvider as O } from "react-hook-form";
6
+ import { zodResolver as _ } from "@hookform/resolvers/zod";
7
+ import { AddressFormSchema as B, AddressProvider as H } from "./useAddress.js";
8
+ import { Head as p } from "./Head.js";
9
+ import { Form as u } from "./Form.js";
11
10
  import { Actions as f } from "./Actions.js";
12
11
  import { Form as N } from "../../Common/Form/Form.js";
13
- import { useComponentDictionary as j, useI18n as M } from "../../../i18n/I18n.js";
14
- import { Flex as Q } from "../../Common/Flex/Flex.js";
15
- import { BaseComponent as $ } from "../../Base/Base.js";
16
- import { useBase as k } from "../../Base/useBase.js";
12
+ import { useComponentDictionary as j, useI18n as q } from "../../../i18n/I18n.js";
13
+ import { Flex as w } from "../../Common/Flex/Flex.js";
14
+ import { BaseComponent as G } from "../../Base/Base.js";
15
+ import { useBase as M } from "../../Base/useBase.js";
17
16
  import { contractorEvents as a } from "../../../shared/constants.js";
18
17
  function n(r) {
19
- return /* @__PURE__ */ t($, { ...r, children: /* @__PURE__ */ t(J, { ...r, children: r.children }) });
18
+ return /* @__PURE__ */ t(G, { ...r, children: /* @__PURE__ */ t($, { ...r, children: r.children }) });
20
19
  }
21
- function J({ contractorId: r, defaultValues: o, children: i, className: A, dictionary: C }) {
22
- j("Contractor.Address", C), M("Contractor.Address");
23
- const l = _(), { onEvent: c, baseSubmitHandler: D } = k(), { data: m } = U({ contractorUuid: r }), { data: h } = b({ contractorUuid: r }), { mutateAsync: S, isPending: v } = O(), y = m.contractor, F = m.contractor?.type, e = h.contractorAddress, R = {
24
- street1: e?.street1 || o?.street1 || "",
25
- street2: e?.street2 || o?.street2 || "",
26
- city: e?.city || o?.city || "",
27
- state: e?.state || o?.state || "",
28
- zip: e?.zip || o?.zip || ""
29
- }, d = q({
30
- resolver: B(G),
31
- defaultValues: R
32
- }), g = async (z) => {
33
- await D(z, async (s) => {
34
- const { contractorAddress: E } = await S({
20
+ function $({ contractorId: r, defaultValues: e, children: i, className: A, dictionary: D }) {
21
+ j("Contractor.Address", D), q("Contractor.Address");
22
+ const { onEvent: c, baseSubmitHandler: h } = M(), { data: m } = T({ contractorUuid: r }), { data: C } = U({ contractorUuid: r }), { mutateAsync: S, isPending: l } = b(), v = m.contractor, F = m.contractor?.type, o = C.contractorAddress, y = {
23
+ street1: o?.street1 || e?.street1 || "",
24
+ street2: o?.street2 || e?.street2 || "",
25
+ city: o?.city || e?.city || "",
26
+ state: o?.state || e?.state || "",
27
+ zip: o?.zip || e?.zip || ""
28
+ }, d = x({
29
+ resolver: _(B),
30
+ defaultValues: y
31
+ }), R = async (g) => {
32
+ await h(g, async (s) => {
33
+ const { contractorAddress: z } = await S({
35
34
  request: {
36
35
  contractorUuid: r,
37
36
  requestBody: {
38
- version: e?.version,
37
+ version: o?.version,
39
38
  street1: s.street1,
40
39
  street2: s.street2,
41
40
  city: s.city,
@@ -44,28 +43,28 @@ function J({ contractorId: r, defaultValues: o, children: i, className: A, dicti
44
43
  }
45
44
  }
46
45
  });
47
- await x(l, [r]), c(a.CONTRACTOR_ADDRESS_UPDATED, E), c(a.CONTRACTOR_ADDRESS_DONE);
46
+ c(a.CONTRACTOR_ADDRESS_UPDATED, z), c(a.CONTRACTOR_ADDRESS_DONE);
48
47
  });
49
48
  };
50
49
  return /* @__PURE__ */ t("section", { className: A, children: /* @__PURE__ */ t(
51
50
  H,
52
51
  {
53
52
  value: {
54
- contractor: y,
53
+ contractor: v,
55
54
  contractorType: F,
56
- address: e,
57
- isPending: v
55
+ address: o,
56
+ isPending: l
58
57
  },
59
- children: /* @__PURE__ */ t(w, { ...d, children: /* @__PURE__ */ t(N, { onSubmit: d.handleSubmit(g), children: /* @__PURE__ */ t(Q, { flexDirection: "column", gap: 32, children: i || /* @__PURE__ */ P(T, { children: [
60
- /* @__PURE__ */ t(u, {}),
58
+ children: /* @__PURE__ */ t(O, { ...d, children: /* @__PURE__ */ t(N, { onSubmit: d.handleSubmit(R), children: /* @__PURE__ */ t(w, { flexDirection: "column", gap: 32, children: i || /* @__PURE__ */ E(P, { children: [
61
59
  /* @__PURE__ */ t(p, {}),
60
+ /* @__PURE__ */ t(u, {}),
62
61
  /* @__PURE__ */ t(f, {})
63
62
  ] }) }) }) })
64
63
  }
65
64
  ) });
66
65
  }
67
- n.Head = u;
68
- n.Form = p;
66
+ n.Head = p;
67
+ n.Form = u;
69
68
  n.Actions = f;
70
69
  export {
71
70
  n as Address,
@@ -1 +1 @@
1
- {"version":3,"file":"Address.js","sources":["../../../../src/components/Contractor/Address/Address.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useContractorsGetSuspense } from '@gusto/embedded-api/react-query/contractorsGet'\nimport {\n useContractorsGetAddressSuspense,\n invalidateContractorsGetAddress,\n} from '@gusto/embedded-api/react-query/contractorsGetAddress'\nimport { useContractorsUpdateAddressMutation } from '@gusto/embedded-api/react-query/contractorsUpdateAddress'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { AddressFormSchema, AddressProvider } from './useAddress'\nimport { Head } from './Head'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { AddressDefaultValues, AddressFormValues } from './useAddress'\nimport { Form as HtmlForm } from '@/components/Common/Form/Form'\nimport { useI18n, useComponentDictionary } from '@/i18n'\nimport { Flex } from '@/components/Common'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { contractorEvents } from '@/shared/constants'\n\nexport interface AddressProps extends BaseComponentInterface<'Contractor.Address'> {\n contractorId: string\n defaultValues?: AddressDefaultValues\n children?: ReactNode\n className?: string\n}\n\nexport function Address(props: AddressProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ contractorId, defaultValues, children, className, dictionary }: AddressProps) {\n useComponentDictionary('Contractor.Address', dictionary)\n useI18n('Contractor.Address')\n const queryClient = useQueryClient()\n\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { data: contractorData } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const { data: addressData } = useContractorsGetAddressSuspense({ contractorUuid: contractorId })\n\n const { mutateAsync: updateAddress, isPending: isUpdatingAddressPending } =\n useContractorsUpdateAddressMutation()\n\n const contractor = contractorData.contractor\n const contractorType = contractorData.contractor?.type\n const address = addressData.contractorAddress\n\n const formDefaultValues = {\n street1: address?.street1 || defaultValues?.street1 || '',\n street2: address?.street2 || defaultValues?.street2 || '',\n city: address?.city || defaultValues?.city || '',\n state: address?.state || defaultValues?.state || '',\n zip: address?.zip || defaultValues?.zip || '',\n }\n\n const formMethods = useForm<AddressFormValues>({\n resolver: zodResolver(AddressFormSchema),\n defaultValues: formDefaultValues,\n })\n\n const onSubmit = async (data: AddressFormValues) => {\n await baseSubmitHandler(data, async payload => {\n const { contractorAddress } = await updateAddress({\n request: {\n contractorUuid: contractorId,\n requestBody: {\n version: address?.version as string,\n street1: payload.street1,\n street2: payload.street2,\n city: payload.city,\n state: payload.state,\n zip: payload.zip,\n },\n },\n })\n\n await invalidateContractorsGetAddress(queryClient, [contractorId])\n\n onEvent(contractorEvents.CONTRACTOR_ADDRESS_UPDATED, contractorAddress)\n onEvent(contractorEvents.CONTRACTOR_ADDRESS_DONE)\n })\n }\n\n return (\n <section className={className}>\n <AddressProvider\n value={{\n contractor,\n contractorType,\n address,\n isPending: isUpdatingAddressPending,\n }}\n >\n <FormProvider {...formMethods}>\n <HtmlForm onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </HtmlForm>\n </FormProvider>\n </AddressProvider>\n </section>\n )\n}\n\nAddress.Head = Head\nAddress.Form = Form\nAddress.Actions = Actions\n\nexport default Address\n"],"names":["Address","props","jsx","BaseComponent","Root","contractorId","defaultValues","children","className","dictionary","useComponentDictionary","useI18n","queryClient","useQueryClient","onEvent","baseSubmitHandler","useBase","contractorData","useContractorsGetSuspense","addressData","useContractorsGetAddressSuspense","updateAddress","isUpdatingAddressPending","useContractorsUpdateAddressMutation","contractor","contractorType","address","formDefaultValues","formMethods","useForm","zodResolver","AddressFormSchema","onSubmit","data","payload","contractorAddress","invalidateContractorsGetAddress","contractorEvents","AddressProvider","FormProvider","HtmlForm","Flex","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UAChB,aAAa;AAAA,YACX,SAASqB,GAAS;AAAA,YAClB,SAASQ,EAAQ;AAAA,YACjB,SAASA,EAAQ;AAAA,YACjB,MAAMA,EAAQ;AAAA,YACd,OAAOA,EAAQ;AAAA,YACf,KAAKA,EAAQ;AAAA,UAAA;AAAA,QACf;AAAA,MACF,CACD;AAED,YAAME,EAAgCxB,GAAa,CAACP,CAAY,CAAC,GAEzDS,EAAAuB,EAAiB,4BAA4BF,CAAiB,GACtErB,EAAQuB,EAAiB,uBAAuB;AAAA,IAAA,CACjD;AAAA,EACH;AAGE,SAAA,gBAAAnC,EAAC,aAAQ,WAAAM,GACP,UAAA,gBAAAN;AAAA,IAACoC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,YAAAd;AAAA,QACA,gBAAAC;AAAA,QACA,SAAAC;AAAA,QACA,WAAWJ;AAAA,MACb;AAAA,MAEA,4BAACiB,GAAc,EAAA,GAAGX,GAChB,UAAC,gBAAA1B,EAAAsC,GAAA,EAAS,UAAUZ,EAAY,aAAaI,CAAQ,GACnD,UAAA,gBAAA9B,EAACuC,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAAlC,KAIG,gBAAAmC,EAAAC,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAAzC,EAAC0C,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,GACX,EAAA,CAEJ,GACF,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAEA9C,EAAQ,OAAO4C;AACf5C,EAAQ,OAAO6C;AACf7C,EAAQ,UAAU8C;"}
1
+ {"version":3,"file":"Address.js","sources":["../../../../src/components/Contractor/Address/Address.tsx"],"sourcesContent":["import type { ReactNode } from 'react'\nimport { useContractorsGetSuspense } from '@gusto/embedded-api/react-query/contractorsGet'\nimport { useContractorsGetAddressSuspense } from '@gusto/embedded-api/react-query/contractorsGetAddress'\nimport { useContractorsUpdateAddressMutation } from '@gusto/embedded-api/react-query/contractorsUpdateAddress'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { AddressFormSchema, AddressProvider } from './useAddress'\nimport { Head } from './Head'\nimport { Form } from './Form'\nimport { Actions } from './Actions'\nimport type { AddressDefaultValues, AddressFormValues } from './useAddress'\nimport { Form as HtmlForm } from '@/components/Common/Form/Form'\nimport { useI18n, useComponentDictionary } from '@/i18n'\nimport { Flex } from '@/components/Common'\nimport type { BaseComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { contractorEvents } from '@/shared/constants'\n\nexport interface AddressProps extends BaseComponentInterface<'Contractor.Address'> {\n contractorId: string\n defaultValues?: AddressDefaultValues\n children?: ReactNode\n className?: string\n}\n\nexport function Address(props: AddressProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\n\nfunction Root({ contractorId, defaultValues, children, className, dictionary }: AddressProps) {\n useComponentDictionary('Contractor.Address', dictionary)\n useI18n('Contractor.Address')\n\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { data: contractorData } = useContractorsGetSuspense({ contractorUuid: contractorId })\n const { data: addressData } = useContractorsGetAddressSuspense({ contractorUuid: contractorId })\n\n const { mutateAsync: updateAddress, isPending: isUpdatingAddressPending } =\n useContractorsUpdateAddressMutation()\n\n const contractor = contractorData.contractor\n const contractorType = contractorData.contractor?.type\n const address = addressData.contractorAddress\n\n const formDefaultValues = {\n street1: address?.street1 || defaultValues?.street1 || '',\n street2: address?.street2 || defaultValues?.street2 || '',\n city: address?.city || defaultValues?.city || '',\n state: address?.state || defaultValues?.state || '',\n zip: address?.zip || defaultValues?.zip || '',\n }\n\n const formMethods = useForm<AddressFormValues>({\n resolver: zodResolver(AddressFormSchema),\n defaultValues: formDefaultValues,\n })\n\n const onSubmit = async (data: AddressFormValues) => {\n await baseSubmitHandler(data, async payload => {\n const { contractorAddress } = await updateAddress({\n request: {\n contractorUuid: contractorId,\n requestBody: {\n version: address?.version as string,\n street1: payload.street1,\n street2: payload.street2,\n city: payload.city,\n state: payload.state,\n zip: payload.zip,\n },\n },\n })\n\n onEvent(contractorEvents.CONTRACTOR_ADDRESS_UPDATED, contractorAddress)\n onEvent(contractorEvents.CONTRACTOR_ADDRESS_DONE)\n })\n }\n\n return (\n <section className={className}>\n <AddressProvider\n value={{\n contractor,\n contractorType,\n address,\n isPending: isUpdatingAddressPending,\n }}\n >\n <FormProvider {...formMethods}>\n <HtmlForm onSubmit={formMethods.handleSubmit(onSubmit)}>\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </HtmlForm>\n </FormProvider>\n </AddressProvider>\n </section>\n )\n}\n\nAddress.Head = Head\nAddress.Form = Form\nAddress.Actions = Actions\n\nexport default Address\n"],"names":["Address","props","jsx","BaseComponent","Root","contractorId","defaultValues","children","className","dictionary","useComponentDictionary","useI18n","onEvent","baseSubmitHandler","useBase","contractorData","useContractorsGetSuspense","addressData","useContractorsGetAddressSuspense","updateAddress","isUpdatingAddressPending","useContractorsUpdateAddressMutation","contractor","contractorType","address","formDefaultValues","formMethods","useForm","zodResolver","AddressFormSchema","onSubmit","data","payload","contractorAddress","contractorEvents","AddressProvider","FormProvider","HtmlForm","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":";;;;;;;;;;;;;;;;AA0BO,SAASA,EAAQC,GAAqB;AAEzC,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AAEA,SAASG,EAAK,EAAE,cAAAC,GAAc,eAAAC,GAAe,UAAAC,GAAU,WAAAC,GAAW,YAAAC,KAA4B;AAC5F,EAAAC,EAAuB,sBAAsBD,CAAU,GACvD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,IAACiC;AAAA,IAAA;AAAA,MACC,OAAO;AAAA,QACL,YAAAb;AAAA,QACA,gBAAAC;AAAA,QACA,SAAAC;AAAA,QACA,WAAWJ;AAAA,MACb;AAAA,MAEA,4BAACgB,GAAc,EAAA,GAAGV,GAChB,UAAC,gBAAAxB,EAAAmC,GAAA,EAAS,UAAUX,EAAY,aAAaI,CAAQ,GACnD,UAAA,gBAAA5B,EAACoC,KAAK,eAAc,UAAS,KAAK,IAC/B,UAAA/B,KAIG,gBAAAgC,EAAAC,GAAA,EAAA,UAAA;AAAA,QAAA,gBAAAtC,EAACuC,GAAK,EAAA;AAAA,0BACLC,GAAK,EAAA;AAAA,0BACLC,GAAQ,CAAA,CAAA;AAAA,MAAA,GACX,EAAA,CAEJ,GACF,EACF,CAAA;AAAA,IAAA;AAAA,EAAA,GAEJ;AAEJ;AAEA3C,EAAQ,OAAOyC;AACfzC,EAAQ,OAAO0C;AACf1C,EAAQ,UAAU2C;"}
@@ -1,84 +1,81 @@
1
- import { jsx as t, jsxs as c, Fragment as p } from "react/jsx-runtime";
2
- import { useTranslation as m } from "react-i18next";
3
- import { useContractors as u } from "./useContractorList.js";
4
- import { Flex as C } from "../../Common/Flex/Flex.js";
5
- import { EmptyData as f } from "../../Common/EmptyData/EmptyData.js";
6
- import { firstLastName as h } from "../../../helpers/formattedStrings.js";
7
- import { HamburgerMenu as L } from "../../Common/HamburgerMenu/HamburgerMenu.js";
8
- import g from "../../../assets/icons/pencil.svg.js";
9
- import { useComponentContext as l } from "../../../contexts/ComponentAdapter/useComponentContext.js";
1
+ import { jsx as t, jsxs as c } from "react/jsx-runtime";
2
+ import { useTranslation as s } from "react-i18next";
3
+ import { useContractors as d } from "./useContractorList.js";
4
+ import { Flex as u } from "../../Common/Flex/Flex.js";
5
+ import { Grid as f } from "../../Common/Grid/Grid.js";
6
+ import { EmptyData as C } from "../../Common/EmptyData/EmptyData.js";
7
+ import { ActionsLayout as L } from "../../Common/ActionsLayout/ActionsLayout.js";
8
+ import { firstLastName as g } from "../../../helpers/formattedStrings.js";
9
+ import { HamburgerMenu as h } from "../../Common/HamburgerMenu/HamburgerMenu.js";
10
+ import y from "../../../assets/icons/pencil.svg.js";
11
+ import { useComponentContext as m } from "../../../contexts/ComponentAdapter/useComponentContext.js";
10
12
  import { ContractorOnboardingStatusBadge as b } from "../../Common/OnboardingStatusBadge/index.js";
11
13
  import { useI18n as T } from "../../../i18n/I18n.js";
12
- import { useDataView as y } from "../../Common/DataView/useDataView.js";
14
+ import { useDataView as A } from "../../Common/DataView/useDataView.js";
13
15
  import { DataView as x } from "../../Common/DataView/DataView.js";
14
- function A({ count: o, handleAdd: n }) {
15
- const { Badge: r, Button: i, Heading: e } = l(), { t: a } = m("Contractor.ContractorList");
16
- return /* @__PURE__ */ c(C, { children: [
17
- /* @__PURE__ */ t(e, { as: "h2", children: a("title") }),
18
- /* @__PURE__ */ t(r, { children: o }),
19
- o !== 0 && /* @__PURE__ */ t(i, { variant: "secondary", onClick: n, children: a("addAnotherCTA") })
16
+ function D({ count: e, handleAdd: o }) {
17
+ const { Button: r, Heading: i } = m(), { t: n } = s("Contractor.ContractorList");
18
+ return /* @__PURE__ */ c(u, { alignItems: "center", justifyContent: "space-between", children: [
19
+ /* @__PURE__ */ t(i, { as: "h2", children: n("title") }),
20
+ e !== 0 && /* @__PURE__ */ t(r, { variant: "secondary", onClick: o, children: n("addAnotherCTA") })
20
21
  ] });
21
22
  }
22
- function D({ handleAdd: o }) {
23
- const { Button: n } = l(), { t: r } = m("Contractor.ContractorList");
24
- return /* @__PURE__ */ c(f, { children: [
25
- /* @__PURE__ */ t("h1", { children: r("emptyTableTitle") }),
26
- r("emptyTableDescription"),
27
- /* @__PURE__ */ t(n, { onClick: o, children: r("addContractorCTA") })
28
- ] });
23
+ function H({ handleAdd: e }) {
24
+ const { Button: o } = m(), { t: r } = s("Contractor.ContractorList");
25
+ return /* @__PURE__ */ t(C, { title: r("emptyTableTitle"), description: r("emptyTableDescription"), children: /* @__PURE__ */ t(L, { justifyContent: "center", children: /* @__PURE__ */ t(o, { onClick: e, children: r("addContractorCTA") }) }) });
29
26
  }
30
- function H({
31
- contractors: o,
32
- handleAdd: n,
27
+ function j({
28
+ contractors: e,
29
+ handleAdd: o,
33
30
  handleEdit: r,
34
31
  totalCount: i
35
32
  }) {
36
33
  T("Contractor.ContractorList");
37
- const { t: e } = m("Contractor.ContractorList"), a = y({
34
+ const { t: n } = s("Contractor.ContractorList"), l = A({
38
35
  columns: [
39
36
  {
40
- title: e("listHeaders.name"),
41
- render: (s) => h({ first_name: s.firstName, last_name: s.lastName })
37
+ title: n("listHeaders.name"),
38
+ render: (a) => g({ first_name: a.firstName, last_name: a.lastName })
42
39
  },
43
40
  {
44
- title: e("listHeaders.status"),
45
- render: ({ onboarded: s, onboardingStatus: d }) => /* @__PURE__ */ t(
41
+ title: n("listHeaders.status"),
42
+ render: ({ onboarded: a, onboardingStatus: p }) => /* @__PURE__ */ t(
46
43
  b,
47
44
  {
48
- onboarded: s,
49
- onboardingStatus: d
45
+ onboarded: a,
46
+ onboardingStatus: p
50
47
  }
51
48
  )
52
49
  }
53
50
  ],
54
- data: o,
51
+ data: e,
55
52
  itemMenu: () => /* @__PURE__ */ t(
56
- L,
53
+ h,
57
54
  {
58
- items: [{ label: e("editCTA"), icon: /* @__PURE__ */ t(g, { "aria-hidden": !0 }), onClick: r }],
59
- triggerLabel: e("editCTA"),
55
+ items: [{ label: n("editCTA"), icon: /* @__PURE__ */ t(y, { "aria-hidden": !0 }), onClick: r }],
56
+ triggerLabel: n("editCTA"),
60
57
  isLoading: !1
61
58
  }
62
59
  ),
63
- emptyState: () => /* @__PURE__ */ t(D, { handleAdd: n })
60
+ emptyState: () => /* @__PURE__ */ t(H, { handleAdd: o })
64
61
  });
65
- return /* @__PURE__ */ c(p, { children: [
66
- /* @__PURE__ */ t(A, { count: i, handleAdd: n }),
67
- /* @__PURE__ */ t(x, { label: e("contractorListLabel"), ...a })
62
+ return /* @__PURE__ */ c(f, { gap: 20, children: [
63
+ /* @__PURE__ */ t(D, { count: i, handleAdd: o }),
64
+ /* @__PURE__ */ t(x, { label: n("contractorListLabel"), ...l })
68
65
  ] });
69
66
  }
70
- function I({
71
- companyId: o,
72
- handleAdd: n,
67
+ function U({
68
+ companyId: e,
69
+ handleAdd: o,
73
70
  handleEdit: r
74
71
  }) {
75
- const i = u({ companyUuid: o, handleAdd: n });
76
- return /* @__PURE__ */ t(H, { handleEdit: r, ...i });
72
+ const i = d({ companyUuid: e, handleAdd: o });
73
+ return /* @__PURE__ */ t(j, { handleEdit: r, ...i });
77
74
  }
78
75
  export {
79
- H as ContractorList,
80
- I as ContractorListWithApi,
81
- D as EmptyDataContractorsList,
82
- A as Head
76
+ j as ContractorList,
77
+ U as ContractorListWithApi,
78
+ H as EmptyDataContractorsList,
79
+ D as Head
83
80
  };
84
81
  //# sourceMappingURL=index.js.map