@gusto/embedded-react-sdk 0.31.0-rc.1 → 0.31.0-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.
|
@@ -2,47 +2,47 @@ import { jsx as i } from "react/jsx-runtime";
|
|
|
2
2
|
import { createMachine as d } from "robot3";
|
|
3
3
|
import { useMemo as l } from "react";
|
|
4
4
|
import { useIsMutating as b } from "@tanstack/react-query";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { documentSignerMachine as A } from "./stateMachine.js";
|
|
5
|
+
import { useI9VerificationGetAuthorization as D } from "@gusto/embedded-api/react-query/i9VerificationGetAuthorization";
|
|
6
|
+
import { mutationKeyI9VerificationUpdate as y } from "@gusto/embedded-api/react-query/i9VerificationUpdate";
|
|
7
|
+
import { useEmployeesGet as L } from "@gusto/embedded-api/react-query/employeesGet";
|
|
8
|
+
import { EmploymentEligibilityContextual as S, DocumentListContextual as h } from "./documentSignerStateMachine.js";
|
|
9
|
+
import { documentSignerMachine as x } from "./stateMachine.js";
|
|
11
10
|
import { Flow as C } from "../../Flow/Flow.js";
|
|
12
11
|
import { BaseComponent as M } from "../../Base/Base.js";
|
|
13
|
-
import { useBase as
|
|
12
|
+
import { useBase as A } from "../../Base/useBase.js";
|
|
14
13
|
import { useComponentDictionary as z } from "../../../i18n/I18n.js";
|
|
15
|
-
function
|
|
14
|
+
function J(o) {
|
|
16
15
|
return /* @__PURE__ */ i(M, { ...o, children: /* @__PURE__ */ i(B, { ...o }) });
|
|
17
16
|
}
|
|
18
17
|
function B({ employeeId: o, onEvent: m, dictionary: a, withEmployeeI9: t = !1 }) {
|
|
19
18
|
z("Employee.DocumentSigner", a);
|
|
20
|
-
const { LoadingIndicator: s } =
|
|
19
|
+
const { LoadingIndicator: s } = A(), { data: u, isLoading: c } = L(
|
|
21
20
|
{ employeeId: o },
|
|
22
21
|
{ enabled: t }
|
|
23
|
-
), r = u?.employee?.onboardingDocumentsConfig?.i9Document === !0, { data: f, isLoading: p } =
|
|
22
|
+
), r = u?.employee?.onboardingDocumentsConfig?.i9Document === !0, { data: f, isLoading: p } = D(
|
|
24
23
|
{ employeeId: o },
|
|
25
24
|
{
|
|
26
25
|
enabled: t && r,
|
|
27
26
|
retry: !1,
|
|
28
|
-
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
28
|
+
throwOnError: (e) => e.httpMeta?.response?.status !== 404
|
|
29
29
|
}
|
|
30
|
-
),
|
|
30
|
+
), n = t && r && !f?.i9Authorization?.employeeSigned, g = l(
|
|
31
31
|
() => d(
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
(
|
|
35
|
-
...
|
|
36
|
-
component:
|
|
32
|
+
n ? "employmentEligibility" : "index",
|
|
33
|
+
x,
|
|
34
|
+
(e) => ({
|
|
35
|
+
...e,
|
|
36
|
+
component: n ? S : h,
|
|
37
37
|
employeeId: o,
|
|
38
38
|
withEmployeeI9: t
|
|
39
39
|
})
|
|
40
40
|
),
|
|
41
|
-
[o,
|
|
41
|
+
[o, n, t]
|
|
42
42
|
);
|
|
43
|
-
return !(b({ mutationKey:
|
|
43
|
+
return !(b({ mutationKey: y() }) > 0) && t && (c || p) ? /* @__PURE__ */ i(s, {}) : /* @__PURE__ */ i(C, { machine: g, onEvent: m });
|
|
44
44
|
}
|
|
45
45
|
export {
|
|
46
|
-
|
|
46
|
+
J as DocumentSigner
|
|
47
47
|
};
|
|
48
48
|
//# sourceMappingURL=DocumentSigner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DocumentSigner.js","sources":["../../../../src/components/Employee/DocumentSigner/DocumentSigner.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { useIsMutating } from '@tanstack/react-query'\nimport { APIError } from '@gusto/embedded-api/models/errors/apierror'\nimport { useI9VerificationGetAuthorization } from '@gusto/embedded-api/react-query/i9VerificationGetAuthorization'\nimport { mutationKeyI9VerificationUpdate } from '@gusto/embedded-api/react-query/i9VerificationUpdate'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n DocumentListContextual,\n EmploymentEligibilityContextual,\n type DocumentSignerContextInterface,\n} from './documentSignerStateMachine'\nimport { documentSignerMachine } from './stateMachine'\nimport { Flow } from '@/components/Flow/Flow'\nimport { BaseComponent, type BaseComponentInterface } from '@/components/Base'\nimport { useBase } from '@/components/Base'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\nexport interface DocumentSignerProps extends BaseComponentInterface<'Employee.DocumentSigner'> {\n employeeId: string\n withEmployeeI9?: boolean\n}\n\nexport function DocumentSigner(props: DocumentSignerProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\nfunction Root({ employeeId, onEvent, dictionary, withEmployeeI9 = false }: DocumentSignerProps) {\n useComponentDictionary('Employee.DocumentSigner', dictionary)\n const { LoadingIndicator } = useBase()\n\n const { data: employeeData, isLoading: employeeLoading } = useEmployeesGet(\n { employeeId },\n { enabled: withEmployeeI9 },\n )\n\n const employeeHasI9Enabled =\n employeeData?.employee?.onboardingDocumentsConfig?.i9Document === true\n\n const { data: i9AuthData, isLoading: i9AuthLoading } = useI9VerificationGetAuthorization(\n { employeeId },\n {\n enabled: withEmployeeI9 && employeeHasI9Enabled,\n retry: false,\n throwOnError: (error: Error) =>
|
|
1
|
+
{"version":3,"file":"DocumentSigner.js","sources":["../../../../src/components/Employee/DocumentSigner/DocumentSigner.tsx"],"sourcesContent":["import { createMachine } from 'robot3'\nimport { useMemo } from 'react'\nimport { useIsMutating } from '@tanstack/react-query'\nimport type { APIError } from '@gusto/embedded-api/models/errors/apierror'\nimport { useI9VerificationGetAuthorization } from '@gusto/embedded-api/react-query/i9VerificationGetAuthorization'\nimport { mutationKeyI9VerificationUpdate } from '@gusto/embedded-api/react-query/i9VerificationUpdate'\nimport { useEmployeesGet } from '@gusto/embedded-api/react-query/employeesGet'\nimport {\n DocumentListContextual,\n EmploymentEligibilityContextual,\n type DocumentSignerContextInterface,\n} from './documentSignerStateMachine'\nimport { documentSignerMachine } from './stateMachine'\nimport { Flow } from '@/components/Flow/Flow'\nimport { BaseComponent, type BaseComponentInterface } from '@/components/Base'\nimport { useBase } from '@/components/Base'\nimport { useComponentDictionary } from '@/i18n/I18n'\n\nexport interface DocumentSignerProps extends BaseComponentInterface<'Employee.DocumentSigner'> {\n employeeId: string\n withEmployeeI9?: boolean\n}\n\nexport function DocumentSigner(props: DocumentSignerProps) {\n return (\n <BaseComponent {...props}>\n <Root {...props} />\n </BaseComponent>\n )\n}\n\nfunction Root({ employeeId, onEvent, dictionary, withEmployeeI9 = false }: DocumentSignerProps) {\n useComponentDictionary('Employee.DocumentSigner', dictionary)\n const { LoadingIndicator } = useBase()\n\n const { data: employeeData, isLoading: employeeLoading } = useEmployeesGet(\n { employeeId },\n { enabled: withEmployeeI9 },\n )\n\n const employeeHasI9Enabled =\n employeeData?.employee?.onboardingDocumentsConfig?.i9Document === true\n\n const { data: i9AuthData, isLoading: i9AuthLoading } = useI9VerificationGetAuthorization(\n { employeeId },\n {\n enabled: withEmployeeI9 && employeeHasI9Enabled,\n retry: false,\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n throwOnError: (error: Error) => (error as APIError).httpMeta?.response?.status !== 404,\n },\n )\n\n const needsI9Form =\n withEmployeeI9 && employeeHasI9Enabled && !i9AuthData?.i9Authorization?.employeeSigned\n\n const machine = useMemo(\n () =>\n createMachine(\n needsI9Form ? 'employmentEligibility' : 'index',\n documentSignerMachine,\n (initialContext: DocumentSignerContextInterface) => ({\n ...initialContext,\n component: needsI9Form ? EmploymentEligibilityContextual : DocumentListContextual,\n employeeId,\n withEmployeeI9,\n }),\n ),\n [employeeId, needsI9Form, withEmployeeI9],\n )\n\n const isSubmittingI9 = useIsMutating({ mutationKey: mutationKeyI9VerificationUpdate() }) > 0\n\n if (!isSubmittingI9 && withEmployeeI9 && (employeeLoading || i9AuthLoading)) {\n return <LoadingIndicator />\n }\n\n return <Flow machine={machine} onEvent={onEvent} />\n}\n"],"names":["DocumentSigner","props","jsx","BaseComponent","Root","employeeId","onEvent","dictionary","withEmployeeI9","useComponentDictionary","LoadingIndicator","useBase","employeeData","employeeLoading","useEmployeesGet","employeeHasI9Enabled","i9AuthData","i9AuthLoading","useI9VerificationGetAuthorization","error","needsI9Form","machine","useMemo","createMachine","documentSignerMachine","initialContext","EmploymentEligibilityContextual","DocumentListContextual","useIsMutating","mutationKeyI9VerificationUpdate","Flow"],"mappings":";;;;;;;;;;;;;AAuBO,SAASA,EAAeC,GAA4B;AACzD,SACE,gBAAAC,EAACC,KAAe,GAAGF,GACjB,4BAACG,GAAA,EAAM,GAAGH,GAAO,EAAA,CACnB;AAEJ;AAEA,SAASG,EAAK,EAAE,YAAAC,GAAY,SAAAC,GAAS,YAAAC,GAAY,gBAAAC,IAAiB,MAA8B;AAC9F,EAAAC,EAAuB,2BAA2BF,CAAU;AAC5D,QAAM,EAAE,kBAAAG,EAAA,IAAqBC,EAAA,GAEvB,EAAE,MAAMC,GAAc,WAAWC,MAAoBC;AAAA,IACzD,EAAE,YAAAT,EAAA;AAAA,IACF,EAAE,SAASG,EAAA;AAAA,EAAe,GAGtBO,IACJH,GAAc,UAAU,2BAA2B,eAAe,IAE9D,EAAE,MAAMI,GAAY,WAAWC,MAAkBC;AAAA,IACrD,EAAE,YAAAb,EAAA;AAAA,IACF;AAAA,MACE,SAASG,KAAkBO;AAAA,MAC3B,OAAO;AAAA;AAAA,MAEP,cAAc,CAACI,MAAkBA,EAAmB,UAAU,UAAU,WAAW;AAAA,IAAA;AAAA,EACrF,GAGIC,IACJZ,KAAkBO,KAAwB,CAACC,GAAY,iBAAiB,gBAEpEK,IAAUC;AAAA,IACd,MACEC;AAAA,MACEH,IAAc,0BAA0B;AAAA,MACxCI;AAAA,MACA,CAACC,OAAoD;AAAA,QACnD,GAAGA;AAAA,QACH,WAAWL,IAAcM,IAAkCC;AAAA,QAC3D,YAAAtB;AAAA,QACA,gBAAAG;AAAA,MAAA;AAAA,IACF;AAAA,IAEJ,CAACH,GAAYe,GAAaZ,CAAc;AAAA,EAAA;AAK1C,SAAI,EAFmBoB,EAAc,EAAE,aAAaC,EAAA,EAAgC,CAAG,IAAI,MAEpErB,MAAmBK,KAAmBI,uBACnDP,GAAA,EAAiB,IAGpB,gBAAAR,EAAC4B,GAAA,EAAK,SAAAT,GAAkB,SAAAf,EAAA,CAAkB;AACnD;"}
|