@remoteoss/remote-flows 0.4.0-alpha.18 → 0.4.0-alpha.19
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-W2T4VYM3.js → chunk-CG64S2K7.js} +2 -2
- package/dist/chunk-PIIDSBAO.js +2 -0
- package/dist/chunk-PIIDSBAO.js.map +1 -0
- package/dist/flows/CostCalculator/CostCalculatorFlow.js +1 -1
- package/dist/flows/CostCalculator/hooks.js +1 -1
- package/dist/flows/CostCalculator/index.js +1 -1
- package/dist/flows/CostCalculator/utils.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/dist/chunk-Y5SFM4H7.js +0 -2
- package/dist/chunk-Y5SFM4H7.js.map +0 -1
- /package/dist/{chunk-W2T4VYM3.js.map → chunk-CG64S2K7.js.map} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as l}from"./chunk-KSHK3ZPX.js";import{c as s,d as e}from"./chunk-
|
|
2
|
-
//# sourceMappingURL=chunk-
|
|
1
|
+
import{a as l}from"./chunk-KSHK3ZPX.js";import{c as s,d as e}from"./chunk-PIIDSBAO.js";import{b as a}from"./chunk-CFIJKJXD.js";import{a as r}from"./chunk-P37U34EQ.js";import{useId as g}from"react";import{useForm as p}from"react-hook-form";import{jsx as y}from"react/jsx-runtime";var P=r(({estimationOptions:n=s,defaultValues:o={countryRegionSlug:"",currencySlug:"",salary:""},options:i,render:u})=>{let c=g(),t=e({defaultRegion:o.countryRegionSlug,estimationOptions:n,options:i}),m=a(t.handleValidation),C=p({resolver:m,defaultValues:{country:o?.countryRegionSlug,currency:o?.currencySlug,region:"",salary:o?.salary},shouldUnregister:!1,mode:"onBlur"});return y(l.Provider,{value:{form:C,formId:c,costCalculatorBag:t},children:u(t)})},"CostCalculatorFlow");export{P as a};
|
|
2
|
+
//# sourceMappingURL=chunk-CG64S2K7.js.map
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as q}from"./chunk-LZ3R4ZK2.js";import{a as L}from"./chunk-UPRUP24B.js";import{a as O,b as x,c as A,e as k}from"./chunk-Q23DM4O3.js";import{a as J}from"./chunk-CFIJKJXD.js";import{c as g}from"./chunk-MH6KKP6K.js";import{a as n}from"./chunk-P37U34EQ.js";import{object as le}from"yup";import{createHeadlessForm as oe,modify as ne}from"@remoteoss/json-schema-form";import{useMemo as ie,useState as j}from"react";import{string as T,ValidationError as U}from"yup";import{jsx as ae}from"react/jsx-runtime";var M={title:"Estimation",includeBenefits:!1,includeCostBreakdowns:!1,includePremiumBenefits:!1,enableCurrencyConversion:!1},se=n(t=>{let{schema:o}=ne(L.data.schema,t?.jsfModify||{});return oe(o)},"useStaticSchema"),be=n(({defaultRegion:t,estimationOptions:o,options:a}={estimationOptions:M})=>{let[l,m]=j(t),[f,B]=j(),[y,H]=j(),{data:E,isLoading:I}=O({includePremiumBenefits:o.includePremiumBenefits}),{data:b,isLoading:N}=x(),z=l||f?.value,{data:S,isLoading:D}=k(z,{includePremiumBenefits:o.includePremiumBenefits,options:a}),w=A(),p=f?.currency,c=a?.jsfModify?.fields?.salary,C=c&&typeof c=="object"&&"presentation"in c?c.presentation:void 0,K=ie(()=>{let r=!!(o.enableCurrencyConversion&&p&&y&&p!==y);if(console.log({shouldUseCurrencyConversion:r,employeeBillingCurrency:p,employerBillingCurrency:y,enableCurrencyConversion:o.enableCurrencyConversion}),r)return{fields:{salary:{...c,presentation:{salary_conversion_properties:{label:C?.salary_conversion_properties?.label,description:C?.salary_conversion_properties?.description},currencies:{from:p,to:y},Component:n(e=>ae(q,{...e}),"Component")}}}}},[p,y,o.enableCurrencyConversion,c,C?.salary_conversion_properties?.description,C?.salary_conversion_properties?.label]),u=se({jsfModify:{fields:{...a?.jsfModify?.fields,...K?.fields}}});async function Q(r){try{await h.validate(r,{abortEarly:!1})}catch(e){return{data:null,error:e}}return new Promise((e,i)=>{w.mutate($(r,o),{onSuccess:n(s=>{s.data?e({data:s.data,error:null}):e({data:null,error:new Error("Something went wrong. Please try again later.")})},"onSuccess"),onError:n(s=>{i({data:null,error:s})},"onError")})})}n(Q,"onSubmit");function W(r){let e=E?.find(({value:i})=>i===r);e&&e.childRegions.length===0&&e.hasAdditionalFields?m(e.regionSlug):m(void 0),B(e)}n(W,"onCountryChange");function X(r){m(r)}n(X,"onRegionChange");function Y(r){let e=b?.find(i=>i.value===r)?.label;H(e)}n(Y,"onChangeCurrency");let d=u.fields.find(r=>r.name==="region");if(d){let r=f?.childRegions.map(e=>({value:e.slug,label:e.name}))??[];d.options=r,d.isVisible=r.length>0,d.required=r.length>0,d.onChange=X,d.schema=r.length>0?T().transform(e=>typeof e=="string"?e:"").required("Region is required"):T()}if(b){let r=u.fields.find(e=>e.name==="currency");r&&(r.options=b,r.onChange=Y)}if(E){let r=u.fields.find(e=>e.name==="country");r&&(r.options=E,r.onChange=W)}let Z=n(()=>{B(void 0),m(t)},"resetForm"),v=[...u.fields,...S?.fields||[]],h=G(u.fields);async function ee(r){let e=null,i=g(r,v);try{await h.validate(i,{abortEarly:!1}),e={formErrors:{},yupError:new U([],r)}}catch(V){let R=J(V);e={formErrors:Object.entries(R).reduce((P,[re,te])=>({...P,[re]:te.message}),{}),yupError:V}}let s=S?.handleValidation(i),_=[...e?.yupError.inner||[],...s?.yupError?.inner||[]],F={...e?.yupError?.value||{},...s?.yupError?.value||{}};return{formErrors:{...e?.formErrors||{},...s?.formErrors||{}},yupError:new U(_,F)}}return n(ee,"handleValidation"),{stepState:{current:0,total:1,isLastStep:!0},fields:v,validationSchema:h,parseFormValues:n(r=>{let{country:e,region:i,salary:s,currency:_,...F}=r,R=g({country:e,region:i,salary:s,currency:_},u.fields),P=g(F,S?.fields||[]);return{...R,...P}},"parseFormValues"),handleValidation:ee,isSubmitting:w.isPending,isLoading:I&&N&&D,onSubmit:Q,resetForm:Z}},"useCostCalculator");function G(t){let o=t.reduce((a,l)=>(a[l.name]=l.schema,a),{});return le(o)}n(G,"buildValidationSchema");function ce(t){let o="benefit-";return Object.keys(t).reduce((a,l)=>{let f={benefit_group_slug:l.replace(o,""),benefit_tier_slug:t[l]};return[...a,f]},[])}n(ce,"formatBenefits");function $(t,o=M){return{employer_currency_slug:t.currency,include_benefits:o.includeBenefits,include_cost_breakdowns:o.includeCostBreakdowns,include_premium_benefits:o.includePremiumBenefits,employments:[{region_slug:t.region||t.country,annual_gross_salary:t.salary,annual_gross_salary_in_employer_currency:t.salary,employment_term:t.contract_duration_type??"fixed",title:o.title,age:t.age??void 0,...t.benefits&&{benefits:ce(t.benefits)}}]}}n($,"buildPayload");export{G as a,$ as b,M as c,be as d};
|
|
2
|
+
//# sourceMappingURL=chunk-PIIDSBAO.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/flows/CostCalculator/utils.ts","../src/flows/CostCalculator/hooks.tsx"],"sourcesContent":["import type { CostCalculatorEstimateParams } from '@/src/client';\n\nimport { $TSFixMe } from '@/src/types/remoteFlows';\nimport { AnyObjectSchema, object } from 'yup';\nimport { defaultEstimationOptions } from './hooks';\nimport type {\n CostCalculatorEstimationOptions,\n CostCalculatorEstimationSubmitValues,\n} from './types';\n\n/**\n * Build the validation schema for the form.\n * @returns\n */\nexport function buildValidationSchema(fields: $TSFixMe[]) {\n const fieldsSchema = fields.reduce<Record<string, AnyObjectSchema>>(\n (fieldsSchemaAcc, field) => {\n fieldsSchemaAcc[field.name] = field.schema as AnyObjectSchema;\n return fieldsSchemaAcc;\n },\n {},\n );\n return object(fieldsSchema) as AnyObjectSchema;\n}\n\n/**\n * Format the benefits to the expected format by the API.\n * @param benefits\n * @returns\n */\nfunction formatBenefits(benefits: Record<string, string>) {\n const needle = 'benefit-';\n return Object.keys(benefits).reduce<\n Array<{ benefit_group_slug: string; benefit_tier_slug: string }>\n >((acc, key) => {\n const benefitGroupSlug = key.replace(needle, '');\n const benefitEntry = {\n benefit_group_slug: benefitGroupSlug,\n benefit_tier_slug: benefits[key],\n };\n return [...acc, benefitEntry];\n }, []);\n}\n\n/**\n * Build the payload for the cost calculator estimation.\n * @param values\n * @param estimationOptions\n * @returns\n */\nexport function buildPayload(\n values: CostCalculatorEstimationSubmitValues,\n estimationOptions: CostCalculatorEstimationOptions = defaultEstimationOptions,\n): CostCalculatorEstimateParams {\n return {\n employer_currency_slug: values.currency,\n include_benefits: estimationOptions.includeBenefits,\n include_cost_breakdowns: estimationOptions.includeCostBreakdowns,\n include_premium_benefits: estimationOptions.includePremiumBenefits,\n employments: [\n {\n region_slug: values.region || values.country,\n annual_gross_salary: values.salary,\n annual_gross_salary_in_employer_currency: values.salary,\n employment_term: values.contract_duration_type ?? 'fixed',\n title: estimationOptions.title,\n age: values.age ?? undefined,\n ...(values.benefits && { benefits: formatBenefits(values.benefits) }),\n },\n ],\n };\n}\n","import {\n CostCalculatorEstimateResponse,\n MinimalRegion,\n PostCreateEstimationError,\n} from '@/src/client';\nimport { jsonSchema } from '@/src/flows/CostCalculator/jsonSchema';\nimport type {\n CostCalculatorEstimationFormValues,\n CostCalculatorEstimationOptions,\n CostCalculatorEstimationSubmitValues,\n} from '@/src/flows/CostCalculator/types';\nimport type { JSFModify, Result } from '@/src/flows/types';\n\nimport { parseJSFToValidate } from '@/src/components/form/utils';\nimport { iterateErrors } from '@/src/components/form/yupValidationResolver';\nimport { createHeadlessForm, modify } from '@remoteoss/json-schema-form';\nimport { useMemo, useState } from 'react';\nimport { string, ValidationError } from 'yup';\nimport { buildPayload, buildValidationSchema } from './utils';\nimport {\n useCompanyCurrencies,\n useCostCalculatorCountries,\n useCostCalculatorEstimation,\n useRegionFields,\n} from '@/src/flows/CostCalculator/api';\nimport { JSFField } from '@/src/types/remoteFlows';\nimport { SalaryField } from '@/src/flows/CostCalculator/components/SalaryField';\n\ntype CostCalculatorCountry = {\n value: string;\n label: string;\n childRegions: MinimalRegion[];\n hasAdditionalFields: boolean | undefined;\n regionSlug: string;\n currency: string;\n};\n\ntype JSFValidationError = {\n formErrors: Record<\n string,\n {\n type: string;\n message: string;\n }\n >;\n yupError: ValidationError;\n};\n\nexport const defaultEstimationOptions: CostCalculatorEstimationOptions = {\n title: 'Estimation',\n includeBenefits: false,\n includeCostBreakdowns: false,\n includePremiumBenefits: false,\n enableCurrencyConversion: false,\n};\n\ntype UseCostCalculatorParams = {\n /**\n * The default region slug to preselect a country and a region.\n */\n defaultRegion?: string;\n /**\n * The estimation options.\n */\n estimationOptions: CostCalculatorEstimationOptions;\n options?: {\n jsfModify?: JSFModify;\n };\n};\n\nexport type EstimationError = PostCreateEstimationError | ValidationError;\n\nconst useStaticSchema = (options?: { jsfModify?: JSFModify }) => {\n const { schema: jsonSchemaModified } = modify(\n jsonSchema.data.schema,\n options?.jsfModify || {},\n );\n\n return createHeadlessForm(jsonSchemaModified);\n};\n\n/**\n * Hook to use the cost calculator.\n */\nexport const useCostCalculator = (\n { defaultRegion, estimationOptions, options }: UseCostCalculatorParams = {\n estimationOptions: defaultEstimationOptions,\n },\n) => {\n const [selectedRegion, setSelectedRegion] = useState<string | undefined>(\n defaultRegion,\n );\n const [selectedCountry, setSelectedCountry] =\n useState<CostCalculatorCountry>();\n const [employerBillingCurrency, setEmployerBillingCurrency] = useState<\n string | undefined\n >();\n const { data: countries, isLoading: isLoadingCountries } =\n useCostCalculatorCountries({\n includePremiumBenefits: estimationOptions.includePremiumBenefits,\n });\n const { data: currencies, isLoading: isLoadingCurrencies } =\n useCompanyCurrencies();\n\n const jsonSchemaRegionSlug = selectedRegion || selectedCountry?.value;\n\n const { data: jsonSchemaRegionFields, isLoading: isLoadingRegionFields } =\n useRegionFields(jsonSchemaRegionSlug, {\n includePremiumBenefits: estimationOptions.includePremiumBenefits,\n options,\n });\n const costCalculatorEstimationMutation = useCostCalculatorEstimation();\n const employeeBillingCurrency = selectedCountry?.currency;\n\n const salaryField = options?.jsfModify?.fields?.salary;\n const salaryFieldPresentation =\n salaryField &&\n typeof salaryField === 'object' &&\n 'presentation' in salaryField\n ? (\n salaryField as {\n presentation?: {\n salary_conversion_properties?: {\n label?: string;\n description?: string;\n };\n };\n }\n ).presentation\n : undefined;\n\n const customFields = useMemo(() => {\n const shouldUseCurrencyConversion = Boolean(\n estimationOptions.enableCurrencyConversion &&\n employeeBillingCurrency &&\n employerBillingCurrency &&\n employeeBillingCurrency !== employerBillingCurrency,\n );\n\n console.log({\n shouldUseCurrencyConversion,\n employeeBillingCurrency,\n employerBillingCurrency,\n enableCurrencyConversion: estimationOptions.enableCurrencyConversion,\n });\n\n if (shouldUseCurrencyConversion) {\n return {\n fields: {\n salary: {\n ...salaryField,\n presentation: {\n salary_conversion_properties: {\n label:\n salaryFieldPresentation?.salary_conversion_properties?.label,\n description:\n salaryFieldPresentation?.salary_conversion_properties\n ?.description,\n },\n currencies: {\n from: employeeBillingCurrency,\n to: employerBillingCurrency,\n },\n Component: (\n props: JSFField & { currencies: { from: string; to: string } },\n ) => {\n return <SalaryField {...props} />;\n },\n },\n },\n },\n };\n }\n\n return undefined;\n }, [\n employeeBillingCurrency,\n employerBillingCurrency,\n estimationOptions.enableCurrencyConversion,\n salaryField,\n salaryFieldPresentation?.salary_conversion_properties?.description,\n salaryFieldPresentation?.salary_conversion_properties?.label,\n ]);\n\n const fieldsJSONSchema = useStaticSchema({\n jsfModify: {\n fields: {\n ...options?.jsfModify?.fields,\n ...customFields?.fields,\n },\n },\n });\n\n /**\n * Submit the estimation form with the given values.\n * @param values\n */\n async function onSubmit(\n values: CostCalculatorEstimationSubmitValues,\n ): Promise<Result<CostCalculatorEstimateResponse, EstimationError>> {\n try {\n await validationSchema.validate(values, { abortEarly: false });\n } catch (err) {\n return {\n data: null,\n error: err as ValidationError,\n };\n }\n\n return new Promise((resolve, reject) => {\n costCalculatorEstimationMutation.mutate(\n buildPayload(values, estimationOptions),\n {\n onSuccess: (response) => {\n if (response.data) {\n resolve({\n data: response.data,\n error: null,\n });\n } else {\n resolve({\n data: null,\n error: new Error(\n 'Something went wrong. Please try again later.',\n ),\n });\n }\n },\n onError: (error) => {\n reject({\n data: null,\n error: error as PostCreateEstimationError,\n });\n },\n },\n );\n });\n }\n\n /**\n * If the selected country has no child regions and has additional fields,\n * set the current region to the country's region slug and fetch the region fields.\n * @param country\n */\n function onCountryChange(country: string) {\n const currentCountry = countries?.find(({ value }) => value === country);\n\n if (\n currentCountry &&\n currentCountry.childRegions.length === 0 &&\n currentCountry.hasAdditionalFields\n ) {\n setSelectedRegion(currentCountry.regionSlug);\n } else {\n setSelectedRegion(undefined);\n }\n setSelectedCountry(currentCountry);\n }\n\n /**\n * Update the selected region and fetch the region fields.\n * @param region\n */\n function onRegionChange(region: string) {\n setSelectedRegion(region);\n }\n\n function onChangeCurrency(currency: string) {\n const selectedCurrency = currencies?.find(\n (c) => c.value === currency,\n )?.label;\n setEmployerBillingCurrency(selectedCurrency);\n }\n\n const regionField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'region',\n );\n\n if (regionField) {\n const regions =\n selectedCountry?.childRegions.map((region) => ({\n value: region.slug,\n label: region.name,\n })) ?? [];\n regionField.options = regions;\n regionField.isVisible = regions.length > 0;\n regionField.required = regions.length > 0;\n regionField.onChange = onRegionChange;\n regionField.schema =\n regions.length > 0\n ? string()\n .transform((value) => (typeof value === 'string' ? value : ''))\n .required('Region is required')\n : string();\n }\n\n if (currencies) {\n const currencyField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'currency',\n );\n if (currencyField) {\n currencyField.options = currencies;\n currencyField.onChange = onChangeCurrency;\n }\n }\n\n if (countries) {\n const countryField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'country',\n );\n if (countryField) {\n countryField.options = countries;\n countryField.onChange = onCountryChange;\n }\n }\n\n const resetForm = () => {\n setSelectedCountry(undefined);\n setSelectedRegion(defaultRegion);\n };\n\n const allFields = [\n ...fieldsJSONSchema.fields,\n ...(jsonSchemaRegionFields?.fields || []),\n ];\n\n const validationSchema = buildValidationSchema(fieldsJSONSchema.fields);\n\n async function handleValidation(values: CostCalculatorEstimationFormValues) {\n let errors: JSFValidationError | null = null;\n\n const parsedValues = parseJSFToValidate(values, allFields);\n\n // 1. validate static fields first using Yup validate function\n try {\n await validationSchema.validate(parsedValues, {\n abortEarly: false,\n });\n errors = {\n formErrors: {},\n yupError: new ValidationError([], values),\n };\n } catch (error) {\n const iterateResult = iterateErrors(error as ValidationError);\n\n errors = {\n // convert the errors to a format that can be used in the form\n formErrors: Object.entries(iterateResult).reduce(\n (acc, [key, value]) => ({ ...acc, [key]: value.message }),\n {},\n ),\n yupError: error as ValidationError,\n };\n }\n\n // 2. validate json schema fields using the handleValidation (from json-schema-form)\n const handleValidationResult =\n jsonSchemaRegionFields?.handleValidation(parsedValues);\n\n // 3. combine the errors from both validations\n const combinedInnerErrors = [\n ...(errors?.yupError.inner || []),\n ...(handleValidationResult?.yupError?.inner || []),\n ];\n const combinedValues = {\n ...(errors?.yupError?.value || {}),\n ...(handleValidationResult?.yupError?.value || {}),\n };\n\n return {\n formErrors: {\n ...(errors?.formErrors || {}),\n ...(handleValidationResult?.formErrors || {}),\n },\n yupError: new ValidationError(combinedInnerErrors, combinedValues),\n };\n }\n\n return {\n stepState: {\n current: 0,\n total: 1,\n isLastStep: true,\n },\n fields: allFields,\n validationSchema,\n parseFormValues: (\n values: CostCalculatorEstimationFormValues,\n ): CostCalculatorEstimationSubmitValues => {\n const { country, region, salary, currency, ...rest } = values;\n const jsonSchemaStaticFieldValues = {\n country,\n region,\n salary,\n currency,\n };\n const parsedStaticFields = parseJSFToValidate(\n jsonSchemaStaticFieldValues,\n fieldsJSONSchema.fields,\n );\n\n const parsedRegionFields = parseJSFToValidate(\n rest,\n jsonSchemaRegionFields?.fields || [],\n );\n\n return {\n ...parsedStaticFields,\n ...parsedRegionFields,\n } as CostCalculatorEstimationSubmitValues;\n },\n handleValidation,\n isSubmitting: costCalculatorEstimationMutation.isPending,\n isLoading:\n isLoadingCountries && isLoadingCurrencies && isLoadingRegionFields,\n onSubmit,\n resetForm,\n };\n};\n"],"mappings":"qQAGA,OAA0B,UAA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BR,EAAAO,EAAA","names":["object","createHeadlessForm","modify","useMemo","useState","string","ValidationError","jsx","defaultEstimationOptions","useStaticSchema","__name","options","jsonSchemaModified","modify","jsonSchema","createHeadlessForm","useCostCalculator","defaultRegion","estimationOptions","selectedRegion","setSelectedRegion","useState","selectedCountry","setSelectedCountry","employerBillingCurrency","setEmployerBillingCurrency","countries","isLoadingCountries","useCostCalculatorCountries","currencies","isLoadingCurrencies","useCompanyCurrencies","jsonSchemaRegionSlug","jsonSchemaRegionFields","isLoadingRegionFields","useRegionFields","costCalculatorEstimationMutation","useCostCalculatorEstimation","employeeBillingCurrency","salaryField","salaryFieldPresentation","customFields","useMemo","shouldUseCurrencyConversion","props","SalaryField","fieldsJSONSchema","onSubmit","values","validationSchema","err","resolve","reject","buildPayload","response","error","onCountryChange","country","currentCountry","value","onRegionChange","region","onChangeCurrency","currency","selectedCurrency","c","regionField","field","regions","string","currencyField","countryField","resetForm","allFields","buildValidationSchema","handleValidation","errors","parsedValues","parseJSFToValidate","ValidationError","iterateResult","iterateErrors","acc","key","handleValidationResult","combinedInnerErrors","combinedValues","salary","rest","parsedStaticFields","parsedRegionFields","buildValidationSchema","fields","fieldsSchema","fieldsSchemaAcc","field","object","__name","formatBenefits","benefits","needle","acc","key","benefitEntry","buildPayload","values","estimationOptions","defaultEstimationOptions"]}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-CG64S2K7.js";import"../../chunk-KSHK3ZPX.js";import"../../chunk-PIIDSBAO.js";import"../../chunk-LZ3R4ZK2.js";import"../../chunk-UPRUP24B.js";import"../../chunk-G3OSPYB5.js";import"../../chunk-XKSOWDLS.js";import"../../chunk-WVJDCDGZ.js";import"../../chunk-Q23DM4O3.js";import"../../chunk-PWUYHFON.js";import"../../chunk-WKK63LAY.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-RLETCEUU.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as CostCalculatorFlow};
|
|
2
2
|
//# sourceMappingURL=CostCalculatorFlow.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{c as a,d as b}from"../../chunk-
|
|
1
|
+
import{c as a,d as b}from"../../chunk-PIIDSBAO.js";import"../../chunk-LZ3R4ZK2.js";import"../../chunk-UPRUP24B.js";import"../../chunk-G3OSPYB5.js";import"../../chunk-XKSOWDLS.js";import"../../chunk-WVJDCDGZ.js";import"../../chunk-Q23DM4O3.js";import"../../chunk-PWUYHFON.js";import"../../chunk-WKK63LAY.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-RLETCEUU.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{a as defaultEstimationOptions,b as useCostCalculator};
|
|
2
2
|
//# sourceMappingURL=hooks.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../chunk-YJXRJTOH.js";import{a as j}from"../../chunk-MNO47WC2.js";import"../../chunk-WIRFNWEU.js";import"../../chunk-3NZ6PO4D.js";import"../../chunk-YO4OQIFP.js";import"../../chunk-32RYPLZK.js";import"../../chunk-PJCUSCO4.js";import"../../chunk-EEAMZPP6.js";import"../../chunk-FB5J7SRP.js";import{a as e}from"../../chunk-Y56L3QKM.js";import{a as g}from"../../chunk-3HPG2L62.js";import{a as f}from"../../chunk-KM4XVL2X.js";import{a as i}from"../../chunk-EV5YPN4F.js";import{a as h}from"../../chunk-DYB3RWP7.js";import{a as d}from"../../chunk-
|
|
1
|
+
import"../../chunk-YJXRJTOH.js";import{a as j}from"../../chunk-MNO47WC2.js";import"../../chunk-WIRFNWEU.js";import"../../chunk-3NZ6PO4D.js";import"../../chunk-YO4OQIFP.js";import"../../chunk-32RYPLZK.js";import"../../chunk-PJCUSCO4.js";import"../../chunk-EEAMZPP6.js";import"../../chunk-FB5J7SRP.js";import{a as e}from"../../chunk-Y56L3QKM.js";import{a as g}from"../../chunk-3HPG2L62.js";import{a as f}from"../../chunk-KM4XVL2X.js";import{a as i}from"../../chunk-EV5YPN4F.js";import{a as h}from"../../chunk-DYB3RWP7.js";import{a as d}from"../../chunk-CG64S2K7.js";import"../../chunk-KSHK3ZPX.js";import{b as a,d as c}from"../../chunk-PIIDSBAO.js";import"../../chunk-LZ3R4ZK2.js";import"../../chunk-UPRUP24B.js";import"../../chunk-G3OSPYB5.js";import"../../chunk-XKSOWDLS.js";import"../../chunk-WVJDCDGZ.js";import{d as b}from"../../chunk-Q23DM4O3.js";import"../../chunk-PWUYHFON.js";import"../../chunk-WKK63LAY.js";import"../../chunk-2NLOH7NZ.js";import"../../chunk-XO3JWN33.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-RLETCEUU.js";import"../../chunk-GEYFQVQI.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{i as CostCalculatorDisclaimer,d as CostCalculatorFlow,e as CostCalculatorForm,g as CostCalculatorResetButton,j as CostCalculatorResults,f as CostCalculatorSubmitButton,a as buildCostCalculatorEstimationPayload,h as disclaimerData,c as useCostCalculator,b as useCostCalculatorEstimationPdf};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a,b}from"../../chunk-
|
|
1
|
+
import{a,b}from"../../chunk-PIIDSBAO.js";import"../../chunk-LZ3R4ZK2.js";import"../../chunk-UPRUP24B.js";import"../../chunk-G3OSPYB5.js";import"../../chunk-XKSOWDLS.js";import"../../chunk-WVJDCDGZ.js";import"../../chunk-Q23DM4O3.js";import"../../chunk-PWUYHFON.js";import"../../chunk-WKK63LAY.js";import"../../chunk-CFIJKJXD.js";import"../../chunk-RLETCEUU.js";import"../../chunk-3ZWDIEEM.js";import"../../chunk-VNSF5IOL.js";import"../../chunk-MH6KKP6K.js";import"../../chunk-KPHSEIR3.js";import"../../chunk-P37U34EQ.js";export{b as buildPayload,a as buildValidationSchema};
|
|
2
2
|
//# sourceMappingURL=utils.js.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"./chunk-M22FKNEY.js";import{a as tr}from"./chunk-MYGO6KUI.js";import"./chunk-LLIGZSYY.js";import"./chunk-JXCJLQRA.js";import"./chunk-WASEFJAE.js";import"./chunk-HSW5HMHH.js";import"./chunk-VX2UC3HG.js";import"./chunk-XSHHMBMT.js";import"./chunk-XFD3ULUF.js";import"./chunk-JODJFARP.js";import"./chunk-WWANHPT7.js";import"./chunk-W5DG5WWJ.js";import"./chunk-S4XU4SE7.js";import"./chunk-26PHG6H2.js";import"./chunk-X3YONWNH.js";import"./chunk-RDLTU3FE.js";import"./chunk-BF7QENCN.js";import"./chunk-ZUNKCQBT.js";import"./chunk-6SWZH7KI.js";import"./chunk-MRYRNB7Y.js";import"./chunk-GULCZWSK.js";import{a as or}from"./chunk-QXMSFJVB.js";import"./chunk-7TOZZQQJ.js";import"./chunk-T6LHPVKN.js";import"./chunk-76CE6Z77.js";import"./chunk-U6PYTUGP.js";import"./chunk-EAORGT7Z.js";import"./chunk-MSBG52WO.js";import"./chunk-DKJZB2TO.js";import"./chunk-7ZH23EMZ.js";import"./chunk-FUIQ7D6L.js";import"./chunk-KFVOK5X5.js";import"./chunk-PGWKJ6FK.js";import"./chunk-CU75S5F2.js";import"./chunk-ZEUIOZB6.js";import"./chunk-XIPPSRO6.js";import"./chunk-YJXRJTOH.js";import{a as E}from"./chunk-MNO47WC2.js";import"./chunk-WIRFNWEU.js";import"./chunk-3NZ6PO4D.js";import"./chunk-YO4OQIFP.js";import"./chunk-32RYPLZK.js";import"./chunk-PJCUSCO4.js";import"./chunk-EEAMZPP6.js";import"./chunk-FB5J7SRP.js";import{a as R}from"./chunk-Y56L3QKM.js";import{a as z}from"./chunk-3HPG2L62.js";import{a as T}from"./chunk-KM4XVL2X.js";import"./chunk-A7ZJQCNU.js";import{a as B}from"./chunk-EV5YPN4F.js";import{a as _}from"./chunk-DYB3RWP7.js";import{a as F}from"./chunk-
|
|
1
|
+
import"./chunk-M22FKNEY.js";import{a as tr}from"./chunk-MYGO6KUI.js";import"./chunk-LLIGZSYY.js";import"./chunk-JXCJLQRA.js";import"./chunk-WASEFJAE.js";import"./chunk-HSW5HMHH.js";import"./chunk-VX2UC3HG.js";import"./chunk-XSHHMBMT.js";import"./chunk-XFD3ULUF.js";import"./chunk-JODJFARP.js";import"./chunk-WWANHPT7.js";import"./chunk-W5DG5WWJ.js";import"./chunk-S4XU4SE7.js";import"./chunk-26PHG6H2.js";import"./chunk-X3YONWNH.js";import"./chunk-RDLTU3FE.js";import"./chunk-BF7QENCN.js";import"./chunk-ZUNKCQBT.js";import"./chunk-6SWZH7KI.js";import"./chunk-MRYRNB7Y.js";import"./chunk-GULCZWSK.js";import{a as or}from"./chunk-QXMSFJVB.js";import"./chunk-7TOZZQQJ.js";import"./chunk-T6LHPVKN.js";import"./chunk-76CE6Z77.js";import"./chunk-U6PYTUGP.js";import"./chunk-EAORGT7Z.js";import"./chunk-MSBG52WO.js";import"./chunk-DKJZB2TO.js";import"./chunk-7ZH23EMZ.js";import"./chunk-FUIQ7D6L.js";import"./chunk-KFVOK5X5.js";import"./chunk-PGWKJ6FK.js";import"./chunk-CU75S5F2.js";import"./chunk-ZEUIOZB6.js";import"./chunk-XIPPSRO6.js";import"./chunk-YJXRJTOH.js";import{a as E}from"./chunk-MNO47WC2.js";import"./chunk-WIRFNWEU.js";import"./chunk-3NZ6PO4D.js";import"./chunk-YO4OQIFP.js";import"./chunk-32RYPLZK.js";import"./chunk-PJCUSCO4.js";import"./chunk-EEAMZPP6.js";import"./chunk-FB5J7SRP.js";import{a as R}from"./chunk-Y56L3QKM.js";import{a as z}from"./chunk-3HPG2L62.js";import{a as T}from"./chunk-KM4XVL2X.js";import"./chunk-A7ZJQCNU.js";import{a as B}from"./chunk-EV5YPN4F.js";import{a as _}from"./chunk-DYB3RWP7.js";import{a as F}from"./chunk-CG64S2K7.js";import"./chunk-KSHK3ZPX.js";import{b as y,d as P}from"./chunk-PIIDSBAO.js";import"./chunk-LZ3R4ZK2.js";import"./chunk-UPRUP24B.js";import"./chunk-G3OSPYB5.js";import"./chunk-XKSOWDLS.js";import"./chunk-WVJDCDGZ.js";import{d as k}from"./chunk-Q23DM4O3.js";import"./chunk-PWUYHFON.js";import{a as er}from"./chunk-FJ2XPRKU.js";import{a as H}from"./chunk-RXK4RLF6.js";import{a as ar}from"./chunk-AIEAUPO6.js";import{a as J,b as rr}from"./chunk-LX7QBDSF.js";import"./chunk-QW4JPW6J.js";import"./chunk-5SMMQQXP.js";import{a as p}from"./chunk-WKK63LAY.js";import"./chunk-PJBAQZ6G.js";import"./chunk-CTTXXEWI.js";import{a as G}from"./chunk-CSU6IQX3.js";import{a as Z}from"./chunk-MA4IML3T.js";import"./chunk-2NLOH7NZ.js";import"./chunk-XO3JWN33.js";import"./chunk-CFIJKJXD.js";import"./chunk-RLETCEUU.js";import"./chunk-GEYFQVQI.js";import{a as g,c as v}from"./chunk-3ZWDIEEM.js";import"./chunk-VNSF5IOL.js";import"./chunk-MH6KKP6K.js";import"./chunk-TVZAFTPT.js";import{c as C}from"./chunk-KPHSEIR3.js";import{a as e}from"./chunk-P37U34EQ.js";import{QueryClient as L,QueryClientProvider as q}from"@tanstack/react-query";function l(r){let a=document.documentElement;Object.keys(r).forEach(t=>{let o=r[t];o&&a.style.setProperty(t,o)})}e(l,"setCssProperties");function S(r){let a={};return Object.keys(r).forEach(t=>{a[`--${t}`]=r[t]}),a}e(S,"mapThemeColors");function N(r){return{"--spacing":r}}e(N,"mapThemeSpacing");function O(r){return{"--radius":r}}e(O,"mapThemeBorderRadius");function j(r){return{"--fontSizeBase":r.fontSizeBase}}e(j,"mapThemeFont");function h(r){r?.colors&&l(S(r.colors)),r?.spacing&&l(N(r.spacing)),r?.borderRadius&&l(O(r.borderRadius)),r?.font&&l(j(r.font))}e(h,"applyTheme");import{createContext as D,useEffect as I,useMemo as A}from"react";import{jsx as V}from"react/jsx-runtime";var K=D({theme:{}});function u(r){I(()=>{r.theme&&Object.keys(r.theme).length>0&&h(r.theme)},[r.theme]);let a=A(()=>({theme:r.theme}),[r.theme]);return V(K.Provider,{value:a,children:r.children})}e(u,"ThemeProvider");var m={partners:"https://gateway.partners.remote-sandbox.com",production:"https://gateway.remote.com",sandbox:"https://gateway.remote-sandbox.com",staging:"https://gateway.niceremote.com"};import{createClient as U}from"@hey-api/client-fetch";import{useQuery as W}from"@tanstack/react-query";import{useRef as w}from"react";function M(r){try{return new URL(r),!0}catch{return!1}}e(M,"isValidUrl");var f=e(({auth:r,options:a})=>{let t=w(null),{refetch:o}=W({queryKey:["auth"],queryFn:r,enabled:!1}),c=a?.environment?m[a?.environment]:"https://gateway.remote.com",s=p.getConfig(),x="0.4.0-alpha.19",d=!!a?.proxy&&M(a.proxy.url);return a?.proxy&&!d&&console.error("Invalid proxy URL provided. Using default base URL."),w(U({...s,headers:{...s.headers,...d?a?.proxy?.headers:{},"X-Client-Name":"remote-flows-sdk","X-Client-Version":x},baseUrl:d?a.proxy?.url:c,auth:e(async()=>{function b(i){return!i||Date.now()+6e4>i}if(e(b,"hasTokenExpired"),!t.current||b(t.current.expiresAt)){let{data:i}=await o();i&&(t.current={accessToken:i.accessToken,expiresAt:Date.now()+i.expiresIn*1e3})}return t.current?.accessToken},"auth")}))},"useAuth");import{jsx as n}from"react/jsx-runtime";var Q=new L;function X({children:r,auth:a,proxy:t,environment:o}){let c=f({auth:a,options:{proxy:t,environment:o}});return n(v.Provider,{value:{client:c.current},children:r})}e(X,"RemoteFlowContextWrapper");function Y({children:r,components:a}){return n(g.Provider,{value:a?{components:a}:{components:{}},children:r})}e(Y,"FormFieldsProvider");function $({auth:r,children:a,components:t,theme:o,proxy:c,environment:s}){return n(q,{client:Q,children:n(Y,{components:t,children:n(X,{auth:r,proxy:c,environment:s,children:n(u,{theme:o,children:a})})})})}e($,"RemoteFlows");export{G as ContractAmendmentConfirmationForm,er as ContractAmendmentFlow,Z as ContractAmendmentForm,H as ContractAmendmentSubmit,B as CostCalculatorDisclaimer,F as CostCalculatorFlow,R as CostCalculatorForm,z as CostCalculatorResetButton,E as CostCalculatorResults,T as CostCalculatorSubmitButton,or as OnboardingFlow,$ as RemoteFlows,tr as TerminationFlow,y as buildCostCalculatorEstimationPayload,_ as disclaimerData,C as transformYupErrorsIntoObject,ar as useContractAmendment,P as useCostCalculator,k as useCostCalculatorEstimationPdf,J as useEmploymentQuery,rr as useTimeOffQuery};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
package/dist/chunk-Y5SFM4H7.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as k}from"./chunk-LZ3R4ZK2.js";import{a as v}from"./chunk-UPRUP24B.js";import{a as L,b as x,c as A,e as U}from"./chunk-Q23DM4O3.js";import{a as O}from"./chunk-CFIJKJXD.js";import{c as g}from"./chunk-MH6KKP6K.js";import{a as o}from"./chunk-P37U34EQ.js";import{object as le}from"yup";import{createHeadlessForm as oe,modify as ne}from"@remoteoss/json-schema-form";import{useMemo as ie,useState as j}from"react";import{string as q,ValidationError as T}from"yup";import{jsx as ae}from"react/jsx-runtime";var M={title:"Estimation",includeBenefits:!1,includeCostBreakdowns:!1,includePremiumBenefits:!1,enableCurrencyConversion:!1},se=o(t=>{let{schema:n}=ne(v.data.schema,t?.jsfModify||{});return oe(n)},"useStaticSchema"),Se=o(({defaultRegion:t,estimationOptions:n,options:a}={estimationOptions:M})=>{let[l,m]=j(t),[f,B]=j(),[y,H]=j(),{data:E,isLoading:I}=L({includePremiumBenefits:n.includePremiumBenefits}),{data:S,isLoading:N}=x(),z=l||f?.value,{data:b,isLoading:D}=U(z,{includePremiumBenefits:n.includePremiumBenefits,options:a}),w=A(),p=f?.currency,c=a?.jsfModify?.fields?.salary,C=c&&typeof c=="object"&&"presentation"in c?c.presentation:void 0,K=ie(()=>{if(n.enableCurrencyConversion&&p&&y&&p!==y)return{fields:{salary:{...c,presentation:{salary_conversion_properties:{label:C?.salary_conversion_properties?.label,description:C?.salary_conversion_properties?.description},currencies:{from:p,to:y},Component:o(e=>ae(k,{...e}),"Component")}}}}},[p,y,n.enableCurrencyConversion,c,C?.salary_conversion_properties?.description,C?.salary_conversion_properties?.label]),u=se({jsfModify:{fields:{...a?.jsfModify?.fields,...K?.fields}}});async function Q(r){try{await h.validate(r,{abortEarly:!1})}catch(e){return{data:null,error:e}}return new Promise((e,i)=>{w.mutate($(r,n),{onSuccess:o(s=>{s.data?e({data:s.data,error:null}):e({data:null,error:new Error("Something went wrong. Please try again later.")})},"onSuccess"),onError:o(s=>{i({data:null,error:s})},"onError")})})}o(Q,"onSubmit");function W(r){let e=E?.find(({value:i})=>i===r);e&&e.childRegions.length===0&&e.hasAdditionalFields?m(e.regionSlug):m(void 0),B(e)}o(W,"onCountryChange");function X(r){m(r)}o(X,"onRegionChange");function Y(r){let e=S?.find(i=>i.value===r)?.label;H(e)}o(Y,"onChangeCurrency");let d=u.fields.find(r=>r.name==="region");if(d){let r=f?.childRegions.map(e=>({value:e.slug,label:e.name}))??[];d.options=r,d.isVisible=r.length>0,d.required=r.length>0,d.onChange=X,d.schema=r.length>0?q().transform(e=>typeof e=="string"?e:"").required("Region is required"):q()}if(S){let r=u.fields.find(e=>e.name==="currency");r&&(r.options=S,r.onChange=Y)}if(E){let r=u.fields.find(e=>e.name==="country");r&&(r.options=E,r.onChange=W)}let Z=o(()=>{B(void 0),m(t)},"resetForm"),J=[...u.fields,...b?.fields||[]],h=G(u.fields);async function ee(r){let e=null,i=g(r,J);try{await h.validate(i,{abortEarly:!1}),e={formErrors:{},yupError:new T([],r)}}catch(V){let R=O(V);e={formErrors:Object.entries(R).reduce((P,[re,te])=>({...P,[re]:te.message}),{}),yupError:V}}let s=b?.handleValidation(i),_=[...e?.yupError.inner||[],...s?.yupError?.inner||[]],F={...e?.yupError?.value||{},...s?.yupError?.value||{}};return{formErrors:{...e?.formErrors||{},...s?.formErrors||{}},yupError:new T(_,F)}}return o(ee,"handleValidation"),{stepState:{current:0,total:1,isLastStep:!0},fields:J,validationSchema:h,parseFormValues:o(r=>{let{country:e,region:i,salary:s,currency:_,...F}=r,R=g({country:e,region:i,salary:s,currency:_},u.fields),P=g(F,b?.fields||[]);return{...R,...P}},"parseFormValues"),handleValidation:ee,isSubmitting:w.isPending,isLoading:I&&N&&D,onSubmit:Q,resetForm:Z}},"useCostCalculator");function G(t){let n=t.reduce((a,l)=>(a[l.name]=l.schema,a),{});return le(n)}o(G,"buildValidationSchema");function ce(t){let n="benefit-";return Object.keys(t).reduce((a,l)=>{let f={benefit_group_slug:l.replace(n,""),benefit_tier_slug:t[l]};return[...a,f]},[])}o(ce,"formatBenefits");function $(t,n=M){return{employer_currency_slug:t.currency,include_benefits:n.includeBenefits,include_cost_breakdowns:n.includeCostBreakdowns,include_premium_benefits:n.includePremiumBenefits,employments:[{region_slug:t.region||t.country,annual_gross_salary:t.salary,annual_gross_salary_in_employer_currency:t.salary,employment_term:t.contract_duration_type??"fixed",title:n.title,age:t.age??void 0,...t.benefits&&{benefits:ce(t.benefits)}}]}}o($,"buildPayload");export{G as a,$ as b,M as c,Se as d};
|
|
2
|
-
//# sourceMappingURL=chunk-Y5SFM4H7.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/flows/CostCalculator/utils.ts","../src/flows/CostCalculator/hooks.tsx"],"sourcesContent":["import type { CostCalculatorEstimateParams } from '@/src/client';\n\nimport { $TSFixMe } from '@/src/types/remoteFlows';\nimport { AnyObjectSchema, object } from 'yup';\nimport { defaultEstimationOptions } from './hooks';\nimport type {\n CostCalculatorEstimationOptions,\n CostCalculatorEstimationSubmitValues,\n} from './types';\n\n/**\n * Build the validation schema for the form.\n * @returns\n */\nexport function buildValidationSchema(fields: $TSFixMe[]) {\n const fieldsSchema = fields.reduce<Record<string, AnyObjectSchema>>(\n (fieldsSchemaAcc, field) => {\n fieldsSchemaAcc[field.name] = field.schema as AnyObjectSchema;\n return fieldsSchemaAcc;\n },\n {},\n );\n return object(fieldsSchema) as AnyObjectSchema;\n}\n\n/**\n * Format the benefits to the expected format by the API.\n * @param benefits\n * @returns\n */\nfunction formatBenefits(benefits: Record<string, string>) {\n const needle = 'benefit-';\n return Object.keys(benefits).reduce<\n Array<{ benefit_group_slug: string; benefit_tier_slug: string }>\n >((acc, key) => {\n const benefitGroupSlug = key.replace(needle, '');\n const benefitEntry = {\n benefit_group_slug: benefitGroupSlug,\n benefit_tier_slug: benefits[key],\n };\n return [...acc, benefitEntry];\n }, []);\n}\n\n/**\n * Build the payload for the cost calculator estimation.\n * @param values\n * @param estimationOptions\n * @returns\n */\nexport function buildPayload(\n values: CostCalculatorEstimationSubmitValues,\n estimationOptions: CostCalculatorEstimationOptions = defaultEstimationOptions,\n): CostCalculatorEstimateParams {\n return {\n employer_currency_slug: values.currency,\n include_benefits: estimationOptions.includeBenefits,\n include_cost_breakdowns: estimationOptions.includeCostBreakdowns,\n include_premium_benefits: estimationOptions.includePremiumBenefits,\n employments: [\n {\n region_slug: values.region || values.country,\n annual_gross_salary: values.salary,\n annual_gross_salary_in_employer_currency: values.salary,\n employment_term: values.contract_duration_type ?? 'fixed',\n title: estimationOptions.title,\n age: values.age ?? undefined,\n ...(values.benefits && { benefits: formatBenefits(values.benefits) }),\n },\n ],\n };\n}\n","import {\n CostCalculatorEstimateResponse,\n MinimalRegion,\n PostCreateEstimationError,\n} from '@/src/client';\nimport { jsonSchema } from '@/src/flows/CostCalculator/jsonSchema';\nimport type {\n CostCalculatorEstimationFormValues,\n CostCalculatorEstimationOptions,\n CostCalculatorEstimationSubmitValues,\n} from '@/src/flows/CostCalculator/types';\nimport type { JSFModify, Result } from '@/src/flows/types';\n\nimport { parseJSFToValidate } from '@/src/components/form/utils';\nimport { iterateErrors } from '@/src/components/form/yupValidationResolver';\nimport { createHeadlessForm, modify } from '@remoteoss/json-schema-form';\nimport { useMemo, useState } from 'react';\nimport { string, ValidationError } from 'yup';\nimport { buildPayload, buildValidationSchema } from './utils';\nimport {\n useCompanyCurrencies,\n useCostCalculatorCountries,\n useCostCalculatorEstimation,\n useRegionFields,\n} from '@/src/flows/CostCalculator/api';\nimport { JSFField } from '@/src/types/remoteFlows';\nimport { SalaryField } from '@/src/flows/CostCalculator/components/SalaryField';\n\ntype CostCalculatorCountry = {\n value: string;\n label: string;\n childRegions: MinimalRegion[];\n hasAdditionalFields: boolean | undefined;\n regionSlug: string;\n currency: string;\n};\n\ntype JSFValidationError = {\n formErrors: Record<\n string,\n {\n type: string;\n message: string;\n }\n >;\n yupError: ValidationError;\n};\n\nexport const defaultEstimationOptions: CostCalculatorEstimationOptions = {\n title: 'Estimation',\n includeBenefits: false,\n includeCostBreakdowns: false,\n includePremiumBenefits: false,\n enableCurrencyConversion: false,\n};\n\ntype UseCostCalculatorParams = {\n /**\n * The default region slug to preselect a country and a region.\n */\n defaultRegion?: string;\n /**\n * The estimation options.\n */\n estimationOptions: CostCalculatorEstimationOptions;\n options?: {\n jsfModify?: JSFModify;\n };\n};\n\nexport type EstimationError = PostCreateEstimationError | ValidationError;\n\nconst useStaticSchema = (options?: { jsfModify?: JSFModify }) => {\n const { schema: jsonSchemaModified } = modify(\n jsonSchema.data.schema,\n options?.jsfModify || {},\n );\n\n return createHeadlessForm(jsonSchemaModified);\n};\n\n/**\n * Hook to use the cost calculator.\n */\nexport const useCostCalculator = (\n { defaultRegion, estimationOptions, options }: UseCostCalculatorParams = {\n estimationOptions: defaultEstimationOptions,\n },\n) => {\n const [selectedRegion, setSelectedRegion] = useState<string | undefined>(\n defaultRegion,\n );\n const [selectedCountry, setSelectedCountry] =\n useState<CostCalculatorCountry>();\n const [employerBillingCurrency, setEmployerBillingCurrency] = useState<\n string | undefined\n >();\n const { data: countries, isLoading: isLoadingCountries } =\n useCostCalculatorCountries({\n includePremiumBenefits: estimationOptions.includePremiumBenefits,\n });\n const { data: currencies, isLoading: isLoadingCurrencies } =\n useCompanyCurrencies();\n\n const jsonSchemaRegionSlug = selectedRegion || selectedCountry?.value;\n\n const { data: jsonSchemaRegionFields, isLoading: isLoadingRegionFields } =\n useRegionFields(jsonSchemaRegionSlug, {\n includePremiumBenefits: estimationOptions.includePremiumBenefits,\n options,\n });\n const costCalculatorEstimationMutation = useCostCalculatorEstimation();\n const employeeBillingCurrency = selectedCountry?.currency;\n\n const salaryField = options?.jsfModify?.fields?.salary;\n const salaryFieldPresentation =\n salaryField &&\n typeof salaryField === 'object' &&\n 'presentation' in salaryField\n ? (\n salaryField as {\n presentation?: {\n salary_conversion_properties?: {\n label?: string;\n description?: string;\n };\n };\n }\n ).presentation\n : undefined;\n\n const customFields = useMemo(() => {\n const shouldUseCurrencyConversion =\n estimationOptions.enableCurrencyConversion &&\n employeeBillingCurrency &&\n employerBillingCurrency &&\n employeeBillingCurrency !== employerBillingCurrency;\n\n if (shouldUseCurrencyConversion) {\n return {\n fields: {\n salary: {\n ...salaryField,\n presentation: {\n salary_conversion_properties: {\n label:\n salaryFieldPresentation?.salary_conversion_properties?.label,\n description:\n salaryFieldPresentation?.salary_conversion_properties\n ?.description,\n },\n currencies: {\n from: employeeBillingCurrency,\n to: employerBillingCurrency,\n },\n Component: (\n props: JSFField & { currencies: { from: string; to: string } },\n ) => {\n return <SalaryField {...props} />;\n },\n },\n },\n },\n };\n }\n\n return undefined;\n }, [\n employeeBillingCurrency,\n employerBillingCurrency,\n estimationOptions.enableCurrencyConversion,\n salaryField,\n salaryFieldPresentation?.salary_conversion_properties?.description,\n salaryFieldPresentation?.salary_conversion_properties?.label,\n ]);\n\n const fieldsJSONSchema = useStaticSchema({\n jsfModify: {\n fields: {\n ...options?.jsfModify?.fields,\n ...customFields?.fields,\n },\n },\n });\n\n /**\n * Submit the estimation form with the given values.\n * @param values\n */\n async function onSubmit(\n values: CostCalculatorEstimationSubmitValues,\n ): Promise<Result<CostCalculatorEstimateResponse, EstimationError>> {\n try {\n await validationSchema.validate(values, { abortEarly: false });\n } catch (err) {\n return {\n data: null,\n error: err as ValidationError,\n };\n }\n\n return new Promise((resolve, reject) => {\n costCalculatorEstimationMutation.mutate(\n buildPayload(values, estimationOptions),\n {\n onSuccess: (response) => {\n if (response.data) {\n resolve({\n data: response.data,\n error: null,\n });\n } else {\n resolve({\n data: null,\n error: new Error(\n 'Something went wrong. Please try again later.',\n ),\n });\n }\n },\n onError: (error) => {\n reject({\n data: null,\n error: error as PostCreateEstimationError,\n });\n },\n },\n );\n });\n }\n\n /**\n * If the selected country has no child regions and has additional fields,\n * set the current region to the country's region slug and fetch the region fields.\n * @param country\n */\n function onCountryChange(country: string) {\n const currentCountry = countries?.find(({ value }) => value === country);\n\n if (\n currentCountry &&\n currentCountry.childRegions.length === 0 &&\n currentCountry.hasAdditionalFields\n ) {\n setSelectedRegion(currentCountry.regionSlug);\n } else {\n setSelectedRegion(undefined);\n }\n setSelectedCountry(currentCountry);\n }\n\n /**\n * Update the selected region and fetch the region fields.\n * @param region\n */\n function onRegionChange(region: string) {\n setSelectedRegion(region);\n }\n\n function onChangeCurrency(currency: string) {\n const selectedCurrency = currencies?.find(\n (c) => c.value === currency,\n )?.label;\n setEmployerBillingCurrency(selectedCurrency);\n }\n\n const regionField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'region',\n );\n\n if (regionField) {\n const regions =\n selectedCountry?.childRegions.map((region) => ({\n value: region.slug,\n label: region.name,\n })) ?? [];\n regionField.options = regions;\n regionField.isVisible = regions.length > 0;\n regionField.required = regions.length > 0;\n regionField.onChange = onRegionChange;\n regionField.schema =\n regions.length > 0\n ? string()\n .transform((value) => (typeof value === 'string' ? value : ''))\n .required('Region is required')\n : string();\n }\n\n if (currencies) {\n const currencyField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'currency',\n );\n if (currencyField) {\n currencyField.options = currencies;\n currencyField.onChange = onChangeCurrency;\n }\n }\n\n if (countries) {\n const countryField = fieldsJSONSchema.fields.find(\n (field) => field.name === 'country',\n );\n if (countryField) {\n countryField.options = countries;\n countryField.onChange = onCountryChange;\n }\n }\n\n const resetForm = () => {\n setSelectedCountry(undefined);\n setSelectedRegion(defaultRegion);\n };\n\n const allFields = [\n ...fieldsJSONSchema.fields,\n ...(jsonSchemaRegionFields?.fields || []),\n ];\n\n const validationSchema = buildValidationSchema(fieldsJSONSchema.fields);\n\n async function handleValidation(values: CostCalculatorEstimationFormValues) {\n let errors: JSFValidationError | null = null;\n\n const parsedValues = parseJSFToValidate(values, allFields);\n\n // 1. validate static fields first using Yup validate function\n try {\n await validationSchema.validate(parsedValues, {\n abortEarly: false,\n });\n errors = {\n formErrors: {},\n yupError: new ValidationError([], values),\n };\n } catch (error) {\n const iterateResult = iterateErrors(error as ValidationError);\n\n errors = {\n // convert the errors to a format that can be used in the form\n formErrors: Object.entries(iterateResult).reduce(\n (acc, [key, value]) => ({ ...acc, [key]: value.message }),\n {},\n ),\n yupError: error as ValidationError,\n };\n }\n\n // 2. validate json schema fields using the handleValidation (from json-schema-form)\n const handleValidationResult =\n jsonSchemaRegionFields?.handleValidation(parsedValues);\n\n // 3. combine the errors from both validations\n const combinedInnerErrors = [\n ...(errors?.yupError.inner || []),\n ...(handleValidationResult?.yupError?.inner || []),\n ];\n const combinedValues = {\n ...(errors?.yupError?.value || {}),\n ...(handleValidationResult?.yupError?.value || {}),\n };\n\n return {\n formErrors: {\n ...(errors?.formErrors || {}),\n ...(handleValidationResult?.formErrors || {}),\n },\n yupError: new ValidationError(combinedInnerErrors, combinedValues),\n };\n }\n\n return {\n stepState: {\n current: 0,\n total: 1,\n isLastStep: true,\n },\n fields: allFields,\n validationSchema,\n parseFormValues: (\n values: CostCalculatorEstimationFormValues,\n ): CostCalculatorEstimationSubmitValues => {\n const { country, region, salary, currency, ...rest } = values;\n const jsonSchemaStaticFieldValues = {\n country,\n region,\n salary,\n currency,\n };\n const parsedStaticFields = parseJSFToValidate(\n jsonSchemaStaticFieldValues,\n fieldsJSONSchema.fields,\n );\n\n const parsedRegionFields = parseJSFToValidate(\n rest,\n jsonSchemaRegionFields?.fields || [],\n );\n\n return {\n ...parsedStaticFields,\n ...parsedRegionFields,\n } as CostCalculatorEstimationSubmitValues;\n },\n handleValidation,\n isSubmitting: costCalculatorEstimationMutation.isPending,\n isLoading:\n isLoadingCountries && isLoadingCurrencies && isLoadingRegionFields,\n onSubmit,\n resetForm,\n };\n};\n"],"mappings":"qQAGA,OAA0B,UAAAA,OAAc,MCYxC,OAAS,sBAAAC,GAAoB,UAAAC,OAAc,8BAC3C,OAAS,WAAAC,GAAS,YAAAC,MAAgB,QAClC,OAAS,UAAAC,EAAQ,mBAAAC,MAAuB,MA6IjB,cAAAC,OAAA,oBA9GhB,IAAMC,EAA4D,CACvE,MAAO,aACP,gBAAiB,GACjB,sBAAuB,GACvB,uBAAwB,GACxB,yBAA0B,EAC5B,EAkBMC,GAAkBC,EAACC,GAAwC,CAC/D,GAAM,CAAE,OAAQC,CAAmB,EAAIC,GACrCC,EAAW,KAAK,OAChBH,GAAS,WAAa,CAAC,CACzB,EAEA,OAAOI,GAAmBH,CAAkB,CAC9C,EAPwB,mBAYXI,GAAoBN,EAAA,CAC/B,CAAE,cAAAO,EAAe,kBAAAC,EAAmB,QAAAP,CAAQ,EAA6B,CACvE,kBAAmBH,CACrB,IACG,CACH,GAAM,CAACW,EAAgBC,CAAiB,EAAIC,EAC1CJ,CACF,EACM,CAACK,EAAiBC,CAAkB,EACxCF,EAAgC,EAC5B,CAACG,EAAyBC,CAA0B,EAAIJ,EAE5D,EACI,CAAE,KAAMK,EAAW,UAAWC,CAAmB,EACrDC,EAA2B,CACzB,uBAAwBV,EAAkB,sBAC5C,CAAC,EACG,CAAE,KAAMW,EAAY,UAAWC,CAAoB,EACvDC,EAAqB,EAEjBC,EAAuBb,GAAkBG,G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B,uBAC5C,YAAa,CACX,CACE,YAAaD,EAAO,QAAUA,EAAO,QACrC,oBAAqBA,EAAO,OAC5B,yCAA0CA,EAAO,OACjD,gBAAiBA,EAAO,wBAA0B,QAClD,MAAOC,EAAkB,MACzB,IAAKD,EAAO,KAAO,OACnB,GAAIA,EAAO,UAAY,CAAE,SAAUP,GAAeO,EAAO,QAAQ,CAAE,CACrE,CACF,CACF,CACF,CArBgBR,EAAAO,EAAA","names":["object","createHeadlessForm","modify","useMemo","useState","string","ValidationError","jsx","defaultEstimationOptions","useStaticSchema","__name","options","jsonSchemaModified","modify","jsonSchema","createHeadlessForm","useCostCalculator","defaultRegion","estimationOptions","selectedRegion","setSelectedRegion","useState","selectedCountry","setSelectedCountry","employerBillingCurrency","setEmployerBillingCurrency","countries","isLoadingCountries","useCostCalculatorCountries","currencies","isLoadingCurrencies","useCompanyCurrencies","jsonSchemaRegionSlug","jsonSchemaRegionFields","isLoadingRegionFields","useRegionFields","costCalculatorEstimationMutation","useCostCalculatorEstimation","employeeBillingCurrency","salaryField","salaryFieldPresentation","customFields","useMemo","props","SalaryField","fieldsJSONSchema","onSubmit","values","validationSchema","err","resolve","reject","buildPayload","response","error","onCountryChange","country","currentCountry","value","onRegionChange","region","onChangeCurrency","currency","selectedCurrency","c","regionField","field","regions","string","currencyField","countryField","resetForm","allFields","buildValidationSchema","handleValidation","errors","parsedValues","parseJSFToValidate","ValidationError","iterateResult","iterateErrors","acc","key","handleValidationResult","combinedInnerErrors","combinedValues","salary","rest","parsedStaticFields","parsedRegionFields","buildValidationSchema","fields","fieldsSchema","fieldsSchemaAcc","field","object","__name","formatBenefits","benefits","needle","acc","key","benefitEntry","buildPayload","values","estimationOptions","defaultEstimationOptions"]}
|
|
File without changes
|