@remoteoss/remote-flows 1.1.2 → 1.1.4
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/dist/{chunk-RHFPRVJN.js → chunk-2D5I4RIF.js} +2 -2
- package/dist/{chunk-75QLYO7Q.js → chunk-2DL2FNZG.js} +2 -2
- package/dist/{chunk-AVMBXERH.js → chunk-2DYRPCHC.js} +2 -2
- package/dist/{chunk-7OTI6JXY.js → chunk-2LR4VZUK.js} +2 -2
- package/dist/chunk-3JVRFY6F.js +2 -0
- package/dist/chunk-3JVRFY6F.js.map +1 -0
- package/dist/{chunk-QGGFY3DW.js → chunk-3TVKDZSP.js} +2 -2
- package/dist/{chunk-WPPOKYOE.js → chunk-3XOY4F3D.js} +2 -2
- package/dist/{chunk-J6QOM4P4.js → chunk-4C7Y76IS.js} +2 -2
- package/dist/{chunk-VXZN2TCG.js → chunk-4P5BLP5U.js} +2 -2
- package/dist/{chunk-I5ZXDJAN.js → chunk-4Y3PH3Z7.js} +2 -2
- package/dist/chunk-7NCYKLRU.js +2 -0
- package/dist/chunk-7NCYKLRU.js.map +1 -0
- package/dist/{chunk-O3IPCXFD.js → chunk-AW7XS7Z5.js} +2 -2
- package/dist/{chunk-3JKQNLJQ.js → chunk-BGNCB335.js} +2 -2
- package/dist/{chunk-7ZP6I6HO.js → chunk-EOV62SUU.js} +2 -2
- package/dist/{chunk-HAPPSY4M.js → chunk-GTP4CHJD.js} +2 -2
- package/dist/{chunk-LDMTOUJT.js → chunk-H62DYWRD.js} +2 -2
- package/dist/{chunk-LCVAJK7F.js → chunk-I4S5X7NU.js} +2 -2
- package/dist/{chunk-43JVUULE.js → chunk-ITIZBBRW.js} +2 -2
- package/dist/{chunk-UXQVACXI.js → chunk-J667C5G4.js} +2 -2
- package/dist/{chunk-OMRLBAVD.js → chunk-KG63T7OU.js} +2 -2
- package/dist/{chunk-3S3JPGGN.js → chunk-LPAKW2MR.js} +2 -2
- package/dist/{chunk-S57MEMTM.js → chunk-PA7PBUX6.js} +2 -2
- package/dist/{chunk-7OHYERFX.js → chunk-PHWZOEDE.js} +2 -2
- package/dist/{chunk-L23UIJDU.js → chunk-PWKYZHOL.js} +2 -2
- package/dist/{chunk-XJGMRPGR.js → chunk-R36C4F5D.js} +2 -2
- package/dist/{chunk-H2KQYDBI.js → chunk-S5PJSCJF.js} +2 -2
- package/dist/{chunk-KIFLAWFQ.js → chunk-S7X4AB7C.js} +2 -2
- package/dist/{chunk-AFYLN24W.js → chunk-SGTUQ7OX.js} +2 -2
- package/dist/chunk-U2AUFXNA.js +2 -0
- package/dist/chunk-U2AUFXNA.js.map +1 -0
- package/dist/{chunk-3KYIP6FF.js → chunk-U2DDV6SE.js} +2 -2
- package/dist/{chunk-H5ALF54Z.js → chunk-U2PJLKXO.js} +2 -2
- package/dist/{chunk-FF3CQXEL.js → chunk-VC66HET6.js} +2 -2
- package/dist/chunk-VC66HET6.js.map +1 -0
- package/dist/{chunk-CE4VVNUZ.js → chunk-WDH34P74.js} +2 -2
- package/dist/{chunk-QGLNP2MO.js → chunk-WK5QE22Y.js} +2 -2
- package/dist/{chunk-3E3A3LIN.js → chunk-XDYSADZN.js} +2 -2
- package/dist/flows/ContractAmendment/ContractAmendmentConfirmationForm.d.ts +1 -1
- package/dist/flows/ContractAmendment/ContractAmendmentFlow.d.ts +3 -3
- package/dist/flows/ContractAmendment/ContractAmendmentFlow.js +1 -1
- package/dist/flows/ContractAmendment/ContractAmendmentForm.d.ts +1 -1
- package/dist/flows/ContractAmendment/ContractAmendmentForm.js +1 -1
- package/dist/flows/ContractAmendment/context.d.ts +3 -3
- package/dist/flows/ContractAmendment/hooks.d.ts +3 -3
- package/dist/flows/ContractAmendment/index.d.ts +3 -3
- package/dist/flows/ContractAmendment/index.js +1 -1
- package/dist/flows/ContractAmendment/types.d.ts +3 -3
- package/dist/flows/ContractAmendment/utils.d.ts +1 -1
- package/dist/flows/ContractorOnboarding/ContractorOnboarding.d.ts +6 -6
- package/dist/flows/ContractorOnboarding/ContractorOnboarding.js +1 -1
- package/dist/flows/ContractorOnboarding/api.d.ts +2 -2
- package/dist/flows/ContractorOnboarding/components/BasicInformationStep.d.ts +5 -5
- package/dist/flows/ContractorOnboarding/components/BasicInformationStep.js +1 -1
- package/dist/flows/ContractorOnboarding/components/ContractDetailsStep.d.ts +6 -6
- package/dist/flows/ContractorOnboarding/components/ContractDetailsStep.js +1 -1
- package/dist/flows/ContractorOnboarding/components/ContractPreviewStep.d.ts +6 -6
- package/dist/flows/ContractorOnboarding/components/ContractPreviewStep.js +1 -1
- package/dist/flows/ContractorOnboarding/components/ContractorOnboardingForm.d.ts +6 -6
- package/dist/flows/ContractorOnboarding/components/ContractorOnboardingForm.js +1 -1
- package/dist/flows/ContractorOnboarding/components/OnboardingInvite.d.ts +4 -4
- package/dist/flows/ContractorOnboarding/components/OnboardingInvite.js +1 -1
- package/dist/flows/ContractorOnboarding/components/PricingPlan.d.ts +6 -6
- package/dist/flows/ContractorOnboarding/components/PricingPlan.js +1 -1
- package/dist/flows/ContractorOnboarding/components/SelectCountryStep.d.ts +5 -5
- package/dist/flows/ContractorOnboarding/components/SelectCountryStep.js +1 -1
- package/dist/flows/ContractorOnboarding/context.d.ts +5 -5
- package/dist/flows/ContractorOnboarding/hooks.d.ts +5 -5
- package/dist/flows/ContractorOnboarding/hooks.js +1 -1
- package/dist/flows/ContractorOnboarding/index.d.ts +6 -6
- package/dist/flows/ContractorOnboarding/index.js +1 -1
- package/dist/flows/ContractorOnboarding/types.d.ts +5 -5
- package/dist/flows/CostCalculator/CostCalculatorFlow.d.ts +4 -4
- package/dist/flows/CostCalculator/CostCalculatorFlow.js +1 -1
- package/dist/flows/CostCalculator/CostCalculatorForm.d.ts +4 -4
- package/dist/flows/CostCalculator/CostCalculatorForm.js +1 -1
- package/dist/flows/CostCalculator/EstimationResults/EstimationResults.d.ts +3 -3
- package/dist/flows/CostCalculator/SummaryResults/SummaryResults.d.ts +3 -3
- package/dist/flows/CostCalculator/api.d.ts +3 -3
- package/dist/flows/CostCalculator/components/SalaryField.d.ts +3 -3
- package/dist/flows/CostCalculator/components/SalaryField.js +1 -1
- package/dist/flows/CostCalculator/context.d.ts +3 -3
- package/dist/flows/CostCalculator/hooks.d.ts +4 -4
- package/dist/flows/CostCalculator/hooks.js +1 -1
- package/dist/flows/CostCalculator/index.d.ts +4 -4
- package/dist/flows/CostCalculator/index.js +1 -1
- package/dist/flows/CostCalculator/types.d.ts +3 -3
- package/dist/flows/CostCalculator/utils.d.ts +4 -4
- package/dist/flows/CostCalculator/utils.js +1 -1
- package/dist/flows/Onboarding/OnboardingFlow.d.ts +5 -5
- package/dist/flows/Onboarding/OnboardingFlow.js +1 -1
- package/dist/flows/Onboarding/api.d.ts +4 -4
- package/dist/flows/Onboarding/api.js +1 -1
- package/dist/flows/Onboarding/components/AnnualGrossSalary.d.ts +3 -3
- package/dist/flows/Onboarding/components/AnnualGrossSalary.js +1 -1
- package/dist/flows/Onboarding/components/BasicInformationStep.d.ts +5 -5
- package/dist/flows/Onboarding/components/BasicInformationStep.js +1 -1
- package/dist/flows/Onboarding/components/BenefitsStep.d.ts +5 -5
- package/dist/flows/Onboarding/components/BenefitsStep.js +1 -1
- package/dist/flows/Onboarding/components/ContractDetailsStep.d.ts +5 -5
- package/dist/flows/Onboarding/components/ContractDetailsStep.js +1 -1
- package/dist/flows/Onboarding/components/OnboardingForm.d.ts +5 -5
- package/dist/flows/Onboarding/components/OnboardingForm.js +1 -1
- package/dist/flows/Onboarding/components/OnboardingInvite.d.ts +4 -4
- package/dist/flows/Onboarding/components/OnboardingInvite.js +1 -1
- package/dist/flows/Onboarding/components/ReviewStep.d.ts +5 -5
- package/dist/flows/Onboarding/components/SaveDraftButton.d.ts +4 -4
- package/dist/flows/Onboarding/components/SelectCountryStep.d.ts +5 -5
- package/dist/flows/Onboarding/components/SelectCountryStep.js +1 -1
- package/dist/flows/Onboarding/context.d.ts +4 -4
- package/dist/flows/Onboarding/hooks.d.ts +4 -4
- package/dist/flows/Onboarding/hooks.js +1 -1
- package/dist/flows/Onboarding/index.d.ts +5 -5
- package/dist/flows/Onboarding/index.js +1 -1
- package/dist/flows/Onboarding/types.d.ts +5 -5
- package/dist/flows/Onboarding/utils.d.ts +5 -5
- package/dist/flows/Termination/AdditionalDetailsForm.d.ts +5 -5
- package/dist/flows/Termination/AdditionalDetailsForm.js +1 -1
- package/dist/flows/Termination/EmployeeComunicationForm.d.ts +5 -5
- package/dist/flows/Termination/EmployeeComunicationForm.js +1 -1
- package/dist/flows/Termination/PaidTimeOffForm.d.ts +5 -5
- package/dist/flows/Termination/PaidTimeOffForm.js +1 -1
- package/dist/flows/Termination/TerminationDetailsForm.d.ts +5 -5
- package/dist/flows/Termination/TerminationDetailsForm.js +1 -1
- package/dist/flows/Termination/TerminationFlow.d.ts +5 -5
- package/dist/flows/Termination/TerminationFlow.js +1 -1
- package/dist/flows/Termination/TerminationForm.d.ts +5 -5
- package/dist/flows/Termination/TerminationForm.js +1 -1
- package/dist/flows/Termination/api.d.ts +6 -6
- package/dist/flows/Termination/components/PaidTimeOff/PaidTimeOff.d.ts +7 -7
- package/dist/flows/Termination/components/PaidTimeOff/PaidTimeOffContainer.d.ts +7 -7
- package/dist/flows/Termination/components/PaidTimeOff/types.d.ts +7 -7
- package/dist/flows/Termination/context.d.ts +5 -5
- package/dist/flows/Termination/hooks.d.ts +5 -5
- package/dist/flows/Termination/hooks.js +1 -1
- package/dist/flows/Termination/index.d.ts +7 -7
- package/dist/flows/Termination/index.js +1 -1
- package/dist/flows/Termination/json-schemas/schema.d.ts +5 -5
- package/dist/flows/Termination/types.d.ts +5 -5
- package/dist/flows/Termination/utils.d.ts +4 -4
- package/dist/flows/types.d.ts +3 -3
- package/dist/index.d.ts +9 -9
- package/dist/index.js +1 -1
- package/dist/{mutations-CxBW1zxv.d.ts → mutations-C42x30Z2.d.ts} +1 -1
- package/dist/{remoteFlows-CY58Msdt.d.ts → remoteFlows-KXJic_nA.d.ts} +56 -48
- package/dist/{types-B9DYionD.d.ts → types-Cr9xHwZe.d.ts} +3 -3
- package/dist/{types-BoBuxeV0.d.ts → types-D1gbtymE.d.ts} +4 -4
- package/dist/{types-QAgBmZlN.d.ts → types-DDcdRWu_.d.ts} +1 -1
- package/dist/{types-C9ltj_p9.d.ts → types-DiNEkqSd.d.ts} +2 -2
- package/dist/{types.gen-D7WEgMDJ.d.ts → types.gen-UyEyxhzQ.d.ts} +1 -1
- package/package.json +4 -4
- package/dist/chunk-2TCLBL2U.js +0 -2
- package/dist/chunk-2TCLBL2U.js.map +0 -1
- package/dist/chunk-67MPL47V.js +0 -2
- package/dist/chunk-67MPL47V.js.map +0 -1
- package/dist/chunk-FF3CQXEL.js.map +0 -1
- package/dist/chunk-IKS3YZ7X.js +0 -2
- package/dist/chunk-IKS3YZ7X.js.map +0 -1
- /package/dist/{chunk-RHFPRVJN.js.map → chunk-2D5I4RIF.js.map} +0 -0
- /package/dist/{chunk-75QLYO7Q.js.map → chunk-2DL2FNZG.js.map} +0 -0
- /package/dist/{chunk-AVMBXERH.js.map → chunk-2DYRPCHC.js.map} +0 -0
- /package/dist/{chunk-7OTI6JXY.js.map → chunk-2LR4VZUK.js.map} +0 -0
- /package/dist/{chunk-QGGFY3DW.js.map → chunk-3TVKDZSP.js.map} +0 -0
- /package/dist/{chunk-WPPOKYOE.js.map → chunk-3XOY4F3D.js.map} +0 -0
- /package/dist/{chunk-J6QOM4P4.js.map → chunk-4C7Y76IS.js.map} +0 -0
- /package/dist/{chunk-VXZN2TCG.js.map → chunk-4P5BLP5U.js.map} +0 -0
- /package/dist/{chunk-I5ZXDJAN.js.map → chunk-4Y3PH3Z7.js.map} +0 -0
- /package/dist/{chunk-O3IPCXFD.js.map → chunk-AW7XS7Z5.js.map} +0 -0
- /package/dist/{chunk-3JKQNLJQ.js.map → chunk-BGNCB335.js.map} +0 -0
- /package/dist/{chunk-7ZP6I6HO.js.map → chunk-EOV62SUU.js.map} +0 -0
- /package/dist/{chunk-HAPPSY4M.js.map → chunk-GTP4CHJD.js.map} +0 -0
- /package/dist/{chunk-LDMTOUJT.js.map → chunk-H62DYWRD.js.map} +0 -0
- /package/dist/{chunk-LCVAJK7F.js.map → chunk-I4S5X7NU.js.map} +0 -0
- /package/dist/{chunk-43JVUULE.js.map → chunk-ITIZBBRW.js.map} +0 -0
- /package/dist/{chunk-UXQVACXI.js.map → chunk-J667C5G4.js.map} +0 -0
- /package/dist/{chunk-OMRLBAVD.js.map → chunk-KG63T7OU.js.map} +0 -0
- /package/dist/{chunk-3S3JPGGN.js.map → chunk-LPAKW2MR.js.map} +0 -0
- /package/dist/{chunk-S57MEMTM.js.map → chunk-PA7PBUX6.js.map} +0 -0
- /package/dist/{chunk-7OHYERFX.js.map → chunk-PHWZOEDE.js.map} +0 -0
- /package/dist/{chunk-L23UIJDU.js.map → chunk-PWKYZHOL.js.map} +0 -0
- /package/dist/{chunk-XJGMRPGR.js.map → chunk-R36C4F5D.js.map} +0 -0
- /package/dist/{chunk-H2KQYDBI.js.map → chunk-S5PJSCJF.js.map} +0 -0
- /package/dist/{chunk-KIFLAWFQ.js.map → chunk-S7X4AB7C.js.map} +0 -0
- /package/dist/{chunk-AFYLN24W.js.map → chunk-SGTUQ7OX.js.map} +0 -0
- /package/dist/{chunk-3KYIP6FF.js.map → chunk-U2DDV6SE.js.map} +0 -0
- /package/dist/{chunk-H5ALF54Z.js.map → chunk-U2PJLKXO.js.map} +0 -0
- /package/dist/{chunk-CE4VVNUZ.js.map → chunk-WDH34P74.js.map} +0 -0
- /package/dist/{chunk-QGLNP2MO.js.map → chunk-WK5QE22Y.js.map} +0 -0
- /package/dist/{chunk-3E3A3LIN.js.map → chunk-XDYSADZN.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as l}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as l}from"./chunk-PHWZOEDE.js";import{b as s}from"./chunk-TOA3JILU.js";import{b as t}from"./chunk-2YTBWEC7.js";import{a as n}from"./chunk-P37U34EQ.js";import{jsx as u}from"react/jsx-runtime";function w({onSubmit:d,onSuccess:c,onError:a}){let{contractorOnboardingBag:r}=s(),m=n(async e=>{try{let i=await r.parseFormValues(e);await d?.(i);let o=await r.onSubmit(e);if(o?.data){await c?.(o?.data),r?.next();return}if(o?.error){let P=t(o?.fieldErrors||[],r.meta?.fields?.pricing_plan);a?.({error:o?.error,rawError:o?.rawError,fieldErrors:P})}}catch(i){a?.({error:i,rawError:i,fieldErrors:[]})}},"handleSubmit"),p=r.stepState.values?.pricing_plan||r.initialValues.pricing_plan;return u(l,{defaultValues:p,onSubmit:m})}n(w,"PricingPlanStep");export{w as a};
|
|
2
|
+
//# sourceMappingURL=chunk-2D5I4RIF.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as i}from"./chunk-ITIZBBRW.js";import{a as e}from"./chunk-WK5QE22Y.js";import{a as c}from"./chunk-AW7XS7Z5.js";import{a as d}from"./chunk-S7X4AB7C.js";import{a as n}from"./chunk-QP5V46OP.js";import{a as f}from"./chunk-KG63T7OU.js";import{a as m}from"./chunk-BFMUZP2O.js";import{a as p}from"./chunk-2D5I4RIF.js";import{a as t}from"./chunk-TOA3JILU.js";import{a}from"./chunk-4P5BLP5U.js";import{a as r}from"./chunk-P37U34EQ.js";import{useId as u}from"react";import{jsx as v}from"react/jsx-runtime";var A=r(({render:g,employmentId:C,externalId:S,countryCode:b,skipSteps:s,initialValues:O,options:l})=>{let o=a({options:l,employmentId:C,externalId:S,countryCode:b,skipSteps:s,initialValues:O}),P=u();return v(t.Provider,{value:{contractorOnboardingBag:o,formId:P},children:g({contractorOnboardingBag:o,components:{BasicInformationStep:e,SelectCountryStep:i,BackButton:n,SubmitButton:m,PricingPlanStep:p,ContractDetailsStep:c,ContractPreviewStep:d,OnboardingInvite:f}})})},"ContractorOnboardingFlow");export{A as a};
|
|
2
|
+
//# sourceMappingURL=chunk-2DL2FNZG.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as l}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as l}from"./chunk-I4S5X7NU.js";import{b as s}from"./chunk-PGWKJ6FK.js";import{b as n}from"./chunk-2YTBWEC7.js";import{a as t}from"./chunk-P37U34EQ.js";import{jsx as E}from"react/jsx-runtime";function S({onSubmit:d,onError:a,onSuccess:m}){let{onboardingBag:r}=s(),c=t(async i=>{try{let e=await r.parseFormValues(i);await d?.(e);let o=await r.onSubmit(i);if(o?.data){await m?.(o.data),r?.next();return}if(o?.error){let p=n(o?.fieldErrors||[],r.meta?.fields?.contract_details);a?.({error:o.error,rawError:o.rawError,fieldErrors:p})}}catch(e){a?.({error:e,rawError:e,fieldErrors:[]})}},"handleSubmit");return E(l,{defaultValues:r.stepState.values?.contract_details||r.initialValues.contract_details,onSubmit:c})}t(S,"ContractDetailsStep");export{S as a};
|
|
2
|
+
//# sourceMappingURL=chunk-2DYRPCHC.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as m}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as m}from"./chunk-I4S5X7NU.js";import{b as a}from"./chunk-PGWKJ6FK.js";import{b as t}from"./chunk-2YTBWEC7.js";import{d as s}from"./chunk-2SO4LW7V.js";import{a as e}from"./chunk-P37U34EQ.js";import{jsx as E}from"react/jsx-runtime";function P({components:d,onSubmit:l,onError:i,onSuccess:f}){let{onboardingBag:o}=a(),p=o.fields??[],c=s(p,o.initialValues.benefits);return E(m,{defaultValues:c,components:d,onSubmit:e(async n=>{try{await l?.(n);let r=await o.onSubmit(n);if(r?.data){await f?.(r.data),o?.next();return}if(r?.error){let u=t(r?.fieldErrors||[],o.meta?.fields?.benefits);i?.({error:r.error,rawError:r.rawError,fieldErrors:u})}}catch(r){i?.({error:r,rawError:r,fieldErrors:[]})}},"handleSubmit")})}e(P,"BenefitsStep");export{P as a};
|
|
2
|
+
//# sourceMappingURL=chunk-2LR4VZUK.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as U}from"./chunk-WVJDCDGZ.js";import{b as N}from"./chunk-Z5WMKCRJ.js";import{A as P,B as x,E as V,H as R,e as F,g as C,j as g,k as S,q as j,r as w,t as O,w as v,x as E,y as q}from"./chunk-NFUP6BFU.js";import{d as a}from"./chunk-KQPDXXG3.js";import{a as b}from"./chunk-2SO4LW7V.js";import{a as r}from"./chunk-P37U34EQ.js";import{modify as d,createHeadlessForm as h}from"@remoteoss/remote-json-schema-form-kit";import{useMutation as l,useQuery as f}from"@tanstack/react-query";var $=r(t=>{let{client:n}=a();return f({queryKey:["employment",t],retry:!1,enabled:!!t,select:r(({data:e})=>e?.data.employment,"select"),queryFn:r(async()=>{let e=await E({client:n,headers:{Authorization:""},path:{employment_id:t}});if(e.error||!e.data)throw new Error("Failed to fetch employment data");return e},"queryFn")})},"useEmployment"),ee=r(t=>{let{client:n}=a();return f({queryKey:["company",t],retry:!1,enabled:!!t,queryFn:r(async()=>{let e=await w({client:n,headers:{Authorization:""},path:{company_id:t}});if(e.error||!e.data)throw new Error("Failed to fetch employment data");return e},"queryFn"),select:r(({data:e})=>e.data.company,"select")})},"useCompany"),te=r(t=>{let{client:n}=a();return f({queryKey:["benefit-offers",t],retry:!1,enabled:!!t,queryFn:r(async()=>g({client:n,path:{employment_id:t}}).then(e=>{if(e.error||!e.data)throw new Error("Failed to fetch benefit offers data");return e}),"queryFn"),select:r(({data:e})=>e?.data?.reduce((o,s)=>({...o,[s.benefit_group.slug]:{value:s.benefit_tier?.slug??"no",...s.benefit_group?.filter?.slug?{filter:s.benefit_group?.filter?.slug}:{}}}),{}),"select")})},"useBenefitOffers"),re=r(()=>{let{client:t}=a();return l({mutationFn:r(n=>R({client:t,headers:{Authorization:""},path:n}),"mutationFn")})},"useEmploymentInvite"),ne=r(()=>{let{client:t}=a();return l({mutationFn:r(n=>j({client:t,body:n}),"mutationFn")})},"useCreateReserveInvoice"),oe=r(({countryCode:t,form:n,fieldValues:e,options:o,query:s={},jsonSchemaVersion:i})=>{let{client:m}=a(),p=i?{json_schema_version:i}:{};return f({queryKey:["onboarding-json-schema-form",t,n],retry:!1,queryFn:r(async()=>{let u=await O({client:m,headers:{Authorization:""},path:{country_code:t,form:n},query:{skip_benefits:!0,...s,...p}});if(u.error||!u.data)throw new Error("Failed to fetch onboarding schema");return u},"queryFn"),enabled:o?.queryOptions?.enabled,select:r(({data:u})=>{let c=u?.data||{};if(o&&o.jsfModify){let{schema:y}=d(c,o.jsfModify);c=y}let J=N(c.properties||{},"money").reduce((y,_)=>(y[_]=b(e[_]),y),{}),Q=JSON.parse(JSON.stringify({...e,...J}));return{meta:{"x-jsf-fieldsets":c["x-jsf-fieldsets"]},...h(c,{initialValues:Q})}},"select")})},"useJSONSchemaForm"),se=r((t,n,e)=>{let o=e?.jsonSchemaVersion?.benefit_offers_form_schema?{json_schema_version:e.jsonSchemaVersion.benefit_offers_form_schema}:{},{client:s}=a();return f({queryKey:["benefit-offers-schema",t],retry:!1,enabled:!!t,queryFn:r(async()=>{let i=await v({client:s,path:{employment_id:t},query:o});if(i.error||!i.data)throw new Error("Failed to fetch benefit offers schema");return i},"queryFn"),select:r(({data:i})=>{let m=i?.data?.schema||{};if(e&&e.jsfModify?.benefits){let{schema:c}=d(m,e.jsfModify.benefits);m=c}let p=Object.keys(n).length>0;return h(m,{initialValues:p?{...n}:{}})},"select")})},"useBenefitOffersSchema"),ae=r(t=>{let{client:n}=a(),e=t?.jsonSchemaVersion?.form_schema?.employment_basic_information?{json_schema_version:t.jsonSchemaVersion.form_schema.employment_basic_information}:{};return l({mutationFn:r(o=>C({client:n,headers:{Authorization:""},body:o,query:{...e}}),"mutationFn")})},"useCreateEmployment"),ie=r(t=>{let{client:n}=a(),e={employment_basic_information_json_schema_version:t?.jsonSchemaVersion?.form_schema?.employment_basic_information,employment_contract_details_json_schema_version:t?.jsonSchemaVersion?.form_schema?.contract_details},o=Object.fromEntries(Object.entries(e).filter(([,s])=>s!==void 0));return l({mutationFn:r(({employmentId:s,...i})=>q({client:n,headers:{Authorization:""},body:i,path:{employment_id:s},query:{skip_benefits:!0,...o}}),"mutationFn")})},"useUpdateEmployment"),me=r(t=>{let{client:n}=a();return l({mutationFn:r(({employmentId:e,...o})=>{let s=t?.jsonSchemaVersion?.benefit_offers_form_schema?{json_schema_version:t.jsonSchemaVersion.benefit_offers_form_schema}:{};return S({client:n,body:o,path:{employment_id:e},query:{...s}})},"mutationFn")})},"useUpdateBenefitsOffers"),B=r(t=>{let{client:n}=a();return f({...t,queryKey:["countries"],retry:!1,queryFn:r(async()=>{let e=await x({client:n,headers:{Authorization:""}});if(e.error||!e.data)throw new Error("Failed to fetch supported countries");return e},"queryFn"),select:r(({data:e})=>e?.data?.filter(o=>o.eor_onboarding).map(o=>({label:o.name,value:o.code}))||[],"select")})},"useCountries"),ce=r(t=>{let{data:n,isLoading:e}=B(t?.queryOptions),{schema:o}=d(U.data.schema,t?.jsfModify||{}),s=h(o);if(n){let i=s.fields.find(m=>m.name==="country");i&&(i.options=n)}return{isLoading:e,selectCountryForm:s}},"useCountriesSchemaField"),le=r(({type:t="spread"})=>{let{client:n}=a();return l({mutationFn:r(e=>(t==="no_spread"?F:V)({client:n,body:e}),"mutationFn")})},"useConvertCurrency"),ue=r(()=>{let{client:t}=a();return l({mutationFn:r(({employmentId:n,...e})=>P({client:t,path:{employment_id:n},body:e}),"mutationFn")})},"useUpsertContractEligibility");export{$ as a,ee as b,te as c,re as d,ne as e,oe as f,se as g,ae as h,ie as i,me as j,ce as k,le as l,ue as m};
|
|
2
|
+
//# sourceMappingURL=chunk-3JVRFY6F.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/flows/Onboarding/api.ts"],"sourcesContent":["import {\n modify,\n createHeadlessForm,\n} from '@remoteoss/remote-json-schema-form-kit';\nimport { useMutation, useQuery, UseQueryResult } from '@tanstack/react-query';\nimport { FieldValues } from 'react-hook-form';\nimport { Client } from '@/src/client/client';\nimport {\n ConvertCurrencyParams,\n CreateContractEligibilityParams,\n EmploymentCreateParams,\n EmploymentFullParams,\n getIndexBenefitOffer,\n getShowCompany,\n getShowEmployment,\n getShowFormCountry,\n getShowSchema,\n getSupportedCountry,\n patchUpdateEmployment2,\n postConvertRawCurrencyConverter,\n postConvertWithSpreadCurrencyConverter,\n postCreateContractEligibility,\n postCreateEmployment2,\n postCreateRiskReserve,\n postInviteEmploymentInvitation,\n PostInviteEmploymentInvitationData,\n putUpdateBenefitOffer,\n UnifiedEmploymentUpsertBenefitOffersRequest,\n} from '@/src/client';\n\nimport { convertToCents } from '@/src/components/form/utils';\nimport { useClient } from '@/src/context';\nimport { selectCountryStepSchema } from '@/src/flows/Onboarding/json-schemas/selectCountryStep';\nimport { OnboardingFlowProps } from '@/src/flows/Onboarding/types';\nimport {\n JSONSchemaFormResultWithFieldsets,\n JSONSchemaFormType,\n NextFlowOptions,\n} from '@/src/flows/types';\nimport { findFieldsByType } from '@/src/flows/utils';\nimport { JSFFieldset } from '@/src/types/remoteFlows';\n\nexport const useEmployment = (employmentId: string | undefined) => {\n const { client } = useClient();\n\n return useQuery({\n queryKey: ['employment', employmentId],\n retry: false,\n enabled: !!employmentId,\n select: ({ data }) => {\n return data?.data.employment;\n },\n queryFn: async () => {\n const response = await getShowEmployment({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: {\n employment_id: employmentId as string,\n },\n });\n\n // If response status is 404 or other error, throw an error to trigger isError\n if (response.error || !response.data) {\n throw new Error('Failed to fetch employment data');\n }\n\n return response;\n },\n });\n};\n\nexport const useCompany = (companyId: string) => {\n const { client } = useClient();\n return useQuery({\n queryKey: ['company', companyId],\n retry: false,\n enabled: !!companyId,\n queryFn: async () => {\n const response = await getShowCompany({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: {\n company_id: companyId,\n },\n });\n\n if (response.error || !response.data) {\n throw new Error('Failed to fetch employment data');\n }\n\n return response;\n },\n select: ({ data }) => {\n return data.data.company;\n },\n });\n};\n\nexport const useBenefitOffers = (employmentId: string | undefined) => {\n const { client } = useClient();\n return useQuery({\n queryKey: ['benefit-offers', employmentId],\n retry: false,\n enabled: !!employmentId,\n queryFn: async () => {\n return getIndexBenefitOffer({\n client: client as Client,\n path: {\n employment_id: employmentId as string,\n },\n }).then((response) => {\n // If response status is 404 or other error, throw an error to trigger isError\n if (response.error || !response.data) {\n throw new Error('Failed to fetch benefit offers data');\n }\n\n return response;\n });\n },\n select: ({ data }) =>\n data?.data?.reduce(\n (acc, item) => {\n return {\n ...acc,\n [item.benefit_group.slug]: {\n value: item.benefit_tier?.slug ?? 'no',\n ...(item.benefit_group?.filter?.slug\n ? { filter: item.benefit_group?.filter?.slug }\n : {}),\n },\n };\n },\n {} as Record<string, { value: string }>,\n ),\n });\n};\n/**\n * Use this hook to invite an employee to the onboarding flow\n * @returns\n */\nexport const useEmploymentInvite = () => {\n const { client } = useClient();\n\n return useMutation({\n mutationFn: (payload: PostInviteEmploymentInvitationData['path']) => {\n return postInviteEmploymentInvitation({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: payload,\n });\n },\n });\n};\n\nexport const useCreateReserveInvoice = () => {\n const { client } = useClient();\n return useMutation({\n mutationFn: (payload: { employment_slug: string }) => {\n return postCreateRiskReserve({\n client: client as Client,\n body: payload,\n });\n },\n });\n};\n\n/**\n * Use this hook to get the JSON schema form for the onboarding flow\n * @param param0\n * @returns\n */\nexport const useJSONSchemaForm = ({\n countryCode,\n form,\n fieldValues,\n options,\n query = {},\n jsonSchemaVersion,\n}: {\n countryCode: string;\n form: JSONSchemaFormType;\n fieldValues: FieldValues;\n options?: NextFlowOptions & { queryOptions?: { enabled?: boolean } };\n query?: Record<string, unknown>;\n jsonSchemaVersion?: number;\n}): UseQueryResult<JSONSchemaFormResultWithFieldsets> => {\n const { client } = useClient();\n const jsonSchemaQueryParam = jsonSchemaVersion\n ? {\n json_schema_version: jsonSchemaVersion,\n }\n : {};\n return useQuery({\n queryKey: ['onboarding-json-schema-form', countryCode, form],\n retry: false,\n queryFn: async () => {\n const response = await getShowFormCountry({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n path: {\n country_code: countryCode,\n form: form,\n },\n query: {\n skip_benefits: true,\n ...query,\n ...jsonSchemaQueryParam,\n },\n });\n\n // If response status is 404 or other error, throw an error to trigger isError\n if (response.error || !response.data) {\n throw new Error('Failed to fetch onboarding schema');\n }\n\n return response;\n },\n enabled: options?.queryOptions?.enabled,\n select: ({ data }) => {\n let jsfSchema = data?.data || {};\n if (options && options.jsfModify) {\n const { schema } = modify(jsfSchema, options.jsfModify);\n jsfSchema = schema;\n }\n\n // Contract details contains x-jsf-logic that need to be calculated every time a form value changes\n // In particular there are calculations involving the annual_gross_salary field. However this field value doesn't get\n // here in cents. So we need to convert the money fields to cents, so that the calculations are correct.\n const moneyFields = findFieldsByType(jsfSchema.properties || {}, 'money');\n const moneyFieldsData = moneyFields.reduce<Record<string, number | null>>(\n (acc, field) => {\n acc[field] = convertToCents(fieldValues[field]);\n return acc;\n },\n {},\n );\n\n const initialValues = JSON.parse(\n JSON.stringify({\n ...fieldValues,\n ...moneyFieldsData,\n }),\n );\n\n return {\n meta: {\n 'x-jsf-fieldsets': jsfSchema['x-jsf-fieldsets'] as JSFFieldset,\n },\n ...createHeadlessForm(jsfSchema, {\n initialValues,\n }),\n };\n },\n });\n};\n\nexport const useBenefitOffersSchema = (\n employmentId: string,\n fieldValues: FieldValues,\n options: OnboardingFlowProps['options'],\n) => {\n const jsonSchemaQueryParam = options?.jsonSchemaVersion\n ?.benefit_offers_form_schema\n ? {\n json_schema_version:\n options.jsonSchemaVersion.benefit_offers_form_schema,\n }\n : {};\n const { client } = useClient();\n return useQuery({\n queryKey: ['benefit-offers-schema', employmentId],\n retry: false,\n enabled: !!employmentId,\n queryFn: async () => {\n const response = await getShowSchema({\n client: client as Client,\n path: {\n employment_id: employmentId,\n },\n query: jsonSchemaQueryParam,\n });\n\n // If response status is 404 or other error, throw an error to trigger isError\n if (response.error || !response.data) {\n throw new Error('Failed to fetch benefit offers schema');\n }\n\n return response;\n },\n select: ({ data }) => {\n let jsfSchema = data?.data?.schema || {};\n\n if (options && options.jsfModify?.benefits) {\n const { schema } = modify(jsfSchema, options.jsfModify.benefits);\n jsfSchema = schema;\n }\n const hasFieldValues = Object.keys(fieldValues).length > 0;\n const result = createHeadlessForm(jsfSchema, {\n // we need to clone the fieldValues to prevent side effects\n // if we don't do this, the benefits get included in the other steps\n initialValues: hasFieldValues ? { ...fieldValues } : {},\n });\n return result;\n },\n });\n};\n\n/**\n * Use this hook to create an employment\n * @returns\n */\nexport const useCreateEmployment = (\n options?: OnboardingFlowProps['options'],\n) => {\n const { client } = useClient();\n const jsonSchemaQueryParam = options?.jsonSchemaVersion?.form_schema\n ?.employment_basic_information\n ? {\n json_schema_version:\n options.jsonSchemaVersion.form_schema.employment_basic_information,\n }\n : {};\n return useMutation({\n mutationFn: (payload: EmploymentCreateParams) => {\n return postCreateEmployment2({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n query: {\n ...jsonSchemaQueryParam,\n },\n });\n },\n });\n};\n\nexport const useUpdateEmployment = (\n options?: OnboardingFlowProps['options'],\n) => {\n const { client } = useClient();\n const jsonSchemaQueryParams = {\n employment_basic_information_json_schema_version:\n options?.jsonSchemaVersion?.form_schema?.employment_basic_information,\n employment_contract_details_json_schema_version:\n options?.jsonSchemaVersion?.form_schema?.contract_details,\n };\n\n const filteredQueryParams = Object.fromEntries(\n Object.entries(jsonSchemaQueryParams).filter(\n ([, value]) => value !== undefined,\n ),\n );\n\n return useMutation({\n mutationFn: ({\n employmentId,\n ...payload\n }: EmploymentFullParams & { employmentId: string }) => {\n return patchUpdateEmployment2({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n path: {\n employment_id: employmentId,\n },\n query: {\n skip_benefits: true,\n ...filteredQueryParams,\n },\n });\n },\n });\n};\n\nexport const useUpdateBenefitsOffers = (\n options?: OnboardingFlowProps['options'],\n) => {\n const { client } = useClient();\n return useMutation({\n mutationFn: ({\n employmentId,\n ...payload\n }: UnifiedEmploymentUpsertBenefitOffersRequest & {\n employmentId: string;\n }) => {\n const jsonSchemaQueryParam = options?.jsonSchemaVersion\n ?.benefit_offers_form_schema\n ? {\n json_schema_version:\n options.jsonSchemaVersion.benefit_offers_form_schema,\n }\n : {};\n return putUpdateBenefitOffer({\n client: client as Client,\n body: payload,\n path: {\n employment_id: employmentId,\n },\n query: {\n ...jsonSchemaQueryParam,\n },\n });\n },\n });\n};\n\nconst useCountries = (queryOptions?: { enabled?: boolean }) => {\n const { client } = useClient();\n return useQuery({\n ...queryOptions,\n queryKey: ['countries'],\n retry: false,\n queryFn: async () => {\n const response = await getSupportedCountry({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n });\n\n // If response status is 404 or other error, throw an error to trigger isError\n if (response.error || !response.data) {\n throw new Error('Failed to fetch supported countries');\n }\n\n return response;\n },\n select: ({ data }) => {\n return (\n data?.data\n ?.filter((country) => country.eor_onboarding)\n .map((country) => {\n return {\n label: country.name,\n value: country.code,\n };\n }) || []\n );\n },\n });\n};\n\nexport const useCountriesSchemaField = (\n options?: Omit<NextFlowOptions, 'jsonSchemaVersion'> & {\n queryOptions?: { enabled?: boolean };\n },\n) => {\n const { data: countries, isLoading } = useCountries(options?.queryOptions);\n\n const { schema: selectCountrySchema } = modify(\n selectCountryStepSchema.data.schema,\n options?.jsfModify || {},\n );\n\n const selectCountryForm = createHeadlessForm(selectCountrySchema);\n\n if (countries) {\n const countryField = selectCountryForm.fields.find(\n (field) => field.name === 'country',\n );\n if (countryField) {\n countryField.options = countries;\n }\n }\n\n return {\n isLoading,\n selectCountryForm,\n };\n};\n\nexport const useConvertCurrency = ({\n type = 'spread',\n}: {\n type?: 'spread' | 'no_spread';\n}) => {\n const { client } = useClient();\n return useMutation({\n mutationFn: (payload: ConvertCurrencyParams) => {\n const apiFn =\n type === 'no_spread'\n ? postConvertRawCurrencyConverter\n : postConvertWithSpreadCurrencyConverter;\n return apiFn({\n client: client as Client,\n body: payload,\n });\n },\n });\n};\n\nexport const useUpsertContractEligibility = () => {\n const { client } = useClient();\n return useMutation({\n mutationFn: ({\n employmentId,\n ...payload\n }: { employmentId: string } & CreateContractEligibilityParams) => {\n return postCreateContractEligibility({\n client: client as Client,\n path: {\n employment_id: employmentId,\n },\n body: payload,\n });\n },\n });\n};\n"],"mappings":"2UAAA,OACE,UAAAA,EACA,sBAAAC,MACK,yCACP,OAAS,eAAAC,EAAa,YAAAC,MAAgC,wBAsC/C,IAAMC,EAAgBC,EAACC,GAAqC,CACjE,GAAM,CAAE,OAAAC,CAAO,EAAIC,EAAU,EAE7B,OAAOC,EAAS,CACd,SAAU,CAAC,aAAcH,CAAY,EACrC,MAAO,GACP,QAAS,CAAC,CAACA,EACX,OAAQD,EAAA,CAAC,CAAE,KAAAK,CAAK,IACPA,GAAM,KAAK,WADZ,UAGR,QAASL,EAAA,SAAY,CACnB,IAAMM,EAAW,MAAMC,EAAkB,CACvC,OAAQL,EACR,QAAS,CACP,cAAe,EACjB,EACA,KAAM,CACJ,cAAeD,CACjB,CACF,CAAC,EAGD,GAAIK,EAAS,OAAS,CAACA,EAAS,KAC9B,MAAM,IAAI,MAAM,iCAAiC,EAGnD,OAAOA,CACT,EAjBS,UAkBX,CAAC,CACH,EA7B6B,iBA+BhBE,GAAaR,EAACS,GAAsB,CAC/C,GAAM,CAAE,OAAAP,CAAO,EAAIC,EAAU,EAC7B,OAAOC,EAAS,CACd,SAAU,CAAC,UAAWK,CAAS,EAC/B,MAAO,GACP,QAAS,CAAC,CAACA,EACX,QAAST,EAAA,SAAY,CACnB,IAAMM,EAAW,MAAMI,EAAe,CACpC,OAAQR,EACR,QAAS,CACP,cAAe,EACjB,EACA,KAAM,CACJ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CACL,IACSkD,EAA8B,CACnC,OAAQjE,EACR,KAAM,CACJ,cAAeD,CACjB,EACA,KAAMgB,CACR,CAAC,EAVS,aAYd,CAAC,CACH,EAhB4C","names":["modify","createHeadlessForm","useMutation","useQuery","useEmployment","__name","employmentId","client","useClient","useQuery","data","response","getShowEmployment","useCompany","companyId","getShowCompany","useBenefitOffers","getIndexBenefitOffer","acc","item","useEmploymentInvite","useMutation","payload","postInviteEmploymentInvitation","useCreateReserveInvoice","postCreateRiskReserve","useJSONSchemaForm","countryCode","form","fieldValues","options","query","jsonSchemaVersion","jsonSchemaQueryParam","getShowFormCountry","jsfSchema","schema","modify","moneyFieldsData","findFieldsByType","field","convertToCents","initialValues","createHeadlessForm","useBenefitOffersSchema","getShowSchema","hasFieldValues","useCreateEmployment","postCreateEmployment2","useUpdateEmployment","jsonSchemaQueryParams","filteredQueryParams","value","patchUpdateEmployment2","useUpdateBenefitsOffers","putUpdateBenefitOffer","useCountries","queryOptions","getSupportedCountry","country","useCountriesSchemaField","countries","isLoading","selectCountrySchema","selectCountryStepSchema","selectCountryForm","countryField","useConvertCurrency","type","postConvertRawCurrencyConverter","postConvertWithSpreadCurrencyConverter","useUpsertContractEligibility","postCreateContractEligibility"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as l}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as l}from"./chunk-7NCYKLRU.js";import{a as m,b as y}from"./chunk-7FMR3EIX.js";import{c}from"./chunk-66N57DKF.js";import{a as t}from"./chunk-P37U34EQ.js";import{useEffect as N}from"react";import{Fragment as b,jsx as v,jsxs as C}from"react/jsx-runtime";var R=t(({currencies:{from:d,to:F},shouldSwapOrder:s,salary_conversion_properties:a,conversionType:_="no_spread",defaultValue:r,...e})=>{let{setValue:n,getValues:i}=c(),f={label:a?.label||"Salary conversion",description:a?.description||C(b,{children:["The conversion is based on the Remote FX rate."," ",v(y,{className:"text-sm",zendeskId:m.remoteFxRate,children:"Learn more \u2197"})]})},g=s?"salary_conversion":e.name,u=s?e.name:"salary_conversion";return N(()=>{if(s){let o=i(e.name);o?(n("salary_conversion",o),n("salary_converted","salary_conversion")):r&&(n("salary_conversion",r),n("salary_converted","salary_conversion"))}else{let o=i("salary_conversion");o?(n(e.name,o),n("salary_converted",e.name)):r&&(n(e.name,r),n("salary_converted",e.name))}},[s,r,n,i,e.name]),v(l,{...e,sourceCurrency:d,targetCurrency:F,mainFieldName:g,conversionFieldName:u,conversionProperties:f,classNamePrefix:"RemoteFlows-Salary",conversionType:_})},"SalaryField");export{R as a};
|
|
2
|
+
//# sourceMappingURL=chunk-3TVKDZSP.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as e}from"./chunk-GTP4CHJD.js";import{b as a}from"./chunk-MRYRNB7Y.js";import{a as i}from"./chunk-P37U34EQ.js";import{jsx as s}from"react/jsx-runtime";function d({onSubmit:m}){let{terminationBag:o}=a(),r=i(async t=>{let n=await o?.parseFormValues(t);await m?.(n),o?.next()},"handleSubmit");return s(e,{defaultValues:o.fieldValues,onSubmit:r})}i(d,"PaidTimeOffForm");export{d as a};
|
|
2
|
+
//# sourceMappingURL=chunk-3XOY4F3D.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as s}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as s}from"./chunk-7NCYKLRU.js";import{a as e}from"./chunk-P37U34EQ.js";import{jsx as i}from"react/jsx-runtime";var l=e(({currency:n,desiredCurrency:o,annual_gross_salary_conversion_properties:r,...a})=>i(s,{...a,sourceCurrency:n,targetCurrency:o,conversionFieldName:"annual_gross_salary_conversion",conversionProperties:{...r,description:r?.description||"Estimated amount. This is an estimation. We calculate conversions based on spot rates that are subject to fluctuation over time."},classNamePrefix:"RemoteFlows-AnnualGrossSalary",conversionType:"no_spread"}),"AnnualGrossSalary");export{l as a};
|
|
2
|
+
//# sourceMappingURL=chunk-4C7Y76IS.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as et,d as nt}from"./chunk-ELXVVBRD.js";import{a as at,b as it,c as ct,e as st,f as lt,g as mt,h as ut}from"./chunk-OAPK6TR7.js";import{a as ot,b as rt}from"./chunk-3UDG4IJO.js";import{a as dt,b as pt}from"./chunk-ZOTFS35J.js";import{a as z,f as Q,h as X,k as Z}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{c as et,d as nt}from"./chunk-ELXVVBRD.js";import{a as at,b as it,c as ct,e as st,f as lt,g as mt,h as ut}from"./chunk-OAPK6TR7.js";import{a as ot,b as rt}from"./chunk-3UDG4IJO.js";import{a as dt,b as pt}from"./chunk-ZOTFS35J.js";import{a as z,f as Q,h as X,k as Z}from"./chunk-3JVRFY6F.js";import{a as v}from"./chunk-2YTBWEC7.js";import{a as tt}from"./chunk-PJBAQZ6G.js";import{c as f,d as C}from"./chunk-2SO4LW7V.js";import{g as P}from"./chunk-L3Z2G32A.js";import{a as p}from"./chunk-P37U34EQ.js";import{useEffect as Kt,useMemo as c,useRef as Yt,useState as k}from"react";var zt={select_country:null,basic_information:"employment_basic_information",contract_details:null,pricing_plan:null,contract_preview:null,review:null},Qt={employment_basic_information:"basic_information"},me=p(({countryCode:ft,externalId:yt,employmentId:y,skipSteps:_t,options:u,initialValues:i})=>{let[a,A]=k(ft||null),[o,St]=k(y),[T,gt]=k(void 0),O=Yt({select_country:{},basic_information:{},contract_details:{},contract_preview:{},pricing_plan:{}}),bt=_t?.includes("select_country")?pt:dt,{fieldValues:w,stepState:e,setFieldValues:Ct,previousStep:wt,nextStep:ht,goToStep:D,setStepValues:B}=tt(bt),{data:s,isLoading:I,refetch:Ft}=z(o),{status:_}=s||{},j=_&&et.includes(_),Vt=_&&!nt.includes(_),Et=c(()=>_==="invited"?"invited":"not_invited",[_]),J=X(u),q=lt(),N=it(),Pt=st(),{mutateAsync:vt}=v(J),{mutateAsync:Ot}=v(q),{mutateAsync:Mt}=v(N),{mutateAsync:x}=v(Pt);y&&s?.country?.code&&!a&&A(s.country.code);let{selectCountryForm:M,isLoading:Tt}=Z({jsfModify:u?.jsfModify?.select_country,queryOptions:{enabled:e.currentStep.name==="select_country"}}),{form:U,isLoading:Dt}=ut(o,{jsonSchemaVersion:u?.jsonSchemaVersion,queryOptions:{enabled:e.currentStep.name==="pricing_plan"}}),It=zt[e.currentStep.name]||"contractor_basic_information",jt=Qt[It],Rt=s?.[jt]||{},Lt=p(({form:t,options:r={},query:g={}})=>{let b=Object.keys(w).length>0?{...i,...e.values?.[e.currentStep.name],...w}:{...i,...Rt};return Q({countryCode:a,form:t,fieldValues:b,query:g,options:{...r,queryOptions:{enabled:r.queryOptions?.enabled??!0}}})},"useJSONSchema"),kt=!!(a&&(e.currentStep.name==="basic_information"||y)),At=!!(a&&(e.currentStep.name==="contract_details"||y)),{data:l,isLoading:Bt}=Lt({form:"contractor_basic_information",options:{jsfModify:u?.jsfModify?.basic_information,queryOptions:{enabled:kt},jsonSchemaVersion:u?.jsonSchemaVersion}}),{data:m,isLoading:Jt}=mt({countryCode:a,fieldValues:w,options:{queryOptions:{enabled:At},jsfModify:u?.jsfModify?.contract_details,jsonSchemaVersion:u?.jsonSchemaVersion}}),{data:d}=at({fieldValues:w,options:{queryOptions:{enabled:e.currentStep.name==="contract_preview"}}}),{data:qt,isLoading:Nt}=ct({employmentId:o,contractDocumentId:T,options:{queryOptions:{enabled:!!T}}}),n=c(()=>({select_country:M?.fields||[],basic_information:l?.fields||[],pricing_plan:U?.fields||[],contract_details:m?.fields||[],contract_preview:d?.fields||[],review:[]}),[M?.fields,l?.fields,U?.fields,m?.fields,d?.fields]),xt={select_country:null,basic_information:l?.meta["x-jsf-fieldsets"],pricing_plan:null,contract_details:m?.meta["x-jsf-fieldsets"],contract_preview:null,review:null},{country:Ut,basic_information:H={},contract_details:S={}}=s||{},G=Ut?.code,h=c(()=>C(n.select_country,{country:a||G||""}),[n.select_country,a,G]),F=c(()=>{let t={...i,...H};return C(n.basic_information,t)},[n.basic_information,H,i]),V=c(()=>{let t={...i,...S};return C(n.contract_details,t)},[n.contract_details,S,i]),W=c(()=>{let t={...i,...S};return C(n.contract_preview,t)},[n.contract_preview,S,i]),$=c(()=>{let t={...i,...S};return C(n.pricing_plan,t?.pricing_plan??{})},[n.pricing_plan,S,i]),Ht=c(()=>({select_country:h,basic_information:F,contract_details:V,contract_preview:W,pricing_plan:$}),[h,F,V,W,$]),K=c(()=>!!(!!(y&&j&&e.currentStep.name!=="review")&&!I&&n.basic_information.length>0&&n.contract_details.length>0),[y,j,I,n.basic_information.length,n.contract_details.length,e.currentStep.name]);Kt(()=>{K&&(O.current={select_country:P(h,n.select_country),basic_information:P(F,n.basic_information),contract_details:P(V,n.contract_details),contract_preview:{},pricing_plan:{}},B({select_country:h,basic_information:F,contract_details:V,contract_preview:{},pricing_plan:{},review:{}}),D("review"))},[K,D,h,F,V,B,n.select_country,n.basic_information,n.contract_details]);let Gt=p(t=>{D(t)},"goTo"),Y=p(async t=>M&&e.currentStep.name==="select_country"?t:l&&e.currentStep.name==="basic_information"?await f(t,l?.fields,{isPartialValidation:!1}):m&&e.currentStep.name==="contract_details"?await f(t,m?.fields,{isPartialValidation:!1}):d&&e.currentStep.name==="contract_preview"?await f(t,d?.fields,{isPartialValidation:!1}):e.currentStep.name==="pricing_plan"?t:{},"parseFormValues");async function Wt(t){let r=e.currentStep.name;r in O.current&&(O.current[r]=P(t,n[r]));let g=await Y(t);switch(e.currentStep.name){case"select_country":return A(g.country),Promise.resolve({data:{countryCode:g.country}});case"basic_information":{let R=!o&&a,b=o&&a&&s?.country&&s?.country.code!==a;if(R||b){let L={basic_information:g,type:"contractor",country_code:a,external_id:yt};try{let E=await vt(L),$t=E.data?.data?.employment?.id;return St($t),E}catch(E){throw console.error("Error creating onboarding:",E),E}}else if(o)return Promise.resolve({data:{employmentId:o}});return}case"contract_details":{let b=await Ot({employmentId:o,payload:{contract_document:g}}),L=b.data?.data?.contract_document?.id;return gt(L),b}case"contract_preview":return Mt({employmentId:o,contractDocumentId:T,payload:{signature:t.signature}});case"pricing_plan":return t.subscription==ot?x({employmentId:o,payload:{operation:"downgrade"}}):t.subscription==rt?x({employmentId:o,payload:{operation:"upgrade"}}):Promise.reject({error:"invalid selection"});default:throw new Error("Invalid step state")}}return p(Wt,"onSubmit"),{isLoading:Tt||Bt||I||Jt||Dt||Nt,fieldValues:w,stepState:e,checkFieldUpdates:Ct,back:wt,next:ht,goTo:Gt,onSubmit:Wt,fields:n[e.currentStep.name],meta:{fields:O.current,fieldsets:xt[e.currentStep.name]},parseFormValues:Y,handleValidation:p(async t=>{if(e.currentStep.name==="select_country")return M.handleValidation(t);if(l&&e.currentStep.name==="basic_information"){let r=await f(t,l?.fields,{isPartialValidation:!1});return l?.handleValidation(r)}if(m&&e.currentStep.name==="contract_details"){let r=await f(t,m?.fields,{isPartialValidation:!1});return m?.handleValidation(r)}if(d&&e.currentStep.name==="contract_preview"){let r=await f(t,d?.fields,{isPartialValidation:!1});return d?.handleValidation(r)}return e.currentStep.name==="pricing_plan"?{formErrors:{}}:null},"handleValidation"),initialValues:Ht,employmentId:o,refetchEmployment:Ft,isSubmitting:J.isPending||q.isPending||N.isPending,documentPreviewPdf:qt,canInvite:Vt,isEmploymentReadOnly:j,invitedStatus:Et,employment:s}},"useContractorOnboarding");export{me as a};
|
|
2
|
+
//# sourceMappingURL=chunk-4P5BLP5U.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as F}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as F}from"./chunk-VC66HET6.js";import{b as u}from"./chunk-LNV36S6D.js";import{f as l,g as p}from"./chunk-66N57DKF.js";import{c as f}from"./chunk-2SO4LW7V.js";import{b as _}from"./chunk-TVZAFTPT.js";import{a}from"./chunk-P37U34EQ.js";import{useEffect as w}from"react";import{jsx as r}from"react/jsx-runtime";var R=["effective_date","reason_for_change","reason_for_change_description","additional_comments","additional_comments_toggle"];function x({onSubmit:b,onError:m,onSuccess:A}){let{formId:C,contractAmendment:{checkFieldUpdates:h,fields:s,onSubmit:y,stepState:S,initialValues:i,handleValidation:g}}=_(),V=u(g),e=l({resolver:V,defaultValues:S.values?.form||i,shouldUnregister:!0,mode:"onBlur"});w(()=>{let t=e?.watch(o=>{(Object.keys(e.formState.dirtyFields).length>0||e.formState.isDirty)&&h(o)});return()=>t?.unsubscribe()},[]);let v=a(async t=>{let o=!1;for(let[c,P]of Object.entries(t))if(!R.includes(c)&&i[c]!==P){o=!0;break}if(!o)return m?.({message:"no_changes_detected_contract_details"});let d=await f(t,s,{isPartialValidation:!1});await b?.(d);let n=await y(t);n.error?m?.(n.error):await A?.(n.data)},"handleSubmit");return r(p,{...e,children:r("form",{id:C,"data-testid":"contract-amendment-form",onSubmit:e.handleSubmit(v),className:"space-y-4 RemoteFlows__ContractAmendmentForm",children:r(F,{fields:s})})})}a(x,"ContractAmendmentForm");export{x as a};
|
|
2
|
+
//# sourceMappingURL=chunk-4Y3PH3Z7.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{l as U}from"./chunk-3JVRFY6F.js";import{a as w}from"./chunk-ND4FAALX.js";import{b as J}from"./chunk-KQPDXXG3.js";import{c as G,l as K}from"./chunk-66N57DKF.js";import{a as t,b as d,c as Pe}from"./chunk-P37U34EQ.js";var F=d((Rt,V)=>{"use strict";function _e(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}t(_e,"isObject");V.exports=_e});var z=d((It,X)=>{"use strict";var ke=typeof global=="object"&&global&&global.Object===Object&&global;X.exports=ke});var L=d(($t,Q)=>{"use strict";var we=z(),Fe=typeof self=="object"&&self&&self.Object===Object&&self,Le=we||Fe||Function("return this")();Q.exports=Le});var Z=d((Mt,Y)=>{"use strict";var De=L(),Ae=t(function(){return De.Date.now()},"now");Y.exports=Ae});var te=d((_t,ee)=>{"use strict";var We=/\s/;function Be(e){for(var n=e.length;n--&&We.test(e.charAt(n)););return n}t(Be,"trimmedEndIndex");ee.exports=Be});var re=d((wt,ne)=>{"use strict";var Ne=te(),He=/^\s+/;function Ge(e){return e&&e.slice(0,Ne(e)+1).replace(He,"")}t(Ge,"baseTrim");ne.exports=Ge});var D=d((Lt,oe)=>{"use strict";var Je=L(),Ke=Je.Symbol;oe.exports=Ke});var ce=d((Dt,ae)=>{"use strict";var ie=D(),se=Object.prototype,Ue=se.hasOwnProperty,Ve=se.toString,O=ie?ie.toStringTag:void 0;function Xe(e){var n=Ue.call(e,O),r=e[O];try{e[O]=void 0;var i=!0}catch{}var a=Ve.call(e);return i&&(n?e[O]=r:delete e[O]),a}t(Xe,"getRawTag");ae.exports=Xe});var fe=d((Wt,ue)=>{"use strict";var ze=Object.prototype,Qe=ze.toString;function Ye(e){return Qe.call(e)}t(Ye,"objectToString");ue.exports=Ye});var ge=d((Nt,me)=>{"use strict";var de=D(),Ze=ce(),et=fe(),tt="[object Null]",nt="[object Undefined]",le=de?de.toStringTag:void 0;function rt(e){return e==null?e===void 0?nt:tt:le&&le in Object(e)?Ze(e):et(e)}t(rt,"baseGetTag");me.exports=rt});var be=d((Gt,pe)=>{"use strict";function ot(e){return e!=null&&typeof e=="object"}t(ot,"isObjectLike");pe.exports=ot});var ye=d((Kt,ve)=>{"use strict";var it=ge(),st=be(),at="[object Symbol]";function ct(e){return typeof e=="symbol"||st(e)&&it(e)==at}t(ct,"isSymbol");ve.exports=ct});var Ce=d((Vt,Te)=>{"use strict";var ut=re(),he=F(),ft=ye(),xe=NaN,dt=/^[-+]0x[0-9a-f]+$/i,lt=/^0b[01]+$/i,mt=/^0o[0-7]+$/i,gt=parseInt;function pt(e){if(typeof e=="number")return e;if(ft(e))return xe;if(he(e)){var n=typeof e.valueOf=="function"?e.valueOf():e;e=he(n)?n+"":n}if(typeof e!="string")return e===0?e:+e;e=ut(e);var r=lt.test(e);return r||mt.test(e)?gt(e.slice(2),r?2:8):dt.test(e)?xe:+e}t(pt,"toNumber");Te.exports=pt});var Oe=d((zt,je)=>{"use strict";var bt=F(),A=Z(),Se=Ce(),vt="Expected a function",yt=Math.max,ht=Math.min;function xt(e,n,r){var i,a,p,l,c,s,m=0,E=!1,u=!1,h=!0;if(typeof e!="function")throw new TypeError(vt);n=Se(n)||0,bt(r)&&(E=!!r.leading,u="maxWait"in r,p=u?yt(Se(r.maxWait)||0,n):p,h="trailing"in r?!!r.trailing:h);function x(o){var g=i,y=a;return i=a=void 0,m=o,l=e.apply(y,g),l}t(x,"invokeFunc");function R(o){return m=o,c=setTimeout(v,n),E?x(o):l}t(R,"leadingEdge");function C(o){var g=o-s,y=o-m,M=n-g;return u?ht(M,p-y):M}t(C,"remainingWait");function q(o){var g=o-s,y=o-m;return s===void 0||g>=n||g<0||u&&y>=p}t(q,"shouldInvoke");function v(){var o=A();if(q(o))return b(o);c=setTimeout(v,C(o))}t(v,"timerExpired");function b(o){return c=void 0,h&&i?x(o):(i=a=void 0,l)}t(b,"trailingEdge");function I(){c!==void 0&&clearTimeout(c),m=0,i=s=a=c=void 0}t(I,"cancel");function $(){return c===void 0?l:b(A())}t($,"flush");function S(){var o=A(),g=q(o);if(i=arguments,a=this,s=o,g){if(c===void 0)return R(s);if(u)return clearTimeout(c),c=setTimeout(v,n),x(s)}return c===void 0&&(c=setTimeout(v,n)),l}return t(S,"debounced"),S.cancel=I,S.flush=$,S}t(xt,"debounce");je.exports=xt});import{useState as St,useCallback as jt,useEffect as qe,useRef as Ie}from"react";var Re=Pe(Oe(),1);import{useCallback as Tt,useEffect as Ct,useRef as Ee}from"react";function W(e,n){let r=Ee(e);Ct(()=>{r.current=e},[e]);let i=Ee((0,Re.default)(a=>{r.current(a)},n)).current;return Tt(a=>{i(a)},[i])}t(W,"useDebounce");import{Fragment as Et,jsx as T,jsxs as $e}from"react/jsx-runtime";var Ot=t(({description:e,showConversion:n,targetCurrency:r,className:i,onClick:a})=>{let{components:p}=J(),l=n?`Hide ${r} conversion`:`Show ${r} conversion`,c=p?.button||"button";return $e("span",{className:i,children:[T(K,{as:"span",children:e})," ",T(c,{className:`${i.replace("-description","-button")}`,"data-type":"inline",onClick:a,children:l})]})},"DescriptionWithConversion"),fn=t(({sourceCurrency:e,targetCurrency:n,mainFieldName:r,conversionFieldName:i,conversionProperties:a,classNamePrefix:p,description:l,conversionType:c="spread",...s})=>{let[m,E]=St(!1),{setValue:u,watch:h}=G(),x=h(r||s.name),R=Ie(!0),C=Ie(new Map),q=e&&n&&e!==n,{mutateAsync:v}=U({type:c}),b=`${s.name}_converted`;qe(()=>{u(b,r||s.name)},[u,r,s.name,b]),qe(()=>{if(R.current){R.current=!1;return}u(i,"")},[e,i,u]);let I=jt(async(f,j,k,B)=>{if(!f)return;let N=`${j}_${k}_${f}`,H=C.current.get(N);if(H){u(B,H.targetAmount);return}try{let P=await v({source_currency:j,target_currency:k,amount:Number(f)});if(P.data?.data?.conversion_data?.target_amount){let _=P.data.data.conversion_data.target_amount;if(_){u(B,_?.toString()),C.current.set(N,{targetAmount:_.toString()});let Me=`${k}_${j}_${_}`;C.current.set(Me,{targetAmount:f.toString()})}}}catch(P){console.error("Error converting currency:",P)}},[v,u]),$=W(f=>I(f,e,n,i),500),S=W(f=>I(f,n,e,r||s.name),500),o=t(f=>{u(b,r||s.name),m&&$(f.target.value)},"handleMainFieldChange"),g=t(f=>{u(b,i),S(f.target.value)},"handleConversionFieldChange"),y=t(f=>{f.preventDefault(),E(j=>!j),!m&&x&&$(x)},"toggleConversion"),M=q?T(Ot,{targetCurrency:n,description:l,showConversion:m,className:`${p}-description`,onClick:y}):l;return $e(Et,{children:[T(w,{...s,name:r||s.name,additionalProps:{currency:e},description:M,type:"text",inputMode:"decimal",pattern:"^[0-9.]*$",maxLength:15,onChange:o}),m&&T(w,{additionalProps:{currency:n},name:i,label:a?.label||"Conversion",description:a?.description,type:"text",inputMode:"decimal",pattern:"^[0-9.]*$",maxLength:15,onChange:g}),T("input",{type:"hidden",name:b,value:h(b)||r||s.name})]})},"CurrencyConversionField");export{fn as a};
|
|
2
|
+
//# sourceMappingURL=chunk-7NCYKLRU.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../node_modules/lodash/isObject.js","../node_modules/lodash/_freeGlobal.js","../node_modules/lodash/_root.js","../node_modules/lodash/now.js","../node_modules/lodash/_trimmedEndIndex.js","../node_modules/lodash/_baseTrim.js","../node_modules/lodash/_Symbol.js","../node_modules/lodash/_getRawTag.js","../node_modules/lodash/_objectToString.js","../node_modules/lodash/_baseGetTag.js","../node_modules/lodash/isObjectLike.js","../node_modules/lodash/isSymbol.js","../node_modules/lodash/toNumber.js","../node_modules/lodash/debounce.js","../src/components/form/fields/CurrencyConversionField.tsx","../src/common/hooks.ts"],"sourcesContent":["/**\n * Checks if `value` is the\n * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)\n * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is an object, else `false`.\n * @example\n *\n * _.isObject({});\n * // => true\n *\n * _.isObject([1, 2, 3]);\n * // => true\n *\n * _.isObject(_.noop);\n * // => true\n *\n * _.isObject(null);\n * // => false\n */\nfunction isObject(value) {\n var type = typeof value;\n return value != null && (type == 'object' || type == 'function');\n}\n\nmodule.exports = isObject;\n","/** Detect free variable `global` from Node.js. */\nvar freeGlobal = typeof global == 'object' && global && global.Object === Object && global;\n\nmodule.exports = freeGlobal;\n","var freeGlobal = require('./_freeGlobal');\n\n/** Detect free variable `self`. */\nvar freeSelf = typeof self == 'object' && self && self.Object === Object && self;\n\n/** Used as a reference to the global object. */\nvar root = freeGlobal || freeSelf || Function('return this')();\n\nmodule.exports = root;\n","var root = require('./_root');\n\n/**\n * Gets the timestamp of the number of milliseconds that have elapsed since\n * the Unix epoch (1 January 1970 00:00:00 UTC).\n *\n * @static\n * @memberOf _\n * @since 2.4.0\n * @category Date\n * @returns {number} Returns the timestamp.\n * @example\n *\n * _.defer(function(stamp) {\n * console.log(_.now() - stamp);\n * }, _.now());\n * // => Logs the number of milliseconds it took for the deferred invocation.\n */\nvar now = function() {\n return root.Date.now();\n};\n\nmodule.exports = now;\n","/** Used to match a single whitespace character. */\nvar reWhitespace = /\\s/;\n\n/**\n * Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace\n * character of `string`.\n *\n * @private\n * @param {string} string The string to inspect.\n * @returns {number} Returns the index of the last non-whitespace character.\n */\nfunction trimmedEndIndex(string) {\n var index = string.length;\n\n while (index-- && reWhitespace.test(string.charAt(index))) {}\n return index;\n}\n\nmodule.exports = trimmedEndIndex;\n","var trimmedEndIndex = require('./_trimmedEndIndex');\n\n/** Used to match leading whitespace. */\nvar reTrimStart = /^\\s+/;\n\n/**\n * The base implementation of `_.trim`.\n *\n * @private\n * @param {string} string The string to trim.\n * @returns {string} Returns the trimmed string.\n */\nfunction baseTrim(string) {\n return string\n ? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')\n : string;\n}\n\nmodule.exports = baseTrim;\n","var root = require('./_root');\n\n/** Built-in value references. */\nvar Symbol = root.Symbol;\n\nmodule.exports = Symbol;\n","var Symbol = require('./_Symbol');\n\n/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/** Used to check objects for own properties. */\nvar hasOwnProperty = objectProto.hasOwnProperty;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the raw `toStringTag`.\n */\nfunction getRawTag(value) {\n var isOwn = hasOwnProperty.call(value, symToStringTag),\n tag = value[symToStringTag];\n\n try {\n value[symToStringTag] = undefined;\n var unmasked = true;\n } catch (e) {}\n\n var result = nativeObjectToString.call(value);\n if (unmasked) {\n if (isOwn) {\n value[symToStringTag] = tag;\n } else {\n delete value[symToStringTag];\n }\n }\n return result;\n}\n\nmodule.exports = getRawTag;\n","/** Used for built-in method references. */\nvar objectProto = Object.prototype;\n\n/**\n * Used to resolve the\n * [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)\n * of values.\n */\nvar nativeObjectToString = objectProto.toString;\n\n/**\n * Converts `value` to a string using `Object.prototype.toString`.\n *\n * @private\n * @param {*} value The value to convert.\n * @returns {string} Returns the converted string.\n */\nfunction objectToString(value) {\n return nativeObjectToString.call(value);\n}\n\nmodule.exports = objectToString;\n","var Symbol = require('./_Symbol'),\n getRawTag = require('./_getRawTag'),\n objectToString = require('./_objectToString');\n\n/** `Object#toString` result references. */\nvar nullTag = '[object Null]',\n undefinedTag = '[object Undefined]';\n\n/** Built-in value references. */\nvar symToStringTag = Symbol ? Symbol.toStringTag : undefined;\n\n/**\n * The base implementation of `getTag` without fallbacks for buggy environments.\n *\n * @private\n * @param {*} value The value to query.\n * @returns {string} Returns the `toStringTag`.\n */\nfunction baseGetTag(value) {\n if (value == null) {\n return value === undefined ? undefinedTag : nullTag;\n }\n return (symToStringTag && symToStringTag in Object(value))\n ? getRawTag(value)\n : objectToString(value);\n}\n\nmodule.exports = baseGetTag;\n","/**\n * Checks if `value` is object-like. A value is object-like if it's not `null`\n * and has a `typeof` result of \"object\".\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is object-like, else `false`.\n * @example\n *\n * _.isObjectLike({});\n * // => true\n *\n * _.isObjectLike([1, 2, 3]);\n * // => true\n *\n * _.isObjectLike(_.noop);\n * // => false\n *\n * _.isObjectLike(null);\n * // => false\n */\nfunction isObjectLike(value) {\n return value != null && typeof value == 'object';\n}\n\nmodule.exports = isObjectLike;\n","var baseGetTag = require('./_baseGetTag'),\n isObjectLike = require('./isObjectLike');\n\n/** `Object#toString` result references. */\nvar symbolTag = '[object Symbol]';\n\n/**\n * Checks if `value` is classified as a `Symbol` primitive or object.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to check.\n * @returns {boolean} Returns `true` if `value` is a symbol, else `false`.\n * @example\n *\n * _.isSymbol(Symbol.iterator);\n * // => true\n *\n * _.isSymbol('abc');\n * // => false\n */\nfunction isSymbol(value) {\n return typeof value == 'symbol' ||\n (isObjectLike(value) && baseGetTag(value) == symbolTag);\n}\n\nmodule.exports = isSymbol;\n","var baseTrim = require('./_baseTrim'),\n isObject = require('./isObject'),\n isSymbol = require('./isSymbol');\n\n/** Used as references for various `Number` constants. */\nvar NAN = 0 / 0;\n\n/** Used to detect bad signed hexadecimal string values. */\nvar reIsBadHex = /^[-+]0x[0-9a-f]+$/i;\n\n/** Used to detect binary string values. */\nvar reIsBinary = /^0b[01]+$/i;\n\n/** Used to detect octal string values. */\nvar reIsOctal = /^0o[0-7]+$/i;\n\n/** Built-in method references without a dependency on `root`. */\nvar freeParseInt = parseInt;\n\n/**\n * Converts `value` to a number.\n *\n * @static\n * @memberOf _\n * @since 4.0.0\n * @category Lang\n * @param {*} value The value to process.\n * @returns {number} Returns the number.\n * @example\n *\n * _.toNumber(3.2);\n * // => 3.2\n *\n * _.toNumber(Number.MIN_VALUE);\n * // => 5e-324\n *\n * _.toNumber(Infinity);\n * // => Infinity\n *\n * _.toNumber('3.2');\n * // => 3.2\n */\nfunction toNumber(value) {\n if (typeof value == 'number') {\n return value;\n }\n if (isSymbol(value)) {\n return NAN;\n }\n if (isObject(value)) {\n var other = typeof value.valueOf == 'function' ? value.valueOf() : value;\n value = isObject(other) ? (other + '') : other;\n }\n if (typeof value != 'string') {\n return value === 0 ? value : +value;\n }\n value = baseTrim(value);\n var isBinary = reIsBinary.test(value);\n return (isBinary || reIsOctal.test(value))\n ? freeParseInt(value.slice(2), isBinary ? 2 : 8)\n : (reIsBadHex.test(value) ? NAN : +value);\n}\n\nmodule.exports = toNumber;\n","var isObject = require('./isObject'),\n now = require('./now'),\n toNumber = require('./toNumber');\n\n/** Error message constants. */\nvar FUNC_ERROR_TEXT = 'Expected a function';\n\n/* Built-in method references for those with the same name as other `lodash` methods. */\nvar nativeMax = Math.max,\n nativeMin = Math.min;\n\n/**\n * Creates a debounced function that delays invoking `func` until after `wait`\n * milliseconds have elapsed since the last time the debounced function was\n * invoked. The debounced function comes with a `cancel` method to cancel\n * delayed `func` invocations and a `flush` method to immediately invoke them.\n * Provide `options` to indicate whether `func` should be invoked on the\n * leading and/or trailing edge of the `wait` timeout. The `func` is invoked\n * with the last arguments provided to the debounced function. Subsequent\n * calls to the debounced function return the result of the last `func`\n * invocation.\n *\n * **Note:** If `leading` and `trailing` options are `true`, `func` is\n * invoked on the trailing edge of the timeout only if the debounced function\n * is invoked more than once during the `wait` timeout.\n *\n * If `wait` is `0` and `leading` is `false`, `func` invocation is deferred\n * until to the next tick, similar to `setTimeout` with a timeout of `0`.\n *\n * See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)\n * for details over the differences between `_.debounce` and `_.throttle`.\n *\n * @static\n * @memberOf _\n * @since 0.1.0\n * @category Function\n * @param {Function} func The function to debounce.\n * @param {number} [wait=0] The number of milliseconds to delay.\n * @param {Object} [options={}] The options object.\n * @param {boolean} [options.leading=false]\n * Specify invoking on the leading edge of the timeout.\n * @param {number} [options.maxWait]\n * The maximum time `func` is allowed to be delayed before it's invoked.\n * @param {boolean} [options.trailing=true]\n * Specify invoking on the trailing edge of the timeout.\n * @returns {Function} Returns the new debounced function.\n * @example\n *\n * // Avoid costly calculations while the window size is in flux.\n * jQuery(window).on('resize', _.debounce(calculateLayout, 150));\n *\n * // Invoke `sendMail` when clicked, debouncing subsequent calls.\n * jQuery(element).on('click', _.debounce(sendMail, 300, {\n * 'leading': true,\n * 'trailing': false\n * }));\n *\n * // Ensure `batchLog` is invoked once after 1 second of debounced calls.\n * var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });\n * var source = new EventSource('/stream');\n * jQuery(source).on('message', debounced);\n *\n * // Cancel the trailing debounced invocation.\n * jQuery(window).on('popstate', debounced.cancel);\n */\nfunction debounce(func, wait, options) {\n var lastArgs,\n lastThis,\n maxWait,\n result,\n timerId,\n lastCallTime,\n lastInvokeTime = 0,\n leading = false,\n maxing = false,\n trailing = true;\n\n if (typeof func != 'function') {\n throw new TypeError(FUNC_ERROR_TEXT);\n }\n wait = toNumber(wait) || 0;\n if (isObject(options)) {\n leading = !!options.leading;\n maxing = 'maxWait' in options;\n maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;\n trailing = 'trailing' in options ? !!options.trailing : trailing;\n }\n\n function invokeFunc(time) {\n var args = lastArgs,\n thisArg = lastThis;\n\n lastArgs = lastThis = undefined;\n lastInvokeTime = time;\n result = func.apply(thisArg, args);\n return result;\n }\n\n function leadingEdge(time) {\n // Reset any `maxWait` timer.\n lastInvokeTime = time;\n // Start the timer for the trailing edge.\n timerId = setTimeout(timerExpired, wait);\n // Invoke the leading edge.\n return leading ? invokeFunc(time) : result;\n }\n\n function remainingWait(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime,\n timeWaiting = wait - timeSinceLastCall;\n\n return maxing\n ? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)\n : timeWaiting;\n }\n\n function shouldInvoke(time) {\n var timeSinceLastCall = time - lastCallTime,\n timeSinceLastInvoke = time - lastInvokeTime;\n\n // Either this is the first call, activity has stopped and we're at the\n // trailing edge, the system time has gone backwards and we're treating\n // it as the trailing edge, or we've hit the `maxWait` limit.\n return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||\n (timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));\n }\n\n function timerExpired() {\n var time = now();\n if (shouldInvoke(time)) {\n return trailingEdge(time);\n }\n // Restart the timer.\n timerId = setTimeout(timerExpired, remainingWait(time));\n }\n\n function trailingEdge(time) {\n timerId = undefined;\n\n // Only invoke if we have `lastArgs` which means `func` has been\n // debounced at least once.\n if (trailing && lastArgs) {\n return invokeFunc(time);\n }\n lastArgs = lastThis = undefined;\n return result;\n }\n\n function cancel() {\n if (timerId !== undefined) {\n clearTimeout(timerId);\n }\n lastInvokeTime = 0;\n lastArgs = lastCallTime = lastThis = timerId = undefined;\n }\n\n function flush() {\n return timerId === undefined ? result : trailingEdge(now());\n }\n\n function debounced() {\n var time = now(),\n isInvoking = shouldInvoke(time);\n\n lastArgs = arguments;\n lastThis = this;\n lastCallTime = time;\n\n if (isInvoking) {\n if (timerId === undefined) {\n return leadingEdge(lastCallTime);\n }\n if (maxing) {\n // Handle invocations in a tight loop.\n clearTimeout(timerId);\n timerId = setTimeout(timerExpired, wait);\n return invokeFunc(lastCallTime);\n }\n }\n if (timerId === undefined) {\n timerId = setTimeout(timerExpired, wait);\n }\n return result;\n }\n debounced.cancel = cancel;\n debounced.flush = flush;\n return debounced;\n}\n\nmodule.exports = debounce;\n","import { ReactNode, useState, useCallback, useEffect, useRef } from 'react';\nimport { useFormContext } from 'react-hook-form';\nimport { TextField } from '@/src/components/form/fields/TextField';\nimport { useConvertCurrency } from '@/src/flows/Onboarding/api';\nimport { JSFField } from '@/src/types/remoteFlows';\nimport { useFormFields } from '@/src/context';\nimport { useDebounce } from '@/src/common/hooks';\nimport { FormDescription } from '@/src/components/ui/form';\n\ntype DescriptionWithConversionProps = {\n description: ReactNode;\n showConversion: boolean;\n targetCurrency: string;\n className: string;\n onClick: (evt: React.MouseEvent<HTMLButtonElement>) => void;\n};\n\nconst DescriptionWithConversion = ({\n description,\n showConversion,\n targetCurrency,\n className,\n onClick,\n}: DescriptionWithConversionProps) => {\n const { components } = useFormFields();\n const label = showConversion\n ? `Hide ${targetCurrency} conversion`\n : `Show ${targetCurrency} conversion`;\n\n const CustomButton = components?.button || 'button';\n return (\n <span className={className}>\n <FormDescription as='span'>{description}</FormDescription>{' '}\n <CustomButton\n className={`${className.replace('-description', '-button')}`}\n data-type='inline'\n onClick={onClick}\n >\n {label}\n </CustomButton>\n </span>\n );\n};\n\nexport type CurrencyConversionFieldProps = JSFField & {\n sourceCurrency: string;\n targetCurrency: string;\n mainFieldName?: string;\n conversionFieldName: string;\n conversionProperties?: {\n label?: string;\n description?: ReactNode;\n };\n useProxy?: boolean;\n classNamePrefix: string;\n conversionType?: 'spread' | 'no_spread';\n};\n\nexport const CurrencyConversionField = ({\n sourceCurrency,\n targetCurrency,\n mainFieldName,\n conversionFieldName,\n conversionProperties,\n classNamePrefix,\n description,\n conversionType = 'spread',\n ...props\n}: CurrencyConversionFieldProps) => {\n const [showConversion, setShowConversion] = useState(false);\n const { setValue, watch } = useFormContext();\n const fieldValue = watch(mainFieldName || props.name);\n const isFirstRender = useRef(true);\n\n const conversionCache = useRef<Map<string, { targetAmount: string }>>(\n new Map(),\n );\n\n const canShowConversion =\n sourceCurrency && targetCurrency && sourceCurrency !== targetCurrency;\n\n const { mutateAsync: convertCurrency } = useConvertCurrency({\n type: conversionType,\n });\n\n // we keep track of the last input the user used, so we can make sure\n // we keep consistent currency rates\n const lastInputFieldName = `${props.name}_converted`;\n useEffect(() => {\n setValue(lastInputFieldName, mainFieldName || props.name);\n }, [setValue, mainFieldName, props.name, lastInputFieldName]);\n\n useEffect(() => {\n if (isFirstRender.current) {\n isFirstRender.current = false;\n return;\n }\n\n // when source currency changes, reset the conversion field\n setValue(conversionFieldName, '');\n }, [sourceCurrency, conversionFieldName, setValue]);\n\n const convertCurrencyCallback = useCallback(\n async (\n value: string,\n fromCurrency: string,\n toCurrency: string,\n targetField: string,\n ) => {\n if (!value) return;\n\n const cacheKey = `${fromCurrency}_${toCurrency}_${value}`;\n const cached = conversionCache.current.get(cacheKey);\n\n if (cached) {\n setValue(targetField, cached.targetAmount);\n return;\n }\n\n try {\n const response = await convertCurrency({\n source_currency: fromCurrency,\n target_currency: toCurrency,\n amount: Number(value),\n });\n if (response.data?.data?.conversion_data?.target_amount) {\n const amount = response.data.data.conversion_data.target_amount;\n if (amount) {\n setValue(targetField, amount?.toString());\n // Cache both directions\n conversionCache.current.set(cacheKey, {\n targetAmount: amount.toString(),\n });\n const reverseKey = `${toCurrency}_${fromCurrency}_${amount}`;\n conversionCache.current.set(reverseKey, {\n targetAmount: value.toString(),\n });\n }\n }\n } catch (error) {\n console.error('Error converting currency:', error);\n }\n },\n [convertCurrency, setValue],\n );\n\n const debouncedConvertCurrency = useDebounce(\n (value: string) =>\n convertCurrencyCallback(\n value,\n sourceCurrency,\n targetCurrency,\n conversionFieldName,\n ),\n 500,\n );\n const debouncedConvertCurrencyReverse = useDebounce(\n (value: string) =>\n convertCurrencyCallback(\n value,\n targetCurrency,\n sourceCurrency,\n mainFieldName || props.name,\n ),\n 500,\n );\n\n const handleMainFieldChange = (evt: React.ChangeEvent<HTMLInputElement>) => {\n setValue(lastInputFieldName, mainFieldName || props.name);\n if (showConversion) {\n debouncedConvertCurrency(evt.target.value);\n }\n };\n\n const handleConversionFieldChange = (\n evt: React.ChangeEvent<HTMLInputElement>,\n ) => {\n setValue(lastInputFieldName, conversionFieldName);\n debouncedConvertCurrencyReverse(evt.target.value);\n };\n\n const toggleConversion = (evt: React.MouseEvent<HTMLButtonElement>) => {\n evt.preventDefault();\n setShowConversion((prev) => !prev);\n\n if (!showConversion && fieldValue) {\n debouncedConvertCurrency(fieldValue);\n }\n };\n\n const extraDescription = canShowConversion ? (\n <DescriptionWithConversion\n targetCurrency={targetCurrency}\n description={description}\n showConversion={showConversion}\n className={`${classNamePrefix}-description`}\n onClick={toggleConversion}\n />\n ) : (\n description\n );\n\n return (\n <>\n <TextField\n {...props}\n name={mainFieldName || props.name}\n additionalProps={{ currency: sourceCurrency }}\n description={extraDescription}\n type='text'\n inputMode='decimal'\n pattern='^[0-9.]*$'\n maxLength={15}\n onChange={handleMainFieldChange}\n />\n {showConversion && (\n <TextField\n additionalProps={{ currency: targetCurrency }}\n name={conversionFieldName}\n label={conversionProperties?.label || 'Conversion'}\n description={conversionProperties?.description}\n type='text'\n inputMode='decimal'\n pattern='^[0-9.]*$'\n maxLength={15}\n onChange={handleConversionFieldChange}\n />\n )}\n <input\n type='hidden'\n name={lastInputFieldName}\n value={watch(lastInputFieldName) || mainFieldName || props.name}\n />\n </>\n );\n};\n","import { useCallback, useEffect, useRef } from 'react';\nimport debounce from 'lodash/debounce';\n\nexport function useDebounce(\n callback: (value: string) => Promise<void>,\n delay: number,\n) {\n const callbackRef = useRef(callback);\n\n useEffect(() => {\n callbackRef.current = callback;\n }, [callback]);\n\n const debouncedFn = useRef(\n debounce((value: string) => {\n callbackRef.current(value);\n }, delay),\n ).current;\n\n return useCallback(\n (value: string) => {\n debouncedFn(value);\n },\n [debouncedFn],\n );\n}\n"],"mappings":"8NAAA,IAAAA,EAAAC,EAAA,CAAAC,GAAAC,IAAA,cAyBA,SAASC,GAASC,EAAO,CACvB,IAAIC,EAAO,OAAOD,EAClB,OAAOA,GAAS,OAASC,GAAQ,UAAYA,GAAQ,WACvD,CAHSC,EAAAH,GAAA,YAKTD,EAAO,QAAUC,KC9BjB,IAAAI,EAAAC,EAAA,CAAAC,GAAAC,IAAA,cACA,IAAIC,GAAa,OAAO,QAAU,UAAY,QAAU,OAAO,SAAW,QAAU,OAEpFD,EAAO,QAAUC,KCHjB,IAAAC,EAAAC,EAAA,CAAAC,GAAAC,IAAA,kBAAIC,GAAa,IAGbC,GAAW,OAAO,MAAQ,UAAY,MAAQ,KAAK,SAAW,QAAU,KAGxEC,GAAOF,IAAcC,IAAY,SAAS,aAAa,EAAE,EAE7DF,EAAO,QAAUG,KCRjB,IAAAC,EAAAC,EAAA,CAAAC,GAAAC,IAAA,kBAAIC,GAAO,IAkBPC,GAAMC,EAAA,UAAW,CACnB,OAAOF,GAAK,KAAK,IAAI,CACvB,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D,CAAe,EAC5C,KAAMW,EACN,MAAOC,GAAsB,OAAS,aACtC,YAAaA,GAAsB,YACnC,KAAK,OACL,UAAU,UACV,QAAQ,YACR,UAAW,GACX,SAAUmC,EACZ,EAEFrD,EAAC,SACC,KAAK,SACL,KAAMkC,EACN,MAAOT,EAAMS,CAAkB,GAAKlB,GAAiBK,EAAM,KAC7D,GACF,CAEJ,EAjLuC","names":["require_isObject","__commonJSMin","exports","module","isObject","value","type","__name","require_freeGlobal","__commonJSMin","exports","module","freeGlobal","require_root","__commonJSMin","exports","module","freeGlobal","freeSelf","root","require_now","__commonJSMin","exports","module","root","now","__name","require_trimmedEndIndex","__commonJSMin","exports","module","reWhitespace","trimmedEndIndex","string","index","__name","require_baseTrim","__commonJSMin","exports","module","trimmedEndIndex","reTrimStart","baseTrim","string","__name","require_Symbol","__commonJSMin","exports","module","root","Symbol","require_getRawTag","__commonJSMin","exports","module","Symbol","objectProto","hasOwnProperty","nativeObjectToString","symToStringTag","getRawTag","value","isOwn","tag","unmasked","result","__name","require_objectToString","__commonJSMin","exports","module","objectProto","nativeObjectToString","objectToString","value","__name","require_baseGetTag","__commonJSMin","exports","module","Symbol","getRawTag","objectToString","nullTag","undefinedTag","symToStringTag","baseGetTag","value","__name","require_isObjectLike","__commonJSMin","exports","module","isObjectLike","value","__name","require_isSymbol","__commonJSMin","exports","module","baseGetTag","isObjectLike","symbolTag","isSymbol","value","__name","require_toNumber","__commonJSMin","exports","module","baseTrim","isObject","isSymbol","NAN","reIsBadHex","reIsBinary","reIsOctal","freeParseInt","toNumber","value","other","isBinary","__name","require_debounce","__commonJSMin","exports","module","isObject","now","toNumber","FUNC_ERROR_TEXT","nativeMax","nativeMin","debounce","func","wait","options","lastArgs","lastThis","maxWait","result","timerId","lastCallTime","lastInvokeTime","leading","maxing","trailing","invokeFunc","time","args","thisArg","__name","leadingEdge","timerExpired","remainingWait","timeSinceLastCall","timeSinceLastInvoke","timeWaiting","shouldInvoke","trailingEdge","cancel","flush","debounced","isInvoking","useState","useCallback","useEffect","useRef","import_debounce","useCallback","useEffect","useRef","useDebounce","callback","delay","callbackRef","useRef","useEffect","debouncedFn","debounce","value","useCallback","__name","Fragment","jsx","jsxs","DescriptionWithConversion","__name","description","showConversion","targetCurrency","className","onClick","components","useFormFields","label","CustomButton","FormDescription","CurrencyConversionField","sourceCurrency","mainFieldName","conversionFieldName","conversionProperties","classNamePrefix","conversionType","props","setShowConversion","useState","setValue","watch","useFormContext","fieldValue","isFirstRender","useRef","conversionCache","canShowConversion","convertCurrency","useConvertCurrency","lastInputFieldName","useEffect","convertCurrencyCallback","useCallback","value","fromCurrency","toCurrency","targetField","cacheKey","cached","response","amount","reverseKey","error","debouncedConvertCurrency","useDebounce","debouncedConvertCurrencyReverse","handleMainFieldChange","evt","handleConversionFieldChange","toggleConversion","prev","extraDescription","TextField"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as d}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as d}from"./chunk-PHWZOEDE.js";import{b as s}from"./chunk-TOA3JILU.js";import{b as i}from"./chunk-2YTBWEC7.js";import{a}from"./chunk-P37U34EQ.js";import{jsx as E}from"react/jsx-runtime";function F({onSubmit:l,onSuccess:c,onError:e}){let{contractorOnboardingBag:r}=s(),m=a(async n=>{try{let t=await r.parseFormValues(n);await l?.(t);let o=await r.onSubmit(n);if(o?.data){await c?.(o?.data),r?.next();return}if(o?.error){let u=i(o?.fieldErrors||[],r.meta?.fields?.contract_details);e?.({error:o?.error,rawError:o?.rawError,fieldErrors:u})}}catch(t){e?.({error:t,rawError:t,fieldErrors:[]})}},"handleSubmit"),p=r.stepState.values?.contract_details||r.initialValues.contract_details;return E(d,{defaultValues:p,onSubmit:m})}a(F,"ContractDetailsStep");export{F as a};
|
|
2
|
+
//# sourceMappingURL=chunk-AW7XS7Z5.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as g}from"./chunk-PGWKJ6FK.js";import{d as f,e as w}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as g}from"./chunk-PGWKJ6FK.js";import{d as f,e as w}from"./chunk-3JVRFY6F.js";import{a as m}from"./chunk-2YTBWEC7.js";import{b as y}from"./chunk-KQPDXXG3.js";import{b as E}from"./chunk-LJGCFFAT.js";import{a}from"./chunk-P37U34EQ.js";import{jsx as R}from"react/jsx-runtime";function A({onSubmit:S,onSuccess:d,onError:o,render:u,...r}){let{components:I}=y(),{onboardingBag:t,setCreditScore:c}=g(),n=f(),i=w(),{mutateAsync:b}=m(n),{mutateAsync:_}=m(i),l=a(async()=>{try{if(await S?.(),t.creditRiskStatus==="deposit_required"&&t.employmentId&&t.employment?.status&&!t.isEmploymentReadOnly){let e=await _({employment_slug:t.employmentId});if(e.data){await d?.({data:e.data,employmentStatus:"created_awaiting_reserve"}),c?.(s=>({...s,showReserveInvoice:!0})),t.refetchEmployment();return}e.error&&o?.({error:e.error,rawError:e.rawError,fieldErrors:[]})}else if(t.employmentId){let e=await b({employment_id:t.employmentId});if(e.data){await d?.({data:e.data,employmentStatus:"invited"}),c?.(s=>({...s,showInviteSuccessful:!0})),t.refetchEmployment();return}e.error&&o?.({error:e.error,rawError:e.rawError,fieldErrors:[]})}}catch(e){o?.({error:e,rawError:e,fieldErrors:[]})}},"handleSubmit"),p=t.creditRiskStatus==="deposit_required"&&t.employment?.status&&!t.isEmploymentReadOnly,v=I?.button;return v?R(v,{...r,disabled:n.isPending||i.isPending||r.disabled,onClick:e=>{l(),r.onClick?.(e)},children:u({employmentStatus:p?"created_awaiting_reserve":"invited"})}):R(E,{...r,disabled:n.isPending||i.isPending||r.disabled,onClick:()=>{l()},children:u({employmentStatus:p?"created_awaiting_reserve":"invited"})})}a(A,"OnboardingInvite");export{A as a};
|
|
2
|
+
//# sourceMappingURL=chunk-BGNCB335.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a}from"./chunk-I4S5X7NU.js";import{b as i}from"./chunk-PGWKJ6FK.js";import{a as e}from"./chunk-P37U34EQ.js";import{jsx as d}from"react/jsx-runtime";function y({onSubmit:s,onSuccess:c,onError:t}){let{onboardingBag:o}=i(),u=e(async n=>{try{await s?.({countryCode:n.country});let r=await o.onSubmit(n);if(r?.data){await c?.(r?.data),o?.next();return}r?.error&&t?.({error:r.error,rawError:r.rawError,fieldErrors:[]})}catch(r){t?.({error:r,rawError:r,fieldErrors:[]})}},"handleSubmit"),l=o.stepState.values?.select_country||o.initialValues.select_country;return d(a,{defaultValues:l,onSubmit:u})}e(y,"SelectCountryStep");export{y as a};
|
|
2
|
+
//# sourceMappingURL=chunk-EOV62SUU.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as u}from"./chunk-MRYRNB7Y.js";import{a as f}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as u}from"./chunk-MRYRNB7Y.js";import{a as f}from"./chunk-VC66HET6.js";import{b as a}from"./chunk-LNV36S6D.js";import{f as s,g as l}from"./chunk-66N57DKF.js";import{a as t}from"./chunk-P37U34EQ.js";import{useEffect as y}from"react";import{jsx as r}from"react/jsx-runtime";function B({defaultValues:F,fields:m,onSubmit:d}){let{formId:c,terminationBag:o}=u(),p=a(o.handleValidation),e=s({resolver:p,defaultValues:F,shouldUnregister:!1,mode:"onBlur"});y(()=>{let V=e?.watch(i=>{Object.keys(i).some(n=>i[n]!==o?.initialValues?.[n])&&o?.checkFieldUpdates(i)});return()=>V?.unsubscribe()},[]);let T=m||(o?.fields??[]);return r(l,{...e,children:r("form",{id:c,onSubmit:e.handleSubmit(d),className:"space-y-4 RemoteFlows__TerminationForm",children:r(f,{fields:T})})})}t(B,"TerminationForm");export{B as a};
|
|
2
|
+
//# sourceMappingURL=chunk-GTP4CHJD.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as r}from"./chunk-QP3VWGCS.js";import{a as t}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as r}from"./chunk-QP3VWGCS.js";import{a as t}from"./chunk-PWKYZHOL.js";import{a as f}from"./chunk-S5PJSCJF.js";import{a as e}from"./chunk-PA7PBUX6.js";import{a as p}from"./chunk-3XOY4F3D.js";import{a as n}from"./chunk-STPJXT2A.js";import{a}from"./chunk-J667C5G4.js";import{a as m}from"./chunk-MRYRNB7Y.js";import{a as i}from"./chunk-P37U34EQ.js";import{useId as c}from"react";import{jsx as F}from"react/jsx-runtime";var k=i(({employmentId:l,render:T,options:d,initialValues:s})=>{let u=c(),o=t({employmentId:l,options:d,initialValues:s});return F(m.Provider,{value:{formId:u,terminationBag:o},children:T({terminationBag:o,components:{SubmitButton:r,Back:n,EmployeeComunicationStep:e,TerminationDetailsStep:a,PaidTimeOffStep:p,AdditionalDetailsStep:f}})})},"TerminationFlow");export{k as a};
|
|
2
|
+
//# sourceMappingURL=chunk-H62DYWRD.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as y}from"./chunk-PGWKJ6FK.js";import{a as F}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as y}from"./chunk-PGWKJ6FK.js";import{a as F}from"./chunk-VC66HET6.js";import{b as c}from"./chunk-LNV36S6D.js";import{b as u}from"./chunk-2YTBWEC7.js";import{f,g as p}from"./chunk-66N57DKF.js";import{a as m}from"./chunk-P37U34EQ.js";import{useEffect as S}from"react";import{jsx as b}from"react/jsx-runtime";import{createElement as V}from"react";function U({defaultValues:d,onSubmit:g,components:E}){let{formId:k,onboardingBag:o}=y(),w=c(o.handleValidation),r=f({resolver:w,defaultValues:d,shouldUnregister:!1,mode:"onBlur"});S(()=>{o.employmentId&&o?.checkFieldUpdates(r.getValues())},[]),S(()=>{let t=r?.watch(e=>{Object.keys(e).some(i=>e[i]!==d[i])&&o?.checkFieldUpdates(e)});return()=>t?.unsubscribe()},[]);let h=m(async(t,e)=>{let s=e?.nativeEvent;if(s?.isDraftSubmission){let{onSuccess:i,onError:l}=s.draftCallbacks;try{if(!await r.trigger())return;let n=await o.onSubmit(t);if(n?.data)i?.();else if(n?.error){let B=o.stepState.currentStep.name,P=o.meta?.fields?.[B],O=u(n?.fieldErrors||[],P);l?.({error:n.error,rawError:n.rawError,fieldErrors:O})}}catch(a){l?.({error:a,rawError:a,fieldErrors:[]})}}else g(t)},"handleSubmit");return V(p,{...r,key:`form-${o.stepState.currentStep.name}`},b("form",{id:k,onSubmit:r.handleSubmit(h),className:"space-y-4 RemoteFlows__OnboardingForm",children:b(F,{components:E,fields:o.fields,fieldsets:o.meta.fieldsets,fieldValues:o.fieldValues})}))}m(U,"OnboardingForm");export{U as a};
|
|
2
|
+
//# sourceMappingURL=chunk-I4S5X7NU.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as i}from"./chunk-PHWZOEDE.js";import{b as a}from"./chunk-TOA3JILU.js";import{a as t}from"./chunk-P37U34EQ.js";import{jsx as d}from"react/jsx-runtime";function y({onSubmit:c,onSuccess:s,onError:e}){let{contractorOnboardingBag:o}=a(),u=t(async n=>{try{await c?.({countryCode:n.country});let r=await o.onSubmit(n);if(r?.data){await s?.(r?.data),o?.next();return}r?.error&&e?.({error:r.error,rawError:r.rawError,fieldErrors:[]})}catch(r){e?.({error:r,rawError:r,fieldErrors:[]})}},"handleSubmit"),l=o.stepState.values?.select_country||o.initialValues.select_country;return d(i,{defaultValues:l,onSubmit:u})}t(y,"SelectCountryStep");export{y as a};
|
|
2
|
+
//# sourceMappingURL=chunk-ITIZBBRW.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as e}from"./chunk-GTP4CHJD.js";import{b as a}from"./chunk-MRYRNB7Y.js";import{a as i}from"./chunk-P37U34EQ.js";import{jsx as s}from"react/jsx-runtime";function p({onSubmit:t}){let{terminationBag:o}=a(),n=i(async r=>{let m=await o?.parseFormValues(r);await t?.(m),o?.next()},"handleSubmit");return s(e,{defaultValues:o.fieldValues,onSubmit:n})}i(p,"TerminationDetailsForm");export{p as a};
|
|
2
|
+
//# sourceMappingURL=chunk-J667C5G4.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as p}from"./chunk-TOA3JILU.js";import{d as u}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as p}from"./chunk-TOA3JILU.js";import{d as u}from"./chunk-3JVRFY6F.js";import{a as l}from"./chunk-2YTBWEC7.js";import{b as d}from"./chunk-KQPDXXG3.js";import{b as c}from"./chunk-LJGCFFAT.js";import{a as e}from"./chunk-P37U34EQ.js";import{jsx as y}from"react/jsx-runtime";function k({onSubmit:f,onSuccess:E,onError:i,render:s,...o}){let{components:v}=d(),{contractorOnboardingBag:r}=p(),n=u(),{mutateAsync:b}=l(n),m=e(async()=>{try{if(await f?.(),r.employmentId){let t=await b({employment_id:r.employmentId});if(t.data){await E?.({data:t.data,employmentStatus:"invited"}),r.refetchEmployment();return}t.error&&i?.({error:t.error,rawError:t.rawError,fieldErrors:[]})}}catch(t){i?.({error:t,rawError:t,fieldErrors:[]})}},"handleSubmit"),a=v?.button;return a?y(a,{...o,disabled:n.isPending||o.disabled,onClick:t=>{m(),o.onClick?.(t)},children:s({employmentStatus:"invited"})}):y(c,{...o,disabled:n.isPending||o.disabled,onClick:()=>{m()},children:s({employmentStatus:"invited"})})}e(k,"OnboardingInvite");export{k as a};
|
|
2
|
+
//# sourceMappingURL=chunk-KG63T7OU.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as m}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as m}from"./chunk-I4S5X7NU.js";import{b as s}from"./chunk-PGWKJ6FK.js";import{b as t}from"./chunk-2YTBWEC7.js";import{a}from"./chunk-P37U34EQ.js";import{jsx as E}from"react/jsx-runtime";function b({onSubmit:d,onSuccess:l,onError:n}){let{onboardingBag:r}=s(),f=a(async e=>{try{let i=await r.parseFormValues(e);await d?.(i);let o=await r.onSubmit(e);if(o?.data){await l?.(o?.data),r?.next();return}if(o?.error){let c=t(o?.fieldErrors||[],r.meta?.fields?.basic_information);n?.({error:o?.error,rawError:o?.rawError,fieldErrors:c})}}catch(i){n?.({error:i,rawError:i,fieldErrors:[]})}},"handleSubmit"),p=r.stepState.values?.basic_information||r.initialValues.basic_information;return E(m,{defaultValues:p,onSubmit:f})}a(b,"BasicInformationStep");export{b as a};
|
|
2
|
+
//# sourceMappingURL=chunk-LPAKW2MR.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as i}from"./chunk-GTP4CHJD.js";import{b as e}from"./chunk-MRYRNB7Y.js";import{a as m}from"./chunk-P37U34EQ.js";import{jsx as u}from"react/jsx-runtime";function p({onSubmit:n}){let{terminationBag:o}=e(),a=m(async t=>{let r=await o?.parseFormValues(t);await n?.(r),o?.next()},"handleSubmit");return u(i,{defaultValues:o.fieldValues,onSubmit:a})}m(p,"EmployeeCommunicationForm");export{p as a};
|
|
2
|
+
//# sourceMappingURL=chunk-PA7PBUX6.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{b as c}from"./chunk-TOA3JILU.js";import{a as l}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{b as c}from"./chunk-TOA3JILU.js";import{a as l}from"./chunk-VC66HET6.js";import{b as s}from"./chunk-LNV36S6D.js";import{f as m,g as d}from"./chunk-66N57DKF.js";import{a as e}from"./chunk-P37U34EQ.js";import{useEffect as f}from"react";import{jsx as p}from"react/jsx-runtime";import{createElement as P}from"react";function B({defaultValues:i,onSubmit:F,components:u}){let{formId:y,contractorOnboardingBag:o}=c(),b=s(o.handleValidation),r=m({resolver:b,defaultValues:i,shouldUnregister:!1,mode:"onBlur"});f(()=>{o.employmentId&&o?.checkFieldUpdates(r.getValues())},[]),f(()=>{let n=r?.watch(t=>{Object.keys(t).some(a=>t[a]!==i[a])&&o?.checkFieldUpdates(t)});return()=>n?.unsubscribe()},[]);let g=e(async n=>{F(n)},"handleSubmit");return P(d,{...r,key:`form-${o.stepState.currentStep.name}`},p("form",{id:y,onSubmit:r.handleSubmit(g),className:"space-y-4 RemoteFlows__OnboardingForm",children:p(l,{components:u,fields:o.fields,fieldsets:o.meta.fieldsets,fieldValues:o.fieldValues})}))}e(B,"ContractorOnboardingForm");export{B as a};
|
|
2
|
+
//# sourceMappingURL=chunk-PHWZOEDE.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as R}from"./chunk-MKE27NUF.js";import{a as Z}from"./chunk-NS4FRCEH.js";import{a as K}from"./chunk-IWA5B4U6.js";import{a as Q}from"./chunk-AT7VHJMW.js";import{a as J}from"./chunk-3SAV2OEE.js";import{a as z}from"./chunk-I4XJ764Y.js";import{c as H,d as L}from"./chunk-2TILNBMK.js";import{a as A}from"./chunk-ZXGAFQXW.js";import{a as S,b as E,c as N,d as B,e as q}from"./chunk-QUQLW5YW.js";import{a as D}from"./chunk-Z5WMKCRJ.js";import{a as O}from"./chunk-JA7UP6GN.js";import{a as u,b as $}from"./chunk-7FMR3EIX.js";import{a as v}from"./chunk-2YTBWEC7.js";import{m as b}from"./chunk-NFUP6BFU.js";import{a as I}from"./chunk-PJBAQZ6G.js";import{d as w}from"./chunk-KQPDXXG3.js";import{c as p}from"./chunk-2SO4LW7V.js";import{a as h}from"./chunk-L3Z2G32A.js";import{a as o}from"./chunk-P37U34EQ.js";import{createHeadlessForm as ye}from"@remoteoss/json-schema-form-old";import Te from"lodash.omitby";import Fe from"lodash.isnull";import{format as g,isFuture as Me,parseISO as x,subDays as Se}from"date-fns";import{useMemo as j}from"react";import ge from"lodash.omit";import{useQuery as ce}from"@tanstack/react-query";var U=o(({query:t,options:e})=>{let{client:_}=w();return ce({queryKey:["payroll-calendars"],queryFn:o(()=>b({client:_,query:{year:t?.year,country_code:t?.countryCode}}),"queryFn"),enabled:e?.enabled,select:o(c=>c.data?.data?.payroll_calendars?.[0],"select")})},"usePayrollCalendars");import{isFuture as pe,isToday as ue,parseISO as _e}from"date-fns";var W=o(t=>{if(!t)return!1;let e=_e(t);return pe(e)||ue(e)},"isInProbationPeriod");import{Fragment as xe,jsx as d,jsxs as je}from"react/jsx-runtime";var so=o(({employmentId:t,options:e,initialValues:_})=>{let{fieldValues:c,setFieldValues:Y,stepState:a,previousStep:G,nextStep:X}=I(E),{data:n}=O({employmentId:t}),{data:ee}=U({query:{year:new Date().getFullYear().toString(),countryCode:n?.country?.code},options:{enabled:!!n?.country?.code}}),y=W(n?.probation_period_end_date),T=N(ee),P=j(()=>y?g(new Date,"yyyy-MM-dd"):g(T,"yyyy-MM-dd"),[y,T]),F=!!(n?.provisional_start_date&&Me(x(n.provisional_start_date))),M=q({...a.values?.employee_communication,...a.values?.termination_details,...a.values?.paid_time_off,...a.values?.additional_information,..._},F),f=j(()=>({...M,...a.values?.[a.currentStep.name],...c}),[a.values,a.currentStep.name,c,M]),V=B({minTerminationDate:T,isEmployeeInProbationPeriod:y,selectedDate:x(f.proposed_termination_date)}),oe=j(()=>{let m=A.data.schema.properties.termination_reason.oneOf,r=F?m.filter(i=>i.const==="cancellation_before_start_date"):m.filter(i=>i.const!=="cancellation_before_start_date");return{fields:{risk_assesment_info:S("Offboarding risk assessment","Employees may be protected from termination if they fall into certain categories. To help avoid claims from employees, let us know if the employee is part of one or more of these categories. Select all that apply.",{className:e?.jsfModify?.fields?.risk_assesment_info?.["x-jsf-presentation"]?.className}),termination_reason:{...e?.jsfModify?.fields?.termination_reason,oneOf:r},proposed_termination_date_info:S("Proposed termination date",je(xe,{children:["In most cases, we must provide notice to the employee before termination. The required notice period depends on local labor laws, the employment agreement, and other factors. We'll use those factors to determine the required notice period.",d($,{external:!0,zendeskId:u.terminationNoticePeriods,className:h("text-sm",e?.jsfModify?.fields?.proposed_termination_date_info?.["x-jsf-presentation"]?.zendeskTriggerButtonClassName),children:"Learn about notice periods"})]}),{className:e?.jsfModify?.fields?.proposed_termination_date_info?.["x-jsf-presentation"]?.className}),proposed_termination_date:{...e?.jsfModify?.fields?.proposed_termination_date,"x-jsf-presentation":{...e?.jsfModify?.fields?.proposed_termination_date?.["x-jsf-presentation"],minDate:P,...f.termination_reason==="cancellation_before_start_date"&&n?.provisional_start_date?{maxDate:g(Se(x(n.provisional_start_date),1),"yyyy-MM-dd")}:{},...V},...f.termination_reason==="cancellation_before_start_date"?{"x-jsf-errorMessage":{maximum:"The proposed termination date must be before the employee's start date."}}:{}},paid_time_off_info:{...e?.jsfModify?.fields?.paid_time_off_info,"x-jsf-presentation":{...e?.jsfModify?.fields?.paid_time_off_info?.["x-jsf-presentation"],Component:o(()=>{let i=e?.jsfModify?.fields?.paid_time_off_info?.["x-jsf-presentation"]?.Component;return d(Z,{employeeName:n?.basic_information?.name,proposedTerminationDate:f.proposed_termination_date,employmentId:t,employment:n,render:s=>i?d(i,{...s}):d(R,{...s})})},"Component")}},acknowledge_termination_procedure_info:{...e?.jsfModify?.fields?.acknowledge_termination_procedure_info,"x-jsf-presentation":{...e?.jsfModify?.fields?.acknowledge_termination_procedure_info?.["x-jsf-presentation"],Component:o(()=>{let i=e?.jsfModify?.fields?.acknowledge_termination_procedure_info?.["x-jsf-presentation"]?.Component;return d(K,{render:s=>i?d(i,{...s}):d(Q,{...s})})},"Component")}},acknowledge_termination_procedure_fees_info:{...e?.jsfModify?.fields?.acknowledge_termination_procedure_fees_info,"x-jsf-presentation":{...e?.jsfModify?.fields?.acknowledge_termination_procedure_fees_info?.["x-jsf-presentation"],Component:o(()=>{let i={involuntaryOffboardingServiceChargeZendeskId:u.involuntaryOffboardingServiceCharge,reconciliationInvoiceZendeskId:u.reconciliationInvoice},s=e?.jsfModify?.fields?.acknowledge_termination_procedure_fees_info?.["x-jsf-presentation"]?.Component;return s?d(s,{...i}):d(J,{...i})},"Component")}}}}},[n,t,f.proposed_termination_date,f.termination_reason,F,P,e?.jsfModify?.fields?.acknowledge_termination_procedure_fees_info,e?.jsfModify?.fields?.acknowledge_termination_procedure_info,e?.jsfModify?.fields?.paid_time_off_info,e?.jsfModify?.fields?.proposed_termination_date,e?.jsfModify?.fields?.proposed_termination_date_info,e?.jsfModify?.fields?.risk_assesment_info,e?.jsfModify?.fields?.termination_reason,V]),{data:l,isLoading:ie}=L({formValues:f,jsfModify:{...e?.jsfModify,fields:{...e?.jsfModify?.fields,...oe?.fields}},step:a.currentStep.name}),te=ye(z.data.schema),k=H(),{mutateAsync:ne}=v(k);async function ae(m){if(!t)throw new Error("Employment id is missing");if(l){let r=await C(m,!0),{customer_informed_employee:i}=r,s=i==="yes"?{employee_awareness:{date:r.customer_informed_employee_date,note:r.customer_informed_employee_description}}:void 0,de=await D(r,["agrees_to_pto_amount","confidential","customer_informed_employee","will_challenge_termination"]),fe=ge(de,"customer_informed_employee_date","customer_informed_employee_description"),le=Te({...fe,...s},Fe);return ne({employment_id:t,termination_details:le,type:"termination"})}}o(ae,"onSubmit");function re(){G()}o(re,"back");function se(){X()}o(se,"next");let me=Object.keys(c).length>0,C=o(async(m,r=!1)=>r?await p(m,te.fields,{isPartialValidation:!0}):l?await p(m,l?.fields,{isPartialValidation:!0}):{},"parseFormValues");return{employmentId:t,employment:n,fieldValues:f,isDirty:me,stepState:a,fields:l?.fields||[],isLoading:ie,isSubmitting:k.isPending,initialValues:M,handleValidation:o(async m=>{if(l){let r=await p(m,l?.fields);return l?.handleValidation(r)}return null},"handleValidation"),checkFieldUpdates:Y,parseFormValues:C,onSubmit:ae,back:re,next:se}},"useTermination");export{so as a};
|
|
2
|
+
//# sourceMappingURL=chunk-PWKYZHOL.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as S}from"./chunk-RPTB2HUM.js";import{a as f}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as S}from"./chunk-RPTB2HUM.js";import{a as f}from"./chunk-EOV62SUU.js";import{a as p}from"./chunk-2LR4VZUK.js";import{a as s}from"./chunk-2DYRPCHC.js";import{a as m}from"./chunk-MDDI5GLL.js";import{a}from"./chunk-BGNCB335.js";import{a as i}from"./chunk-YWZI5KJN.js";import{a as c}from"./chunk-Z7WBY27D.js";import{a as n}from"./chunk-LPAKW2MR.js";import{a as r}from"./chunk-PGWKJ6FK.js";import{a as e}from"./chunk-SGTUQ7OX.js";import{a as t}from"./chunk-P37U34EQ.js";import{useId as D,useState as P}from"react";import{jsx as R}from"react/jsx-runtime";var L=t(({employmentId:d,companyId:u,countryCode:b,type:l="employee",externalId:v,skipSteps:g,initialValues:B,render:I,options:O})=>{let w=D(),o=e({companyId:u,countryCode:b,employmentId:d,type:l,options:O,skipSteps:g,externalId:v,initialValues:B}),[C,h]=P({showReserveInvoice:!1,showInviteSuccessful:!1});return R(r.Provider,{value:{formId:w,onboardingBag:o,creditScore:C,setCreditScore:h},children:I({onboardingBag:o,components:{BasicInformationStep:n,ContractDetailsStep:s,BenefitsStep:p,SubmitButton:i,SaveDraftButton:S,BackButton:m,OnboardingInvite:a,SelectCountryStep:f,ReviewStep:c}})})},"OnboardingFlow");export{L as a};
|
|
2
|
+
//# sourceMappingURL=chunk-R36C4F5D.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as t}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as t}from"./chunk-GTP4CHJD.js";import{b as e}from"./chunk-MRYRNB7Y.js";import{a as r}from"./chunk-P37U34EQ.js";import{jsx as f}from"react/jsx-runtime";function F({onSubmit:n,onSuccess:s,onError:m}){let{terminationBag:o}=e(),d=r(async a=>{let l=await o?.parseFormValues(a,!0);await n?.(l);let i=await o?.onSubmit(a);i?.error?m?.(i.error):i?.data&&await s?.(i.data)},"handleSubmit");return f(t,{defaultValues:o.fieldValues,fields:o?.fields,onSubmit:d})}r(F,"AdditionalDetailsForm");export{F as a};
|
|
2
|
+
//# sourceMappingURL=chunk-S5PJSCJF.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as m}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as m}from"./chunk-PHWZOEDE.js";import{b as c}from"./chunk-TOA3JILU.js";import{b as d}from"./chunk-2YTBWEC7.js";import{a as t}from"./chunk-P37U34EQ.js";import{Suspense as u,lazy as F}from"react";import{jsx as i}from"react/jsx-runtime";var E=F(()=>import("./PdfPreview-6C3GGXIN.js").then(o=>({default:o.PDFPreview}))),l=t(o=>i(u,{fallback:i("div",{className:"animate-pulse",children:"Loading PDF..."}),children:i(E,{...o})}),"LazyPdfPreview");import{jsx as p,jsxs as S}from"react/jsx-runtime";function M({onSubmit:o,onSuccess:P,onError:n}){let{contractorOnboardingBag:r}=c(),w=t(async s=>{try{let a=await r.parseFormValues(s);await o?.(a);let e=await r.onSubmit(s);if(e?.data){await P?.(e?.data),r?.next();return}if(e?.error){let f=d(e?.fieldErrors||[],r.meta?.fields?.contract_preview);n?.({error:e?.error,rawError:e?.rawError,fieldErrors:f})}}catch(a){n?.({error:a,rawError:a,fieldErrors:[]})}},"handleSubmit"),v=r.stepState.values?.contract_preview||r.initialValues.contract_preview;return S("div",{className:"space-y-4",children:[p(l,{base64Data:r.documentPreviewPdf?.contract_document.content}),p(m,{defaultValues:v,onSubmit:w})]})}t(M,"ContractPreviewStep");export{M as a};
|
|
2
|
+
//# sourceMappingURL=chunk-S7X4AB7C.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ke}from"./chunk-VAIBLWOY.js";import{a as Be}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as ke}from"./chunk-VAIBLWOY.js";import{a as Be}from"./chunk-4C7Y76IS.js";import{a as Oe,b as Me,c as Pe,d as Te,f as Le,g as we}from"./chunk-ELXVVBRD.js";import{a as ye,b as pe,c as _e,f as Se,g as be,h as ge,i as Fe,j as Ee,k as he,m as Ve}from"./chunk-3JVRFY6F.js";import{a as v}from"./chunk-2YTBWEC7.js";import{a as Ce}from"./chunk-PJBAQZ6G.js";import{c as V,d as L,f as W}from"./chunk-2SO4LW7V.js";import{g as C}from"./chunk-L3Z2G32A.js";import{a as l}from"./chunk-P37U34EQ.js";import{useEffect as st,useMemo as d,useRef as rt,useState as Re}from"react";import ct from"lodash.mergewith";import{jsx as qe}from"react/jsx-runtime";var lt={employment_basic_information:"basic_information",contract_details:"contract_details"},mt={select_country:null,basic_information:"employment_basic_information",contract_details:"contract_details",benefits:null,review:null},dt=l(({isLoadingBasicInformationForm:f,isLoadingContractDetailsForm:I,isLoadingEmployment:j,isLoadingBenefitsOffersSchema:A,isLoadingBenefitOffers:i,isLoadingCompany:D,isLoadingCountries:O,employmentStatus:a,employmentId:_,currentStepName:s,basicInformationFields:J,contractDetailsFields:r})=>{let M=f||I||j||A||i||D||O,c=a&&Pe.includes(a),w=a&&!Te.includes(a),B=!!(_&&c&&s!=="review"),k=M||B,R=!!(B&&!M&&J.length>0&&r.length>0);return{isLoading:k,isNavigatingToReview:R,isEmploymentReadOnly:c,canInvite:w}},"getLoadingStates"),Vt=l(({employmentId:f,companyId:I,countryCode:j,type:A,options:i,skipSteps:D,externalId:O,initialValues:a})=>{let _=rt({select_country:{},basic_information:{},contract_details:{},benefits:{}}),[s,J]=Re(f),[r,M]=Re(j||null),{data:c,isLoading:w,refetch:B}=ye(s);f&&c?.country?.code&&!r&&M(c.country.code);let{data:k,isLoading:R}=_e(s),{data:q,isLoading:G,refetch:Ne}=pe(I),ve=D?.includes("select_country")?Me:Oe,{fieldValues:S,stepState:n,setFieldValues:Ie,previousStep:je,nextStep:Ae,goToStep:x,setStepValues:$}=Ce(ve),{selectCountryForm:N,isLoading:z}=he({jsfModify:i?.jsfModify?.select_country,queryOptions:{enabled:n.currentStep.name==="select_country"}}),K=ge(i),Y=Fe(i),Q=Ee(i),De=Ve(),{mutateAsync:Je}=v(K),{mutateAsync:X}=v(Y),{mutateAsync:xe}=v(Q),Ue=mt[n.currentStep.name]||"employment_basic_information",He=lt[Ue],We=c?.[He]||{},Z=l(({form:e,options:o={},query:m={},jsonSchemaVersion:h})=>{let H=Object.keys(S).length>0?{...a,...n.values?.[n.currentStep.name],...S}:{...a,...We};return Se({countryCode:r,form:e,fieldValues:H,query:m,options:{...o,queryOptions:{enabled:o.queryOptions?.enabled??!0}},jsonSchemaVersion:h})},"useJSONSchema"),Ge=!!(r&&(n.currentStep.name==="basic_information"||f)),$e=!!(r&&(n.currentStep.name==="contract_details"||f)),{data:u,isLoading:ee}=Z({form:"employment_basic_information",options:{jsfModify:i?.jsfModify?.basic_information,queryOptions:{enabled:Ge}},jsonSchemaVersion:Le}),b=i?.jsfModify?.contract_details?.fields?.annual_gross_salary,U=b&&typeof b=="object"&&"presentation"in b?b.presentation:void 0,te=i?.jsfModify?.contract_details?.fields?.equity_compensation,ze=d(()=>({fields:{annual_gross_salary:{...b,presentation:{annual_gross_salary_conversion_properties:{label:U?.annual_gross_salary_conversion_properties?.label,description:U?.annual_gross_salary_conversion_properties?.description},desiredCurrency:q?.desired_currency,Component:l(e=>qe(Be,{desiredCurrency:q?.desired_currency||"",...e}),"Component")}},equity_compensation:{...te,presentation:{calculateDynamicProperties:l((e,o)=>{let m=e.equity_compensation?.offer_equity_compensation,h=o?.meta?.cost;return{extra:qe(ke,{offerEquity:m,equityCost:h})}},"calculateDynamicProperties")}}}}),[b,U,q?.desired_currency,te]),Ke=we(i,r),{data:y,isLoading:ne}=Z({form:"contract_details",query:{employment_id:s},options:{jsfModify:{...i?.jsfModify?.contract_details,fields:{...i?.jsfModify?.contract_details?.fields,...ze.fields}},queryOptions:{enabled:$e}},jsonSchemaVersion:Ke}),{data:P,isLoading:oe}=be(s,S,i),ie=d(()=>{if(n.currentStep.name==="benefits"){let e={...n.values?.[n.currentStep.name],...S};return ct({},k,e)}return{}},[n.currentStep.name,k,n.values,S]),t=d(()=>({select_country:N?.fields||[],basic_information:u?.fields||[],contract_details:y?.fields||[],benefits:P?.fields||[],review:[]}),[N?.fields,u?.fields,y?.fields,P?.fields]),Ye={select_country:null,basic_information:u?.meta["x-jsf-fieldsets"],contract_details:y?.meta["x-jsf-fieldsets"],benefits:null,review:null},{country:Qe,basic_information:ae={},contract_details:se={},status:re}=c||{},ce=Qe?.code,le=n.currentStep.name,g=d(()=>L(t.select_country,{country:r||ce||""}),[t.select_country,r,ce]),F=d(()=>{let e={...a,...ae};return L(t.basic_information,e)},[t.basic_information,ae,a]),p=d(()=>{let e={...a,...se};return L(t.contract_details,e)},[t.contract_details,se,a]),E=d(()=>{let e={...a,...ie};return L(t.benefits,e)},[t.benefits,ie,a]),Xe=d(()=>c?{select_country:g,basic_information:W(t.basic_information,F),contract_details:c?.contract_details!==null?W(t.contract_details,p):p,benefits:E}:{select_country:g,basic_information:F,contract_details:p,benefits:E},[g,F,p,E,c,t]),{isLoading:Ze,isNavigatingToReview:me,isEmploymentReadOnly:et,canInvite:tt}=d(()=>dt({isLoadingBasicInformationForm:ee,isLoadingContractDetailsForm:ne,isLoadingEmployment:w,isLoadingBenefitsOffersSchema:oe,isLoadingBenefitOffers:R,isLoadingCompany:G,isLoadingCountries:z,employmentId:f,employmentStatus:re,basicInformationFields:t.basic_information,contractDetailsFields:t.contract_details,currentStepName:le}),[ee,ne,w,oe,R,G,z,f,re,t.basic_information,t.contract_details,le]);st(()=>{me&&(_.current={select_country:C(g,t.select_country),basic_information:C(F,t.basic_information),contract_details:C(p,t.contract_details),benefits:C(E,t.benefits)},$({select_country:g,basic_information:F,contract_details:p,benefits:E,review:{}}),x("review"))},[F,E,p,x,me,g,$,t.basic_information,t.benefits,t.contract_details,t.select_country]);let de=l(async e=>N&&n.currentStep.name==="select_country"?e:u&&n.currentStep.name==="basic_information"?await V(e,u?.fields,{isPartialValidation:!1}):y&&n.currentStep.name==="contract_details"?await V(e,y?.fields,{isPartialValidation:!1}):{},"parseFormValues");async function nt(e){let o=n.currentStep.name;o in _.current&&(_.current[o]=C(e,t[o]));let m=await de(e);switch(Ne(),n.currentStep.name){case"select_country":return M(m.country),Promise.resolve({data:{countryCode:m.country}});case"basic_information":{let h=!s&&r,fe=s&&r&&c?.country&&c?.country.code!==r;if(h||fe){let H={basic_information:m,type:A,country_code:r,external_id:O};try{let T=await Je(H),ue=T.data?.data?.employment?.id;return J(ue),await De.mutateAsync({employmentId:ue,eligible_to_work_in_residing_country:"citizen",employer_or_work_restrictions:!1}),T}catch(T){throw console.error("Error creating onboarding:",T),T}}else if(s)return X({employmentId:s,basic_information:m,pricing_plan_details:{frequency:"monthly"},external_id:O});return}case"contract_details":return X({employmentId:s,external_id:O,...{contract_details:m,pricing_plan_details:{frequency:"monthly"}}});case"benefits":return xe({employmentId:s,...e})}}l(nt,"onSubmit");function ot(){je()}l(ot,"back");function it(){Ae()}l(it,"next");function at(e){x(e)}return l(at,"goTo"),{employmentId:s,creditRiskStatus:q?.default_legal_entity_credit_risk_status,fieldValues:S,stepState:n,fields:t[n.currentStep.name],isLoading:Ze,isSubmitting:K.isPending||Y.isPending||Q.isPending,initialValues:Xe,handleValidation:l(async e=>{if(n.currentStep.name==="select_country")return N.handleValidation(e);if(n.currentStep.name==="benefits"&&P){let o=await V(e,P?.fields,{isPartialValidation:!1});return P?.handleValidation(o)}if(u&&n.currentStep.name==="basic_information"){let o=await V(e,u?.fields,{isPartialValidation:!1});return u?.handleValidation(o)}if(y&&n.currentStep.name==="contract_details"){let o=await V(e,y?.fields,{isPartialValidation:!1});return y?.handleValidation(o)}return null},"handleValidation"),checkFieldUpdates:Ie,parseFormValues:de,onSubmit:nt,back:ot,next:it,goTo:at,meta:{fields:_.current,fieldsets:Ye[n.currentStep.name]},refetchEmployment:B,employment:c,isEmploymentReadOnly:et,canInvite:tt}},"useOnboarding");export{Vt as a};
|
|
2
|
+
//# sourceMappingURL=chunk-SGTUQ7OX.js.map
|