@remoteoss/remote-flows 0.4.0-alpha.11 → 0.4.0-alpha.12
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.
- package/README.md +1 -0
- package/dist/chunk-7N7ND6Z4.js +2 -0
- package/dist/chunk-7N7ND6Z4.js.map +1 -0
- package/dist/chunk-AN7L3GVL.js +2 -0
- package/dist/{chunk-RWYOUDM5.js.map → chunk-AN7L3GVL.js.map} +1 -1
- package/dist/chunk-AOJAZ4FT.js +2 -0
- package/dist/chunk-AOJAZ4FT.js.map +1 -0
- package/dist/chunk-ASFAGLQI.js +2 -0
- package/dist/chunk-ASFAGLQI.js.map +1 -0
- package/dist/chunk-BYFO5OB6.js +2 -0
- package/dist/chunk-BYFO5OB6.js.map +1 -0
- package/dist/chunk-D53FKWGJ.js +2 -0
- package/dist/chunk-D53FKWGJ.js.map +1 -0
- package/dist/{chunk-RIWPSA6V.js → chunk-IEZAM2XO.js} +2 -2
- package/dist/{chunk-RC2UQDK7.js → chunk-NIOH7TNP.js} +2 -2
- package/dist/{chunk-INW2EQZR.js → chunk-OS3QI7CV.js} +2 -2
- package/dist/{chunk-3QTURBOX.js → chunk-QUM7V5EP.js} +2 -2
- package/dist/{chunk-IG3FJLDR.js → chunk-RDAO365M.js} +2 -2
- package/dist/chunk-WRKHWEZA.js +2 -0
- package/dist/chunk-WRKHWEZA.js.map +1 -0
- package/dist/chunk-X6DRD2I4.js +2 -0
- package/dist/chunk-X6DRD2I4.js.map +1 -0
- package/dist/chunk-XQXFQ7LM.js +2 -0
- package/dist/{chunk-L6LGRALQ.js.map → chunk-XQXFQ7LM.js.map} +1 -1
- package/dist/flows/ContractAmendment/ContractAmendmentFlow.d.ts +1 -1
- package/dist/flows/ContractAmendment/ContractAmendmentFlow.js +1 -1
- package/dist/flows/ContractAmendment/context.d.ts +1 -1
- package/dist/flows/ContractAmendment/hooks.d.ts +1 -1
- package/dist/flows/ContractAmendment/hooks.js +1 -1
- package/dist/flows/ContractAmendment/index.d.ts +1 -1
- package/dist/flows/ContractAmendment/index.js +1 -1
- package/dist/flows/Onboarding/AnnualGrossSalary.js +1 -1
- package/dist/flows/Onboarding/BasicInformationStep.d.ts +6 -1
- package/dist/flows/Onboarding/BasicInformationStep.js +1 -1
- package/dist/flows/Onboarding/BenefitsStep.d.ts +6 -1
- package/dist/flows/Onboarding/BenefitsStep.js +1 -1
- package/dist/flows/Onboarding/ContractDetailsStep.d.ts +6 -1
- package/dist/flows/Onboarding/ContractDetailsStep.js +1 -1
- package/dist/flows/Onboarding/OnboardingFlow.d.ts +2 -2
- package/dist/flows/Onboarding/OnboardingFlow.js +1 -1
- package/dist/flows/Onboarding/OnboardingInvite.d.ts +7 -2
- package/dist/flows/Onboarding/OnboardingInvite.js +1 -1
- package/dist/flows/Onboarding/SelectCountryStep.d.ts +6 -1
- package/dist/flows/Onboarding/SelectCountryStep.js +1 -1
- package/dist/flows/Onboarding/api.d.ts +5 -1
- package/dist/flows/Onboarding/api.js +1 -1
- package/dist/flows/Onboarding/context.d.ts +2 -3
- package/dist/flows/Onboarding/hooks.d.ts +3 -4
- package/dist/flows/Onboarding/hooks.js +1 -1
- package/dist/flows/Onboarding/index.d.ts +1 -1
- package/dist/flows/Onboarding/index.js +1 -1
- package/dist/flows/Onboarding/types.d.ts +19 -0
- package/dist/flows/Termination/TerminationFlow.d.ts +1 -1
- package/dist/flows/Termination/TerminationFlow.js +1 -1
- package/dist/flows/Termination/context.d.ts +1 -1
- package/dist/flows/Termination/hooks.d.ts +1 -1
- package/dist/flows/Termination/hooks.js +1 -1
- package/dist/flows/Termination/index.d.ts +1 -1
- package/dist/flows/Termination/index.js +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/mutations-B6HWH-rZ.d.ts +22 -0
- package/package.json +1 -1
- package/dist/chunk-GAXGAK4P.js +0 -2
- package/dist/chunk-GAXGAK4P.js.map +0 -1
- package/dist/chunk-HGHKZF7M.js +0 -2
- package/dist/chunk-HGHKZF7M.js.map +0 -1
- package/dist/chunk-JTP3LZ77.js +0 -2
- package/dist/chunk-JTP3LZ77.js.map +0 -1
- package/dist/chunk-KHZ2ITFO.js +0 -2
- package/dist/chunk-KHZ2ITFO.js.map +0 -1
- package/dist/chunk-L6LGRALQ.js +0 -2
- package/dist/chunk-RWYOUDM5.js +0 -2
- package/dist/chunk-VEOGRXYK.js +0 -2
- package/dist/chunk-VEOGRXYK.js.map +0 -1
- package/dist/chunk-VJEJUUY2.js +0 -2
- package/dist/chunk-VJEJUUY2.js.map +0 -1
- package/dist/chunk-VJEL5MZJ.js +0 -2
- package/dist/chunk-VJEL5MZJ.js.map +0 -1
- package/dist/mutations-v9H353tz.d.ts +0 -10
- /package/dist/{chunk-RIWPSA6V.js.map → chunk-IEZAM2XO.js.map} +0 -0
- /package/dist/{chunk-RC2UQDK7.js.map → chunk-NIOH7TNP.js.map} +0 -0
- /package/dist/{chunk-INW2EQZR.js.map → chunk-OS3QI7CV.js.map} +0 -0
- /package/dist/{chunk-3QTURBOX.js.map → chunk-QUM7V5EP.js.map} +0 -0
- /package/dist/{chunk-IG3FJLDR.js.map → chunk-RDAO365M.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-D53FKWGJ.js";import"../../chunk-QKTDO33H.js";import"../../chunk-PGWKJ6FK.js";import"../../chunk-WRKHWEZA.js";import"../../chunk-Z3HWTDRE.js";import"../../chunk-XO3JWN33.js";import"../../chunk-GFMFGU7A.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-GEYFQVQI.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as BasicInformationStep};
|
|
2
2
|
//# sourceMappingURL=BasicInformationStep.js.map
|
|
@@ -2,6 +2,7 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
2
2
|
import { C as Components } from '../../remoteFlows-lYAFzyXi.js';
|
|
3
3
|
import { S as SuccessResponse } from '../../types.gen-D_v539E_.js';
|
|
4
4
|
import { BenefitsFormPayload } from './types.js';
|
|
5
|
+
import { N as NormalizedFieldError } from '../../mutations-B6HWH-rZ.js';
|
|
5
6
|
import 'react';
|
|
6
7
|
import 'react-hook-form';
|
|
7
8
|
import 'yup';
|
|
@@ -24,7 +25,11 @@ type BenefitsStepProps = {
|
|
|
24
25
|
* @param error
|
|
25
26
|
* @returns
|
|
26
27
|
*/
|
|
27
|
-
onError?: (error
|
|
28
|
+
onError?: ({ error, rawError, fieldErrors, }: {
|
|
29
|
+
error: Error;
|
|
30
|
+
rawError: Record<string, unknown>;
|
|
31
|
+
fieldErrors: NormalizedFieldError[];
|
|
32
|
+
}) => void;
|
|
28
33
|
/**
|
|
29
34
|
* Callback function to be called when benefits form is successfully submitted.
|
|
30
35
|
* This function is called after the submitting benefits form is submitted.
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-X6DRD2I4.js";import"../../chunk-QKTDO33H.js";import"../../chunk-PGWKJ6FK.js";import"../../chunk-WRKHWEZA.js";import"../../chunk-Z3HWTDRE.js";import"../../chunk-XO3JWN33.js";import"../../chunk-GFMFGU7A.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-GEYFQVQI.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as BenefitsStep};
|
|
2
2
|
//# sourceMappingURL=BenefitsStep.js.map
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { n as EmploymentResponse } from '../../types.gen-D_v539E_.js';
|
|
3
3
|
import { ContractDetailsFormPayload } from './types.js';
|
|
4
|
+
import { N as NormalizedFieldError } from '../../mutations-B6HWH-rZ.js';
|
|
4
5
|
import '../types.js';
|
|
5
6
|
import '@remoteoss/json-schema-form';
|
|
6
7
|
|
|
7
8
|
type ContractDetailsStepProps = {
|
|
8
9
|
onSubmit?: (payload: ContractDetailsFormPayload) => void | Promise<void>;
|
|
9
10
|
onSuccess?: (response: EmploymentResponse) => void | Promise<void>;
|
|
10
|
-
onError?: (error
|
|
11
|
+
onError?: ({ error, rawError, fieldErrors, }: {
|
|
12
|
+
error: Error;
|
|
13
|
+
rawError: Record<string, unknown>;
|
|
14
|
+
fieldErrors: NormalizedFieldError[];
|
|
15
|
+
}) => void;
|
|
11
16
|
};
|
|
12
17
|
declare function ContractDetailsStep({ onSubmit, onError, onSuccess, }: ContractDetailsStepProps): react_jsx_runtime.JSX.Element;
|
|
13
18
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-AOJAZ4FT.js";import"../../chunk-QKTDO33H.js";import"../../chunk-PGWKJ6FK.js";import"../../chunk-WRKHWEZA.js";import"../../chunk-Z3HWTDRE.js";import"../../chunk-XO3JWN33.js";import"../../chunk-GFMFGU7A.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-GEYFQVQI.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as ContractDetailsStep};
|
|
2
2
|
//# sourceMappingURL=ContractDetailsStep.js.map
|
|
@@ -12,7 +12,7 @@ import { SelectCountryStep } from './SelectCountryStep.js';
|
|
|
12
12
|
import { ReviewStep } from './ReviewStep.js';
|
|
13
13
|
import '@tanstack/query-core';
|
|
14
14
|
import '../../types.gen-D_v539E_.js';
|
|
15
|
-
import '../../mutations-
|
|
15
|
+
import '../../mutations-B6HWH-rZ.js';
|
|
16
16
|
import '@remoteoss/json-schema-form';
|
|
17
17
|
import '../useStepState.js';
|
|
18
18
|
import 'react-hook-form';
|
|
@@ -57,6 +57,6 @@ type OnboardingRenderProps = {
|
|
|
57
57
|
type OnboardingFlowProps = OnboardingFlowParams & {
|
|
58
58
|
render: ({ onboardingBag, components, }: OnboardingRenderProps) => react__default.ReactNode;
|
|
59
59
|
};
|
|
60
|
-
declare const OnboardingFlow: ({ employmentId, companyId, countryCode, type, render, options, }: OnboardingFlowProps) => react_jsx_runtime.JSX.Element;
|
|
60
|
+
declare const OnboardingFlow: ({ employmentId, companyId, countryCode, type, skipSteps, render, options, }: OnboardingFlowProps) => react_jsx_runtime.JSX.Element;
|
|
61
61
|
|
|
62
62
|
export { OnboardingFlow, type OnboardingRenderProps };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-XQXFQ7LM.js";import"../../chunk-BYFO5OB6.js";import"../../chunk-C3HJSV4T.js";import"../../chunk-GPAE53HO.js";import"../../chunk-ASFAGLQI.js";import"../../chunk-7N7ND6Z4.js";import"../../chunk-7JHIPWS7.js";import"../../chunk-RDAO365M.js";import"../../chunk-AN7L3GVL.js";import"../../chunk-WVJDCDGZ.js";import"../../chunk-D53FKWGJ.js";import"../../chunk-X6DRD2I4.js";import"../../chunk-AOJAZ4FT.js";import"../../chunk-QKTDO33H.js";import"../../chunk-VN4HDCRB.js";import"../../chunk-PGWKJ6FK.js";import"../../chunk-PWUYHFON.js";import"../../chunk-WRKHWEZA.js";import"../../chunk-WKK63LAY.js";import"../../chunk-PJBAQZ6G.js";import"../../chunk-Z3HWTDRE.js";import"../../chunk-XO3JWN33.js";import"../../chunk-GFMFGU7A.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-GEYFQVQI.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as OnboardingFlow};
|
|
2
2
|
//# sourceMappingURL=OnboardingFlow.js.map
|
|
@@ -1,13 +1,18 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { ButtonHTMLAttributes, ReactNode } from 'react';
|
|
3
|
+
import { F as FieldError } from '../../mutations-B6HWH-rZ.js';
|
|
3
4
|
import { S as SuccessResponse } from '../../types.gen-D_v539E_.js';
|
|
4
5
|
|
|
5
|
-
type OnboardingInviteProps = ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
6
|
+
type OnboardingInviteProps = Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'onError'> & {
|
|
6
7
|
onSuccess?: ({ data, employmentStatus, }: {
|
|
7
8
|
data: SuccessResponse;
|
|
8
9
|
employmentStatus: 'invited' | 'created_awaiting_reserve';
|
|
9
10
|
}) => void | Promise<void>;
|
|
10
|
-
onError?: (error
|
|
11
|
+
onError?: ({ error, rawError, fieldErrors, }: {
|
|
12
|
+
error: Error;
|
|
13
|
+
rawError: Record<string, unknown>;
|
|
14
|
+
fieldErrors: FieldError[];
|
|
15
|
+
}) => void;
|
|
11
16
|
onSubmit?: () => void | Promise<void>;
|
|
12
17
|
render: (props: {
|
|
13
18
|
employmentStatus: 'invited' | 'created_awaiting_reserve';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-BYFO5OB6.js";import"../../chunk-AN7L3GVL.js";import"../../chunk-WVJDCDGZ.js";import"../../chunk-PGWKJ6FK.js";import"../../chunk-PWUYHFON.js";import"../../chunk-WRKHWEZA.js";import"../../chunk-WKK63LAY.js";import"../../chunk-GEYFQVQI.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as OnboardingInvite};
|
|
2
2
|
//# sourceMappingURL=OnboardingInvite.js.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import { SelectCountryFormPayload, SelectCountrySuccess } from './types.js';
|
|
3
|
+
import { N as NormalizedFieldError } from '../../mutations-B6HWH-rZ.js';
|
|
3
4
|
import '../../types.gen-D_v539E_.js';
|
|
4
5
|
import '../types.js';
|
|
5
6
|
import '@remoteoss/json-schema-form';
|
|
@@ -7,7 +8,11 @@ import '@remoteoss/json-schema-form';
|
|
|
7
8
|
type SelectCountryStepProps = {
|
|
8
9
|
onSubmit?: (payload: SelectCountryFormPayload) => void | Promise<void>;
|
|
9
10
|
onSuccess?: (data: SelectCountrySuccess) => void | Promise<void>;
|
|
10
|
-
onError?: (error
|
|
11
|
+
onError?: ({ error, rawError, fieldErrors, }: {
|
|
12
|
+
error: Error;
|
|
13
|
+
rawError: Record<string, unknown>;
|
|
14
|
+
fieldErrors: NormalizedFieldError[];
|
|
15
|
+
}) => void;
|
|
11
16
|
};
|
|
12
17
|
declare function SelectCountryStep({ onSubmit, onSuccess, onError, }: SelectCountryStepProps): react_jsx_runtime.JSX.Element;
|
|
13
18
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-ASFAGLQI.js";import"../../chunk-QKTDO33H.js";import"../../chunk-PGWKJ6FK.js";import"../../chunk-Z3HWTDRE.js";import"../../chunk-XO3JWN33.js";import"../../chunk-GFMFGU7A.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-GEYFQVQI.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as SelectCountryStep};
|
|
2
2
|
//# sourceMappingURL=SelectCountryStep.js.map
|
|
@@ -104,7 +104,11 @@ declare const useMagicLink: () => _tanstack_react_query.UseMutationResult<({
|
|
|
104
104
|
request: Request;
|
|
105
105
|
response: Response;
|
|
106
106
|
}, Error, MagicLinkParams, unknown>;
|
|
107
|
-
declare const useCountriesSchemaField: (options?: FlowOptions
|
|
107
|
+
declare const useCountriesSchemaField: (options?: FlowOptions & {
|
|
108
|
+
queryOptions?: {
|
|
109
|
+
enabled?: boolean;
|
|
110
|
+
};
|
|
111
|
+
}) => {
|
|
108
112
|
isLoading: boolean;
|
|
109
113
|
selectCountryForm: _remoteoss_json_schema_form.HeadlessFormOutput;
|
|
110
114
|
};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../../chunk-
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k,l,m}from"../../chunk-AN7L3GVL.js";import"../../chunk-WVJDCDGZ.js";import"../../chunk-PWUYHFON.js";import"../../chunk-WKK63LAY.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-P37U34EQ.js";export{c as useBenefitOffers,g as useBenefitOffersSchema,b as useCompany,m as useConvertCurrency,l as useCountriesSchemaField,h as useCreateEmployment,e as useCreateReserveInvoice,a as useEmployment,d as useEmploymentInvite,f as useJSONSchemaForm,k as useMagicLink,j as useUpdateBenefitsOffers,i as useUpdateEmployment};
|
|
2
2
|
//# sourceMappingURL=api.js.map
|
|
@@ -4,7 +4,7 @@ import { l as EmploymentCreationResponse, m as PostCreateEmployment2Error, n as
|
|
|
4
4
|
import * as _remoteoss_json_schema_form from '@remoteoss/json-schema-form';
|
|
5
5
|
import * as react from 'react';
|
|
6
6
|
import * as react_hook_form from 'react-hook-form';
|
|
7
|
-
import { E as ErrorResponse, S as SuccessResponse } from '../../mutations-
|
|
7
|
+
import { E as ErrorResponse, S as SuccessResponse } from '../../mutations-B6HWH-rZ.js';
|
|
8
8
|
import { Step } from '../useStepState.js';
|
|
9
9
|
import { useOnboarding } from './hooks.js';
|
|
10
10
|
import './types.js';
|
|
@@ -27,7 +27,6 @@ declare const useOnboardingContext: () => {
|
|
|
27
27
|
readonly onboardingBag: {
|
|
28
28
|
employmentId: string | undefined;
|
|
29
29
|
creditRiskStatus: "fail" | "not_started" | "ready" | "in_progress" | "referred" | "deposit_required" | "no_deposit_required" | undefined;
|
|
30
|
-
owner_id: string | undefined;
|
|
31
30
|
stepState: {
|
|
32
31
|
currentStep: Step<"benefits" | "review" | "basic_information" | "contract_details" | "select_country">;
|
|
33
32
|
totalSteps: number;
|
|
@@ -46,7 +45,7 @@ declare const useOnboardingContext: () => {
|
|
|
46
45
|
select_country: Record<string, unknown>;
|
|
47
46
|
basic_information: Record<string, unknown>;
|
|
48
47
|
contract_details: Record<string, unknown>;
|
|
49
|
-
benefits:
|
|
48
|
+
benefits: Record<string, unknown>;
|
|
50
49
|
};
|
|
51
50
|
handleValidation: (values: react_hook_form.FieldValues) => {
|
|
52
51
|
yupError: _remoteoss_json_schema_form.$TSFixMe;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as _tanstack_query_core from '@tanstack/query-core';
|
|
2
2
|
import { l as EmploymentCreationResponse, m as PostCreateEmployment2Error, n as EmploymentResponse, o as PatchUpdateEmployment2Error, S as SuccessResponse$1, p as PutUpdateBenefitOfferError, j as Employment } from '../../types.gen-D_v539E_.js';
|
|
3
|
-
import { E as ErrorResponse, S as SuccessResponse } from '../../mutations-
|
|
3
|
+
import { E as ErrorResponse, S as SuccessResponse } from '../../mutations-B6HWH-rZ.js';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import * as _remoteoss_json_schema_form from '@remoteoss/json-schema-form';
|
|
6
6
|
import { Fields } from '@remoteoss/json-schema-form';
|
|
@@ -11,7 +11,7 @@ import { OnboardingFlowParams } from './types.js';
|
|
|
11
11
|
import '../types.js';
|
|
12
12
|
|
|
13
13
|
type OnboardingHookProps = OnboardingFlowParams;
|
|
14
|
-
declare const useOnboarding: ({ employmentId, companyId, countryCode, type, options, }: OnboardingHookProps) => {
|
|
14
|
+
declare const useOnboarding: ({ employmentId, companyId, countryCode, type, options, skipSteps, }: OnboardingHookProps) => {
|
|
15
15
|
/**
|
|
16
16
|
* Employment id passed useful to be used between components
|
|
17
17
|
*/
|
|
@@ -28,7 +28,6 @@ declare const useOnboarding: ({ employmentId, companyId, countryCode, type, opti
|
|
|
28
28
|
* - no_deposit_required
|
|
29
29
|
*/
|
|
30
30
|
creditRiskStatus: "fail" | "not_started" | "ready" | "in_progress" | "referred" | "deposit_required" | "no_deposit_required" | undefined;
|
|
31
|
-
owner_id: string | undefined;
|
|
32
31
|
/**
|
|
33
32
|
* Current step state containing the current step and total number of steps
|
|
34
33
|
*/
|
|
@@ -62,7 +61,7 @@ declare const useOnboarding: ({ employmentId, companyId, countryCode, type, opti
|
|
|
62
61
|
select_country: Record<string, unknown>;
|
|
63
62
|
basic_information: Record<string, unknown>;
|
|
64
63
|
contract_details: Record<string, unknown>;
|
|
65
|
-
benefits:
|
|
64
|
+
benefits: Record<string, unknown>;
|
|
66
65
|
};
|
|
67
66
|
/**
|
|
68
67
|
* Function to validate form values against the onboarding schema
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-7N7ND6Z4.js";import"../../chunk-7JHIPWS7.js";import"../../chunk-RDAO365M.js";import"../../chunk-AN7L3GVL.js";import"../../chunk-WVJDCDGZ.js";import"../../chunk-PWUYHFON.js";import"../../chunk-WRKHWEZA.js";import"../../chunk-WKK63LAY.js";import"../../chunk-PJBAQZ6G.js";import"../../chunk-GFMFGU7A.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as useOnboarding};
|
|
2
2
|
//# sourceMappingURL=hooks.js.map
|
|
@@ -6,7 +6,7 @@ import 'react';
|
|
|
6
6
|
import './hooks.js';
|
|
7
7
|
import '@tanstack/query-core';
|
|
8
8
|
import '../../types.gen-D_v539E_.js';
|
|
9
|
-
import '../../mutations-
|
|
9
|
+
import '../../mutations-B6HWH-rZ.js';
|
|
10
10
|
import '@remoteoss/json-schema-form';
|
|
11
11
|
import '../useStepState.js';
|
|
12
12
|
import 'react-hook-form';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../chunk-GULCZWSK.js";import{a}from"../../chunk-
|
|
1
|
+
import"../../chunk-GULCZWSK.js";import{a}from"../../chunk-XQXFQ7LM.js";import"../../chunk-BYFO5OB6.js";import"../../chunk-C3HJSV4T.js";import"../../chunk-GPAE53HO.js";import"../../chunk-ASFAGLQI.js";import"../../chunk-7N7ND6Z4.js";import"../../chunk-7JHIPWS7.js";import"../../chunk-RDAO365M.js";import"../../chunk-AN7L3GVL.js";import"../../chunk-WVJDCDGZ.js";import"../../chunk-D53FKWGJ.js";import"../../chunk-X6DRD2I4.js";import"../../chunk-AOJAZ4FT.js";import"../../chunk-QKTDO33H.js";import"../../chunk-VN4HDCRB.js";import"../../chunk-PGWKJ6FK.js";import"../../chunk-PWUYHFON.js";import"../../chunk-WRKHWEZA.js";import"../../chunk-WKK63LAY.js";import"../../chunk-PJBAQZ6G.js";import"../../chunk-Z3HWTDRE.js";import"../../chunk-XO3JWN33.js";import"../../chunk-GFMFGU7A.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-GEYFQVQI.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as OnboardingFlow};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -3,10 +3,29 @@ import { FlowOptions, JSFModify } from '../types.js';
|
|
|
3
3
|
import '@remoteoss/json-schema-form';
|
|
4
4
|
|
|
5
5
|
type OnboardingFlowParams = {
|
|
6
|
+
/**
|
|
7
|
+
* The country code to use for the onboarding.
|
|
8
|
+
*/
|
|
6
9
|
countryCode?: string;
|
|
10
|
+
/**
|
|
11
|
+
* The employment id to use for the onboarding.
|
|
12
|
+
*/
|
|
7
13
|
employmentId?: string;
|
|
14
|
+
/**
|
|
15
|
+
* The company id to use for the onboarding.
|
|
16
|
+
*/
|
|
8
17
|
companyId: string;
|
|
18
|
+
/**
|
|
19
|
+
* The steps to skip for the onboarding. We only support skipping the select_country step for now.
|
|
20
|
+
*/
|
|
21
|
+
skipSteps?: ['select_country'];
|
|
22
|
+
/**
|
|
23
|
+
* The type of employment to use for the onboarding. Employee or contractor.
|
|
24
|
+
*/
|
|
9
25
|
type?: EmploymentCreateParams['type'];
|
|
26
|
+
/**
|
|
27
|
+
* The options to use for the onboarding.
|
|
28
|
+
*/
|
|
10
29
|
options?: Omit<FlowOptions, 'jsfModify'> & {
|
|
11
30
|
jsfModify?: {
|
|
12
31
|
select_country?: JSFModify;
|
|
@@ -11,7 +11,7 @@ import { AdditionalDetailsForm } from './AdditionalDetailsForm.js';
|
|
|
11
11
|
import { JSFModify } from '../types.js';
|
|
12
12
|
import './types.js';
|
|
13
13
|
import '../../types.gen-D_v539E_.js';
|
|
14
|
-
import '../../mutations-
|
|
14
|
+
import '../../mutations-B6HWH-rZ.js';
|
|
15
15
|
import '@remoteoss/json-schema-form';
|
|
16
16
|
import '../useStepState.js';
|
|
17
17
|
import 'react-hook-form';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-QUM7V5EP.js";import"../../chunk-LLIGZSYY.js";import"../../chunk-JXCJLQRA.js";import"../../chunk-OS3QI7CV.js";import"../../chunk-XFD3ULUF.js";import"../../chunk-WWANHPT7.js";import"../../chunk-DR7VGNO2.js";import"../../chunk-XSHHMBMT.js";import"../../chunk-JODJFARP.js";import"../../chunk-W5DG5WWJ.js";import"../../chunk-VX2UC3HG.js";import"../../chunk-S4XU4SE7.js";import"../../chunk-KGSIUWBI.js";import"../../chunk-4BOE6EEO.js";import"../../chunk-O4PJ6GWS.js";import"../../chunk-BF7QENCN.js";import"../../chunk-OP4QGFLS.js";import"../../chunk-U6OPL6WG.js";import"../../chunk-MRYRNB7Y.js";import"../../chunk-PWUYHFON.js";import"../../chunk-LX7QBDSF.js";import"../../chunk-WRKHWEZA.js";import"../../chunk-WKK63LAY.js";import"../../chunk-PJBAQZ6G.js";import"../../chunk-Z3HWTDRE.js";import"../../chunk-XO3JWN33.js";import"../../chunk-GFMFGU7A.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-GEYFQVQI.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as TerminationFlow};
|
|
2
2
|
//# sourceMappingURL=TerminationFlow.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { O as OffboardingResponse, k as PostCreateOffboardingError } from '../../types.gen-D_v539E_.js';
|
|
2
2
|
import * as _remoteoss_json_schema_form from '@remoteoss/json-schema-form';
|
|
3
3
|
import * as react from 'react';
|
|
4
|
-
import { E as ErrorResponse, S as SuccessResponse } from '../../mutations-
|
|
4
|
+
import { E as ErrorResponse, S as SuccessResponse } from '../../mutations-B6HWH-rZ.js';
|
|
5
5
|
import { Step } from '../useStepState.js';
|
|
6
6
|
import { useTermination } from './hooks.js';
|
|
7
7
|
import { TerminationFormValues } from './types.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { O as OffboardingResponse, k as PostCreateOffboardingError } from '../../types.gen-D_v539E_.js';
|
|
2
|
-
import { E as ErrorResponse, S as SuccessResponse } from '../../mutations-
|
|
2
|
+
import { E as ErrorResponse, S as SuccessResponse } from '../../mutations-B6HWH-rZ.js';
|
|
3
3
|
import * as _remoteoss_json_schema_form from '@remoteoss/json-schema-form';
|
|
4
4
|
import { Step } from '../useStepState.js';
|
|
5
5
|
import { StepTerminationKeys } from './utils.js';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-OS3QI7CV.js";import"../../chunk-XFD3ULUF.js";import"../../chunk-WWANHPT7.js";import"../../chunk-DR7VGNO2.js";import"../../chunk-XSHHMBMT.js";import"../../chunk-JODJFARP.js";import"../../chunk-W5DG5WWJ.js";import"../../chunk-VX2UC3HG.js";import"../../chunk-S4XU4SE7.js";import"../../chunk-PWUYHFON.js";import"../../chunk-WRKHWEZA.js";import"../../chunk-WKK63LAY.js";import"../../chunk-PJBAQZ6G.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-P37U34EQ.js";export{a as useTermination};
|
|
2
2
|
//# sourceMappingURL=hooks.js.map
|
|
@@ -4,7 +4,7 @@ import 'react/jsx-runtime';
|
|
|
4
4
|
import 'react';
|
|
5
5
|
import './hooks.js';
|
|
6
6
|
import '../../types.gen-D_v539E_.js';
|
|
7
|
-
import '../../mutations-
|
|
7
|
+
import '../../mutations-B6HWH-rZ.js';
|
|
8
8
|
import '@remoteoss/json-schema-form';
|
|
9
9
|
import '../useStepState.js';
|
|
10
10
|
import 'react-hook-form';
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../chunk-M22FKNEY.js";import{a}from"../../chunk-
|
|
1
|
+
import"../../chunk-M22FKNEY.js";import{a}from"../../chunk-QUM7V5EP.js";import"../../chunk-LLIGZSYY.js";import"../../chunk-JXCJLQRA.js";import"../../chunk-OS3QI7CV.js";import"../../chunk-XFD3ULUF.js";import"../../chunk-WWANHPT7.js";import"../../chunk-DR7VGNO2.js";import"../../chunk-XSHHMBMT.js";import"../../chunk-JODJFARP.js";import"../../chunk-W5DG5WWJ.js";import"../../chunk-VX2UC3HG.js";import"../../chunk-S4XU4SE7.js";import"../../chunk-KGSIUWBI.js";import"../../chunk-4BOE6EEO.js";import"../../chunk-O4PJ6GWS.js";import"../../chunk-BF7QENCN.js";import"../../chunk-OP4QGFLS.js";import"../../chunk-U6OPL6WG.js";import"../../chunk-MRYRNB7Y.js";import"../../chunk-PWUYHFON.js";import"../../chunk-LX7QBDSF.js";import"../../chunk-WRKHWEZA.js";import"../../chunk-WKK63LAY.js";import"../../chunk-PJBAQZ6G.js";import"../../chunk-Z3HWTDRE.js";import"../../chunk-XO3JWN33.js";import"../../chunk-GFMFGU7A.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-GEYFQVQI.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as TerminationFlow};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.d.ts
CHANGED
|
@@ -27,12 +27,12 @@ import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
|
27
27
|
import { PropsWithChildren } from 'react';
|
|
28
28
|
import { R as RemoteFlowsSDKProps } from './remoteFlows-lYAFzyXi.js';
|
|
29
29
|
export { $ as $TSFixMe, B as ButtonComponentProps, C as Components, F as FieldComponentProps, S as StatementComponentProps } from './remoteFlows-lYAFzyXi.js';
|
|
30
|
+
export { F as FieldError, N as NormalizedFieldError } from './mutations-B6HWH-rZ.js';
|
|
30
31
|
import './flows/types.js';
|
|
31
32
|
import '@remoteoss/json-schema-form';
|
|
32
33
|
import 'react-hook-form';
|
|
33
34
|
import './types-CxSFjQw5.js';
|
|
34
35
|
import './flows/ContractAmendment/ContractAmendmentBack.js';
|
|
35
|
-
import './mutations-v9H353tz.js';
|
|
36
36
|
import './flows/useStepState.js';
|
|
37
37
|
import './flows/Termination/hooks.js';
|
|
38
38
|
import './flows/Termination/utils.js';
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-M22FKNEY.js";import{a as tr}from"./chunk-
|
|
1
|
+
import"./chunk-M22FKNEY.js";import{a as tr}from"./chunk-QUM7V5EP.js";import"./chunk-LLIGZSYY.js";import"./chunk-JXCJLQRA.js";import"./chunk-OS3QI7CV.js";import"./chunk-XFD3ULUF.js";import"./chunk-WWANHPT7.js";import"./chunk-DR7VGNO2.js";import"./chunk-XSHHMBMT.js";import"./chunk-JODJFARP.js";import"./chunk-W5DG5WWJ.js";import"./chunk-VX2UC3HG.js";import"./chunk-S4XU4SE7.js";import"./chunk-GULCZWSK.js";import"./chunk-KGSIUWBI.js";import"./chunk-4BOE6EEO.js";import"./chunk-O4PJ6GWS.js";import"./chunk-BF7QENCN.js";import"./chunk-OP4QGFLS.js";import"./chunk-U6OPL6WG.js";import"./chunk-MRYRNB7Y.js";import{a as or}from"./chunk-XQXFQ7LM.js";import"./chunk-BYFO5OB6.js";import"./chunk-C3HJSV4T.js";import"./chunk-GPAE53HO.js";import"./chunk-ASFAGLQI.js";import"./chunk-7N7ND6Z4.js";import"./chunk-7JHIPWS7.js";import"./chunk-RDAO365M.js";import"./chunk-AN7L3GVL.js";import"./chunk-WVJDCDGZ.js";import"./chunk-D53FKWGJ.js";import"./chunk-X6DRD2I4.js";import"./chunk-AOJAZ4FT.js";import"./chunk-QKTDO33H.js";import"./chunk-VN4HDCRB.js";import"./chunk-PGWKJ6FK.js";import"./chunk-FGBEOUQK.js";import{a as E}from"./chunk-DKIWM2PT.js";import"./chunk-WIRFNWEU.js";import"./chunk-3NZ6PO4D.js";import"./chunk-YO4OQIFP.js";import"./chunk-32RYPLZK.js";import"./chunk-PJCUSCO4.js";import"./chunk-EEAMZPP6.js";import"./chunk-FB5J7SRP.js";import{a as F}from"./chunk-H4BI3LJD.js";import{a as z}from"./chunk-3HPG2L62.js";import{a as R}from"./chunk-KM4XVL2X.js";import"./chunk-A7ZJQCNU.js";import{a as B}from"./chunk-EV5YPN4F.js";import{a as _}from"./chunk-DYB3RWP7.js";import{a as T}from"./chunk-ZOG52VVG.js";import"./chunk-KSHK3ZPX.js";import{b as y,c as k,e as C}from"./chunk-SUS7UBI5.js";import"./chunk-UPRUP24B.js";import"./chunk-PWUYHFON.js";import{a as er}from"./chunk-IEZAM2XO.js";import{a as H}from"./chunk-RXK4RLF6.js";import{a as ar}from"./chunk-NIOH7TNP.js";import{a as J,b as rr}from"./chunk-LX7QBDSF.js";import"./chunk-WRKHWEZA.js";import"./chunk-5SMMQQXP.js";import{a as p}from"./chunk-WKK63LAY.js";import"./chunk-PJBAQZ6G.js";import"./chunk-CTTXXEWI.js";import{a as G}from"./chunk-CSU6IQX3.js";import{a as Z}from"./chunk-RFYJGH2X.js";import"./chunk-Z3HWTDRE.js";import"./chunk-XO3JWN33.js";import"./chunk-GFMFGU7A.js";import"./chunk-CFIJKJXD.js";import"./chunk-GEYFQVQI.js";import{a as g,c as v}from"./chunk-3ZWDIEEM.js";import"./chunk-VNSF5IOL.js";import"./chunk-MH6KKP6K.js";import"./chunk-TVZAFTPT.js";import{c as P}from"./chunk-KPHSEIR3.js";import{a as e}from"./chunk-P37U34EQ.js";import{QueryClient as L,QueryClientProvider as q}from"@tanstack/react-query";function l(r){let a=document.documentElement;Object.keys(r).forEach(t=>{let o=r[t];o&&a.style.setProperty(t,o)})}e(l,"setCssProperties");function S(r){let a={};return Object.keys(r).forEach(t=>{a[`--${t}`]=r[t]}),a}e(S,"mapThemeColors");function j(r){return{"--spacing":r}}e(j,"mapThemeSpacing");function M(r){return{"--radius":r}}e(M,"mapThemeBorderRadius");function O(r){return{"--fontSizeBase":r.fontSizeBase}}e(O,"mapThemeFont");function h(r){r?.colors&&l(S(r.colors)),r?.spacing&&l(j(r.spacing)),r?.borderRadius&&l(M(r.borderRadius)),r?.font&&l(O(r.font))}e(h,"applyTheme");import{createContext as A,useEffect as D,useMemo as I}from"react";import{jsx as K}from"react/jsx-runtime";var N=A({theme:{}});function u(r){D(()=>{r.theme&&Object.keys(r.theme).length>0&&h(r.theme)},[r.theme]);let a=I(()=>({theme:r.theme}),[r.theme]);return K(N.Provider,{value:a,children:r.children})}e(u,"ThemeProvider");var m={staging:"https://gateway.niceremote.com",partners:"https://gateway.partners.remote-sandbox.com",production:"https://gateway.remote.com"};import{createClient as U}from"@hey-api/client-fetch";import{useQuery as V}from"@tanstack/react-query";import{useRef as w}from"react";function W(r){try{return new URL(r),!0}catch{return!1}}e(W,"isValidUrl");var f=e(({auth:r,options:a})=>{let t=w(null),{refetch:o}=V({queryKey:["auth"],queryFn:r,enabled:!1}),c=a.isTestingMode?m.partners:"https://gateway.remote.com",s=p.getConfig(),x="0.4.0-alpha.12",d=!!a.proxy&&W(a.proxy.url);return a.proxy&&!d&&console.error("Invalid proxy URL provided. Using default base URL."),w(U({...s,headers:{...s.headers,...d?a.proxy?.headers:{},"X-Client-Name":"remote-flows-sdk","X-Client-Version":x},baseUrl:d?a.proxy?.url:c,auth:e(async()=>{function b(i){return!i||Date.now()+6e4>i}if(e(b,"hasTokenExpired"),!t.current||b(t.current.expiresAt)){let{data:i}=await o();i&&(t.current={accessToken:i.accessToken,expiresAt:Date.now()+i.expiresIn*1e3})}return t.current?.accessToken},"auth")}))},"useAuth");import{jsx as n}from"react/jsx-runtime";var Q=new L;function X({children:r,auth:a,isTestingMode:t,proxy:o}){let c=f({auth:a,options:{isTestingMode:!!t,proxy:o}});return n(v.Provider,{value:{client:c.current},children:r})}e(X,"RemoteFlowContextWrapper");function Y({children:r,components:a}){return n(g.Provider,{value:a?{components:a}:{components:{}},children:r})}e(Y,"FormFieldsProvider");function $({auth:r,children:a,components:t,isTestingMode:o=!1,theme:c,proxy:s}){return n(q,{client:Q,children:n(Y,{components:t,children:n(X,{isTestingMode:o,auth:r,proxy:s,children:n(u,{theme:c,children:a})})})})}e($,"RemoteFlows");export{G as ContractAmendmentConfirmationForm,er as ContractAmendmentFlow,Z as ContractAmendmentForm,H as ContractAmendmentSubmit,B as CostCalculatorDisclaimer,T as CostCalculatorFlow,F as CostCalculatorForm,z as CostCalculatorResetButton,E as CostCalculatorResults,R as CostCalculatorSubmitButton,or as OnboardingFlow,$ as RemoteFlows,tr as TerminationFlow,y as buildCostCalculatorEstimationPayload,_ as disclaimerData,P as transformYupErrorsIntoObject,ar as useContractAmendment,C as useCostCalculator,k as useCostCalculatorEstimationPdf,J as useEmploymentQuery,rr as useTimeOffQuery};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
interface SuccessResponse<D> {
|
|
2
|
+
data: D;
|
|
3
|
+
error: null;
|
|
4
|
+
}
|
|
5
|
+
interface FieldError {
|
|
6
|
+
field: string;
|
|
7
|
+
messages: string[];
|
|
8
|
+
}
|
|
9
|
+
interface ErrorResponse<E> {
|
|
10
|
+
data: null;
|
|
11
|
+
error: E;
|
|
12
|
+
rawError: Record<string, unknown>;
|
|
13
|
+
fieldErrors: FieldError[];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Enhanced FieldError interface with user-friendly labels
|
|
17
|
+
*/
|
|
18
|
+
interface NormalizedFieldError extends FieldError {
|
|
19
|
+
userFriendlyLabel: string;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type { ErrorResponse as E, FieldError as F, NormalizedFieldError as N, SuccessResponse as S };
|
package/package.json
CHANGED
package/dist/chunk-GAXGAK4P.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as i}from"./chunk-QKTDO33H.js";import{b as a}from"./chunk-PGWKJ6FK.js";import{a as r}from"./chunk-P37U34EQ.js";import{jsx as l}from"react/jsx-runtime";function m({onSubmit:c,onSuccess:u,onError:e}){let{onboardingBag:t}=a(),s=r(async n=>{try{await c?.({countryCode:n.country});let o=await t.onSubmit(n);if(o?.data){await u?.(o?.data),t?.next();return}o?.error&&e?.(o?.error)}catch(o){e?.(o)}},"handleSubmit"),S=t.stepState.values?.select_country||t.initialValues.select_country;return l(i,{defaultValues:S,onSubmit:s})}r(m,"SelectCountryStep");export{m as a};
|
|
2
|
-
//# sourceMappingURL=chunk-GAXGAK4P.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/flows/Onboarding/SelectCountryStep.tsx"],"sourcesContent":["import { useOnboardingContext } from './context';\nimport { OnboardingForm } from '@/src/flows/Onboarding/OnboardingForm';\nimport {\n SelectCountryFormPayload,\n SelectCountrySuccess,\n} from '@/src/flows/Onboarding/types';\nimport { $TSFixMe } from '@/src/types/remoteFlows';\n\ntype SelectCountryStepProps = {\n /*\n * The function is called when the form is submitted. It receives the form values as an argument.\n */\n onSubmit?: (payload: SelectCountryFormPayload) => void | Promise<void>;\n /*\n * The function is called when the form submission is successful.\n */\n onSuccess?: (data: SelectCountrySuccess) => void | Promise<void>;\n /*\n * The function is called when an error occurs during form submission.\n */\n onError?: (error: Error) => void;\n};\n\nexport function SelectCountryStep({\n onSubmit,\n onSuccess,\n onError,\n}: SelectCountryStepProps) {\n const { onboardingBag } = useOnboardingContext();\n const handleSubmit = async (payload: $TSFixMe) => {\n try {\n await onSubmit?.({ countryCode: payload.country });\n const response = await onboardingBag.onSubmit(payload);\n if (response?.data) {\n await onSuccess?.(response?.data as SelectCountrySuccess);\n onboardingBag?.next();\n return;\n }\n if (response?.error) {\n onError?.(response?.error);\n }\n } catch (error: unknown) {\n onError?.(error as Error);\n }\n };\n\n const initialValues =\n onboardingBag.stepState.values?.select_country ||\n onboardingBag.initialValues.select_country;\n\n return (\n <OnboardingForm defaultValues={initialValues} onSubmit={handleSubmit} />\n );\n}\n"],"mappings":"wHAmDI,cAAAA,MAAA,oBA5BG,SAASC,EAAkB,CAChC,SAAAC,EACA,UAAAC,EACA,QAAAC,CACF,EAA2B,CACzB,GAAM,CAAE,cAAAC,CAAc,EAAIC,EAAqB,EACzCC,EAAeC,EAAA,MAAOC,GAAsB,CAChD,GAAI,CACF,MAAMP,IAAW,CAAE,YAAaO,EAAQ,OAAQ,CAAC,EACjD,IAAMC,EAAW,MAAML,EAAc,SAASI,CAAO,EACrD,GAAIC,GAAU,KAAM,CAClB,MAAMP,IAAYO,GAAU,IAA4B,EACxDL,GAAe,KAAK,EACpB,MACF,CACIK,GAAU,OACZN,IAAUM,GAAU,KAAK,CAE7B,OAASC,EAAgB,CACvBP,IAAUO,CAAc,CAC1B,CACF,EAfqB,gBAiBfC,EACJP,EAAc,UAAU,QAAQ,gBAChCA,EAAc,cAAc,eAE9B,OACEL,EAACa,EAAA,CAAe,cAAeD,EAAe,SAAUL,EAAc,CAE1E,CA9BgBC,EAAAP,EAAA","names":["jsx","SelectCountryStep","onSubmit","onSuccess","onError","onboardingBag","useOnboardingContext","handleSubmit","__name","payload","response","error","initialValues","OnboardingForm"]}
|
package/dist/chunk-HGHKZF7M.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-QKTDO33H.js";import{b as t}from"./chunk-PGWKJ6FK.js";import{a}from"./chunk-P37U34EQ.js";import{jsx as f}from"react/jsx-runtime";function u({onSubmit:s,onSuccess:m,onError:i}){let{onboardingBag:r}=t(),p=a(async n=>{try{await s?.(r.parseFormValues(n));let o=await r.onSubmit(n);if(o?.data){await m?.(o?.data),r?.next();return}o?.error&&i?.(o?.error)}catch(o){i?.(o)}},"handleSubmit"),c=r.stepState.values?.basic_information||r.initialValues.basic_information;return f(e,{defaultValues:c,onSubmit:p})}a(u,"BasicInformationStep");export{u as a};
|
|
2
|
-
//# sourceMappingURL=chunk-HGHKZF7M.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/flows/Onboarding/BasicInformationStep.tsx"],"sourcesContent":["import { useOnboardingContext } from './context';\nimport { OnboardingForm } from '@/src/flows/Onboarding/OnboardingForm';\nimport { BasicInformationFormPayload } from '@/src/flows/Onboarding/types';\nimport { EmploymentCreationResponse } from '@/src/client';\nimport { $TSFixMe } from '@/src/types/remoteFlows';\n\ntype BasicInformationStepProps = {\n /*\n * The function is called when the form is submitted. It receives the form values as an argument.\n */\n onSubmit?: (payload: BasicInformationFormPayload) => void | Promise<void>;\n /*\n * The function is called when the form submission is successful.\n */\n onSuccess?: (data: EmploymentCreationResponse) => void | Promise<void>;\n /*\n * The function is called when an error occurs during form submission.\n */\n onError?: (error: Error) => void;\n};\n\nexport function BasicInformationStep({\n onSubmit,\n onSuccess,\n onError,\n}: BasicInformationStepProps) {\n const { onboardingBag } = useOnboardingContext();\n const handleSubmit = async (payload: $TSFixMe) => {\n try {\n await onSubmit?.(\n onboardingBag.parseFormValues(payload) as BasicInformationFormPayload,\n );\n const response = await onboardingBag.onSubmit(payload);\n if (response?.data) {\n await onSuccess?.(response?.data as EmploymentCreationResponse);\n onboardingBag?.next();\n return;\n }\n if (response?.error) {\n onError?.(response?.error);\n }\n } catch (error: unknown) {\n onError?.(error as Error);\n }\n };\n\n const initialValues =\n onboardingBag.stepState.values?.basic_information ||\n onboardingBag.initialValues.basic_information;\n\n return (\n <OnboardingForm defaultValues={initialValues} onSubmit={handleSubmit} />\n );\n}\n"],"mappings":"mHAmDI,cAAAA,MAAA,oBA9BG,SAASC,EAAqB,CACnC,SAAAC,EACA,UAAAC,EACA,QAAAC,CACF,EAA8B,CAC5B,GAAM,CAAE,cAAAC,CAAc,EAAIC,EAAqB,EACzCC,EAAeC,EAAA,MAAOC,GAAsB,CAChD,GAAI,CACF,MAAMP,IACJG,EAAc,gBAAgBI,CAAO,CACvC,EACA,IAAMC,EAAW,MAAML,EAAc,SAASI,CAAO,EACrD,GAAIC,GAAU,KAAM,CAClB,MAAMP,IAAYO,GAAU,IAAkC,EAC9DL,GAAe,KAAK,EACpB,MACF,CACIK,GAAU,OACZN,IAAUM,GAAU,KAAK,CAE7B,OAASC,EAAgB,CACvBP,IAAUO,CAAc,CAC1B,CACF,EAjBqB,gBAmBfC,EACJP,EAAc,UAAU,QAAQ,mBAChCA,EAAc,cAAc,kBAE9B,OACEL,EAACa,EAAA,CAAe,cAAeD,EAAe,SAAUL,EAAc,CAE1E,CAhCgBC,EAAAP,EAAA","names":["jsx","BasicInformationStep","onSubmit","onSuccess","onError","onboardingBag","useOnboardingContext","handleSubmit","__name","payload","response","error","initialValues","OnboardingForm"]}
|
package/dist/chunk-JTP3LZ77.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as x,b as G,c as p,d as W}from"./chunk-7JHIPWS7.js";import{a as ne}from"./chunk-IG3FJLDR.js";import{a as K,b as Y,c as z,f as Q,g as X,h as Z,i as $,j as ee,l as te}from"./chunk-RWYOUDM5.js";import{a as V}from"./chunk-KHZ2ITFO.js";import{a as H}from"./chunk-PJBAQZ6G.js";import{c as u,d as l}from"./chunk-MH6KKP6K.js";import{a as c}from"./chunk-P37U34EQ.js";import{useEffect as je,useMemo as w,useRef as Re,useState as oe}from"react";import ve from"lodash.mergewith";import{jsx as Ae}from"react/jsx-runtime";var Je={employment_basic_information:"basic_information",contract_details:"contract_details"},Ne={select_country:null,basic_information:"employment_basic_information",contract_details:"contract_details",benefits:null,review:null},ze=c(({employmentId:y,companyId:ae,countryCode:k,type:re,options:i})=>{let O=Re({}),[s,ie]=oe(y),[r,B]=oe(k||null),{data:o,isLoading:se,refetch:ce}=K(s);o?.country?.code&&r!==o.country.code&&B(o.country.code);let{data:I,isLoading:le}=z(s),{data:F,isLoading:me,refetch:j}=Y(ae),de=k?G:x,{fieldValues:_,stepState:e,setFieldValues:fe,previousStep:ue,nextStep:pe,goToStep:P,setStepValues:R}=H(de),{selectCountryForm:E,isLoading:ye}=te({jsfModify:i?.jsfModify?.select_country,jsonSchemaVersion:i?.jsonSchemaVersion}),v=Z(i),J=$(i),N=ee(i),{mutateAsync:_e}=V(v),{mutateAsync:A}=V(J),{mutateAsync:Se}=V(N),be=Ne[e.currentStep.name]||"employment_basic_information",ge=Je[be],Fe=o?.[ge]||{},q=c(({form:t,options:n={}})=>Q({countryCode:r,form:t,fieldValues:Object.keys(_).length>0?{...e.values?.[e.currentStep.name],..._}:Fe,options:{...n,queryOptions:{enabled:n.queryOptions?.enabled??!0}}}),"useJSONSchema"),Ee=!!(r&&(e.currentStep.name==="basic_information"||y)),he=!!(r&&(e.currentStep.name==="contract_details"||y)),{data:m,isLoading:Ve}=q({form:"employment_basic_information",options:{jsfModify:i?.jsfModify?.basic_information,queryOptions:{enabled:Ee}}}),f=i?.jsfModify?.contract_details?.fields?.annual_gross_salary,T=f&&typeof f=="object"&&"presentation"in f?f.presentation:void 0,Oe=w(()=>({fields:{annual_gross_salary:{...f,presentation:{annual_gross_salary_conversion_properties:{label:T?.annual_gross_salary_conversion_properties?.label,description:T?.annual_gross_salary_conversion_properties?.description},Component:c(t=>Ae(ne,{desiredCurrency:F?.desired_currency||"",...t}),"Component")}}}}),[F?.desired_currency,T,f]),{data:d,isLoading:Pe}=q({form:"contract_details",options:{jsfModify:{...i?.jsfModify?.contract_details,fields:{...i?.jsfModify?.contract_details?.fields,...Oe.fields}},queryOptions:{enabled:he}}}),{data:S,isLoading:Te}=X(s,_,i),C=w(()=>{if(e.currentStep.name==="benefits"){let t={...e.values?.[e.currentStep.name],..._};return ve({},I,t)}return{}},[e.currentStep.name,I,e.values,_]),a=w(()=>({select_country:E?.fields||[],basic_information:m?.fields||[],contract_details:d?.fields||[],benefits:S?.fields||[],review:[]}),[E?.fields,m?.fields,d?.fields,S?.fields]),Ce={select_country:l(a[e.currentStep.name],{country:r||o?.country.code||""}),basic_information:l(a[e.currentStep.name],o?.basic_information||{}),contract_details:l(a[e.currentStep.name],o?.contract_details||{}),benefits:C||{}},M=Ve||Pe||se||Te||le||me||ye,D=o&&W.includes(o?.status),L=!!(y&&D&&!M&&a.basic_information.length>0&&a.contract_details.length>0&&e.currentStep.name!=="review");je(()=>{if(L){let t=l(a.select_country,{country:r||o?.country.code||""}),n=l(a.basic_information,o?.basic_information||{}),b=l(a.contract_details,o?.contract_details||{}),h=l(a.benefits,C||{});O.current={select_country:p(t,a.select_country),basic_information:p(n,a.basic_information),contract_details:p(b,a.contract_details),benefits:p(h,a.benefits)},R({select_country:t,basic_information:n,contract_details:b,benefits:h,review:{}}),P("review")}},[y,o,M,r,P,C,a,e.currentStep.name,R,L]);let Me=M||L;function U(t){return E&&e.currentStep.name==="select_country"?t:m&&e.currentStep.name==="basic_information"?u(t,m?.fields,{isPartialValidation:!0}):d&&e.currentStep.name==="contract_details"?u(t,d?.fields,{isPartialValidation:!0}):{}}c(U,"parseFormValues");async function Le(t){O.current[e.currentStep.name]=p(t,a[e.currentStep.name]);let n=U(t);switch(j(),e.currentStep.name){case"select_country":return B(n.country),Promise.resolve({data:{countryCode:n.country}});case"basic_information":{let b=!s&&r,h=s&&r&&o?.country&&o?.country.code!==r;if(b||h){let Ie={basic_information:n,type:re,country_code:r};try{let g=await _e(Ie);return await j(),ie(g.data?.data?.employment?.id),g}catch(g){throw console.error("Error creating onboarding:",g),g}}else if(s)return A({employmentId:s,basic_information:n,pricing_plan_details:{frequency:"monthly"}});return}case"contract_details":return A({employmentId:s,...{contract_details:n,pricing_plan_details:{frequency:"monthly"}}});case"benefits":return Se({employmentId:s,...t})}}c(Le,"onSubmit");function we(){ue()}c(we,"back");function ke(){pe()}c(ke,"next");function Be(t){P(t)}return c(Be,"goTo"),{employmentId:s,creditRiskStatus:F?.default_legal_entity_credit_risk_status,owner_id:F?.company_owner_user_id,stepState:e,fields:a[e.currentStep.name],isLoading:Me,isSubmitting:v.isPending||J.isPending||N.isPending,initialValues:Ce,handleValidation:c(t=>{if(e.currentStep.name==="select_country")return E.handleValidation(t);if(e.currentStep.name==="benefits"&&S){let n=u(t,S?.fields);return S?.handleValidation(n)}if(m&&e.currentStep.name==="basic_information"){let n=u(t,m?.fields);return m?.handleValidation(n)}if(d&&e.currentStep.name==="contract_details"){let n=u(t,d?.fields);return d?.handleValidation(n)}return null},"handleValidation"),checkFieldUpdates:fe,parseFormValues:U,onSubmit:Le,back:we,next:ke,goTo:Be,meta:{fields:O.current},refetchEmployment:ce,employment:o,isEmploymentReadOnly:D}},"useOnboarding");export{ze as a};
|
|
2
|
-
//# sourceMappingURL=chunk-JTP3LZ77.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/flows/Onboarding/hooks.tsx"],"sourcesContent":["import {\n Employment,\n EmploymentCreateParams,\n EmploymentFullParams,\n} from '@/src/client';\nimport { Fields } from '@remoteoss/json-schema-form';\n\nimport { useStepState, Step } from '@/src/flows/useStepState';\nimport {\n prettifyFormValues,\n reviewStepAllowedEmploymentStatus,\n STEPS,\n STEPS_WITHOUT_SELECT_COUNTRY,\n} from '@/src/flows/Onboarding/utils';\nimport {\n getInitialValues,\n parseJSFToValidate,\n} from '@/src/components/form/utils';\nimport { mutationToPromise } from '@/src/lib/mutations';\nimport { FieldValues } from 'react-hook-form';\nimport { OnboardingFlowParams } from '@/src/flows/Onboarding/types';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport mergeWith from 'lodash.mergewith';\nimport {\n useBenefitOffers,\n useBenefitOffersSchema,\n useCompany,\n useCountriesSchemaField,\n useCreateEmployment,\n useEmployment,\n useJSONSchemaForm,\n useUpdateBenefitsOffers,\n useUpdateEmployment,\n} from '@/src/flows/Onboarding/api';\nimport { JSFModify, JSONSchemaFormType } from '@/src/flows/types';\nimport { AnnualGrossSalary } from '@/src/flows/Onboarding/AnnualGrossSalary';\nimport { JSFField } from '@/src/types/remoteFlows';\n\ntype OnboardingHookProps = OnboardingFlowParams;\n\nconst jsonSchemaToEmployment: Partial<\n Record<JSONSchemaFormType, keyof Employment>\n> = {\n employment_basic_information: 'basic_information',\n contract_details: 'contract_details',\n};\n\nconst stepToFormSchemaMap: Record<\n keyof typeof STEPS,\n JSONSchemaFormType | null\n> = {\n select_country: null,\n basic_information: 'employment_basic_information',\n contract_details: 'contract_details',\n benefits: null,\n review: null,\n};\n\nexport const useOnboarding = ({\n employmentId,\n companyId,\n countryCode,\n type,\n options,\n}: OnboardingHookProps) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fieldsMetaRef = useRef<Record<string, any>>({});\n const [internalEmploymentId, setInternalEmploymentId] = useState<\n string | undefined\n >(employmentId);\n const [internalCountryCode, setInternalCountryCode] = useState<string | null>(\n countryCode || null,\n );\n const {\n data: employment,\n isLoading: isLoadingEmployment,\n refetch: refetchEmployment,\n } = useEmployment(internalEmploymentId);\n\n // if the employment is loaded, country code has not been set yet\n // we set the internal country code with the employment country code\n if (\n employment?.country?.code &&\n internalCountryCode !== employment.country.code\n ) {\n setInternalCountryCode(employment.country.code);\n }\n\n const { data: benefitOffers, isLoading: isLoadingBenefitOffers } =\n useBenefitOffers(internalEmploymentId);\n const {\n data: company,\n isLoading: isLoadingCompany,\n refetch: refetchCompany,\n } = useCompany(companyId);\n const stepsToUse = countryCode ? STEPS_WITHOUT_SELECT_COUNTRY : STEPS;\n\n const {\n fieldValues,\n stepState,\n setFieldValues,\n previousStep,\n nextStep,\n goToStep,\n setStepValues,\n } = useStepState(\n stepsToUse as Record<keyof typeof STEPS, Step<keyof typeof STEPS>>,\n );\n\n const { selectCountryForm, isLoading: isLoadingCountries } =\n useCountriesSchemaField({\n jsfModify: options?.jsfModify?.select_country,\n jsonSchemaVersion: options?.jsonSchemaVersion,\n });\n\n const createEmploymentMutation = useCreateEmployment(options);\n const updateEmploymentMutation = useUpdateEmployment(options);\n const updateBenefitsOffersMutation = useUpdateBenefitsOffers(options);\n const { mutateAsync: createEmploymentMutationAsync } = mutationToPromise(\n createEmploymentMutation,\n );\n const { mutateAsync: updateEmploymentMutationAsync } = mutationToPromise(\n updateEmploymentMutation,\n );\n const { mutateAsync: updateBenefitsOffersMutationAsync } = mutationToPromise(\n updateBenefitsOffersMutation,\n );\n\n const formType =\n stepToFormSchemaMap[stepState.currentStep.name] ||\n 'employment_basic_information';\n const employmentKey = jsonSchemaToEmployment[formType] as keyof Employment;\n const serverEmploymentData = (employment?.[employmentKey] || {}) as Record<\n string,\n unknown\n >;\n\n const useJSONSchema = ({\n form,\n options: jsonSchemaOptions = {},\n }: {\n form: JSONSchemaFormType;\n options?: {\n jsfModify?: JSFModify;\n queryOptions?: { enabled?: boolean };\n };\n }) => {\n return useJSONSchemaForm({\n countryCode: internalCountryCode as string,\n form: form,\n fieldValues:\n Object.keys(fieldValues).length > 0\n ? {\n ...stepState.values?.[stepState.currentStep.name], // Restore values for the current step\n ...fieldValues,\n }\n : serverEmploymentData,\n options: {\n ...jsonSchemaOptions,\n queryOptions: {\n enabled: jsonSchemaOptions.queryOptions?.enabled ?? true,\n },\n },\n });\n };\n\n const isBasicInformationDetailsEnabled = Boolean(\n internalCountryCode &&\n (stepState.currentStep.name === 'basic_information' ||\n Boolean(employmentId)),\n );\n\n const isContractDetailsEnabled = Boolean(\n internalCountryCode &&\n (stepState.currentStep.name === 'contract_details' ||\n Boolean(employmentId)),\n );\n\n const {\n data: basicInformationForm,\n isLoading: isLoadingBasicInformationForm,\n } = useJSONSchema({\n form: 'employment_basic_information',\n options: {\n jsfModify: options?.jsfModify?.basic_information,\n queryOptions: {\n enabled: isBasicInformationDetailsEnabled,\n },\n },\n });\n\n const annualGrossSalaryField =\n options?.jsfModify?.contract_details?.fields?.annual_gross_salary;\n const annualSalaryFieldPresentation =\n annualGrossSalaryField &&\n typeof annualGrossSalaryField === 'object' &&\n 'presentation' in annualGrossSalaryField\n ? (\n annualGrossSalaryField as {\n presentation?: {\n annual_gross_salary_conversion_properties?: {\n label?: string;\n description?: string;\n };\n };\n }\n ).presentation\n : undefined;\n\n const customFields = useMemo(\n () => ({\n fields: {\n annual_gross_salary: {\n ...annualGrossSalaryField,\n presentation: {\n annual_gross_salary_conversion_properties: {\n label:\n annualSalaryFieldPresentation\n ?.annual_gross_salary_conversion_properties?.label,\n description:\n annualSalaryFieldPresentation\n ?.annual_gross_salary_conversion_properties?.description,\n },\n Component: (props: JSFField & { currency: string }) => (\n <AnnualGrossSalary\n desiredCurrency={company?.desired_currency || ''}\n {...props}\n />\n ),\n },\n },\n },\n }),\n [\n company?.desired_currency,\n annualSalaryFieldPresentation,\n annualGrossSalaryField,\n ],\n );\n\n const { data: contractDetailsForm, isLoading: isLoadingContractDetailsForm } =\n useJSONSchema({\n form: 'contract_details',\n options: {\n jsfModify: {\n ...options?.jsfModify?.contract_details,\n fields: {\n ...options?.jsfModify?.contract_details?.fields,\n ...customFields.fields,\n },\n },\n queryOptions: {\n enabled: isContractDetailsEnabled,\n },\n },\n });\n\n const {\n data: benefitOffersSchema,\n isLoading: isLoadingBenefitsOffersSchema,\n } = useBenefitOffersSchema(\n internalEmploymentId as string,\n fieldValues,\n options,\n );\n\n const initialValuesBenefitOffers = useMemo(() => {\n if (stepState.currentStep.name === 'benefits') {\n const benefitsFormValues = {\n ...stepState.values?.[stepState.currentStep.name as keyof typeof STEPS], // Restore values for the current step\n ...fieldValues,\n };\n return mergeWith({}, benefitOffers, benefitsFormValues);\n }\n return {};\n }, [\n stepState.currentStep.name,\n benefitOffers,\n stepState.values,\n fieldValues,\n ]);\n\n const stepFields: Record<keyof typeof STEPS, Fields> = useMemo(\n () => ({\n select_country: selectCountryForm?.fields || [],\n basic_information: basicInformationForm?.fields || [],\n contract_details: contractDetailsForm?.fields || [],\n benefits: benefitOffersSchema?.fields || [],\n review: [],\n }),\n [\n selectCountryForm?.fields,\n basicInformationForm?.fields,\n contractDetailsForm?.fields,\n benefitOffersSchema?.fields,\n ],\n );\n\n const initialValues = {\n select_country: getInitialValues(stepFields[stepState.currentStep.name], {\n country: internalCountryCode || employment?.country.code || '',\n }),\n basic_information: getInitialValues(\n stepFields[stepState.currentStep.name],\n employment?.basic_information || {},\n ),\n contract_details: getInitialValues(\n stepFields[stepState.currentStep.name],\n employment?.contract_details || {},\n ),\n benefits: initialValuesBenefitOffers || {},\n };\n\n const initialLoading =\n isLoadingBasicInformationForm ||\n isLoadingContractDetailsForm ||\n isLoadingEmployment ||\n isLoadingBenefitsOffersSchema ||\n isLoadingBenefitOffers ||\n isLoadingCompany ||\n isLoadingCountries;\n\n const isEmploymentReadOnly =\n employment &&\n reviewStepAllowedEmploymentStatus.includes(employment?.status);\n\n const isNavigatingToReview = Boolean(\n employmentId &&\n isEmploymentReadOnly &&\n !initialLoading &&\n stepFields['basic_information'].length > 0 &&\n stepFields['contract_details'].length > 0 &&\n stepState.currentStep.name !== 'review',\n );\n\n useEffect(() => {\n if (isNavigatingToReview) {\n const selectCountryInitialValues = getInitialValues(\n stepFields['select_country'],\n {\n country: internalCountryCode || employment?.country.code || '',\n },\n );\n\n const basicInformationInitialValues = getInitialValues(\n stepFields['basic_information'],\n employment?.basic_information || {},\n );\n\n const contractDetailsInitialValues = getInitialValues(\n stepFields['contract_details'],\n employment?.contract_details || {},\n );\n\n const benefitsInitialValues = getInitialValues(\n stepFields['benefits'],\n initialValuesBenefitOffers || {},\n );\n fieldsMetaRef.current = {\n select_country: prettifyFormValues(\n selectCountryInitialValues,\n stepFields['select_country'],\n ),\n basic_information: prettifyFormValues(\n basicInformationInitialValues,\n stepFields['basic_information'],\n ),\n contract_details: prettifyFormValues(\n contractDetailsInitialValues,\n stepFields['contract_details'],\n ),\n benefits: prettifyFormValues(\n benefitsInitialValues,\n stepFields['benefits'],\n ),\n };\n\n setStepValues({\n select_country: selectCountryInitialValues,\n basic_information: basicInformationInitialValues,\n contract_details: contractDetailsInitialValues,\n benefits: benefitsInitialValues,\n review: {},\n });\n\n goToStep('review');\n }\n }, [\n employmentId,\n employment,\n initialLoading,\n internalCountryCode,\n goToStep,\n initialValuesBenefitOffers,\n stepFields,\n stepState.currentStep.name,\n setStepValues,\n isNavigatingToReview,\n ]);\n\n const isLoading = initialLoading || isNavigatingToReview;\n\n function parseFormValues(values: FieldValues) {\n if (selectCountryForm && stepState.currentStep.name === 'select_country') {\n return values;\n }\n if (\n basicInformationForm &&\n stepState.currentStep.name === 'basic_information'\n ) {\n return parseJSFToValidate(values, basicInformationForm?.fields, {\n isPartialValidation: true,\n });\n }\n\n if (\n contractDetailsForm &&\n stepState.currentStep.name === 'contract_details'\n ) {\n return parseJSFToValidate(values, contractDetailsForm?.fields, {\n isPartialValidation: true,\n });\n }\n\n return {};\n }\n\n async function onSubmit(values: FieldValues) {\n // Prettify values for the current step\n fieldsMetaRef.current[stepState.currentStep.name] = prettifyFormValues(\n values,\n stepFields[stepState.currentStep.name],\n );\n\n const parsedValues = parseFormValues(values);\n refetchCompany();\n switch (stepState.currentStep.name) {\n case 'select_country': {\n setInternalCountryCode(parsedValues.country);\n return Promise.resolve({ data: { countryCode: parsedValues.country } });\n }\n case 'basic_information': {\n const isEmploymentNotLoaded =\n !internalEmploymentId && internalCountryCode;\n const hasChangedCountry =\n internalEmploymentId &&\n internalCountryCode &&\n employment?.country &&\n employment?.country.code !== internalCountryCode;\n if (isEmploymentNotLoaded || hasChangedCountry) {\n const payload: EmploymentCreateParams = {\n basic_information: parsedValues,\n type: type,\n country_code: internalCountryCode,\n };\n try {\n const response = await createEmploymentMutationAsync(payload);\n await refetchCompany();\n setInternalEmploymentId(\n // @ts-expect-error the types from the response are not matching\n response.data?.data?.employment?.id,\n );\n return response;\n } catch (error) {\n console.error('Error creating onboarding:', error);\n throw error;\n }\n } else if (internalEmploymentId) {\n return updateEmploymentMutationAsync({\n employmentId: internalEmploymentId,\n basic_information: parsedValues,\n pricing_plan_details: {\n frequency: 'monthly',\n },\n });\n }\n\n return;\n }\n case 'contract_details': {\n const payload: EmploymentFullParams = {\n contract_details: parsedValues,\n pricing_plan_details: {\n frequency: 'monthly',\n },\n };\n return updateEmploymentMutationAsync({\n employmentId: internalEmploymentId as string,\n ...payload,\n });\n }\n\n case 'benefits': {\n return updateBenefitsOffersMutationAsync({\n employmentId: internalEmploymentId as string,\n ...values,\n });\n }\n }\n return;\n }\n\n function back() {\n previousStep();\n }\n\n function next() {\n nextStep();\n }\n\n function goTo(step: keyof typeof STEPS) {\n goToStep(step);\n }\n\n return {\n /**\n * Employment id passed useful to be used between components\n */\n employmentId: internalEmploymentId,\n\n /**\n * Credit risk status of the company, useful to know what to to show in the review step\n * The possible values are:\n * - not_started\n * - ready\n * - in_progress\n * - referred\n * - fail\n * - deposit_required\n * - no_deposit_required\n */\n\n creditRiskStatus: company?.default_legal_entity_credit_risk_status,\n\n owner_id: company?.company_owner_user_id,\n /**\n * Current step state containing the current step and total number of steps\n */\n stepState,\n /**\n * Array of form fields from the onboarding schema\n */\n fields: stepFields[stepState.currentStep.name],\n /**\n * Loading state indicating if the onboarding schema is being fetched\n */\n isLoading: isLoading,\n /**\n * Loading state indicating if the onboarding mutation is in progress\n */\n isSubmitting:\n createEmploymentMutation.isPending ||\n updateEmploymentMutation.isPending ||\n updateBenefitsOffersMutation.isPending,\n /**\n * Initial form values\n */\n initialValues,\n /**\n * Function to validate form values against the onboarding schema\n * @param values - Form values to validate\n * @returns Validation result or null if no schema is available\n */\n handleValidation: (values: FieldValues) => {\n if (stepState.currentStep.name === 'select_country') {\n return selectCountryForm.handleValidation(values);\n }\n if (stepState.currentStep.name === 'benefits' && benefitOffersSchema) {\n const parsedValues = parseJSFToValidate(\n values,\n benefitOffersSchema?.fields,\n );\n\n return benefitOffersSchema?.handleValidation(parsedValues);\n }\n if (\n basicInformationForm &&\n stepState.currentStep.name === 'basic_information'\n ) {\n const parsedValues = parseJSFToValidate(\n values,\n basicInformationForm?.fields,\n );\n return basicInformationForm?.handleValidation(parsedValues);\n }\n\n if (\n contractDetailsForm &&\n stepState.currentStep.name === 'contract_details'\n ) {\n const parsedValues = parseJSFToValidate(\n values,\n contractDetailsForm?.fields,\n );\n return contractDetailsForm?.handleValidation(parsedValues);\n }\n\n return null;\n },\n /**\n * Function to update the current form field values\n * @param values - New form values to set\n */\n checkFieldUpdates: setFieldValues,\n\n /**\n * Function to parse form values before submission\n * @param values - Form values to parse\n * @returns Parsed form values\n */\n parseFormValues,\n\n /**\n * Function to handle form submission\n * @param values - Form values to submit\n * @returns Promise resolving to the mutation result\n */\n onSubmit,\n\n /**\n * Function to handle going back to the previous step\n * @returns {void}\n */\n back,\n\n /**\n * Function to handle going to the next step\n * @returns {void}\n */\n next,\n\n /**\n * Function to handle going to a specific step\n * @param step The step to go to.\n * @returns {void}\n */\n goTo,\n\n /**\n * Fields metadata for each step\n */\n meta: {\n fields: fieldsMetaRef.current,\n },\n\n /**\n * Function to refetch the employment data\n * @returns {void}\n */\n refetchEmployment,\n /**\n * Employment data\n */\n employment,\n\n /**\n * let's the user know that the employment cannot be edited, happens when employment.status is invited, created_awaiting_reserve or created_reserve_paid\n * @returns {boolean}\n */\n isEmploymentReadOnly,\n };\n};\n"],"mappings":"+WAqBA,OAAS,aAA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CpE,EAASoE,CAAI,CACf,CAFS,OAAApG,EAAAmG,GAAA,QAIF,CAIL,aAAc3F,EAcd,iBAAkBY,GAAS,wCAE3B,SAAUA,GAAS,sBAInB,UAAAQ,EAIA,OAAQ6C,EAAW7C,EAAU,YAAY,IAAI,EAI7C,UAAW0D,GAIX,aACEhD,EAAyB,WACzBE,EAAyB,WACzBE,EAA6B,UAI/B,cAAAgC,GAMA,iBAAkB1E,EAACwF,GAAwB,CACzC,GAAI5D,EAAU,YAAY,OAAS,iBACjC,OAAOO,EAAkB,iBAAiBqD,CAAM,EAElD,GAAI5D,EAAU,YAAY,OAAS,YAAcuC,EAAqB,CACpE,IAAMwB,EAAeF,EACnBD,EACArB,GAAqB,MACvB,EAEA,OAAOA,GAAqB,iBAAiBwB,CAAY,CAC3D,CACA,GACElC,GACA7B,EAAU,YAAY,OAAS,oBAC/B,CACA,IAAM+D,EAAeF,EACnBD,EACA/B,GAAsB,MACxB,EACA,OAAOA,GAAsB,iBAAiBkC,CAAY,CAC5D,CAEA,GACE1B,GACArC,EAAU,YAAY,OAAS,mBAC/B,CACA,IAAM+D,EAAeF,EACnBD,EACAvB,GAAqB,MACvB,EACA,OAAOA,GAAqB,iBAAiB0B,CAAY,CAC3D,CAEA,OAAO,IACT,EAnCkB,oBAwClB,kBAAmB9D,GAOnB,gBAAA0D,EAOA,SAAAG,GAMA,KAAAO,GAMA,KAAAC,GAOA,KAAAC,GAKA,KAAM,CACJ,OAAQ7F,EAAc,OACxB,EAMA,kBAAAS,GAIA,WAAAF,EAMA,qBAAAgE,CACF,CACF,EA3lB6B","names":["useEffect","useMemo","useRef","useState","mergeWith","jsx","jsonSchemaToEmployment","stepToFormSchemaMap","useOnboarding","__name","employmentId","companyId","countryCode","type","options","fieldsMetaRef","useRef","internalEmploymentId","setInternalEmploymentId","useState","internalCountryCode","setInternalCountryCode","employment","isLoadingEmployment","refetchEmployment","useEmployment","benefitOffers","isLoadingBenefitOffers","useBenefitOffers","company","isLoadingCompany","refetchCompany","useCompany","stepsToUse","STEPS_WITHOUT_SELECT_COUNTRY","STEPS","fieldValues","stepState","setFieldValues","previousStep","nextStep","goToStep","setStepValues","useStepState","selectCountryForm","isLoadingCountries","useCountriesSchemaField","createEmploymentMutation","useCreateEmployment","updateEmploymentMutation","useUpdateEmployment","updateBenefitsOffersMutation","useUpdateBenefitsOffers","createEmploymentMutationAsync","mutationToPromise","updateEmploymentMutationAsync","updateBenefitsOffersMutationAsync","formType","employmentKey","serverEmploymentData","useJSONSchema","form","jsonSchemaOptions","useJSONSchemaForm","isBasicInformationDetailsEnabled","isContractDetailsEnabled","basicInformationForm","isLoadingBasicInformationForm","annualGrossSalaryField","annualSalaryFieldPresentation","customFields","useMemo","props","AnnualGrossSalary","contractDetailsForm","isLoadingContractDetailsForm","benefitOffersSchema","isLoadingBenefitsOffersSchema","useBenefitOffersSchema","initialValuesBenefitOffers","benefitsFormValues","mergeWith","stepFields","initialValues","getInitialValues","initialLoading","isEmploymentReadOnly","reviewStepAllowedEmploymentStatus","isNavigatingToReview","useEffect","selectCountryInitialValues","basicInformationInitialValues","contractDetailsInitialValues","benefitsInitialValues","prettifyFormValues","isLoading","parseFormValues","values","parseJSFToValidate","onSubmit","parsedValues","isEmploymentNotLoaded","hasChangedCountry","payload","response","error","back","next","goTo","step"]}
|
package/dist/chunk-KHZ2ITFO.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as e}from"./chunk-P37U34EQ.js";function s(a){return{mutateAsync:e(n=>new Promise((t,o)=>{a.mutate(n,{onSuccess:e(r=>{r.data?t({data:r.data,error:null}):t({data:null,error:new Error("Something went wrong. Please try again later.")})},"onSuccess"),onError:e(r=>{o({data:null,error:r})},"onError")})}),"mutateAsync")}}e(s,"mutationToPromise");export{s as a};
|
|
2
|
-
//# sourceMappingURL=chunk-KHZ2ITFO.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/lib/mutations.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { UseMutationResult } from '@tanstack/react-query';\n\ntype MutationData<T> =\n T extends UseMutationResult<infer R, any, any, any> ? R : never;\ntype MutationVariables<T> =\n T extends UseMutationResult<any, any, infer V, any> ? V : never;\ntype MutationError<T> =\n T extends UseMutationResult<any, infer E, any, any> ? E : never;\n\nexport interface SuccessResponse<D> {\n data: D;\n error: null;\n}\n\nexport interface ErrorResponse<E> {\n data: null;\n error: E;\n}\n\ntype PromiseResult<D, E> = SuccessResponse<D> | ErrorResponse<E>;\n\n/**\n * Converts a mutation to a promise-based API. We avoid using the\n * `mutateAsync` method from react-query for 2 reasons:\n * 1. We lose the isPending state of the mutation\n * 2. We want to return the data and error in a consistent way\n * (either data or error is null)\n * @param mutation\n * @returns\n */\nexport function mutationToPromise<\n T extends UseMutationResult<any, any, any, any>,\n>(mutation: T) {\n type Data = MutationData<T>;\n type Variables = MutationVariables<T>;\n type Error = MutationError<T>;\n\n return {\n mutateAsync: (values: Variables): Promise<PromiseResult<Data, Error>> => {\n return new Promise((resolve, reject) => {\n mutation.mutate(values, {\n onSuccess: (response) => {\n if (response.data) {\n resolve({\n data: response.data as Data,\n error: null,\n });\n } else {\n resolve({\n data: null,\n error: new Error(\n 'Something went wrong. Please try again later.',\n ) as unknown as Error,\n });\n }\n },\n onError: (error) => {\n reject({\n data: null,\n error: error as Error,\n });\n },\n });\n });\n },\n };\n}\n"],"mappings":"wCA+BO,SAASA,EAEdC,EAAa,CAKb,MAAO,CACL,YAAaC,EAACC,GACL,IAAI,QAAQ,CAACC,EAASC,IAAW,CACtCJ,EAAS,OAAOE,EAAQ,CACtB,UAAWD,EAACI,GAAa,CACnBA,EAAS,KACXF,EAAQ,CACN,KAAME,EAAS,KACf,MAAO,IACT,CAAC,EAEDF,EAAQ,CACN,KAAM,KACN,MAAO,IAAI,MACT,+CACF,CACF,CAAC,CAEL,EAdW,aAeX,QAASF,EAACK,GAAU,CAClBF,EAAO,CACL,KAAM,KACN,MAAOE,CACT,CAAC,CACH,EALS,UAMX,CAAC,CACH,CAAC,EAzBU,cA2Bf,CACF,CApCgBL,EAAAF,EAAA","names":["mutationToPromise","mutation","__name","values","resolve","reject","response","error"]}
|
package/dist/chunk-L6LGRALQ.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as p}from"./chunk-VEOGRXYK.js";import{a as i}from"./chunk-C3HJSV4T.js";import{a as f}from"./chunk-GPAE53HO.js";import{a as c}from"./chunk-GAXGAK4P.js";import{a as t}from"./chunk-JTP3LZ77.js";import{a as r}from"./chunk-HGHKZF7M.js";import{a as m}from"./chunk-VJEL5MZJ.js";import{a as s}from"./chunk-VJEJUUY2.js";import{a}from"./chunk-VN4HDCRB.js";import{a as n}from"./chunk-PGWKJ6FK.js";import{a as e}from"./chunk-P37U34EQ.js";import{useId as y,useState as I}from"react";import{jsx as w}from"react/jsx-runtime";var A=e(({employmentId:d,companyId:S,countryCode:b,type:g="employee",render:u,options:l})=>{let B=y(),o=t({companyId:S,countryCode:b,employmentId:d,type:g,options:l}),[O,v]=I({showReserveInvoice:!1,showInviteSuccessful:!1});return w(n.Provider,{value:{formId:B,onboardingBag:o,creditScore:O,setCreditScore:v},children:u({onboardingBag:o,components:{BasicInformationStep:r,ContractDetailsStep:s,BenefitsStep:m,SubmitButton:i,BackButton:a,OnboardingInvite:p,SelectCountryStep:c,ReviewStep:f}})})},"OnboardingFlow");export{A as a};
|
|
2
|
-
//# sourceMappingURL=chunk-L6LGRALQ.js.map
|