@gusto/embedded-react-sdk 0.10.2 → 0.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) 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/Industry/Industry.js +30 -31
  22. package/dist/components/Company/Industry/Industry.js.map +1 -1
  23. package/dist/components/Company/Locations/LocationForm/LocationForm.js +34 -37
  24. package/dist/components/Company/Locations/LocationForm/LocationForm.js.map +1 -1
  25. package/dist/components/Company/Locations/LocationsList/List.js +4 -1
  26. package/dist/components/Company/Locations/LocationsList/List.js.map +1 -1
  27. package/dist/components/Company/PaySchedule/PaySchedule.js +70 -71
  28. package/dist/components/Company/PaySchedule/PaySchedule.js.map +1 -1
  29. package/dist/components/Contractor/Address/Address.js +37 -38
  30. package/dist/components/Contractor/Address/Address.js.map +1 -1
  31. package/dist/components/Contractor/NewHireReport/NewHireReport.js +57 -58
  32. package/dist/components/Contractor/NewHireReport/NewHireReport.js.map +1 -1
  33. package/dist/components/Employee/Compensation/Compensation.js +123 -132
  34. package/dist/components/Employee/Compensation/Compensation.js.map +1 -1
  35. package/dist/components/Employee/Deductions/Deductions.js +74 -79
  36. package/dist/components/Employee/Deductions/Deductions.js.map +1 -1
  37. package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js +36 -42
  38. package/dist/components/Employee/DocumentSigner/SignatureForm/SignatureForm.js.map +1 -1
  39. package/dist/components/Employee/EmployeeList/EmployeeList.js +57 -58
  40. package/dist/components/Employee/EmployeeList/EmployeeList.js.map +1 -1
  41. package/dist/components/Employee/PaymentMethod/PaymentMethod.js +95 -97
  42. package/dist/components/Employee/PaymentMethod/PaymentMethod.js.map +1 -1
  43. package/dist/components/Employee/Profile/Profile.js +118 -124
  44. package/dist/components/Employee/Profile/Profile.js.map +1 -1
  45. package/dist/components/Employee/Taxes/FederalForm.js +4 -4
  46. package/dist/components/Employee/Taxes/FederalForm.js.map +1 -1
  47. package/dist/components/Employee/Taxes/Taxes.js +59 -60
  48. package/dist/components/Employee/Taxes/Taxes.js.map +1 -1
  49. package/dist/contexts/ApiProvider/ApiProvider.js +16 -14
  50. package/dist/contexts/ApiProvider/ApiProvider.js.map +1 -1
  51. package/dist/contexts/ComponentAdapter/componentAdapterTypes.d.ts +5 -0
  52. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.d.ts +2 -0
  53. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js +19 -17
  54. package/dist/contexts/GustoProvider/GustoProviderCustomUIAdapter.js.map +1 -1
  55. package/dist/contexts/LoadingIndicatorProvider/LoadingIndicatorProvider.d.ts +7 -0
  56. package/dist/contexts/LoadingIndicatorProvider/LoadingIndicatorProvider.js +10 -0
  57. package/dist/contexts/LoadingIndicatorProvider/LoadingIndicatorProvider.js.map +1 -0
  58. package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.d.ts +6 -0
  59. package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.js +11 -0
  60. package/dist/contexts/LoadingIndicatorProvider/useLoadingIndicator.js.map +1 -0
  61. package/dist/shared/constants.d.ts +2 -0
  62. package/dist/shared/constants.js +10 -9
  63. package/dist/shared/constants.js.map +1 -1
  64. package/dist/style.css +1 -1
  65. package/package.json +5 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.10.3
4
+
5
+ - Expose types for adapter and create a loading indicator provider
6
+ - Remove manual invalidation in favor of automatic invalidation after mutation
7
+ - Invalidate queryCache after running mutation API
8
+ - Produce lockfile for documentation to better organize frontmatter for Github Action
9
+ - Reorganize docs to match readme hierarchy
10
+
3
11
  ## 0.10.2
4
12
 
5
13
  ### Fixes
@@ -3,6 +3,7 @@ import { FallbackProps } from 'react-error-boundary';
3
3
  import { OnEventType } from './useBase';
4
4
  import { EventType } from '../../shared/constants';
5
5
  import { ResourceDictionary, Resources } from '../../types/Helpers';
6
+ import { LoadingIndicatorContextProps } from '../../contexts/LoadingIndicatorProvider/useLoadingIndicator';
6
7
  export interface CommonComponentInterface<TResourceKey extends keyof Resources = keyof Resources> {
7
8
  children?: ReactNode;
8
9
  className?: string;
@@ -11,7 +12,7 @@ export interface CommonComponentInterface<TResourceKey extends keyof Resources =
11
12
  }
12
13
  export interface BaseComponentInterface<TResourceKey extends keyof Resources = keyof Resources> extends CommonComponentInterface<TResourceKey> {
13
14
  FallbackComponent?: (props: FallbackProps) => JSX.Element;
14
- LoaderComponent?: () => JSX.Element;
15
+ LoaderComponent?: LoadingIndicatorContextProps['LoadingIndicator'];
15
16
  onEvent: OnEventType<EventType, unknown>;
16
17
  }
17
- export declare const BaseComponent: <TResourceKey extends keyof Resources = keyof Resources>({ children, FallbackComponent, LoaderComponent, onEvent, }: BaseComponentInterface<TResourceKey>) => import("react/jsx-runtime").JSX.Element;
18
+ export declare const BaseComponent: <TResourceKey extends keyof Resources = keyof Resources>({ children, FallbackComponent, LoaderComponent: LoadingIndicatorFromProps, onEvent, }: BaseComponentInterface<TResourceKey>) => import("react/jsx-runtime").JSX.Element;
@@ -1,20 +1,20 @@
1
1
  import { jsx as r, jsxs as u } from "react/jsx-runtime";
2
- import { useState as y, useCallback as v, Suspense as A } from "react";
2
+ import { useState as y, useCallback as A, Suspense as L } from "react";
3
3
  import { ErrorBoundary as R } from "react-error-boundary";
4
4
  import { useTranslation as S } from "react-i18next";
5
5
  import { APIError as E } from "@gusto/embedded-api/models/errors/apierror";
6
6
  import { SDKValidationError as g } from "@gusto/embedded-api/models/errors/sdkvalidationerror";
7
- import { UnprocessableEntityErrorObject as h } from "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
7
+ import { UnprocessableEntityErrorObject as C } from "@gusto/embedded-api/models/errors/unprocessableentityerrorobject";
8
8
  import { QueryErrorResetBoundary as B } from "@tanstack/react-query";
9
9
  import { FadeIn as T } from "../Common/FadeIn/FadeIn.js";
10
10
  import { BaseContext as _ } from "./useBase.js";
11
11
  import { componentEvents as j } from "../../shared/constants.js";
12
- import { useAsyncError as I } from "../Common/hooks/useAsyncError.js";
13
- import { Loading as K } from "../Common/Loading/Loading.js";
12
+ import { useAsyncError as K } from "../Common/hooks/useAsyncError.js";
14
13
  import { InternalError as P } from "../Common/InternalError/InternalError.js";
15
14
  import { snakeCaseToCamelCase as w } from "../../helpers/formattedStrings.js";
16
- import { useComponentContext as M } from "../../contexts/ComponentAdapter/useComponentContext.js";
17
- const O = (e) => e.map((o) => o.message ? /* @__PURE__ */ r("li", { children: o.message }, o.key) : null), k = (e, o) => {
15
+ import { useComponentContext as F } from "../../contexts/ComponentAdapter/useComponentContext.js";
16
+ import { useLoadingIndicator as M } from "../../contexts/LoadingIndicatorProvider/useLoadingIndicator.js";
17
+ const O = (e) => e.map((o) => o.message ? /* @__PURE__ */ r("li", { children: o.message }, o.key) : null), h = (e, o) => {
18
18
  const m = o ? o + "." : "";
19
19
  if (e.category === "invalid_attribute_value" || e.category === "invalid_operation")
20
20
  return [
@@ -24,28 +24,28 @@ const O = (e) => e.map((o) => o.message ? /* @__PURE__ */ r("li", { children: o.
24
24
  }
25
25
  ];
26
26
  if (e.category === "nested_errors" && e.errors !== void 0) {
27
- let n = "";
28
- return e.metadata?.key && typeof e.metadata.key == "string" ? n = e.metadata.key : e.metadata?.state && typeof e.metadata.state == "string" ? n = e.metadata.state : e.errorKey && (n = e.errorKey), e.errors.flatMap((t) => k(t, m + n));
27
+ let a = "";
28
+ return e.metadata?.key && typeof e.metadata.key == "string" ? a = e.metadata.key : e.metadata?.state && typeof e.metadata.state == "string" ? a = e.metadata.state : e.errorKey && (a = e.errorKey), e.errors.flatMap((t) => h(t, m + a));
29
29
  }
30
30
  return [];
31
- }, $ = ({
31
+ }, te = ({
32
32
  children: e,
33
33
  FallbackComponent: o = P,
34
- LoaderComponent: m = K,
35
- onEvent: n
34
+ LoaderComponent: m,
35
+ onEvent: a
36
36
  }) => {
37
- const [t, l] = y(null), [c, p] = y(null), d = I(), { t: x } = S(), f = M(), C = (s) => {
38
- l(s), s instanceof h && Array.isArray(s.errors) && p(s.errors.flatMap((a) => k(a)));
39
- }, b = v(
40
- async (s, a) => {
37
+ const [t, l] = y(null), [c, p] = y(null), f = K(), { t: k } = S(), d = F(), { LoadingIndicator: x } = M(), b = m ?? x, v = (n) => {
38
+ l(n), n instanceof C && Array.isArray(n.errors) && p(n.errors.flatMap((s) => h(s)));
39
+ }, I = A(
40
+ async (n, s) => {
41
41
  l(null), p(null);
42
42
  try {
43
- await a(s);
43
+ await s(n);
44
44
  } catch (i) {
45
- i instanceof E || i instanceof g || i instanceof h ? C(i) : d(i);
45
+ i instanceof E || i instanceof g || i instanceof C ? v(i) : f(i);
46
46
  }
47
47
  },
48
- [l, d]
48
+ [l, f]
49
49
  );
50
50
  return /* @__PURE__ */ r(
51
51
  _.Provider,
@@ -53,25 +53,25 @@ const O = (e) => e.map((o) => o.message ? /* @__PURE__ */ r("li", { children: o.
53
53
  value: {
54
54
  fieldErrors: c,
55
55
  setError: l,
56
- onEvent: n,
57
- throwError: d,
58
- baseSubmitHandler: b
56
+ onEvent: a,
57
+ throwError: f,
58
+ baseSubmitHandler: I
59
59
  },
60
- children: /* @__PURE__ */ r(B, { children: ({ reset: s }) => /* @__PURE__ */ u(
60
+ children: /* @__PURE__ */ r(B, { children: ({ reset: n }) => /* @__PURE__ */ u(
61
61
  R,
62
62
  {
63
63
  FallbackComponent: o,
64
- onReset: s,
65
- onError: (a) => {
66
- n(j.ERROR, a);
64
+ onReset: n,
65
+ onError: (s) => {
66
+ a(j.ERROR, s);
67
67
  },
68
68
  children: [
69
- (t || c) && /* @__PURE__ */ u(f.Alert, { label: x("status.errorEncountered"), status: "error", children: [
70
- c && /* @__PURE__ */ r(f.UnorderedList, { items: O(c) }),
71
- t && t instanceof E && /* @__PURE__ */ r(f.Text, { children: t.message }),
72
- t && t instanceof g && /* @__PURE__ */ r(f.Text, { as: "pre", children: t.pretty() })
69
+ (t || c) && /* @__PURE__ */ u(d.Alert, { label: k("status.errorEncountered"), status: "error", children: [
70
+ c && /* @__PURE__ */ r(d.UnorderedList, { items: O(c) }),
71
+ t && t instanceof E && /* @__PURE__ */ r(d.Text, { children: t.message }),
72
+ t && t instanceof g && /* @__PURE__ */ r(d.Text, { as: "pre", children: t.pretty() })
73
73
  ] }),
74
- /* @__PURE__ */ r(A, { fallback: /* @__PURE__ */ r(m, {}), children: /* @__PURE__ */ r(T, { children: e }) })
74
+ /* @__PURE__ */ r(L, { fallback: /* @__PURE__ */ r(b, {}), children: /* @__PURE__ */ r(T, { children: e }) })
75
75
  ]
76
76
  }
77
77
  ) })
@@ -79,6 +79,6 @@ const O = (e) => e.map((o) => o.message ? /* @__PURE__ */ r("li", { children: o.
79
79
  );
80
80
  };
81
81
  export {
82
- $ as BaseComponent
82
+ te as BaseComponent
83
83
  };
84
84
  //# sourceMappingURL=Base.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Base.js","sources":["../../../src/components/Base/Base.tsx"],"sourcesContent":["import type { ReactNode, JSX } from 'react'\nimport { Suspense, useState, useCallback } from 'react'\nimport type { FallbackProps } from 'react-error-boundary'\nimport { ErrorBoundary } from 'react-error-boundary'\nimport { useTranslation } from 'react-i18next'\nimport { APIError } from '@gusto/embedded-api/models/errors/apierror'\nimport { SDKValidationError } from '@gusto/embedded-api/models/errors/sdkvalidationerror'\nimport { UnprocessableEntityErrorObject } from '@gusto/embedded-api/models/errors/unprocessableentityerrorobject'\nimport type { EntityErrorObject } from '@gusto/embedded-api/models/components/entityerrorobject'\nimport { QueryErrorResetBoundary } from '@tanstack/react-query'\nimport { FadeIn } from '../Common/FadeIn/FadeIn'\nimport { BaseContext, type FieldError, type KnownErrors, type OnEventType } from './useBase'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport { InternalError, Loading, useAsyncError } from '@/components/Common'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport type { ResourceDictionary, Resources } from '@/types/Helpers'\n\nexport interface CommonComponentInterface<TResourceKey extends keyof Resources = keyof Resources> {\n children?: ReactNode\n className?: string\n defaultValues?: unknown\n dictionary?: ResourceDictionary<TResourceKey>\n}\n\n// Base component wrapper with error and suspense handling\nexport interface BaseComponentInterface<TResourceKey extends keyof Resources = keyof Resources>\n extends CommonComponentInterface<TResourceKey> {\n FallbackComponent?: (props: FallbackProps) => JSX.Element\n LoaderComponent?: () => JSX.Element\n onEvent: OnEventType<EventType, unknown>\n}\n\n/**Traverses errorList and finds items with message properties */\nconst renderErrorList = (errorList: FieldError[]): React.ReactNode[] => {\n return errorList.map(errorFromList => {\n if (errorFromList.message) {\n return <li key={errorFromList.key}>{errorFromList.message}</li>\n }\n return null\n })\n}\n/**Recuresively parses error list and constructs an array of objects containing attribute value error messages associated with form fields. Nested errors construct '.' separated keys\n * metadata.state is a special case for state taxes validation errors\n */\nconst getFieldErrors = (\n error: EntityErrorObject,\n parentKey?: string,\n): { key: string; message: string }[] => {\n const keyPrefix = parentKey ? parentKey + '.' : ''\n if (error.category === 'invalid_attribute_value' || error.category === 'invalid_operation') {\n return [\n {\n key: snakeCaseToCamelCase(keyPrefix + error.errorKey),\n message: error.message ?? '',\n },\n ]\n }\n if (error.category === 'nested_errors' && error.errors !== undefined) {\n //TODO: clean this up once Metadata type is fixed in openapi spec\n let keySuffix = ''\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n if (error.metadata?.key && typeof error.metadata.key === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.key as string\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n } else if (error.metadata?.state && typeof error.metadata.state === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.state as string\n } else if (error.errorKey) {\n keySuffix = error.errorKey\n }\n return error.errors.flatMap(err => getFieldErrors(err, keyPrefix + keySuffix))\n }\n return []\n}\n\ntype SubmitHandler<T> = (data: T) => Promise<void>\n\nexport const BaseComponent = <TResourceKey extends keyof Resources = keyof Resources>({\n children,\n FallbackComponent = InternalError,\n LoaderComponent = Loading,\n onEvent,\n}: BaseComponentInterface<TResourceKey>) => {\n const [error, setError] = useState<KnownErrors | null>(null)\n const [fieldErrors, setFieldErrors] = useState<FieldError[] | null>(null)\n const throwError = useAsyncError()\n const { t } = useTranslation()\n const Components = useComponentContext()\n\n const processError = (error: KnownErrors) => {\n setError(error)\n //422\tapplication/json - content relaited error\n if (error instanceof UnprocessableEntityErrorObject && Array.isArray(error.errors)) {\n setFieldErrors(error.errors.flatMap(err => getFieldErrors(err)))\n }\n }\n\n const baseSubmitHandler = useCallback(\n async <T,>(data: T, componentHandler: SubmitHandler<T>) => {\n setError(null)\n setFieldErrors(null)\n try {\n await componentHandler(data)\n } catch (err) {\n if (\n err instanceof APIError ||\n err instanceof SDKValidationError ||\n err instanceof UnprocessableEntityErrorObject\n ) {\n processError(err)\n } else throwError(err)\n }\n },\n [setError, throwError],\n )\n\n return (\n <BaseContext.Provider\n value={{\n fieldErrors,\n setError,\n onEvent,\n throwError,\n baseSubmitHandler,\n }}\n >\n <QueryErrorResetBoundary>\n {({ reset: resetQueries }) => (\n <ErrorBoundary\n FallbackComponent={FallbackComponent}\n onReset={resetQueries}\n onError={err => {\n onEvent(componentEvents.ERROR, err)\n }}\n >\n {(error || fieldErrors) && (\n <Components.Alert label={t('status.errorEncountered')} status=\"error\">\n {fieldErrors && <Components.UnorderedList items={renderErrorList(fieldErrors)} />}\n {error && error instanceof APIError && (\n <Components.Text>{error.message}</Components.Text>\n )}\n {error && error instanceof SDKValidationError && (\n <Components.Text as=\"pre\">{error.pretty()}</Components.Text>\n )}\n </Components.Alert>\n )}\n <Suspense fallback={<LoaderComponent />}>\n <FadeIn>{children}</FadeIn>\n </Suspense>\n </ErrorBoundary>\n )}\n </QueryErrorResetBoundary>\n </BaseContext.Provider>\n )\n}\n"],"names":["renderErrorList","errorList","errorFromList","jsx","getFieldErrors","error","parentKey","keyPrefix","snakeCaseToCamelCase","keySuffix","err","BaseComponent","children","FallbackComponent","InternalError","LoaderComponent","Loading","onEvent","setError","useState","fieldErrors","setFieldErrors","throwError","useAsyncError","t","useTranslation","Components","useComponentContext","processError","UnprocessableEntityErrorObject","baseSubmitHandler","useCallback","data","componentHandler","APIError","SDKValidationError","BaseContext","QueryErrorResetBoundary","resetQueries","jsxs","ErrorBoundary","componentEvents","Suspense","FadeIn"],"mappings":";;;;;;;;;;;;;;;;AAkCA,MAAMA,IAAkB,CAACC,MAChBA,EAAU,IAAI,CAAiBC,MAChCA,EAAc,UACR,gBAAAC,EAAA,M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AAA;AAAA,MAAA,EAGN,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
1
+ {"version":3,"file":"Base.js","sources":["../../../src/components/Base/Base.tsx"],"sourcesContent":["import type { ReactNode, JSX } from 'react'\nimport { Suspense, useState, useCallback } from 'react'\nimport type { FallbackProps } from 'react-error-boundary'\nimport { ErrorBoundary } from 'react-error-boundary'\nimport { useTranslation } from 'react-i18next'\nimport { APIError } from '@gusto/embedded-api/models/errors/apierror'\nimport { SDKValidationError } from '@gusto/embedded-api/models/errors/sdkvalidationerror'\nimport { UnprocessableEntityErrorObject } from '@gusto/embedded-api/models/errors/unprocessableentityerrorobject'\nimport type { EntityErrorObject } from '@gusto/embedded-api/models/components/entityerrorobject'\nimport { QueryErrorResetBoundary } from '@tanstack/react-query'\nimport { FadeIn } from '../Common/FadeIn/FadeIn'\nimport { BaseContext, type FieldError, type KnownErrors, type OnEventType } from './useBase'\nimport { componentEvents, type EventType } from '@/shared/constants'\nimport { InternalError, useAsyncError } from '@/components/Common'\nimport { snakeCaseToCamelCase } from '@/helpers/formattedStrings'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport type { ResourceDictionary, Resources } from '@/types/Helpers'\nimport { useLoadingIndicator } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\nimport type { LoadingIndicatorContextProps } from '@/contexts/LoadingIndicatorProvider/useLoadingIndicator'\n\nexport interface CommonComponentInterface<TResourceKey extends keyof Resources = keyof Resources> {\n children?: ReactNode\n className?: string\n defaultValues?: unknown\n dictionary?: ResourceDictionary<TResourceKey>\n}\n\n// Base component wrapper with error and suspense handling\nexport interface BaseComponentInterface<TResourceKey extends keyof Resources = keyof Resources>\n extends CommonComponentInterface<TResourceKey> {\n FallbackComponent?: (props: FallbackProps) => JSX.Element\n LoaderComponent?: LoadingIndicatorContextProps['LoadingIndicator']\n onEvent: OnEventType<EventType, unknown>\n}\n\n/**Traverses errorList and finds items with message properties */\nconst renderErrorList = (errorList: FieldError[]): React.ReactNode[] => {\n return errorList.map(errorFromList => {\n if (errorFromList.message) {\n return <li key={errorFromList.key}>{errorFromList.message}</li>\n }\n return null\n })\n}\n/**Recuresively parses error list and constructs an array of objects containing attribute value error messages associated with form fields. Nested errors construct '.' separated keys\n * metadata.state is a special case for state taxes validation errors\n */\nconst getFieldErrors = (\n error: EntityErrorObject,\n parentKey?: string,\n): { key: string; message: string }[] => {\n const keyPrefix = parentKey ? parentKey + '.' : ''\n if (error.category === 'invalid_attribute_value' || error.category === 'invalid_operation') {\n return [\n {\n key: snakeCaseToCamelCase(keyPrefix + error.errorKey),\n message: error.message ?? '',\n },\n ]\n }\n if (error.category === 'nested_errors' && error.errors !== undefined) {\n //TODO: clean this up once Metadata type is fixed in openapi spec\n let keySuffix = ''\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n if (error.metadata?.key && typeof error.metadata.key === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.key as string\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n } else if (error.metadata?.state && typeof error.metadata.state === 'string') {\n //@ts-expect-error: Metadata in speakeasy is incorrectly typed\n keySuffix = error.metadata.state as string\n } else if (error.errorKey) {\n keySuffix = error.errorKey\n }\n return error.errors.flatMap(err => getFieldErrors(err, keyPrefix + keySuffix))\n }\n return []\n}\n\ntype SubmitHandler<T> = (data: T) => Promise<void>\n\nexport const BaseComponent = <TResourceKey extends keyof Resources = keyof Resources>({\n children,\n FallbackComponent = InternalError,\n LoaderComponent: LoadingIndicatorFromProps,\n onEvent,\n}: BaseComponentInterface<TResourceKey>) => {\n const [error, setError] = useState<KnownErrors | null>(null)\n const [fieldErrors, setFieldErrors] = useState<FieldError[] | null>(null)\n const throwError = useAsyncError()\n const { t } = useTranslation()\n const Components = useComponentContext()\n\n const { LoadingIndicator: LoadingIndicatorFromContext } = useLoadingIndicator()\n\n const LoaderComponent = LoadingIndicatorFromProps ?? LoadingIndicatorFromContext\n\n const processError = (error: KnownErrors) => {\n setError(error)\n //422\tapplication/json - content relaited error\n if (error instanceof UnprocessableEntityErrorObject && Array.isArray(error.errors)) {\n setFieldErrors(error.errors.flatMap(err => getFieldErrors(err)))\n }\n }\n\n const baseSubmitHandler = useCallback(\n async <T,>(data: T, componentHandler: SubmitHandler<T>) => {\n setError(null)\n setFieldErrors(null)\n try {\n await componentHandler(data)\n } catch (err) {\n if (\n err instanceof APIError ||\n err instanceof SDKValidationError ||\n err instanceof UnprocessableEntityErrorObject\n ) {\n processError(err)\n } else throwError(err)\n }\n },\n [setError, throwError],\n )\n\n return (\n <BaseContext.Provider\n value={{\n fieldErrors,\n setError,\n onEvent,\n throwError,\n baseSubmitHandler,\n }}\n >\n <QueryErrorResetBoundary>\n {({ reset: resetQueries }) => (\n <ErrorBoundary\n FallbackComponent={FallbackComponent}\n onReset={resetQueries}\n onError={err => {\n onEvent(componentEvents.ERROR, err)\n }}\n >\n {(error || fieldErrors) && (\n <Components.Alert label={t('status.errorEncountered')} status=\"error\">\n {fieldErrors && <Components.UnorderedList items={renderErrorList(fieldErrors)} />}\n {error && error instanceof APIError && (\n <Components.Text>{error.message}</Components.Text>\n )}\n {error && error instanceof SDKValidationError && (\n <Components.Text as=\"pre\">{error.pretty()}</Components.Text>\n )}\n </Components.Alert>\n )}\n <Suspense fallback={<LoaderComponent />}>\n <FadeIn>{children}</FadeIn>\n </Suspense>\n </ErrorBoundary>\n )}\n </QueryErrorResetBoundary>\n </BaseContext.Provider>\n )\n}\n"],"names":["renderErrorList","errorList","errorFromList","jsx","getFieldErrors","error","parentKey","keyPrefix","snakeCaseToCamelCase","keySuffix","err","BaseComponent","children","FallbackComponent","InternalError","LoadingIndicatorFromProps","onEvent","setError","useState","fieldErrors","setFieldErrors","throwError","useAsyncError","t","useTranslation","Components","useComponentContext","LoadingIndicatorFromContext","useLoadingIndicator","LoaderComponent","processError","UnprocessableEntityErrorObject","baseSubmitHandler","useCallback","data","componentHandler","APIError","SDKValidationError","BaseContext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B,EAAW,MAAX,EAAgB,IAAG,OAAO,UAAMpB,EAAA,OAAA,EAAS,CAAA;AAAA,YAAA,GAE9C;AAAA,YAEF,gBAAAF,EAACyC,KAAS,UAAU,gBAAAzC,EAAC0B,KAAgB,GACnC,UAAA,gBAAA1B,EAAC0C,GAAQ,EAAA,UAAAjC,EAAS,CAAA,EACpB,CAAA;AAAA,UAAA;AAAA,QAAA;AAAA,MAAA,EAGN,CAAA;AAAA,IAAA;AAAA,EACF;AAEJ;"}
@@ -1,10 +1,10 @@
1
1
  import { jsx as c } from "react/jsx-runtime";
2
2
  import { BankAccountList as e } from "./BankAccountList/BankAccountList.js";
3
- import { BankAccountForm as m } from "./BankAccountForm/BankAccountForm.js";
4
- import { BankAccountVerify as a } from "./BankAccountVerify/BankAccountVerify.js";
3
+ import { BankAccountForm as i } from "./BankAccountForm/BankAccountForm.js";
4
+ import { BankAccountVerify as m } from "./BankAccountVerify/BankAccountVerify.js";
5
5
  import { useFlow as r } from "../../Flow/useFlow.js";
6
6
  import { ensureRequired as u } from "../../../helpers/ensureRequired.js";
7
- function y() {
7
+ function A() {
8
8
  const { companyId: n, showVerifiedMessage: o, onEvent: t } = r();
9
9
  return /* @__PURE__ */ c(
10
10
  e,
@@ -15,14 +15,21 @@ function y() {
15
15
  }
16
16
  );
17
17
  }
18
- function A() {
19
- const { companyId: n, onEvent: o } = r();
20
- return /* @__PURE__ */ c(m, { companyId: u(n), onEvent: o });
18
+ function y() {
19
+ const { companyId: n, onEvent: o, bankAccount: t } = r();
20
+ return /* @__PURE__ */ c(
21
+ i,
22
+ {
23
+ companyId: u(n),
24
+ onEvent: o,
25
+ isEditing: !!t
26
+ }
27
+ );
21
28
  }
22
29
  function I() {
23
30
  const { bankAccount: n, companyId: o, onEvent: t } = r();
24
31
  return n ? /* @__PURE__ */ c(
25
- a,
32
+ m,
26
33
  {
27
34
  companyId: u(o),
28
35
  bankAccountId: n.uuid,
@@ -31,8 +38,8 @@ function I() {
31
38
  ) : null;
32
39
  }
33
40
  export {
34
- A as BankAccountFormContextual,
35
- y as BankAccountListContextual,
41
+ y as BankAccountFormContextual,
42
+ A as BankAccountListContextual,
36
43
  I as BankAccountVerifyContextual
37
44
  };
38
45
  //# sourceMappingURL=BankAccountComponents.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"BankAccountComponents.js","sources":["../../../../src/components/Company/BankAccount/BankAccountComponents.tsx"],"sourcesContent":["import type { CompanyBankAccount } from '@gusto/embedded-api/models/components/companybankaccount'\nimport { BankAccountList } from './BankAccountList/BankAccountList'\nimport { BankAccountForm } from './BankAccountForm/BankAccountForm'\nimport { BankAccountVerify } from './BankAccountVerify/BankAccountVerify'\nimport { useFlow, type FlowContextInterface } from '@/components/Flow/useFlow'\nimport type { componentEvents } from '@/shared/constants'\nimport { ensureRequired } from '@/helpers/ensureRequired'\n\nexport type EventPayloads = {\n [componentEvents.COMPANY_BANK_ACCOUNT_CREATED]: CompanyBankAccount\n [componentEvents.COMPANY_BANK_ACCOUNT_VERIFIED]: CompanyBankAccount\n [componentEvents.COMPANY_BANK_ACCOUNT_CHANGE]: undefined\n}\n\nexport interface BankAccountContextInterface extends FlowContextInterface {\n companyId: string\n bankAccount: CompanyBankAccount | null\n showVerifiedMessage?: boolean\n}\n\nexport function BankAccountListContextual() {\n const { companyId, showVerifiedMessage, onEvent } = useFlow<BankAccountContextInterface>()\n return (\n <BankAccountList\n onEvent={onEvent}\n companyId={ensureRequired(companyId)}\n showVerifiedMessage={showVerifiedMessage}\n />\n )\n}\nexport function BankAccountFormContextual() {\n const { companyId, onEvent } = useFlow<BankAccountContextInterface>()\n return <BankAccountForm companyId={ensureRequired(companyId)} onEvent={onEvent} />\n}\nexport function BankAccountVerifyContextual() {\n const { bankAccount, companyId, onEvent } = useFlow<BankAccountContextInterface>()\n if (!bankAccount) return null\n return (\n <BankAccountVerify\n companyId={ensureRequired(companyId)}\n bankAccountId={bankAccount.uuid}\n onEvent={onEvent}\n />\n )\n}\n"],"names":["BankAccountListContextual","companyId","showVerifiedMessage","onEvent","useFlow","jsx","BankAccountList","ensureRequired","BankAccountFormContextual","BankAccountForm","BankAccountVerifyContextual","bankAccount","BankAccountVerify"],"mappings":";;;;;;AAoBO,SAASA,IAA4B;AAC1C,QAAM,EAAE,WAAAC,GAAW,qBAAAC,GAAqB,SAAAC,EAAA,IAAYC,EAAqC;AAEvF,SAAA,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,SAAAH;AAAA,MACA,WAAWI,EAAeN,CAAS;AAAA,MACnC,qBAAAC;AAAA,IAAA;AAAA,EACF;AAEJ;AACO,SAASM,IAA4B;AAC1C,QAAM,EAAE,WAAAP,GAAW,SAAAE,EAAQ,IAAIC,EAAqC;AACpE,2BAAQK,GAAgB,EAAA,WAAWF,EAAeN,CAAS,GAAG,SAAAE,GAAkB;AAClF;AACO,SAASO,IAA8B;AAC5C,QAAM,EAAE,aAAAC,GAAa,WAAAV,GAAW,SAAAE,EAAA,IAAYC,EAAqC;AAC7E,SAACO,IAEH,gBAAAN;AAAA,IAACO;AAAA,IAAA;AAAA,MACC,WAAWL,EAAeN,CAAS;AAAA,MACnC,eAAeU,EAAY;AAAA,MAC3B,SAAAR;AAAA,IAAA;AAAA,EACF,IANuB;AAQ3B;"}
1
+ {"version":3,"file":"BankAccountComponents.js","sources":["../../../../src/components/Company/BankAccount/BankAccountComponents.tsx"],"sourcesContent":["import type { CompanyBankAccount } from '@gusto/embedded-api/models/components/companybankaccount'\nimport { BankAccountList } from './BankAccountList/BankAccountList'\nimport { BankAccountForm } from './BankAccountForm/BankAccountForm'\nimport { BankAccountVerify } from './BankAccountVerify/BankAccountVerify'\nimport { useFlow, type FlowContextInterface } from '@/components/Flow/useFlow'\nimport type { componentEvents } from '@/shared/constants'\nimport { ensureRequired } from '@/helpers/ensureRequired'\n\nexport type EventPayloads = {\n [componentEvents.COMPANY_BANK_ACCOUNT_CREATED]: CompanyBankAccount\n [componentEvents.COMPANY_BANK_ACCOUNT_VERIFIED]: CompanyBankAccount\n [componentEvents.COMPANY_BANK_ACCOUNT_CHANGE]: undefined\n}\n\nexport interface BankAccountContextInterface extends FlowContextInterface {\n companyId: string\n bankAccount: CompanyBankAccount | null\n showVerifiedMessage?: boolean\n}\n\nexport function BankAccountListContextual() {\n const { companyId, showVerifiedMessage, onEvent } = useFlow<BankAccountContextInterface>()\n return (\n <BankAccountList\n onEvent={onEvent}\n companyId={ensureRequired(companyId)}\n showVerifiedMessage={showVerifiedMessage}\n />\n )\n}\nexport function BankAccountFormContextual() {\n const { companyId, onEvent, bankAccount } = useFlow<BankAccountContextInterface>()\n return (\n <BankAccountForm\n companyId={ensureRequired(companyId)}\n onEvent={onEvent}\n isEditing={!!bankAccount}\n />\n )\n}\nexport function BankAccountVerifyContextual() {\n const { bankAccount, companyId, onEvent } = useFlow<BankAccountContextInterface>()\n if (!bankAccount) return null\n return (\n <BankAccountVerify\n companyId={ensureRequired(companyId)}\n bankAccountId={bankAccount.uuid}\n onEvent={onEvent}\n />\n )\n}\n"],"names":["BankAccountListContextual","companyId","showVerifiedMessage","onEvent","useFlow","jsx","BankAccountList","ensureRequired","BankAccountFormContextual","bankAccount","BankAccountForm","BankAccountVerifyContextual","BankAccountVerify"],"mappings":";;;;;;AAoBO,SAASA,IAA4B;AAC1C,QAAM,EAAE,WAAAC,GAAW,qBAAAC,GAAqB,SAAAC,EAAA,IAAYC,EAAqC;AAEvF,SAAA,gBAAAC;AAAA,IAACC;AAAA,IAAA;AAAA,MACC,SAAAH;AAAA,MACA,WAAWI,EAAeN,CAAS;AAAA,MACnC,qBAAAC;AAAA,IAAA;AAAA,EACF;AAEJ;AACO,SAASM,IAA4B;AAC1C,QAAM,EAAE,WAAAP,GAAW,SAAAE,GAAS,aAAAM,EAAA,IAAgBL,EAAqC;AAE/E,SAAA,gBAAAC;AAAA,IAACK;AAAA,IAAA;AAAA,MACC,WAAWH,EAAeN,CAAS;AAAA,MACnC,SAAAE;AAAA,MACA,WAAW,CAAC,CAACM;AAAA,IAAA;AAAA,EACf;AAEJ;AACO,SAASE,IAA8B;AAC5C,QAAM,EAAE,aAAAF,GAAa,WAAAR,GAAW,SAAAE,EAAA,IAAYC,EAAqC;AAC7E,SAACK,IAEH,gBAAAJ;AAAA,IAACO;AAAA,IAAA;AAAA,MACC,WAAWL,EAAeN,CAAS;AAAA,MACnC,eAAeQ,EAAY;AAAA,MAC3B,SAAAN;AAAA,IAAA;AAAA,EACF,IANuB;AAQ3B;"}
@@ -1,13 +1,27 @@
1
- import { jsx as t } from "react/jsx-runtime";
2
- import { useTranslation as r } from "react-i18next";
1
+ import { jsxs as e, jsx as o } from "react/jsx-runtime";
2
+ import { useTranslation as s } from "react-i18next";
3
3
  import { useBankAccountForm as m } from "./context.js";
4
- import { ActionsLayout as s } from "../../../Common/ActionsLayout/ActionsLayout.js";
5
- import { useComponentContext as c } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
6
- function f() {
7
- const { t: o } = r("Company.BankAccount"), { isPending: n } = m(), i = c();
8
- return /* @__PURE__ */ t(s, { children: /* @__PURE__ */ t(i.Button, { type: "submit", isLoading: n, "data-testid": "bank-account-submit", children: o("continueCta") }) });
4
+ import { ActionsLayout as a } from "../../../Common/ActionsLayout/ActionsLayout.js";
5
+ import { useComponentContext as u } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
6
+ import { componentEvents as p } from "../../../../shared/constants.js";
7
+ function B() {
8
+ const { t } = s("Company.BankAccount"), { isPending: i, isEditing: r, onEvent: c } = m(), n = u();
9
+ return /* @__PURE__ */ e(a, { children: [
10
+ r && /* @__PURE__ */ o(
11
+ n.Button,
12
+ {
13
+ type: "button",
14
+ variant: "secondary",
15
+ onClick: () => {
16
+ c(p.COMPANY_BANK_ACCOUNT_CANCEL);
17
+ },
18
+ children: t("cancelCta")
19
+ }
20
+ ),
21
+ /* @__PURE__ */ o(n.Button, { type: "submit", isLoading: i, "data-testid": "bank-account-submit", children: t("continueCta") })
22
+ ] });
9
23
  }
10
24
  export {
11
- f as Actions
25
+ B as Actions
12
26
  };
13
27
  //# sourceMappingURL=Actions.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Actions.js","sources":["../../../../../src/components/Company/BankAccount/BankAccountForm/Actions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useBankAccountForm } from './context'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport function Actions() {\n const { t } = useTranslation('Company.BankAccount')\n const { isPending } = useBankAccountForm()\n const Components = useComponentContext()\n\n return (\n <ActionsLayout>\n <Components.Button type=\"submit\" isLoading={isPending} data-testid=\"bank-account-submit\">\n {t('continueCta')}\n </Components.Button>\n </ActionsLayout>\n )\n}\n"],"names":["Actions","t","useTranslation","isPending","useBankAccountForm","Components","useComponentContext","jsx","ActionsLayout"],"mappings":";;;;;AAKO,SAASA,IAAU;AACxB,QAAM,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB,GAC5C,EAAE,WAAAC,EAAU,IAAIC,EAAmB,GACnCC,IAAaC,EAAoB;AAEvC,SACG,gBAAAC,EAAAC,GAAA,EACC,UAAC,gBAAAD,EAAAF,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAWF,GAAW,eAAY,uBAChE,UAAEF,EAAA,aAAa,EAClB,CAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"Actions.js","sources":["../../../../../src/components/Company/BankAccount/BankAccountForm/Actions.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useBankAccountForm } from './context'\nimport { ActionsLayout } from '@/components/Common'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\nimport { componentEvents } from '@/shared/constants'\n\nexport function Actions() {\n const { t } = useTranslation('Company.BankAccount')\n const { isPending, isEditing, onEvent } = useBankAccountForm()\n const Components = useComponentContext()\n\n return (\n <ActionsLayout>\n {isEditing && (\n <Components.Button\n type=\"button\"\n variant=\"secondary\"\n onClick={() => {\n onEvent(componentEvents.COMPANY_BANK_ACCOUNT_CANCEL)\n }}\n >\n {t('cancelCta')}\n </Components.Button>\n )}\n <Components.Button type=\"submit\" isLoading={isPending} data-testid=\"bank-account-submit\">\n {t('continueCta')}\n </Components.Button>\n </ActionsLayout>\n )\n}\n"],"names":["Actions","useTranslation","isPending","isEditing","onEvent","useBankAccountForm","Components","useComponentContext","ActionsLayout","jsx","componentEvents"],"mappings":";;;;;;AAMO,SAASA,IAAU;AACxB,QAAM,EAAE,EAAA,IAAMC,EAAe,qBAAqB,GAC5C,EAAE,WAAAC,GAAW,WAAAC,GAAW,SAAAC,EAAA,IAAYC,EAAmB,GACvDC,IAAaC,EAAoB;AAEvC,2BACGC,GACE,EAAA,UAAA;AAAA,IACCL,KAAA,gBAAAM;AAAA,MAACH,EAAW;AAAA,MAAX;AAAA,QACC,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,SAAS,MAAM;AACb,UAAAF,EAAQM,EAAgB,2BAA2B;AAAA,QACrD;AAAA,QAEC,YAAE,WAAW;AAAA,MAAA;AAAA,IAChB;AAAA,IAED,gBAAAD,EAAAH,EAAW,QAAX,EAAkB,MAAK,UAAS,WAAWJ,GAAW,eAAY,uBAChE,UAAE,EAAA,aAAa,EAClB,CAAA;AAAA,EAAA,GACF;AAEJ;"}
@@ -1,6 +1,7 @@
1
1
  import { BaseComponentInterface, CommonComponentInterface } from '../../../Base/Base';
2
2
  interface BankAccountFormProps extends CommonComponentInterface {
3
3
  companyId: string;
4
+ isEditing?: boolean;
4
5
  }
5
6
  export declare function BankAccountForm(props: BankAccountFormProps & BaseComponentInterface): import("react/jsx-runtime").JSX.Element;
6
7
  export declare namespace BankAccountForm {
@@ -1,45 +1,43 @@
1
- import { jsx as o, jsxs as F, Fragment as k } from "react/jsx-runtime";
2
- import { useBankAccountsCreateMutation as y } from "@gusto/embedded-api/react-query/bankAccountsCreate";
3
- import { useForm as v, FormProvider as b } from "react-hook-form";
4
- import { zodResolver as g } from "@hookform/resolvers/zod";
5
- import { invalidateAllBankAccountsGet as P } from "@gusto/embedded-api/react-query/bankAccountsGet";
6
- import { useQueryClient as x } from "@tanstack/react-query";
7
- import { Head as m } from "./Head.js";
8
- import { BankAccountFormSchema as N, Form as i } from "./Form.js";
9
- import { Actions as c } from "./Actions.js";
10
- import { BankAccountFormProvider as S } from "./context.js";
11
- import { Form as E } from "../../../Common/Form/Form.js";
12
- import { BaseComponent as q } from "../../../Base/Base.js";
13
- import { useBase as w } from "../../../Base/useBase.js";
1
+ import { jsx as o, jsxs as C, Fragment as k } from "react/jsx-runtime";
2
+ import { useBankAccountsCreateMutation as b } from "@gusto/embedded-api/react-query/bankAccountsCreate";
3
+ import { useForm as g, FormProvider as v } from "react-hook-form";
4
+ import { zodResolver as y } from "@hookform/resolvers/zod";
5
+ import { Head as c } from "./Head.js";
6
+ import { BankAccountFormSchema as P, Form as i } from "./Form.js";
7
+ import { Actions as a } from "./Actions.js";
8
+ import { BankAccountFormProvider as x } from "./context.js";
9
+ import { Form as N } from "../../../Common/Form/Form.js";
10
+ import { BaseComponent as S } from "../../../Base/Base.js";
11
+ import { useBase as E } from "../../../Base/useBase.js";
14
12
  import { useI18n as H } from "../../../../i18n/I18n.js";
15
13
  import { Flex as R } from "../../../Common/Flex/Flex.js";
16
14
  import { componentEvents as T } from "../../../../shared/constants.js";
17
15
  function r(n) {
18
- return /* @__PURE__ */ o(q, { ...n, children: /* @__PURE__ */ o(_, { ...n, children: n.children }) });
16
+ return /* @__PURE__ */ o(S, { ...n, children: /* @__PURE__ */ o(_, { ...n, children: n.children }) });
19
17
  }
20
- function _({ companyId: n, className: a, children: t }) {
18
+ function _({ companyId: n, className: s, children: t, isEditing: u = !1 }) {
21
19
  H("Company.BankAccount");
22
- const { onEvent: u, baseSubmitHandler: s } = w(), l = x(), { mutateAsync: d, isPending: f } = y(), { control: p, ...e } = v({
23
- resolver: g(N),
20
+ const { onEvent: e, baseSubmitHandler: d } = E(), { mutateAsync: l, isPending: f } = b(), { control: p, ...m } = g({
21
+ resolver: y(P),
24
22
  defaultValues: { accountNumber: "", routingNumber: "" }
25
23
  }), A = async (h) => {
26
- await s(h, async (B) => {
27
- const { companyBankAccount: C } = await d({
24
+ await d(h, async (B) => {
25
+ const { companyBankAccount: F } = await l({
28
26
  //Account type is always checking for company bank accounts
29
27
  request: { companyId: n, requestBody: { ...B, accountType: "Checking" } }
30
28
  });
31
- await P(l), u(T.COMPANY_BANK_ACCOUNT_CREATED, C);
29
+ e(T.COMPANY_BANK_ACCOUNT_CREATED, F);
32
30
  });
33
31
  };
34
- return /* @__PURE__ */ o("section", { className: a, children: /* @__PURE__ */ o(b, { ...e, control: p, children: /* @__PURE__ */ o(E, { onSubmit: e.handleSubmit(A), children: /* @__PURE__ */ o(S, { value: { isPending: f }, children: /* @__PURE__ */ o(R, { flexDirection: "column", gap: 32, children: t || /* @__PURE__ */ F(k, { children: [
35
- /* @__PURE__ */ o(m, {}),
32
+ return /* @__PURE__ */ o("section", { className: s, children: /* @__PURE__ */ o(v, { ...m, control: p, children: /* @__PURE__ */ o(N, { onSubmit: m.handleSubmit(A), children: /* @__PURE__ */ o(x, { value: { isPending: f, isEditing: u, onEvent: e }, children: /* @__PURE__ */ o(R, { flexDirection: "column", gap: 32, children: t || /* @__PURE__ */ C(k, { children: [
33
+ /* @__PURE__ */ o(c, {}),
36
34
  /* @__PURE__ */ o(i, {}),
37
- /* @__PURE__ */ o(c, {})
35
+ /* @__PURE__ */ o(a, {})
38
36
  ] }) }) }) }) }) });
39
37
  }
40
- r.Head = m;
38
+ r.Head = c;
41
39
  r.Form = i;
42
- r.Actions = c;
40
+ r.Actions = a;
43
41
  export {
44
42
  r as BankAccountForm
45
43
  };
@@ -1 +1 @@
1
- {"version":3,"file":"BankAccountForm.js","sources":["../../../../../src/components/Company/BankAccount/BankAccountForm/BankAccountForm.tsx"],"sourcesContent":["import { useBankAccountsCreateMutation } from '@gusto/embedded-api/react-query/bankAccountsCreate'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { invalidateAllBankAccountsGet } from '@gusto/embedded-api/react-query/bankAccountsGet'\nimport { useQueryClient } from '@tanstack/react-query'\nimport { Head } from './Head'\nimport type { BankAccountFormInputs } from './Form'\nimport { BankAccountFormSchema, Form } from './Form'\nimport { Actions } from './Actions'\nimport { BankAccountFormProvider } from './context'\nimport { Form as HtmlForm } from '@/components/Common/Form'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { useI18n } from '@/i18n/I18n'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { componentEvents } from '@/shared/constants'\n\ninterface BankAccountFormProps extends CommonComponentInterface {\n companyId: string\n}\n\nexport function BankAccountForm(props: BankAccountFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\nfunction Root({ companyId, className, children }: BankAccountFormProps) {\n useI18n('Company.BankAccount')\n const { onEvent, baseSubmitHandler } = useBase()\n const queryClient = useQueryClient()\n\n const { mutateAsync: createBankAccount, isPending: isPendingCreate } =\n useBankAccountsCreateMutation()\n\n const { control, ...methods } = useForm<BankAccountFormInputs>({\n resolver: zodResolver(BankAccountFormSchema),\n defaultValues: { accountNumber: '', routingNumber: '' },\n })\n\n const onSubmit = async (data: BankAccountFormInputs) => {\n await baseSubmitHandler(data, async payload => {\n const { companyBankAccount } = await createBankAccount({\n //Account type is always checking for company bank accounts\n request: { companyId, requestBody: { ...payload, accountType: 'Checking' } },\n })\n\n await invalidateAllBankAccountsGet(queryClient)\n\n onEvent(componentEvents.COMPANY_BANK_ACCOUNT_CREATED, companyBankAccount)\n })\n }\n return (\n <section className={className}>\n <FormProvider {...methods} control={control}>\n <HtmlForm onSubmit={methods.handleSubmit(onSubmit)}>\n <BankAccountFormProvider value={{ isPending: isPendingCreate }}>\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </BankAccountFormProvider>\n </HtmlForm>\n </FormProvider>\n </section>\n )\n}\nBankAccountForm.Head = Head\nBankAccountForm.Form = Form\nBankAccountForm.Actions = Actions\n"],"names":["BankAccountForm","props","jsx","BaseComponent","Root","companyId","className","children","useI18n","onEvent","baseSubmitHandler","useBase","queryClient","useQueryClient","createBankAccount","isPendingCreate","useBankAccountsCreateMutation","control","methods","useForm","zodResolver","BankAccountFormSchema","onSubmit","data","payload","companyBankAccount","invalidateAllBankAccountsGet","componentEvents","FormProvider","HtmlForm","BankAccountFormProvider","Flex","jsxs","Fragment","Head","Form","Actions"],"mappings":";;;;;;;;;;;;;;;;AAsBO,SAASA,EAAgBC,GAAsD;AAElF,SAAA,gBAAAC,EAACC,GAAe,EAAA,GAAGF,GACjB,UAAA,gBAAAC,EAACE,KAAM,GAAGH,GAAQ,UAAMA,EAAA,SAAA,CAAS,EACnC,CAAA;AAEJ;AACA,SAASG,EAAK,EAAE,WAAAC,GAAW,WAAAC,GAAW,UAAAC,KAAkC;AACtE,EAAAC,EAAQ,qBAAqB;AAC7B,QAAM,EAAE,SAAAC,GAAS,mBAAAC,EAAkB,IAAIC,EAAQ,GACzCC,IAAcC,EAAe,GAE7B,EAAE,aAAaC,GAAmB,WAAWC,EAAA,IACjDC,EAA8B,GAE1B,EAAE,SAAAC,GAAS,GAAGC,EAAA,IAAYC,EAA+B;AAAA,IAC7D,UAAUC,EAAYC,CAAqB;AAAA,IAC3C,eAAe,EAAE,eAAe,IAAI,eAAe,GAAG;AAAA,EAAA,CACvD,GAEKC,IAAW,OAAOC,MAAgC;AAChD,UAAAb,EAAkBa,GAAM,OAAMC,MAAW;AAC7C,YAAM,EAAE,oBAAAC,MAAuB,MAAMX,EAAkB;AAAA;AAAA,QAErD,SAAS,EAAE,WAAAT,GAAW,aAAa,EAAE,GAAGmB,GAAS,aAAa,WAAa,EAAA;AAAA,MAAA,CAC5E;AAED,YAAME,EAA6Bd,CAAW,GAEtCH,EAAAkB,EAAgB,8BAA8BF,CAAkB;AAAA,IAAA,CACzE;AAAA,EACH;AACA,SACG,gBAAAvB,EAAA,WAAA,EAAQ,WAAAI,GACP,UAAA,gBAAAJ,EAAC0B,GAAc,EAAA,GAAGV,GAAS,SAAAD,GACzB,UAAC,gBAAAf,EAAA2B,GAAA,EAAS,UAAUX,EAAQ,aAAaI,CAAQ,GAC/C,UAAC,gBAAApB,EAAA4B,GAAA,EAAwB,OAAO,EAAE,WAAWf,EAC3C,GAAA,UAAA,gBAAAb,EAAC6B,GAAK,EAAA,eAAc,UAAS,KAAK,IAC/B,UAAAxB,KAIG,gBAAAyB,EAAAC,GAAA,EAAA,UAAA;AAAA,IAAA,gBAAA/B,EAACgC,GAAK,EAAA;AAAA,sBACLC,GAAK,EAAA;AAAA,sBACLC,GAAQ,CAAA,CAAA;AAAA,EAAA,EAAA,CACX,EAEJ,CAAA,EAAA,CACF,EACF,CAAA,EAAA,CACF,EACF,CAAA;AAEJ;AACApC,EAAgB,OAAOkC;AACvBlC,EAAgB,OAAOmC;AACvBnC,EAAgB,UAAUoC;"}
1
+ {"version":3,"file":"BankAccountForm.js","sources":["../../../../../src/components/Company/BankAccount/BankAccountForm/BankAccountForm.tsx"],"sourcesContent":["import { useBankAccountsCreateMutation } from '@gusto/embedded-api/react-query/bankAccountsCreate'\nimport { FormProvider, useForm } from 'react-hook-form'\nimport { zodResolver } from '@hookform/resolvers/zod'\nimport { Head } from './Head'\nimport type { BankAccountFormInputs } from './Form'\nimport { BankAccountFormSchema, Form } from './Form'\nimport { Actions } from './Actions'\nimport { BankAccountFormProvider } from './context'\nimport { Form as HtmlForm } from '@/components/Common/Form'\nimport type { BaseComponentInterface, CommonComponentInterface } from '@/components/Base/Base'\nimport { BaseComponent } from '@/components/Base/Base'\nimport { useBase } from '@/components/Base/useBase'\nimport { useI18n } from '@/i18n/I18n'\nimport { Flex } from '@/components/Common/Flex/Flex'\nimport { componentEvents } from '@/shared/constants'\n\ninterface BankAccountFormProps extends CommonComponentInterface {\n companyId: string\n isEditing?: boolean\n}\n\nexport function BankAccountForm(props: BankAccountFormProps & BaseComponentInterface) {\n return (\n <BaseComponent {...props}>\n <Root {...props}>{props.children}</Root>\n </BaseComponent>\n )\n}\nfunction Root({ companyId, className, children, isEditing = false }: BankAccountFormProps) {\n useI18n('Company.BankAccount')\n const { onEvent, baseSubmitHandler } = useBase()\n\n const { mutateAsync: createBankAccount, isPending: isPendingCreate } =\n useBankAccountsCreateMutation()\n\n const { control, ...methods } = useForm<BankAccountFormInputs>({\n resolver: zodResolver(BankAccountFormSchema),\n defaultValues: { accountNumber: '', routingNumber: '' },\n })\n\n const onSubmit = async (data: BankAccountFormInputs) => {\n await baseSubmitHandler(data, async payload => {\n const { companyBankAccount } = await createBankAccount({\n //Account type is always checking for company bank accounts\n request: { companyId, requestBody: { ...payload, accountType: 'Checking' } },\n })\n\n onEvent(componentEvents.COMPANY_BANK_ACCOUNT_CREATED, companyBankAccount)\n })\n }\n return (\n <section className={className}>\n <FormProvider {...methods} control={control}>\n <HtmlForm onSubmit={methods.handleSubmit(onSubmit)}>\n <BankAccountFormProvider value={{ isPending: isPendingCreate, isEditing, onEvent }}>\n <Flex flexDirection=\"column\" gap={32}>\n {children ? (\n children\n ) : (\n <>\n <Head />\n <Form />\n <Actions />\n </>\n )}\n </Flex>\n </BankAccountFormProvider>\n </HtmlForm>\n </FormProvider>\n </section>\n )\n}\nBankAccountForm.Head = Head\nBankAccountForm.Form = Form\nBankAccountForm.Actions = Actions\n"],"names":["BankAccountForm","props","jsx","BaseComponent","Root","companyId","className","children","isEditing","useI18n","onEvent","baseSubmitHandler","useBase","createBankAccount","isPendingCreate","useBankAccountsCreateMutation","control","methods","useForm","zodResolver","BankAccountFormSchema","onSubmit","data","payload","companyBankAccount","componentEvents","FormProvider","HtmlForm","BankAccountFormProvider","Flex","jsxs","Fragment","Head","Form","Actions"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GAAA,EAAA,UAAA;AAAA,IAAA,gBAAA7B,EAAC8B,GAAK,EAAA;AAAA,sBACLC,GAAK,EAAA;AAAA,sBACLC,GAAQ,CAAA,CAAA;AAAA,EAAA,EAAA,CACX,EAEJ,CAAA,EAAA,CACF,EACF,CAAA,EAAA,CACF,EACF,CAAA;AAEJ;AACAlC,EAAgB,OAAOgC;AACvBhC,EAAgB,OAAOiC;AACvBjC,EAAgB,UAAUkC;"}
@@ -1,5 +1,9 @@
1
+ import { OnEventType } from '../../../Base/useBase';
2
+ import { EventType } from '../../../../shared/constants';
1
3
  type BankAccountFormContextType = {
2
4
  isPending: boolean;
5
+ isEditing: boolean;
6
+ onEvent: OnEventType<EventType, unknown>;
3
7
  };
4
8
  declare const useBankAccountForm: () => BankAccountFormContextType, BankAccountFormProvider: import('react').Provider<BankAccountFormContextType | null>;
5
9
  export { useBankAccountForm, BankAccountFormProvider };
@@ -1 +1 @@
1
- {"version":3,"file":"context.js","sources":["../../../../../src/components/Company/BankAccount/BankAccountForm/context.ts"],"sourcesContent":["import { createCompoundContext } from '@/components/Base'\n\ntype BankAccountFormContextType = {\n isPending: boolean\n}\n\nconst [useBankAccountForm, BankAccountFormProvider] =\n createCompoundContext<BankAccountFormContextType>('BankAccountContext')\n\nexport { useBankAccountForm, BankAccountFormProvider }\n"],"names":["useBankAccountForm","BankAccountFormProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;AAMA,MAAM,CAACA,GAAoBC,CAAuB,IAChDC,EAAkD,oBAAoB;"}
1
+ {"version":3,"file":"context.js","sources":["../../../../../src/components/Company/BankAccount/BankAccountForm/context.ts"],"sourcesContent":["import { createCompoundContext } from '@/components/Base'\nimport { type OnEventType } from '@/components/Base/useBase'\nimport { type EventType } from '@/shared/constants'\n\ntype BankAccountFormContextType = {\n isPending: boolean\n isEditing: boolean\n onEvent: OnEventType<EventType, unknown>\n}\n\nconst [useBankAccountForm, BankAccountFormProvider] =\n createCompoundContext<BankAccountFormContextType>('BankAccountContext')\n\nexport { useBankAccountForm, BankAccountFormProvider }\n"],"names":["useBankAccountForm","BankAccountFormProvider","createCompoundContext"],"mappings":";;;;;;;;;;;;;AAUA,MAAM,CAACA,GAAoBC,CAAuB,IAChDC,EAAkD,oBAAoB;"}
@@ -1,20 +1,21 @@
1
- import { jsxs as r, jsx as n } from "react/jsx-runtime";
2
- import { useTranslation as t } from "react-i18next";
3
- import { useBankAccount as e } from "./context.js";
4
- function l() {
5
- const { bankAccount: c } = e(), { t: o } = t("Company.BankAccount");
6
- return /* @__PURE__ */ r("dl", { children: [
7
- /* @__PURE__ */ r("div", { children: [
8
- /* @__PURE__ */ n("dt", { children: o("routingNumberLabel") }),
9
- /* @__PURE__ */ n("dd", { children: c?.routingNumber })
1
+ import { jsxs as t, jsx as n } from "react/jsx-runtime";
2
+ import { useTranslation as c } from "react-i18next";
3
+ import { useBankAccount as i } from "./context.js";
4
+ import { useComponentContext as d } from "../../../../contexts/ComponentAdapter/useComponentContext.js";
5
+ function s() {
6
+ const { bankAccount: r } = i(), { t: o } = c("Company.BankAccount"), e = d();
7
+ return /* @__PURE__ */ t("dl", { children: [
8
+ /* @__PURE__ */ t("div", { children: [
9
+ /* @__PURE__ */ n("dt", { children: /* @__PURE__ */ n(e.Text, { children: o("routingNumberLabel") }) }),
10
+ /* @__PURE__ */ n("dd", { children: /* @__PURE__ */ n(e.Text, { children: r?.routingNumber }) })
10
11
  ] }),
11
- /* @__PURE__ */ r("div", { children: [
12
- /* @__PURE__ */ n("dt", { children: o("accountNumberLabel") }),
13
- /* @__PURE__ */ n("dd", { children: c?.hiddenAccountNumber })
12
+ /* @__PURE__ */ t("div", { children: [
13
+ /* @__PURE__ */ n("dt", { children: /* @__PURE__ */ n(e.Text, { children: o("accountNumberLabel") }) }),
14
+ /* @__PURE__ */ n("dd", { children: /* @__PURE__ */ n(e.Text, { children: r?.hiddenAccountNumber }) })
14
15
  ] })
15
16
  ] });
16
17
  }
17
18
  export {
18
- l as AccountView
19
+ s as AccountView
19
20
  };
20
21
  //# sourceMappingURL=AccountView.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AccountView.js","sources":["../../../../../src/components/Company/BankAccount/BankAccountList/AccountView.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useBankAccount } from './context'\n\nexport function AccountView() {\n const { bankAccount } = useBankAccount()\n const { t } = useTranslation('Company.BankAccount')\n\n return (\n <dl>\n <div>\n <dt>{t('routingNumberLabel')}</dt>\n <dd>{bankAccount?.routingNumber}</dd>\n </div>\n <div>\n <dt>{t('accountNumberLabel')}</dt>\n <dd>{bankAccount?.hiddenAccountNumber}</dd>\n </div>\n </dl>\n )\n}\n"],"names":["AccountView","bankAccount","useBankAccount","t","useTranslation","jsxs","jsx"],"mappings":";;;AAGO,SAASA,IAAc;AACtB,QAAA,EAAE,aAAAC,EAAY,IAAIC,EAAe,GACjC,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB;AAElD,2BACG,MACC,EAAA,UAAA;AAAA,IAAA,gBAAAC,EAAC,OACC,EAAA,UAAA;AAAA,MAAC,gBAAAC,EAAA,MAAA,EAAI,UAAEH,EAAA,oBAAoB,EAAE,CAAA;AAAA,MAC7B,gBAAAG,EAAC,MAAI,EAAA,UAAAL,GAAa,cAAc,CAAA;AAAA,IAAA,GAClC;AAAA,sBACC,OACC,EAAA,UAAA;AAAA,MAAC,gBAAAK,EAAA,MAAA,EAAI,UAAEH,EAAA,oBAAoB,EAAE,CAAA;AAAA,MAC7B,gBAAAG,EAAC,MAAI,EAAA,UAAAL,GAAa,oBAAoB,CAAA;AAAA,IAAA,EACxC,CAAA;AAAA,EAAA,GACF;AAEJ;"}
1
+ {"version":3,"file":"AccountView.js","sources":["../../../../../src/components/Company/BankAccount/BankAccountList/AccountView.tsx"],"sourcesContent":["import { useTranslation } from 'react-i18next'\nimport { useBankAccount } from './context'\nimport { useComponentContext } from '@/contexts/ComponentAdapter/useComponentContext'\n\nexport function AccountView() {\n const { bankAccount } = useBankAccount()\n const { t } = useTranslation('Company.BankAccount')\n const Components = useComponentContext()\n\n return (\n <dl>\n <div>\n <dt>\n <Components.Text>{t('routingNumberLabel')}</Components.Text>\n </dt>\n <dd>\n <Components.Text>{bankAccount?.routingNumber}</Components.Text>\n </dd>\n </div>\n <div>\n <dt>\n <Components.Text>{t('accountNumberLabel')}</Components.Text>\n </dt>\n <dd>\n <Components.Text>{bankAccount?.hiddenAccountNumber}</Components.Text>\n </dd>\n </div>\n </dl>\n )\n}\n"],"names":["AccountView","bankAccount","useBankAccount","t","useTranslation","Components","useComponentContext","jsxs","jsx"],"mappings":";;;;AAIO,SAASA,IAAc;AACtB,QAAA,EAAE,aAAAC,EAAY,IAAIC,EAAe,GACjC,EAAE,GAAAC,EAAA,IAAMC,EAAe,qBAAqB,GAC5CC,IAAaC,EAAoB;AAEvC,2BACG,MACC,EAAA,UAAA;AAAA,IAAA,gBAAAC,EAAC,OACC,EAAA,UAAA;AAAA,MAAC,gBAAAC,EAAA,MAAA,EACC,4BAACH,EAAW,MAAX,EAAiB,UAAEF,EAAA,oBAAoB,GAAE,EAC5C,CAAA;AAAA,MACA,gBAAAK,EAAC,QACC,UAAC,gBAAAA,EAAAH,EAAW,MAAX,EAAiB,UAAAJ,GAAa,cAAc,CAAA,EAC/C,CAAA;AAAA,IAAA,GACF;AAAA,sBACC,OACC,EAAA,UAAA;AAAA,MAAC,gBAAAO,EAAA,MAAA,EACC,4BAACH,EAAW,MAAX,EAAiB,UAAEF,EAAA,oBAAoB,GAAE,EAC5C,CAAA;AAAA,MACA,gBAAAK,EAAC,QACC,UAAC,gBAAAA,EAAAH,EAAW,MAAX,EAAiB,UAAAJ,GAAa,oBAAoB,CAAA,EACrD,CAAA;AAAA,IAAA,EACF,CAAA;AAAA,EAAA,GACF;AAEJ;"}
@@ -1,6 +1,6 @@
1
1
  export declare const bankAccountStateMachine: {
2
2
  viewBankAccount: import('robot3').MachineState<"company/bankAccount/change" | "company/bankAccount/verify" | "company/bankAccount/done">;
3
- addBankAccount: import('robot3').MachineState<"company/bankAccount/created">;
3
+ addBankAccount: import('robot3').MachineState<"company/bankAccount/cancel" | "company/bankAccount/created">;
4
4
  verifyBankAccount: import('robot3').MachineState<"company/bankAccount/verified" | "CANCEL">;
5
5
  done: import('robot3').MachineState<string>;
6
6
  };
@@ -1,14 +1,14 @@
1
1
  import { state as a, transition as o, reduce as e } from "robot3";
2
- import { BankAccountListContextual as A, BankAccountFormContextual as i, BankAccountVerifyContextual as C } from "./BankAccountComponents.js";
2
+ import { BankAccountListContextual as A, BankAccountFormContextual as C, BankAccountVerifyContextual as i } from "./BankAccountComponents.js";
3
3
  import { componentEvents as t } from "../../../shared/constants.js";
4
- const s = {
4
+ const B = {
5
5
  viewBankAccount: a(
6
6
  o(
7
7
  t.COMPANY_BANK_ACCOUNT_CHANGE,
8
8
  "addBankAccount",
9
9
  e((n) => ({
10
10
  ...n,
11
- component: i,
11
+ component: C,
12
12
  showVerifiedMessage: !1
13
13
  }))
14
14
  ),
@@ -17,7 +17,7 @@ const s = {
17
17
  "verifyBankAccount",
18
18
  e((n) => ({
19
19
  ...n,
20
- component: C,
20
+ component: i,
21
21
  showVerifiedMessage: !1
22
22
  }))
23
23
  ),
@@ -34,6 +34,14 @@ const s = {
34
34
  bankAccount: c.payload
35
35
  })
36
36
  )
37
+ ),
38
+ o(
39
+ t.COMPANY_BANK_ACCOUNT_CANCEL,
40
+ "viewBankAccount",
41
+ e((n) => ({
42
+ ...n,
43
+ component: A
44
+ }))
37
45
  )
38
46
  ),
39
47
  verifyBankAccount: a(
@@ -61,6 +69,6 @@ const s = {
61
69
  done: a()
62
70
  };
63
71
  export {
64
- s as bankAccountStateMachine
72
+ B as bankAccountStateMachine
65
73
  };
66
74
  //# sourceMappingURL=stateMachine.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stateMachine.js","sources":["../../../../src/components/Company/BankAccount/stateMachine.ts"],"sourcesContent":["import { state, transition, reduce, state as final } from 'robot3'\nimport type { BankAccountContextInterface, EventPayloads } from './BankAccountComponents'\nimport {\n BankAccountFormContextual,\n BankAccountVerifyContextual,\n BankAccountListContextual,\n} from './BankAccountComponents'\nimport { componentEvents } from '@/shared/constants'\nimport type { MachineEventType } from '@/types/Helpers'\n\nexport const bankAccountStateMachine = {\n viewBankAccount: state(\n transition(\n componentEvents.COMPANY_BANK_ACCOUNT_CHANGE,\n 'addBankAccount',\n reduce((ctx: BankAccountContextInterface) => ({\n ...ctx,\n component: BankAccountFormContextual,\n showVerifiedMessage: false,\n })),\n ),\n transition(\n componentEvents.COMPANY_BANK_ACCOUNT_VERIFY,\n 'verifyBankAccount',\n reduce((ctx: BankAccountContextInterface) => ({\n ...ctx,\n component: BankAccountVerifyContextual,\n showVerifiedMessage: false,\n })),\n ),\n transition(componentEvents.COMPANY_BANK_ACCOUNT_DONE, 'done'),\n ),\n addBankAccount: state(\n transition(\n componentEvents.COMPANY_BANK_ACCOUNT_CREATED,\n 'viewBankAccount',\n reduce(\n (\n ctx: BankAccountContextInterface,\n ev: MachineEventType<EventPayloads, typeof componentEvents.COMPANY_BANK_ACCOUNT_CREATED>,\n ) => ({\n ...ctx,\n component: BankAccountListContextual,\n bankAccount: ev.payload,\n }),\n ),\n ),\n ),\n verifyBankAccount: state(\n transition(\n componentEvents.COMPANY_BANK_ACCOUNT_VERIFIED,\n 'viewBankAccount',\n reduce(\n (\n ctx: BankAccountContextInterface,\n ev: MachineEventType<EventPayloads, typeof componentEvents.COMPANY_BANK_ACCOUNT_VERIFIED>,\n ): BankAccountContextInterface => ({\n ...ctx,\n component: BankAccountListContextual,\n bankAccount: ev.payload,\n showVerifiedMessage: ev.payload.verificationStatus === 'verified',\n }),\n ),\n ),\n transition(\n componentEvents.CANCEL,\n 'viewBankAccount',\n reduce((ctx: BankAccountContextInterface) => ({\n ...ctx,\n component: BankAccountListContextual,\n })),\n ),\n ),\n done: final(),\n}\n"],"names":["bankAccountStateMachine","state","transition","componentEvents","reduce","ctx","BankAccountFormContextual","BankAccountVerifyContextual","ev","BankAccountListContextual","final"],"mappings":";;;AAUO,MAAMA,IAA0B;AAAA,EACrC,iBAAiBC;AAAA,IACfC;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC,EAAO,CAACC,OAAsC;AAAA,QAC5C,GAAGA;AAAA,QACH,WAAWC;AAAA,QACX,qBAAqB;AAAA,MAAA,EACrB;AAAA,IACJ;AAAA,IACAJ;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC,EAAO,CAACC,OAAsC;AAAA,QAC5C,GAAGA;AAAA,QACH,WAAWE;AAAA,QACX,qBAAqB;AAAA,MAAA,EACrB;AAAA,IACJ;AAAA,IACAL,EAAWC,EAAgB,2BAA2B,MAAM;AAAA,EAC9D;AAAA,EACA,gBAAgBF;AAAA,IACdC;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC;AAAA,QACE,CACEC,GACAG,OACI;AAAA,UACJ,GAAGH;AAAA,UACH,WAAWI;AAAA,UACX,aAAaD,EAAG;AAAA,QAClB;AAAA,MAAA;AAAA,IACF;AAAA,EAEJ;AAAA,EACA,mBAAmBP;AAAA,IACjBC;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC;AAAA,QACE,CACEC,GACAG,OACiC;AAAA,UACjC,GAAGH;AAAA,UACH,WAAWI;AAAA,UACX,aAAaD,EAAG;AAAA,UAChB,qBAAqBA,EAAG,QAAQ,uBAAuB;AAAA,QACzD;AAAA,MAAA;AAAA,IAEJ;AAAA,IACAN;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC,EAAO,CAACC,OAAsC;AAAA,QAC5C,GAAGA;AAAA,QACH,WAAWI;AAAA,MAAA,EACX;AAAA,IAAA;AAAA,EAEN;AAAA,EACA,MAAMC,EAAM;AACd;"}
1
+ {"version":3,"file":"stateMachine.js","sources":["../../../../src/components/Company/BankAccount/stateMachine.ts"],"sourcesContent":["import { state, transition, reduce, state as final } from 'robot3'\nimport type { BankAccountContextInterface, EventPayloads } from './BankAccountComponents'\nimport {\n BankAccountFormContextual,\n BankAccountVerifyContextual,\n BankAccountListContextual,\n} from './BankAccountComponents'\nimport { componentEvents } from '@/shared/constants'\nimport type { MachineEventType } from '@/types/Helpers'\n\nexport const bankAccountStateMachine = {\n viewBankAccount: state(\n transition(\n componentEvents.COMPANY_BANK_ACCOUNT_CHANGE,\n 'addBankAccount',\n reduce((ctx: BankAccountContextInterface) => ({\n ...ctx,\n component: BankAccountFormContextual,\n showVerifiedMessage: false,\n })),\n ),\n transition(\n componentEvents.COMPANY_BANK_ACCOUNT_VERIFY,\n 'verifyBankAccount',\n reduce((ctx: BankAccountContextInterface) => ({\n ...ctx,\n component: BankAccountVerifyContextual,\n showVerifiedMessage: false,\n })),\n ),\n transition(componentEvents.COMPANY_BANK_ACCOUNT_DONE, 'done'),\n ),\n addBankAccount: state(\n transition(\n componentEvents.COMPANY_BANK_ACCOUNT_CREATED,\n 'viewBankAccount',\n reduce(\n (\n ctx: BankAccountContextInterface,\n ev: MachineEventType<EventPayloads, typeof componentEvents.COMPANY_BANK_ACCOUNT_CREATED>,\n ) => ({\n ...ctx,\n component: BankAccountListContextual,\n bankAccount: ev.payload,\n }),\n ),\n ),\n transition(\n componentEvents.COMPANY_BANK_ACCOUNT_CANCEL,\n 'viewBankAccount',\n reduce((ctx: BankAccountContextInterface) => ({\n ...ctx,\n component: BankAccountListContextual,\n })),\n ),\n ),\n verifyBankAccount: state(\n transition(\n componentEvents.COMPANY_BANK_ACCOUNT_VERIFIED,\n 'viewBankAccount',\n reduce(\n (\n ctx: BankAccountContextInterface,\n ev: MachineEventType<EventPayloads, typeof componentEvents.COMPANY_BANK_ACCOUNT_VERIFIED>,\n ): BankAccountContextInterface => ({\n ...ctx,\n component: BankAccountListContextual,\n bankAccount: ev.payload,\n showVerifiedMessage: ev.payload.verificationStatus === 'verified',\n }),\n ),\n ),\n transition(\n componentEvents.CANCEL,\n 'viewBankAccount',\n reduce((ctx: BankAccountContextInterface) => ({\n ...ctx,\n component: BankAccountListContextual,\n })),\n ),\n ),\n done: final(),\n}\n"],"names":["bankAccountStateMachine","state","transition","componentEvents","reduce","ctx","BankAccountFormContextual","BankAccountVerifyContextual","ev","BankAccountListContextual","final"],"mappings":";;;AAUO,MAAMA,IAA0B;AAAA,EACrC,iBAAiBC;AAAA,IACfC;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC,EAAO,CAACC,OAAsC;AAAA,QAC5C,GAAGA;AAAA,QACH,WAAWC;AAAA,QACX,qBAAqB;AAAA,MAAA,EACrB;AAAA,IACJ;AAAA,IACAJ;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC,EAAO,CAACC,OAAsC;AAAA,QAC5C,GAAGA;AAAA,QACH,WAAWE;AAAA,QACX,qBAAqB;AAAA,MAAA,EACrB;AAAA,IACJ;AAAA,IACAL,EAAWC,EAAgB,2BAA2B,MAAM;AAAA,EAC9D;AAAA,EACA,gBAAgBF;AAAA,IACdC;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC;AAAA,QACE,CACEC,GACAG,OACI;AAAA,UACJ,GAAGH;AAAA,UACH,WAAWI;AAAA,UACX,aAAaD,EAAG;AAAA,QAClB;AAAA,MAAA;AAAA,IAEJ;AAAA,IACAN;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC,EAAO,CAACC,OAAsC;AAAA,QAC5C,GAAGA;AAAA,QACH,WAAWI;AAAA,MAAA,EACX;AAAA,IAAA;AAAA,EAEN;AAAA,EACA,mBAAmBR;AAAA,IACjBC;AAAA,MACEC,EAAgB;AAAA,MAChB;AAAA,MACAC;AAAA,QACE,CACEC,GACAG,OACiC;AAAA,UACjC,GAAGH;AAAA,UACH,WAAWI;AAAA,UACX,aAAaD,EAAG;AAAA,UAChB,qBAAqBA,EAAG,QAAQ,uBAAuB;AAAA,QACzD;AAAA,MAAA;AAAA,IAEJ;AAAA,IACAN;AAAA,MACEC,EAAgB;AAAA,MAChB;AAA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