@remoteoss/remote-flows 0.4.0-alpha.3 → 0.4.0-alpha.5
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-2SDJ4PZ5.js +2 -0
- package/dist/chunk-2SDJ4PZ5.js.map +1 -0
- package/dist/chunk-2Y22JKVE.js +2 -0
- package/dist/chunk-3EQND6W7.js +2 -0
- package/dist/chunk-3EQND6W7.js.map +1 -0
- package/dist/{chunk-QOMUXX6W.js → chunk-3PH5E6CZ.js} +2 -2
- package/dist/chunk-4B7QPI2R.js +2 -0
- package/dist/chunk-4B7QPI2R.js.map +1 -0
- package/dist/{chunk-76JJOA3E.js → chunk-66UY5UHP.js} +2 -2
- package/dist/chunk-6UHKKHB6.js +2 -0
- package/dist/chunk-6UHKKHB6.js.map +1 -0
- package/dist/{chunk-P2COURSU.js → chunk-7CP4PNU4.js} +2 -2
- package/dist/chunk-A36XQBXQ.js +2 -0
- package/dist/chunk-A36XQBXQ.js.map +1 -0
- package/dist/{chunk-TXLTMGOU.js → chunk-ASMIUBMG.js} +2 -2
- package/dist/{chunk-FNTHWOZU.js → chunk-CIGSCITX.js} +2 -2
- package/dist/chunk-CVGR3FDH.js +2 -0
- package/dist/chunk-CVGR3FDH.js.map +1 -0
- package/dist/{chunk-JT5XHQEY.js → chunk-EAB7VHAW.js} +2 -2
- package/dist/{chunk-MI3HDT5D.js → chunk-FQLSGKCJ.js} +2 -2
- package/dist/chunk-G7BISHWK.js +2 -0
- package/dist/chunk-G7BISHWK.js.map +1 -0
- package/dist/{chunk-KGUR7YMA.js → chunk-GHT53KSP.js} +2 -2
- package/dist/chunk-GMU3QGAR.js +2 -0
- package/dist/chunk-GMU3QGAR.js.map +1 -0
- package/dist/{chunk-XOUAD7MS.js → chunk-KDRQW7SO.js} +2 -2
- package/dist/{chunk-YIBRPAR3.js → chunk-LRVJ53MM.js} +2 -2
- package/dist/{chunk-C4E24DUG.js → chunk-NJPLL3RR.js} +2 -2
- package/dist/{chunk-4N3CYS6F.js → chunk-PBUHBIVK.js} +2 -2
- package/dist/{chunk-GQD6NNYO.js → chunk-PX72OIDO.js} +2 -2
- package/dist/{chunk-OXOB35EA.js → chunk-PZKA77DU.js} +2 -2
- package/dist/{chunk-S4FKLPBB.js → chunk-TICIER55.js} +2 -2
- package/dist/{chunk-TGB3TV3K.js → chunk-VT2PJJC7.js} +2 -2
- package/dist/{chunk-D3SD6MMV.js → chunk-WEIRXEXU.js} +2 -2
- package/dist/chunk-WVJDCDGZ.js +2 -0
- package/dist/chunk-WVJDCDGZ.js.map +1 -0
- package/dist/{chunk-WZ5AXHQT.js → chunk-X7BVA4MH.js} +2 -2
- package/dist/chunk-Y4RTK2VE.js +2 -0
- package/dist/chunk-Y4RTK2VE.js.map +1 -0
- package/dist/{chunk-T3PTQ4QM.js → chunk-Y4ZFQBM3.js} +2 -2
- package/dist/{chunk-QOXOAPGX.js → chunk-ZKZDAXNJ.js} +2 -2
- package/dist/flows/ContractAmendment/ContractAmendmentConfirmationForm.d.ts +1 -1
- package/dist/flows/ContractAmendment/ContractAmendmentFlow.d.ts +1 -1
- 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 +1 -1
- package/dist/flows/ContractAmendment/hooks.d.ts +1 -1
- package/dist/flows/ContractAmendment/hooks.js +1 -1
- package/dist/flows/ContractAmendment/index.d.ts +1 -1
- package/dist/flows/ContractAmendment/index.js +1 -1
- package/dist/flows/ContractAmendment/types.d.ts +1 -1
- package/dist/flows/ContractAmendment/utils.d.ts +1 -1
- package/dist/flows/CostCalculator/CostCalculatorFlow.d.ts +1 -1
- package/dist/flows/CostCalculator/CostCalculatorFlow.js +1 -1
- package/dist/flows/CostCalculator/CostCalculatorForm.d.ts +1 -1
- package/dist/flows/CostCalculator/CostCalculatorForm.js +1 -1
- package/dist/flows/CostCalculator/Results/CostCalculatorResults.d.ts +1 -1
- package/dist/flows/CostCalculator/Results/CostCalculatorResults.js +1 -1
- package/dist/flows/CostCalculator/context.d.ts +1 -1
- package/dist/flows/CostCalculator/hooks.d.ts +1 -1
- package/dist/flows/CostCalculator/hooks.js +1 -1
- package/dist/flows/CostCalculator/index.d.ts +1 -1
- package/dist/flows/CostCalculator/index.js +1 -1
- package/dist/flows/CostCalculator/types.d.ts +1 -1
- package/dist/flows/CostCalculator/utils.d.ts +1 -1
- package/dist/flows/CostCalculator/utils.js +1 -1
- package/dist/flows/Onboarding/BasicInformationStep.d.ts +1 -1
- package/dist/flows/Onboarding/BasicInformationStep.js +1 -1
- package/dist/flows/Onboarding/BenefitsStep.d.ts +3 -2
- package/dist/flows/Onboarding/BenefitsStep.js +1 -1
- package/dist/flows/Onboarding/ContractDetailsStep.d.ts +1 -1
- package/dist/flows/Onboarding/ContractDetailsStep.js +1 -1
- package/dist/flows/Onboarding/OnboardingFlow.d.ts +8 -4
- package/dist/flows/Onboarding/OnboardingFlow.js +1 -1
- package/dist/flows/Onboarding/OnboardingForm.d.ts +3 -2
- package/dist/flows/Onboarding/OnboardingForm.js +1 -1
- package/dist/flows/Onboarding/OnboardingInvite.d.ts +1 -1
- package/dist/flows/Onboarding/OnboardingInvite.js +1 -1
- package/dist/flows/Onboarding/SelectCountryStep.d.ts +15 -0
- package/dist/flows/Onboarding/SelectCountryStep.js +2 -0
- package/dist/flows/Onboarding/SelectCountryStep.js.map +1 -0
- package/dist/flows/Onboarding/api.d.ts +114 -0
- package/dist/flows/Onboarding/api.js +2 -0
- package/dist/flows/Onboarding/api.js.map +1 -0
- package/dist/flows/Onboarding/context.d.ts +12 -5
- package/dist/flows/Onboarding/hooks.d.ts +25 -23
- package/dist/flows/Onboarding/hooks.js +1 -1
- package/dist/flows/Onboarding/index.d.ts +5 -4
- package/dist/flows/Onboarding/index.js +1 -1
- package/dist/flows/Onboarding/json-schemas/selectCountryStep.d.ts +24 -0
- package/dist/flows/Onboarding/json-schemas/selectCountryStep.js +2 -0
- package/dist/flows/Onboarding/json-schemas/selectCountryStep.js.map +1 -0
- package/dist/flows/Onboarding/types.d.ts +10 -3
- package/dist/flows/Onboarding/utils.d.ts +3 -2
- package/dist/flows/Onboarding/utils.js +1 -1
- package/dist/flows/Termination/AdditionalDetailsForm.d.ts +1 -1
- package/dist/flows/Termination/AdditionalDetailsForm.js +1 -1
- package/dist/flows/Termination/EmployeeComunicationForm.d.ts +1 -1
- package/dist/flows/Termination/EmployeeComunicationForm.js +1 -1
- package/dist/flows/Termination/PaidTimeOffForm.d.ts +1 -1
- package/dist/flows/Termination/PaidTimeOffForm.js +1 -1
- package/dist/flows/Termination/TerminationDetailsForm.d.ts +1 -1
- package/dist/flows/Termination/TerminationDetailsForm.js +1 -1
- package/dist/flows/Termination/TerminationFlow.d.ts +1 -1
- package/dist/flows/Termination/TerminationFlow.js +1 -1
- package/dist/flows/Termination/TerminationForm.d.ts +1 -1
- package/dist/flows/Termination/TerminationForm.js +1 -1
- package/dist/flows/Termination/TimeOff.d.ts +1 -1
- package/dist/flows/Termination/TimeOff.js +1 -1
- package/dist/flows/Termination/context.d.ts +1 -1
- package/dist/flows/Termination/hooks.d.ts +1 -1
- package/dist/flows/Termination/hooks.js +1 -1
- package/dist/flows/Termination/index.d.ts +1 -1
- package/dist/flows/Termination/index.js +1 -1
- package/dist/flows/Termination/json-schemas/schema.js +1 -1
- package/dist/flows/Termination/types.d.ts +1 -1
- package/dist/flows/types.d.ts +1 -1
- package/dist/flows/utils.d.ts +3 -11
- package/dist/flows/utils.js +1 -1
- package/dist/index.css +1 -1
- package/dist/index.css.map +1 -1
- package/dist/index.d.ts +7 -5
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/{remoteFlows-BqpqaWsU.d.ts → remoteFlows-DgAmG_TD.d.ts} +2 -3
- package/dist/types-CxSFjQw5.d.ts +3 -0
- package/dist/{types.gen-D5alruJJ.d.ts → types.gen-CAOUvsW-.d.ts} +268 -2
- package/package.json +1 -1
- package/dist/chunk-36UPHOJS.js +0 -2
- package/dist/chunk-36UPHOJS.js.map +0 -1
- package/dist/chunk-3KAYKVK5.js +0 -2
- package/dist/chunk-3KAYKVK5.js.map +0 -1
- package/dist/chunk-7B32RZXH.js +0 -2
- package/dist/chunk-7B32RZXH.js.map +0 -1
- package/dist/chunk-DHRIURRT.js +0 -2
- package/dist/chunk-DHRIURRT.js.map +0 -1
- package/dist/chunk-DQM4AWYT.js +0 -2
- package/dist/chunk-DQM4AWYT.js.map +0 -1
- package/dist/chunk-HSW5HMHH.js +0 -2
- package/dist/chunk-SYWI4UB6.js +0 -2
- package/dist/chunk-SYWI4UB6.js.map +0 -1
- package/dist/chunk-U3I3TJKB.js +0 -2
- package/dist/chunk-U3I3TJKB.js.map +0 -1
- /package/dist/{chunk-HSW5HMHH.js.map → chunk-2Y22JKVE.js.map} +0 -0
- /package/dist/{chunk-QOMUXX6W.js.map → chunk-3PH5E6CZ.js.map} +0 -0
- /package/dist/{chunk-76JJOA3E.js.map → chunk-66UY5UHP.js.map} +0 -0
- /package/dist/{chunk-P2COURSU.js.map → chunk-7CP4PNU4.js.map} +0 -0
- /package/dist/{chunk-TXLTMGOU.js.map → chunk-ASMIUBMG.js.map} +0 -0
- /package/dist/{chunk-FNTHWOZU.js.map → chunk-CIGSCITX.js.map} +0 -0
- /package/dist/{chunk-JT5XHQEY.js.map → chunk-EAB7VHAW.js.map} +0 -0
- /package/dist/{chunk-MI3HDT5D.js.map → chunk-FQLSGKCJ.js.map} +0 -0
- /package/dist/{chunk-KGUR7YMA.js.map → chunk-GHT53KSP.js.map} +0 -0
- /package/dist/{chunk-XOUAD7MS.js.map → chunk-KDRQW7SO.js.map} +0 -0
- /package/dist/{chunk-YIBRPAR3.js.map → chunk-LRVJ53MM.js.map} +0 -0
- /package/dist/{chunk-C4E24DUG.js.map → chunk-NJPLL3RR.js.map} +0 -0
- /package/dist/{chunk-4N3CYS6F.js.map → chunk-PBUHBIVK.js.map} +0 -0
- /package/dist/{chunk-GQD6NNYO.js.map → chunk-PX72OIDO.js.map} +0 -0
- /package/dist/{chunk-OXOB35EA.js.map → chunk-PZKA77DU.js.map} +0 -0
- /package/dist/{chunk-S4FKLPBB.js.map → chunk-TICIER55.js.map} +0 -0
- /package/dist/{chunk-TGB3TV3K.js.map → chunk-VT2PJJC7.js.map} +0 -0
- /package/dist/{chunk-D3SD6MMV.js.map → chunk-WEIRXEXU.js.map} +0 -0
- /package/dist/{chunk-WZ5AXHQT.js.map → chunk-X7BVA4MH.js.map} +0 -0
- /package/dist/{chunk-T3PTQ4QM.js.map → chunk-Y4ZFQBM3.js.map} +0 -0
- /package/dist/{chunk-QOXOAPGX.js.map → chunk-ZKZDAXNJ.js.map} +0 -0
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/RemoteFlowsProvider.tsx","../src/lib/applyTheme.ts","../src/theme.tsx","../src/environments.ts","../src/useAuth.ts"],"sourcesContent":["import { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport type { PropsWithChildren } from 'react';\nimport React from 'react';\n\nimport { ThemeProvider } from '@/src/theme';\nimport { FormFieldsContext, RemoteFlowContext } from './context';\nimport { Components, RemoteFlowsSDKProps } from './types/remoteFlows';\nimport { useAuth } from './useAuth';\n\nconst queryClient = new QueryClient();\n\ntype RemoteFlowContextWrapperProps = {\n auth: RemoteFlowsSDKProps['auth'];\n children: React.ReactNode;\n isTestingMode?: RemoteFlowsSDKProps['isTestingMode'];\n proxy?: RemoteFlowsSDKProps['proxy'];\n};\n\nfunction RemoteFlowContextWrapper({\n children,\n auth,\n isTestingMode,\n proxy,\n}: RemoteFlowContextWrapperProps) {\n const remoteApiClient = useAuth({\n auth,\n options: {\n isTestingMode: !!isTestingMode,\n proxy,\n },\n });\n return (\n <RemoteFlowContext.Provider value={{ client: remoteApiClient.current }}>\n {children}\n </RemoteFlowContext.Provider>\n );\n}\n\nexport function FormFieldsProvider({\n children,\n components,\n}: PropsWithChildren<{\n components?: Components;\n}>) {\n return (\n <FormFieldsContext.Provider\n value={components ? { components } : { components: {} }}\n >\n {children}\n </FormFieldsContext.Provider>\n );\n}\n\nexport function RemoteFlows({\n auth,\n children,\n components,\n isTestingMode = false,\n theme,\n proxy,\n}: PropsWithChildren<RemoteFlowsSDKProps>) {\n return (\n <QueryClientProvider client={queryClient}>\n <FormFieldsProvider components={components}>\n <RemoteFlowContextWrapper\n isTestingMode={isTestingMode}\n auth={auth}\n proxy={proxy}\n >\n <ThemeProvider theme={theme}>{children}</ThemeProvider>\n </RemoteFlowContextWrapper>\n </FormFieldsProvider>\n </QueryClientProvider>\n );\n}\n","import {\n CssThemeBorder,\n CssThemeColors,\n CssThemeFont,\n CssThemeSpacing,\n ThemeColors,\n ThemeFont,\n ThemeProviderProps,\n} from '@/src/types/theme';\n\nfunction setCssProperties(variables: Record<string, string>) {\n const root = document.documentElement;\n Object.keys(variables).forEach((v) => {\n const propertyVal = variables[v];\n if (propertyVal) {\n root.style.setProperty(v, propertyVal);\n }\n });\n}\n\nfunction mapThemeColors(colors: ThemeColors): CssThemeColors {\n const result: CssThemeColors = {};\n Object.keys(colors).forEach((key) => {\n result[`--${key}` as keyof CssThemeColors] =\n colors[key as keyof ThemeColors];\n });\n return result;\n}\n\nfunction mapThemeSpacing(spacing: string): CssThemeSpacing {\n return {\n '--spacing': spacing,\n };\n}\n\nfunction mapThemeBorderRadius(borderRadius: string): CssThemeBorder {\n return {\n '--radius': borderRadius,\n };\n}\n\nfunction mapThemeFont(font: ThemeFont): CssThemeFont {\n return {\n '--fontSizeBase': font.fontSizeBase,\n };\n}\n\nexport function applyTheme(theme: ThemeProviderProps['theme']) {\n if (theme?.colors) {\n setCssProperties(mapThemeColors(theme.colors));\n }\n\n if (theme?.spacing) {\n setCssProperties(mapThemeSpacing(theme.spacing));\n }\n\n if (theme?.borderRadius) {\n setCssProperties(mapThemeBorderRadius(theme.borderRadius));\n }\n\n if (theme?.font) {\n setCssProperties(mapThemeFont(theme.font));\n }\n}\n","import { applyTheme } from '@/src/lib/applyTheme';\nimport React, { createContext, useEffect, useMemo } from 'react';\nimport { ThemeProviderProps } from './types/theme';\n\nconst ThemeContext = createContext<Omit<ThemeProviderProps, 'children'>>({\n theme: {},\n});\n\nexport function ThemeProvider(props: ThemeProviderProps) {\n useEffect(() => {\n if (props.theme && Object.keys(props.theme).length > 0) {\n applyTheme(props.theme);\n }\n }, [props.theme]);\n\n const value = useMemo(() => {\n return { theme: props.theme };\n }, [props.theme]);\n\n return (\n <ThemeContext.Provider value={value}>\n {props.children}\n </ThemeContext.Provider>\n );\n}\n","export const ENVIRONMENTS = {\n staging: 'https://gateway.niceremote.com',\n partners: 'https://gateway.partners.remote-sandbox.com',\n production: 'https://gateway.remote.com',\n};\n","import { client } from '@/src/client/client.gen';\nimport { ENVIRONMENTS } from '@/src/environments';\nimport { createClient } from '@hey-api/client-fetch';\nimport { useQuery } from '@tanstack/react-query';\nimport { useRef } from 'react';\nimport { RemoteFlowsSDKProps } from './types/remoteFlows';\n\ntype AuthResponse = {\n accessToken: string;\n expiresIn: number;\n};\n\ntype Options = {\n isTestingMode: boolean;\n proxy?: RemoteFlowsSDKProps['proxy'];\n};\n\nfunction isValidUrl(url: string) {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\nexport const useAuth = ({\n auth,\n options,\n}: {\n auth: () => Promise<AuthResponse>;\n options: Options;\n}) => {\n const session = useRef<{ accessToken: string; expiresAt: number } | null>(\n null,\n );\n const { refetch } = useQuery({\n queryKey: ['auth'],\n queryFn: auth,\n enabled: false,\n });\n\n const baseUrl = options.isTestingMode\n ? ENVIRONMENTS.partners\n : process.env.REMOTE_GATEWAY_URL;\n\n const clientConfig = client.getConfig();\n const npmPackageVersion = process.env.VERSION;\n const isValidProxy = !!options.proxy && isValidUrl(options.proxy.url);\n\n if (options.proxy && !isValidProxy) {\n console.error('Invalid proxy URL provided. Using default base URL.');\n }\n\n return useRef(\n createClient({\n ...clientConfig,\n headers: {\n ...clientConfig.headers,\n ...(isValidProxy ? options.proxy?.headers : {}),\n 'X-Client-Name': 'remote-flows-sdk',\n 'X-Client-Version': npmPackageVersion,\n },\n baseUrl: isValidProxy ? options.proxy?.url : baseUrl,\n auth: async () => {\n function hasTokenExpired(expiresAt: number | undefined) {\n return !expiresAt || Date.now() + 60000 > expiresAt;\n }\n if (!session.current || hasTokenExpired(session.current.expiresAt)) {\n const { data } = await refetch();\n if (data) {\n session.current = {\n accessToken: data.accessToken,\n expiresAt: Date.now() + data.expiresIn * 1000,\n };\n }\n }\n return session.current?.accessToken;\n },\n }),\n );\n};\n"],"mappings":"wwEAAA,OAAS,eAAAA,EAAa,uBAAAC,MAA2B,wBAEjD,OAAOC,MAAW,QCQlB,SAASC,EAAiBC,EAAmC,CAC3D,IAAMC,EAAO,SAAS,gBACtB,OAAO,KAAKD,CAAS,EAAE,QAASE,GAAM,CACpC,IAAMC,EAAcH,EAAUE,CAAC,EAC3BC,GACFF,EAAK,MAAM,YAAYC,EAAGC,CAAW,CAEzC,CAAC,CACH,CARSC,EAAAL,EAAA,oBAUT,SAASM,EAAeC,EAAqC,CAC3D,IAAMC,EAAyB,CAAC,EAChC,cAAO,KAAKD,CAAM,EAAE,QAASE,GAAQ,CACnCD,EAAO,KAAKC,CAAG,EAA0B,EACvCF,EAAOE,CAAwB,CACnC,CAAC,EACMD,CACT,CAPSH,EAAAC,EAAA,kBAST,SAASI,EAAgBC,EAAkC,CACzD,MAAO,CACL,YAAaA,CACf,CACF,CAJSN,EAAAK,EAAA,mBAMT,SAASE,EAAqBC,EAAsC,CAClE,MAAO,CACL,WAAYA,CACd,CACF,CAJSR,EAAAO,EAAA,wBAMT,SAASE,EAAaC,EAA+B,CACnD,MAAO,CACL,iBAAkBA,EAAK,YACzB,CACF,CAJSV,EAAAS,EAAA,gBAMF,SAASE,EAAWC,EAAoC,CACz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AAE,WAAAA,CAAW,EAAI,CAAE,WAAY,CAAC,CAAE,GAErDV,CACH,CAEJ,CAbgBQ,EAAAC,EAAA,sBAeT,SAASG,EAAY,CAC1B,KAAAX,EACA,SAAAD,EACA,WAAAU,EACA,cAAAR,EAAgB,GAChB,MAAAW,EACA,MAAAV,CACF,EAA2C,CACzC,OACEG,EAAA,cAACQ,EAAA,CAAoB,OAAQjB,GAC3BS,EAAA,cAACG,EAAA,CAAmB,WAAYC,GAC9BJ,EAAA,cAACP,EAAA,CACC,cAAeG,EACf,KAAMD,EACN,MAAOE,GAEPG,EAAA,cAACS,EAAA,CAAc,MAAOF,GAAQb,CAAS,CACzC,CACF,CACF,CAEJ,CArBgBQ,EAAAI,EAAA","names":["QueryClient","QueryClientProvider","React","setCssProperties","variables","root","v","propertyVal","__name","mapThemeColors","colors","result","key","mapThemeSpacing","spacing","mapThemeBorderRadius","borderRadius","mapThemeFont","font","applyTheme","theme","React","createContext","useEffect","useMemo","ThemeContext","createContext","ThemeProvider","props","useEffect","applyTheme","value","useMemo","React","__name","ENVIRONMENTS","createClient","useQuery","useRef","isValidUrl","url","__name","useAuth","auth","options","session","useRef","refetch","useQuery","baseUrl","ENVIRONMENTS","clientConfig","client","npmPackageVersion","isValidProxy","createClient","hasTokenExpired","expiresAt","data","queryClient","QueryClient","RemoteFlowContextWrapper","children","auth","isTestingMode","proxy","remoteApiClient","useAuth","React","RemoteFlowContext","__name","FormFieldsProvider","components","FormFieldsContext","RemoteFlows","theme","QueryClientProvider","ThemeProvider"]}
|
|
1
|
+
{"version":3,"sources":["../src/RemoteFlowsProvider.tsx","../src/lib/applyTheme.ts","../src/theme.tsx","../src/environments.ts","../src/useAuth.ts"],"sourcesContent":["import { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport type { PropsWithChildren } from 'react';\nimport React from 'react';\n\nimport { ThemeProvider } from '@/src/theme';\nimport { FormFieldsContext, RemoteFlowContext } from './context';\nimport { Components, RemoteFlowsSDKProps } from './types/remoteFlows';\nimport { useAuth } from './useAuth';\n\nconst queryClient = new QueryClient();\n\ntype RemoteFlowContextWrapperProps = {\n auth: RemoteFlowsSDKProps['auth'];\n children: React.ReactNode;\n isTestingMode?: RemoteFlowsSDKProps['isTestingMode'];\n proxy?: RemoteFlowsSDKProps['proxy'];\n};\n\nfunction RemoteFlowContextWrapper({\n children,\n auth,\n isTestingMode,\n proxy,\n}: RemoteFlowContextWrapperProps) {\n const remoteApiClient = useAuth({\n auth,\n options: {\n isTestingMode: !!isTestingMode,\n proxy,\n },\n });\n return (\n <RemoteFlowContext.Provider value={{ client: remoteApiClient.current }}>\n {children}\n </RemoteFlowContext.Provider>\n );\n}\n\nexport function FormFieldsProvider({\n children,\n components,\n}: PropsWithChildren<{\n components?: Components;\n}>) {\n return (\n <FormFieldsContext.Provider\n value={components ? { components } : { components: {} }}\n >\n {children}\n </FormFieldsContext.Provider>\n );\n}\n\nexport function RemoteFlows({\n auth,\n children,\n components,\n isTestingMode = false,\n theme,\n proxy,\n}: PropsWithChildren<RemoteFlowsSDKProps>) {\n return (\n <QueryClientProvider client={queryClient}>\n <FormFieldsProvider components={components}>\n <RemoteFlowContextWrapper\n isTestingMode={isTestingMode}\n auth={auth}\n proxy={proxy}\n >\n <ThemeProvider theme={theme}>{children}</ThemeProvider>\n </RemoteFlowContextWrapper>\n </FormFieldsProvider>\n </QueryClientProvider>\n );\n}\n","import {\n CssThemeBorder,\n CssThemeColors,\n CssThemeFont,\n CssThemeSpacing,\n ThemeColors,\n ThemeFont,\n ThemeProviderProps,\n} from '@/src/types/theme';\n\nfunction setCssProperties(variables: Record<string, string>) {\n const root = document.documentElement;\n Object.keys(variables).forEach((v) => {\n const propertyVal = variables[v];\n if (propertyVal) {\n root.style.setProperty(v, propertyVal);\n }\n });\n}\n\nfunction mapThemeColors(colors: ThemeColors): CssThemeColors {\n const result: CssThemeColors = {};\n Object.keys(colors).forEach((key) => {\n result[`--${key}` as keyof CssThemeColors] =\n colors[key as keyof ThemeColors];\n });\n return result;\n}\n\nfunction mapThemeSpacing(spacing: string): CssThemeSpacing {\n return {\n '--spacing': spacing,\n };\n}\n\nfunction mapThemeBorderRadius(borderRadius: string): CssThemeBorder {\n return {\n '--radius': borderRadius,\n };\n}\n\nfunction mapThemeFont(font: ThemeFont): CssThemeFont {\n return {\n '--fontSizeBase': font.fontSizeBase,\n };\n}\n\nexport function applyTheme(theme: ThemeProviderProps['theme']) {\n if (theme?.colors) {\n setCssProperties(mapThemeColors(theme.colors));\n }\n\n if (theme?.spacing) {\n setCssProperties(mapThemeSpacing(theme.spacing));\n }\n\n if (theme?.borderRadius) {\n setCssProperties(mapThemeBorderRadius(theme.borderRadius));\n }\n\n if (theme?.font) {\n setCssProperties(mapThemeFont(theme.font));\n }\n}\n","import { applyTheme } from '@/src/lib/applyTheme';\nimport React, { createContext, useEffect, useMemo } from 'react';\nimport { ThemeProviderProps } from './types/theme';\n\nconst ThemeContext = createContext<Omit<ThemeProviderProps, 'children'>>({\n theme: {},\n});\n\nexport function ThemeProvider(props: ThemeProviderProps) {\n useEffect(() => {\n if (props.theme && Object.keys(props.theme).length > 0) {\n applyTheme(props.theme);\n }\n }, [props.theme]);\n\n const value = useMemo(() => {\n return { theme: props.theme };\n }, [props.theme]);\n\n return (\n <ThemeContext.Provider value={value}>\n {props.children}\n </ThemeContext.Provider>\n );\n}\n","export const ENVIRONMENTS = {\n staging: 'https://gateway.niceremote.com',\n partners: 'https://gateway.partners.remote-sandbox.com',\n production: 'https://gateway.remote.com',\n};\n","import { client } from '@/src/client/client.gen';\nimport { ENVIRONMENTS } from '@/src/environments';\nimport { createClient } from '@hey-api/client-fetch';\nimport { useQuery } from '@tanstack/react-query';\nimport { useRef } from 'react';\nimport { RemoteFlowsSDKProps } from './types/remoteFlows';\n\ntype AuthResponse = {\n accessToken: string;\n expiresIn: number;\n};\n\ntype Options = {\n isTestingMode: boolean;\n proxy?: RemoteFlowsSDKProps['proxy'];\n};\n\nfunction isValidUrl(url: string) {\n try {\n new URL(url);\n return true;\n } catch {\n return false;\n }\n}\n\nexport const useAuth = ({\n auth,\n options,\n}: {\n auth: () => Promise<AuthResponse>;\n options: Options;\n}) => {\n const session = useRef<{ accessToken: string; expiresAt: number } | null>(\n null,\n );\n const { refetch } = useQuery({\n queryKey: ['auth'],\n queryFn: auth,\n enabled: false,\n });\n\n const baseUrl = options.isTestingMode\n ? ENVIRONMENTS.partners\n : process.env.REMOTE_GATEWAY_URL;\n\n const clientConfig = client.getConfig();\n const npmPackageVersion = process.env.VERSION;\n const isValidProxy = !!options.proxy && isValidUrl(options.proxy.url);\n\n if (options.proxy && !isValidProxy) {\n console.error('Invalid proxy URL provided. Using default base URL.');\n }\n\n return useRef(\n createClient({\n ...clientConfig,\n headers: {\n ...clientConfig.headers,\n ...(isValidProxy ? options.proxy?.headers : {}),\n 'X-Client-Name': 'remote-flows-sdk',\n 'X-Client-Version': npmPackageVersion,\n },\n baseUrl: isValidProxy ? options.proxy?.url : baseUrl,\n auth: async () => {\n function hasTokenExpired(expiresAt: number | undefined) {\n return !expiresAt || Date.now() + 60000 > expiresAt;\n }\n if (!session.current || hasTokenExpired(session.current.expiresAt)) {\n const { data } = await refetch();\n if (data) {\n session.current = {\n accessToken: data.accessToken,\n expiresAt: Date.now() + data.expiresIn * 1000,\n };\n }\n }\n return session.current?.accessToken;\n },\n }),\n );\n};\n"],"mappings":"41EAAA,OAAS,eAAAA,EAAa,uBAAAC,MAA2B,wBAEjD,OAAOC,MAAW,QCQlB,SAASC,EAAiBC,EAAmC,CAC3D,IAAMC,EAAO,SAAS,gBACtB,OAAO,KAAKD,CAAS,EAAE,QAASE,GAAM,CACpC,IAAMC,EAAcH,EAAUE,CAAC,EAC3BC,GACFF,EAAK,MAAM,YAAYC,EAAGC,CAAW,CAEzC,CAAC,CACH,CARSC,EAAAL,EAAA,oBAUT,SAASM,EAAeC,EAAqC,CAC3D,IAAMC,EAAyB,CAAC,EAChC,cAAO,KAAKD,CAAM,EAAE,QAASE,GAA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A,KAAAC,EACA,cAAAC,EACA,MAAAC,CACF,EAAkC,CAChC,IAAMC,EAAkBC,EAAQ,CAC9B,KAAAJ,EACA,QAAS,CACP,cAAe,CAAC,CAACC,EACjB,MAAAC,CACF,CACF,CAAC,EACD,OACEG,EAAA,cAACC,EAAkB,SAAlB,CAA2B,MAAO,CAAE,OAAQH,EAAgB,OAAQ,GAClEJ,CACH,CAEJ,CAlBSQ,EAAAT,EAAA,4BAoBF,SAASU,EAAmB,CACjC,SAAAT,EACA,WAAAU,CACF,EAEI,CACF,OACEJ,EAAA,cAACK,EAAkB,SAAlB,CACC,MAAOD,EAAa,CAAE,WAAAA,CAAW,EAAI,CAAE,WAAY,CAAC,CAAE,GAErDV,CACH,CAEJ,CAbgBQ,EAAAC,EAAA,sBAeT,SAASG,EAAY,CAC1B,KAAAX,EACA,SAAAD,EACA,WAAAU,EACA,cAAAR,EAAgB,GAChB,MAAAW,EACA,MAAAV,CACF,EAA2C,CACzC,OACEG,EAAA,cAACQ,EAAA,CAAoB,OAAQjB,GAC3BS,EAAA,cAACG,EAAA,CAAmB,WAAYC,GAC9BJ,EAAA,cAACP,EAAA,CACC,cAAeG,EACf,KAAMD,EACN,MAAOE,GAEPG,EAAA,cAACS,EAAA,CAAc,MAAOF,GAAQb,CAAS,CACzC,CACF,CACF,CAEJ,CArBgBQ,EAAAI,EAAA","names":["QueryClient","QueryClientProvider","React","setCssProperties","variables","root","v","propertyVal","__name","mapThemeColors","colors","result","key","mapThemeSpacing","spacing","mapThemeBorderRadius","borderRadius","mapThemeFont","font","applyTheme","theme","React","createContext","useEffect","useMemo","ThemeContext","createContext","ThemeProvider","props","useEffect","applyTheme","value","useMemo","React","__name","ENVIRONMENTS","createClient","useQuery","useRef","isValidUrl","url","__name","useAuth","auth","options","session","useRef","refetch","useQuery","baseUrl","ENVIRONMENTS","clientConfig","client","npmPackageVersion","isValidProxy","createClient","hasTokenExpired","expiresAt","data","queryClient","QueryClient","RemoteFlowContextWrapper","children","auth","isTestingMode","proxy","remoteApiClient","useAuth","React","RemoteFlowContext","__name","FormFieldsProvider","components","FormFieldsContext","RemoteFlows","theme","QueryClientProvider","ThemeProvider"]}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { PropsWithChildren } from 'react';
|
|
2
2
|
import { ControllerRenderProps, FieldValues, ControllerFieldState } from 'react-hook-form';
|
|
3
3
|
import { AnySchema } from 'yup';
|
|
4
|
+
import { S as SupportedTypes } from './types-CxSFjQw5.js';
|
|
4
5
|
|
|
5
6
|
type ThemeProviderProps = PropsWithChildren<{
|
|
6
7
|
theme?: Partial<{
|
|
@@ -24,8 +25,6 @@ type ThemeFont = {
|
|
|
24
25
|
fontSizeBase: string;
|
|
25
26
|
};
|
|
26
27
|
|
|
27
|
-
type SupportedTypes = 'text' | 'number' | 'email' | 'select' | 'radio' | 'fieldset' | 'date' | 'checkbox' | 'textarea' | 'money' | 'file' | 'countries' | 'hidden';
|
|
28
|
-
|
|
29
28
|
type StatementProps = {
|
|
30
29
|
title?: string;
|
|
31
30
|
description: string;
|
|
@@ -77,7 +76,7 @@ type Components = {
|
|
|
77
76
|
* Metadata derived from JSON schema parsing that provides additional context and validation rules for the field.
|
|
78
77
|
* Contains properties defined in the original JSON schema such as type, format, constraints, etc.
|
|
79
78
|
*/
|
|
80
|
-
fieldData: JSFField
|
|
79
|
+
fieldData: Partial<JSFField>;
|
|
81
80
|
}>;
|
|
82
81
|
} & {
|
|
83
82
|
statement?: React.ComponentType<{
|
|
@@ -30,6 +30,14 @@ type TerminationOffboarding = {
|
|
|
30
30
|
will_challenge_termination: boolean;
|
|
31
31
|
will_challenge_termination_description?: string;
|
|
32
32
|
};
|
|
33
|
+
/**
|
|
34
|
+
* Upsert benefit offers request. As its properties may vary depending on the employment,
|
|
35
|
+
* you must query the [Show benefit offers schema](#tag/benefits/operation/get_show_benefit_offer) endpoint
|
|
36
|
+
* passing the employment id
|
|
37
|
+
*/
|
|
38
|
+
type UnifiedEmploymentUpsertBenefitOffersRequest = {
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
};
|
|
33
41
|
type MinimalCountry = {
|
|
34
42
|
alpha_2_code: string;
|
|
35
43
|
code: string;
|
|
@@ -297,6 +305,113 @@ type ShortId = string;
|
|
|
297
305
|
*
|
|
298
306
|
*/
|
|
299
307
|
type NullableApproverId = string | null;
|
|
308
|
+
/**
|
|
309
|
+
* Description of the basic required and onboarding tasks params to create an employment.
|
|
310
|
+
* You do not need to include all onboarding tasks when creating or updating an employment.
|
|
311
|
+
*
|
|
312
|
+
*/
|
|
313
|
+
type EmploymentFullParams = {
|
|
314
|
+
/**
|
|
315
|
+
* Home address information. As its properties may vary depending on the country,
|
|
316
|
+
* you must query the [Show form schema](#tag/Countries/operation/get_show_form_country) endpoint
|
|
317
|
+
* passing the country code and `address_details` as path parameters.
|
|
318
|
+
*/
|
|
319
|
+
address_details?: {
|
|
320
|
+
[key: string]: unknown;
|
|
321
|
+
};
|
|
322
|
+
/**
|
|
323
|
+
* Administrative information. As its properties may vary depending on the country,
|
|
324
|
+
* you must query the [Show form schema](#tag/Countries/operation/get_show_form_country) endpoint
|
|
325
|
+
* passing the country code and `administrative_details` as path parameters.
|
|
326
|
+
*/
|
|
327
|
+
administrative_details?: {
|
|
328
|
+
[key: string]: unknown;
|
|
329
|
+
};
|
|
330
|
+
/**
|
|
331
|
+
* Bank account information. As its properties may vary depending on the country,
|
|
332
|
+
* you must query the [Show form schema](#tag/Countries/operation/get_show_form_country) endpoint
|
|
333
|
+
* passing the country code and `bank_account_details` as path parameters.
|
|
334
|
+
*/
|
|
335
|
+
bank_account_details?: {
|
|
336
|
+
[key: string]: unknown;
|
|
337
|
+
};
|
|
338
|
+
/**
|
|
339
|
+
* Employment basic information. As its properties may vary depending on the country,
|
|
340
|
+
* you must query the [Show form schema](#tag/Countries/operation/get_show_form_country) endpoint
|
|
341
|
+
* passing the country code and `employment_basic_information` as path parameters.
|
|
342
|
+
*/
|
|
343
|
+
basic_information?: {
|
|
344
|
+
[key: string]: unknown;
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* Billing address information. As its properties may vary depending on the country,
|
|
348
|
+
* you must query the [Show form schema](#tag/Countries/operation/get_show_form_country) endpoint
|
|
349
|
+
* passing the country code and `billing_address_details` as path parameters.
|
|
350
|
+
*/
|
|
351
|
+
billing_address_details?: {
|
|
352
|
+
[key: string]: unknown;
|
|
353
|
+
};
|
|
354
|
+
company_id?: string;
|
|
355
|
+
/**
|
|
356
|
+
* Contract information. As its properties may vary depending on the country,
|
|
357
|
+
* you must query the [Show form schema](#tag/Countries/operation/get_show_form_country) endpoint
|
|
358
|
+
* passing the country code and `contract_details` as path parameters.
|
|
359
|
+
*/
|
|
360
|
+
contract_details?: {
|
|
361
|
+
[key: string]: unknown;
|
|
362
|
+
};
|
|
363
|
+
country?: Country;
|
|
364
|
+
country_code?: string;
|
|
365
|
+
/**
|
|
366
|
+
* The department of the employment. The department must belong to the same company as the employment.
|
|
367
|
+
* When set to `null`, the employment will be unassigned from a department.
|
|
368
|
+
*
|
|
369
|
+
*/
|
|
370
|
+
department_id?: string | null;
|
|
371
|
+
/**
|
|
372
|
+
* Emergency contact information. As its properties may vary depending on the country,
|
|
373
|
+
* you must query the [Show form schema](#tag/Countries/operation/get_show_form_country) endpoint
|
|
374
|
+
* passing the country code and `emergency_contact_details` as path parameters.
|
|
375
|
+
*/
|
|
376
|
+
emergency_contact_details?: {
|
|
377
|
+
[key: string]: unknown;
|
|
378
|
+
};
|
|
379
|
+
/**
|
|
380
|
+
* A unique reference code for the employment record in a non-Remote system. This optional field links to external data sources. If not provided, it defaults to `null`. While uniqueness is recommended, it is not strictly enforced within Remote's system.
|
|
381
|
+
*/
|
|
382
|
+
external_id?: string;
|
|
383
|
+
/**
|
|
384
|
+
* The user id of the manager, who should have an `admin`, `owner` or `people_manager` role.
|
|
385
|
+
* You can find these users by querying the [Company Managers endpoint](#operation/get_index_company_manager).
|
|
386
|
+
* **Update of this field is only available for active employments.**
|
|
387
|
+
*
|
|
388
|
+
*/
|
|
389
|
+
manager_id?: string;
|
|
390
|
+
/**
|
|
391
|
+
* Personal details information. As its properties may vary depending on the country,
|
|
392
|
+
* you must query the [Show form schema](#tag/Countries/operation/get_show_form_country) endpoint
|
|
393
|
+
* passing the country code and `personal_details` as path parameters.
|
|
394
|
+
*/
|
|
395
|
+
personal_details?: {
|
|
396
|
+
[key: string]: unknown;
|
|
397
|
+
};
|
|
398
|
+
/**
|
|
399
|
+
* Pricing plan details information. As its properties may vary depending on the country,
|
|
400
|
+
* you must query the [Show form schema](#tag/Countries/operation/get_show_form_country) endpoint
|
|
401
|
+
* passing the country code and `pricing_plan_details` as path parameters.
|
|
402
|
+
*/
|
|
403
|
+
pricing_plan_details?: {
|
|
404
|
+
[key: string]: unknown;
|
|
405
|
+
};
|
|
406
|
+
/**
|
|
407
|
+
* If not provided, it will default to `employee`.
|
|
408
|
+
*/
|
|
409
|
+
type?: 'employee' | 'contractor';
|
|
410
|
+
/**
|
|
411
|
+
* The work email of the employment.
|
|
412
|
+
*/
|
|
413
|
+
work_email?: string;
|
|
414
|
+
};
|
|
300
415
|
type OffboardingFile = {
|
|
301
416
|
/**
|
|
302
417
|
* The content in base64 encoding
|
|
@@ -485,6 +600,11 @@ type ListTimeoffResponse = {
|
|
|
485
600
|
total_pages?: number;
|
|
486
601
|
};
|
|
487
602
|
};
|
|
603
|
+
type MagicLinkResponse = {
|
|
604
|
+
data: {
|
|
605
|
+
url: string;
|
|
606
|
+
};
|
|
607
|
+
};
|
|
488
608
|
/**
|
|
489
609
|
* The stage of employment lifecycle. When it's `onboarded` means the employee is ready to commence or has already commenced.
|
|
490
610
|
*/
|
|
@@ -540,11 +660,142 @@ type SuccessResponse = {
|
|
|
540
660
|
status?: string;
|
|
541
661
|
};
|
|
542
662
|
};
|
|
663
|
+
/**
|
|
664
|
+
* Magic link params
|
|
665
|
+
*/
|
|
666
|
+
type MagicLinkParams = {
|
|
667
|
+
/**
|
|
668
|
+
* The path to which the user will be redirected to after login. This field has a max length of 2000 characters.
|
|
669
|
+
*
|
|
670
|
+
* If not specified, `/dashboard` will be used by default.
|
|
671
|
+
*
|
|
672
|
+
* Must begin with a forward slash (`/`) and, at least one path segment is required (`/dashboard` e.g.).
|
|
673
|
+
* An ending forward slash (`/`) is not allowed and path segments can only include alphanumeric characters, underscore (`_`) and hyphen (`-`).
|
|
674
|
+
*
|
|
675
|
+
* An optional query string can be specified too. If present, the query string must start with a question mark (`?`)
|
|
676
|
+
* and must include at least one key value pair. Both, keys and values, can only include
|
|
677
|
+
* alphanumeric characters, underscore (`_`), hyphen (`-`) or percent encoded values such as `%20` (space character).
|
|
678
|
+
* Additional key value pairs are allowed using ampersand (`&`).
|
|
679
|
+
*
|
|
680
|
+
* Query keys require at least one alphanumeric, underscore (`_`), hyphen (`-`) or valid percent encoded.
|
|
681
|
+
* Query values are optional, the actual value may be empty and the equals sign (`=`) may be missing too.
|
|
682
|
+
*
|
|
683
|
+
* Some **Valid** examples for `path`:
|
|
684
|
+
* - o `/dashboard`
|
|
685
|
+
* - o `/dashboard/people/new/full_time/663e0b79-c893-45ff-a1b2-f6dcabc098b5`
|
|
686
|
+
* - o `/dashboard/people/hiring?filters%5B0%5D%5Bid%5D=exclude_linked_drafts&filters%5B0%5D%5Bvalue%5D=true`
|
|
687
|
+
* - o `/dashboard?key=value&foo=bar`
|
|
688
|
+
*
|
|
689
|
+
* Some **Invalid** examples for `path`:
|
|
690
|
+
* - x `missing_forward_slash`
|
|
691
|
+
* - x `/invalid//path`
|
|
692
|
+
* - x `//some`
|
|
693
|
+
* - x `/?key=value`
|
|
694
|
+
* - x `/some/i.n:valid*`
|
|
695
|
+
* - x `/invalid/end/slash/`
|
|
696
|
+
* - x `/some?malformed_percent_encoded_key%1=value`
|
|
697
|
+
*
|
|
698
|
+
*/
|
|
699
|
+
path?: string;
|
|
700
|
+
user_id: UuidSlug;
|
|
701
|
+
} | {
|
|
702
|
+
employment_id: UuidSlug;
|
|
703
|
+
/**
|
|
704
|
+
* The path to which the user will be redirected to after login. This field has a max length of 2000 characters.
|
|
705
|
+
*
|
|
706
|
+
* If not specified, `/dashboard` will be used by default.
|
|
707
|
+
*
|
|
708
|
+
* Must begin with a forward slash (`/`) and, at least one path segment is required (`/dashboard` e.g.).
|
|
709
|
+
* An ending forward slash (`/`) is not allowed and path segments can only include alphanumeric characters, underscore (`_`) and hyphen (`-`).
|
|
710
|
+
*
|
|
711
|
+
* An optional query string can be specified too. If present, the query string must start with a question mark (`?`)
|
|
712
|
+
* and must include at least one key value pair. Both, keys and values, can only include
|
|
713
|
+
* alphanumeric characters, underscore (`_`), hyphen (`-`) or percent encoded values such as `%20` (space character).
|
|
714
|
+
* Additional key value pairs are allowed using ampersand (`&`).
|
|
715
|
+
*
|
|
716
|
+
* Query keys require at least one alphanumeric, underscore (`_`), hyphen (`-`) or valid percent encoded.
|
|
717
|
+
* Query values are optional, the actual value may be empty and the equals sign (`=`) may be missing too.
|
|
718
|
+
*
|
|
719
|
+
* Some **Valid** examples for `path`:
|
|
720
|
+
* - o `/dashboard`
|
|
721
|
+
* - o `/dashboard/people/new/full_time/663e0b79-c893-45ff-a1b2-f6dcabc098b5`
|
|
722
|
+
* - o `/dashboard/people/hiring?filters%5B0%5D%5Bid%5D=exclude_linked_drafts&filters%5B0%5D%5Bvalue%5D=true`
|
|
723
|
+
* - o `/dashboard?key=value&foo=bar`
|
|
724
|
+
*
|
|
725
|
+
* Some **Invalid** examples for `path`:
|
|
726
|
+
* - x `missing_forward_slash`
|
|
727
|
+
* - x `/invalid//path`
|
|
728
|
+
* - x `//some`
|
|
729
|
+
* - x `/?key=value`
|
|
730
|
+
* - x `/some/i.n:valid*`
|
|
731
|
+
* - x `/invalid/end/slash/`
|
|
732
|
+
* - x `/some?malformed_percent_encoded_key%1=value`
|
|
733
|
+
*
|
|
734
|
+
*/
|
|
735
|
+
path?: string;
|
|
736
|
+
};
|
|
543
737
|
type LeavePolicy = {
|
|
544
738
|
leave_policy_variant_slug: string;
|
|
545
739
|
leave_type: TimeoffType;
|
|
546
740
|
name: string;
|
|
547
741
|
};
|
|
742
|
+
type Company = {
|
|
743
|
+
/**
|
|
744
|
+
* Fields can vary depending on the country. Please, check the required fields structure using the [Show form schema endpoint](#operation/get_show_form_country).
|
|
745
|
+
* Use the desired country and `address_details` as the form name for the placeholders.
|
|
746
|
+
* The response complies with the [JSON Schema](https://remote.com/resources/api/how-json-schemas-work) specification.
|
|
747
|
+
*
|
|
748
|
+
*/
|
|
749
|
+
address_details: {
|
|
750
|
+
[key: string]: unknown;
|
|
751
|
+
};
|
|
752
|
+
/**
|
|
753
|
+
* Fields can vary depending on the country. Please, check the required fields structure using the [Show form schema endpoint](#operation/get_show_form_country).
|
|
754
|
+
* Use the desired country and `bank_account_details` as the form name for the placeholders.
|
|
755
|
+
* The response complies with the [JSON Schema](https://remote.com/resources/api/how-json-schemas-work) specification.
|
|
756
|
+
*
|
|
757
|
+
*/
|
|
758
|
+
bank_account_details?: {
|
|
759
|
+
[key: string]: unknown;
|
|
760
|
+
};
|
|
761
|
+
company_owner_email: string;
|
|
762
|
+
company_owner_name?: string;
|
|
763
|
+
company_owner_user_id: string;
|
|
764
|
+
country_code: string;
|
|
765
|
+
created_at: string;
|
|
766
|
+
/**
|
|
767
|
+
* The credit risk status of the company default legal entity.
|
|
768
|
+
* - `not_started`: The credit risk assessment has not started yet.
|
|
769
|
+
* - `ready`: The credit risk assessment is ready to be started.
|
|
770
|
+
* - `in_progress`: The automated credit risk assessment is in progress.
|
|
771
|
+
* - `referred`: The credit risk assessment has been referred to a human reviewer.
|
|
772
|
+
* - `fail`: The credit risk assessment has failed and the company will be archived.
|
|
773
|
+
* - `deposit_required`: The company default legal entity requires a deposit before onboarding new employees.
|
|
774
|
+
* - `no_deposit_required`: The company default legal entity does not require a deposit before onboarding new employees.
|
|
775
|
+
*
|
|
776
|
+
*/
|
|
777
|
+
default_legal_entity_credit_risk_status: 'not_started' | 'ready' | 'in_progress' | 'referred' | 'fail' | 'deposit_required' | 'no_deposit_required';
|
|
778
|
+
desired_currency: string;
|
|
779
|
+
external_id?: string | null;
|
|
780
|
+
id: string;
|
|
781
|
+
name: string;
|
|
782
|
+
phone_number?: string;
|
|
783
|
+
registration_number?: string | null;
|
|
784
|
+
/**
|
|
785
|
+
* The company status determines what a company is allowed to do:
|
|
786
|
+
* - `pending`: The company has been created and the company owner invited. Remote is waiting for the company owner to complete onboarding.
|
|
787
|
+
* - `review`: The company is under review. In rare occasions, a company may not automatically get created in `active` status because Remote needs to
|
|
788
|
+
* manually review the company that was created. The company will become `active` once the review is completed and no further action is necessary
|
|
789
|
+
* through the Remote API.
|
|
790
|
+
* - `active`: The company owner has completed onboarding and the company is ready to employ.
|
|
791
|
+
* - `archived`: The company is no longer active on the Remote platform and no changes can be made to the company.
|
|
792
|
+
*
|
|
793
|
+
*/
|
|
794
|
+
status: 'pending' | 'review' | 'active' | 'archived';
|
|
795
|
+
tax_number?: string | null;
|
|
796
|
+
terms_of_service_accepted_at: string;
|
|
797
|
+
updated_at: string;
|
|
798
|
+
};
|
|
548
799
|
type TooManyRequestsResponse = {
|
|
549
800
|
message?: string;
|
|
550
801
|
};
|
|
@@ -689,7 +940,7 @@ type ParameterError = {
|
|
|
689
940
|
param: string;
|
|
690
941
|
};
|
|
691
942
|
type GenericFile = Blob | File;
|
|
692
|
-
type TimeoffType = '
|
|
943
|
+
type TimeoffType = 'time_off' | 'sick_leave' | 'public_holiday' | 'unpaid_leave' | 'extended_leave' | 'in_lieu_time' | 'maternity_leave' | 'paternity_leave' | 'parental_leave' | 'bereavement' | 'military_leave' | 'other' | 'paid_time_off' | 'custom_company_leave' | 'rtt' | 'casual_leave' | 'rol' | 'ex_festivita';
|
|
693
944
|
/**
|
|
694
945
|
* The details of the salary decrease request if there is one
|
|
695
946
|
*/
|
|
@@ -867,6 +1118,21 @@ type PostCreateEstimationPdfErrors = {
|
|
|
867
1118
|
422: UnprocessableEntityResponse;
|
|
868
1119
|
};
|
|
869
1120
|
type PostCreateEstimationPdfError = PostCreateEstimationPdfErrors[keyof PostCreateEstimationPdfErrors];
|
|
1121
|
+
type PostCreateRiskReserveErrors = {
|
|
1122
|
+
/**
|
|
1123
|
+
* Unauthorized
|
|
1124
|
+
*/
|
|
1125
|
+
401: UnauthorizedResponse;
|
|
1126
|
+
/**
|
|
1127
|
+
* Not Found
|
|
1128
|
+
*/
|
|
1129
|
+
404: NotFoundResponse;
|
|
1130
|
+
/**
|
|
1131
|
+
* Unprocessable Entity
|
|
1132
|
+
*/
|
|
1133
|
+
422: UnprocessableEntityResponse;
|
|
1134
|
+
};
|
|
1135
|
+
type PostCreateRiskReserveError = PostCreateRiskReserveErrors[keyof PostCreateRiskReserveErrors];
|
|
870
1136
|
type PostCreateContractAmendmentErrors = {
|
|
871
1137
|
/**
|
|
872
1138
|
* Unauthorized
|
|
@@ -944,4 +1210,4 @@ type PostInviteEmploymentInvitationErrors = {
|
|
|
944
1210
|
};
|
|
945
1211
|
type PostInviteEmploymentInvitationError = PostInviteEmploymentInvitationErrors[keyof PostInviteEmploymentInvitationErrors];
|
|
946
1212
|
|
|
947
|
-
export type { ContractAmendmentAutomatableResponse as C, EmploymentShowResponse as E, ListTimeoffResponse as L, OffboardingResponse as O, PostAutomatableContractAmendmentError as P, SuccessResponse as S, TerminationDetailsParams as T, ContractAmendmentResponse as a, PostCreateContractAmendmentError as b, CostCalculatorEstimateResponse as c, PostCreateEstimationError as d, CostCalculatorEstimatePdfResponse as e, PostCreateEstimationPdfError as f, CostCalculatorEstimateParams as g, EmploymentCreateParams as h, EmploymentTermType as i, PostCreateOffboardingError as j, EmploymentCreationResponse as k, PostCreateEmployment2Error as l, EmploymentResponse as m, PatchUpdateEmployment2Error as n, PutUpdateBenefitOfferError as o,
|
|
1213
|
+
export type { ContractAmendmentAutomatableResponse as C, EmploymentShowResponse as E, ListTimeoffResponse as L, MagicLinkResponse as M, OffboardingResponse as O, PostAutomatableContractAmendmentError as P, SuccessResponse as S, TerminationDetailsParams as T, UnifiedEmploymentUpsertBenefitOffersRequest as U, ContractAmendmentResponse as a, PostCreateContractAmendmentError as b, CostCalculatorEstimateResponse as c, PostCreateEstimationError as d, CostCalculatorEstimatePdfResponse as e, PostCreateEstimationPdfError as f, CostCalculatorEstimateParams as g, EmploymentCreateParams as h, EmploymentTermType as i, PostCreateOffboardingError as j, EmploymentCreationResponse as k, PostCreateEmployment2Error as l, EmploymentResponse as m, PatchUpdateEmployment2Error as n, PutUpdateBenefitOfferError as o, Company as p, PostInviteEmploymentInvitationError as q, PostCreateRiskReserveError as r, EmploymentFullParams as s, UnprocessableEntityResponse as t, MagicLinkParams as u, TimeoffStatus as v, CostCalculatorEmployment as w, Currency as x };
|
package/package.json
CHANGED
package/dist/chunk-36UPHOJS.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as o}from"./chunk-AYDF3IFZ.js";import{object as c}from"yup";function d(n){let t=n.reduce((e,r)=>(e[r.name]=r.schema,e),{});return c(t)}o(d,"buildValidationSchema");function u(n,t){return Object.entries(n).reduce((e,[r,a])=>(e[r]=t.includes(r)?a==="yes":a,e),{})}o(u,"parseFormRadioValues");export{d as a,u as b};
|
|
2
|
-
//# sourceMappingURL=chunk-36UPHOJS.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/flows/utils.ts"],"sourcesContent":["import { AnyObjectSchema, object } from 'yup';\nimport { Field } from './types';\n\n/**\n * Build the validation schema for the form.\n * @returns\n */\nexport function buildValidationSchema(fields: Field[]) {\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\ntype ParsedRadioValues = Record<string, unknown>;\n\n/**\n * Parses the form values to convert radio button values from 'yes'/'no' to boolean.\n *\n * @param values - The form values as a record of key-value pairs.\n * @param fieldKeys - An array of field keys that represent radio button fields.\n * @returns A new object with the parsed values, where radio button fields are converted to boolean.\n *\n * @example\n * const values = {\n * ack: 'yes',\n * confidential: 'no',\n * username: 'john_doe',\n * };\n * const fieldKeys = ['ack', 'confidential'];\n * const parsedValues = parseFormRadioValues(values, fieldKeys);\n * // Output: { ack: true, confidential: false, username: 'john_doe' }\n */\nexport function parseFormRadioValues(\n values: Record<string, unknown>,\n fieldKeys: string[],\n) {\n return Object.entries(values).reduce<ParsedRadioValues>(\n (acc, [key, value]) => {\n acc[key] = fieldKeys.includes(key) ? value === 'yes' : value;\n return acc;\n },\n {},\n );\n}\n"],"mappings":"wCAAA,OAA0B,UAAAA,MAAc,MAOjC,SAASC,EAAsBC,EAAiB,CACrD,IAAMC,EAAeD,EAAO,OAC1B,CAACE,EAAiBC,KAChBD,EAAgBC,EAAM,IAAI,EAAIA,EAAM,OAC7BD,GAET,CAAC,CACH,EACA,OAAOE,EAAOH,CAAY,CAC5B,CATgBI,EAAAN,EAAA,yBA8BT,SAASO,EACdC,EACAC,EACA,CACA,OAAO,OAAO,QAAQD,CAAM,EAAE,OAC5B,CAACE,EAAK,CAACC,EAAKC,CAAK,KACfF,EAAIC,CAAG,EAAIF,EAAU,SAASE,CAAG,EAAIC,IAAU,MAAQA,EAChDF,GAET,CAAC,CACH,CACF,CAXgBJ,EAAAC,EAAA","names":["object","buildValidationSchema","fields","fieldsSchema","fieldsSchemaAcc","field","object","__name","parseFormRadioValues","values","fieldKeys","acc","key","value"]}
|
package/dist/chunk-3KAYKVK5.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as J,b as x}from"./chunk-7B32RZXH.js";import{a as F}from"./chunk-JRQSZHUU.js";import{d as A,f as v,g as B,j as M,l as I,m as R,n as L,r as U}from"./chunk-DHRIURRT.js";import{a as z}from"./chunk-2URGWNSM.js";import{d as l}from"./chunk-WRDKLT4N.js";import{c as _,d as O}from"./chunk-N25EBX6R.js";import{a as e}from"./chunk-AYDF3IFZ.js";import{createHeadlessForm as H,modify as N}from"@remoteoss/json-schema-form";import{useMutation as E,useQuery as P}from"@tanstack/react-query";import{useRef as se,useState as me}from"react";import ce from"lodash/mergeWith";var le={employment_basic_information:"basic_information",contract_details:"contract_details"},fe=e(t=>{let{client:o}=l();return P({queryKey:["employment",t],retry:!1,enabled:!!t,queryFn:e(async()=>{let n=await R({client:o,headers:{Authorization:""},path:{employment_id:t}});if(n.error||!n.data)throw new Error("Failed to fetch employment data");return n},"queryFn")})},"useEmployment"),ue=e(t=>{let{client:o}=l();return P({queryKey:["benefit-offers",t],retry:!1,enabled:!!t,queryFn:e(async()=>v({client:o,headers:{Authorization:""},path:{employment_id:t}}).then(n=>{if(n.error||!n.data)throw new Error("Failed to fetch benefit offers data");return n}),"queryFn"),select:e(({data:n})=>n?.data?.reduce((i,c)=>({...i,[c.benefit_group.slug]:{value:c.benefit_tier?.slug??""}}),{}),"select")})},"useBenefitOffers"),Be=e(()=>{let{client:t}=l();return E({mutationFn:e(o=>U({client:t,headers:{Authorization:""},path:o}),"mutationFn")})},"useEmploymentInvite"),de=e(({countryCode:t,form:o,fieldValues:n,options:i,employment:c})=>{let{client:r}=l(),f=i?.jsonSchemaVersion?.form_schema?.[o]?{json_schema_version:i.jsonSchemaVersion.form_schema[o]}:{};return P({queryKey:["onboarding-json-schema-form",t,o],retry:!1,queryFn:e(async()=>{let s=await M({client:r,headers:{Authorization:""},path:{country_code:t,form:o},query:{skip_benefits:!0,...f}});if(s.error||!s.data)throw new Error("Failed to fetch onboarding schema");return s},"queryFn"),select:e(({data:s})=>{let p=s?.data||{};if(i&&i.jsfModify){let{schema:a}=N(p,i.jsfModify);p=a}let y=Object.keys(n).length>0,V=le[o],h=c?.[V]||{};return H(p,{initialValues:y?n:h})},"select")})},"useJSONSchemaForm"),pe=e((t,o,n)=>{let i=n?.jsonSchemaVersion?.benefit_offers_form_schema?{json_schema_version:n.jsonSchemaVersion.benefit_offers_form_schema}:{},{client:c}=l();return P({queryKey:["benefit-offers-schema",t],retry:!1,enabled:!!t,queryFn:e(async()=>{let r=await I({client:c,headers:{Authorization:""},path:{employment_id:t},query:i});if(r.error||!r.data)throw new Error("Failed to fetch benefit offers schema");return r},"queryFn"),select:e(({data:r})=>{let f=r?.data?.schema||{};if(n&&n.jsfModify){let{schema:y}=N(f,n.jsfModify);f=y}let s=Object.keys(o).length>0;return H(f,{initialValues:s?{...o}:{}})},"select")})},"useBenefitOffersSchema"),ye=e(()=>{let{client:t}=l();return E({mutationFn:e(o=>A({client:t,headers:{Authorization:""},body:o}),"mutationFn")})},"useCreateEmployment"),he=e(()=>{let{client:t}=l();return E({mutationFn:e(({employmentId:o,...n})=>L({client:t,headers:{Authorization:""},body:n,path:{employment_id:o},query:{skip_benefits:!0}}),"mutationFn")})},"useUpdateEmployment"),Se=e(()=>{let{client:t}=l();return E({mutationFn:e(({employmentId:o,...n})=>B({client:t,headers:{Authorization:""},body:n,path:{employment_id:o}}),"mutationFn")})},"useUpdateBenefitsOffers"),Me=e(({employmentId:t,countryCode:o,type:n,options:i})=>{let c=se({}),[r,f]=me(t),{data:s,isLoading:p}=fe(t),{data:y,isLoading:V}=ue(r),{fieldValues:h,stepState:a,setFieldValues:K,previousStep:D,nextStep:Q,goToStep:W}=z(J),w=ye(),k=he(),j=Se(),{mutateAsync:G}=F(w),{mutateAsync:T}=F(k),{mutateAsync:X}=F(j),Y={basic_information:"employment_basic_information",contract_details:"contract_details",benefits:null,review:null},{data:u,isLoading:Z}=de({countryCode:o,form:Y[a.currentStep.name]||"employment_basic_information",fieldValues:{...a.values?.[a.currentStep.name],...h},options:i,employment:s?.data?.data?.employment}),{data:g,isLoading:$}=pe(r,h,i),ee={...a.values?.[a.currentStep.name],...h},te=a.currentStep.name==="benefits"?ce({},y,ee):{},b={basic_information:u?.fields||[],contract_details:u?.fields||[],benefits:g?.fields||[],review:[]},ne={basic_information:O(b[a.currentStep.name],s?.data?.data.employment?.basic_information||{}),contract_details:O(b[a.currentStep.name],s?.data?.data.employment?.contract_details||{}),benefits:te||{}};function C(m){return u?_(m,u?.fields,{isPartialValidation:!0}):{}}e(C,"parseFormValues");async function oe(m){c.current[a.currentStep.name]=x(m,b[a.currentStep.name]);let d=C(m);switch(a.currentStep.name){case"basic_information":{if(r)return T({employmentId:r,basic_information:d,pricing_plan_details:{frequency:"monthly"}});{let q={basic_information:d,type:n,country_code:o};try{let S=await G(q);return f(S.data?.data?.employment?.id),S}catch(S){throw console.error("Error creating onboarding:",S),S}}}case"contract_details":return T({employmentId:r,...{contract_details:d}});case"benefits":return X({employmentId:r,...m})}}e(oe,"onSubmit");function ae(){D()}e(ae,"back");function re(){Q()}e(re,"next");function ie(m){W(m)}return e(ie,"goTo"),{employmentId:t,stepState:a,fields:b[a.currentStep.name],isLoading:Z||p||$||V,isSubmitting:w.isPending||k.isPending||j.isPending,initialValues:ne,handleValidation:e(m=>{if(a.currentStep.name==="benefits"&&g){let d=_(m,g?.fields);return g?.handleValidation(d)}if(u){let d=_(m,u?.fields);return u?.handleValidation(d)}return null},"handleValidation"),checkFieldUpdates:K,parseFormValues:C,onSubmit:oe,back:ae,next:re,goTo:ie,meta:{fields:c.current}}},"useOnboarding");export{Be as a,Me as b};
|
|
2
|
-
//# sourceMappingURL=chunk-3KAYKVK5.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/flows/Onboarding/hooks.ts"],"sourcesContent":["import {\n Employment,\n EmploymentCreateParams,\n EmploymentFullParams,\n getShowEmployment,\n getShowFormCountry,\n patchUpdateEmployment2,\n postCreateEmployment2,\n postInviteEmploymentInvitation,\n PostInviteEmploymentInvitationData,\n getShowSchema,\n putUpdateBenefitOffer,\n UnifiedEmploymentUpsertBenefitOffersRequest,\n getIndexBenefitOffer,\n} from '@/src/client';\nimport { Client } from '@hey-api/client-fetch';\nimport {\n createHeadlessForm,\n Fields,\n modify,\n} from '@remoteoss/json-schema-form';\nimport { useMutation, useQuery } from '@tanstack/react-query';\n\nimport { useClient } from '@/src/context';\nimport { useStepState } from '@/src/flows/useStepState';\nimport { prettifyFormValues, STEPS } from '@/src/flows/Onboarding/utils';\nimport {\n getInitialValues,\n parseJSFToValidate,\n} from '@/src/components/form/utils';\nimport { mutationToPromise } from '@/src/lib/mutations';\nimport { FieldValues } from 'react-hook-form';\nimport { OnboardingFlowParams } from '@/src/flows/Onboarding/types';\nimport { JSONSchemaFormType } from '@/src/flows/types';\nimport { useRef, useState } from 'react';\nimport mergeWith from 'lodash/mergeWith';\n\ntype OnboardingHookProps = OnboardingFlowParams;\n\nconst jsonSchemaToEmployment: Partial<\n Record<JSONSchemaFormType, keyof Employment>\n> = {\n employment_basic_information: 'basic_information',\n contract_details: 'contract_details',\n};\n\nconst useEmployment = (employmentId: string | undefined) => {\n const { client } = useClient();\n\n return useQuery({\n queryKey: ['employment', employmentId],\n retry: false,\n enabled: !!employmentId,\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\nconst 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 headers: {\n Authorization: ``,\n },\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 ?? '',\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\n/**\n * Use this hook to get the JSON schema form for the onboarding flow\n * @param param0\n * @returns\n */\nconst useJSONSchemaForm = ({\n countryCode,\n form,\n fieldValues,\n options,\n employment,\n}: {\n countryCode: string;\n form: JSONSchemaFormType;\n fieldValues: FieldValues;\n options?: OnboardingHookProps['options'];\n employment?: Employment;\n}) => {\n const { client } = useClient();\n const jsonSchemaQueryParam = options?.jsonSchemaVersion?.form_schema?.[form]\n ? {\n json_schema_version: options.jsonSchemaVersion.form_schema[form],\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 ...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 select: ({ data }) => {\n let jsfSchema = data?.data || {};\n if (options && options.jsfModify) {\n const { schema } = modify(jsfSchema, options.jsfModify);\n jsfSchema = schema;\n }\n const hasFieldValues = Object.keys(fieldValues).length > 0;\n const employmentField = jsonSchemaToEmployment[form] as keyof Employment;\n const employmentFieldData = (employment?.[employmentField] ||\n {}) as Record<string, unknown>;\n return createHeadlessForm(jsfSchema, {\n initialValues: hasFieldValues ? fieldValues : employmentFieldData,\n });\n },\n });\n};\n\nconst useBenefitOffersSchema = (\n employmentId: string,\n fieldValues: FieldValues,\n options: OnboardingHookProps['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 headers: {\n Authorization: ``,\n },\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) {\n const { schema } = modify(jsfSchema, options.jsfModify);\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 */\nconst useCreateEmployment = () => {\n const { client } = useClient();\n return useMutation({\n mutationFn: (payload: EmploymentCreateParams) => {\n return postCreateEmployment2({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n });\n },\n });\n};\n\nconst useUpdateEmployment = () => {\n const { client } = useClient();\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 },\n });\n },\n });\n};\n\nconst useUpdateBenefitsOffers = () => {\n const { client } = useClient();\n return useMutation({\n mutationFn: ({\n employmentId,\n ...payload\n }: UnifiedEmploymentUpsertBenefitOffersRequest & {\n employmentId: string;\n }) => {\n return putUpdateBenefitOffer({\n client: client as Client,\n headers: {\n Authorization: ``,\n },\n body: payload,\n path: {\n employment_id: employmentId,\n },\n });\n },\n });\n};\n\nexport const useOnboarding = ({\n employmentId,\n countryCode,\n type,\n options,\n}: OnboardingHookProps) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n const fieldsMetaRef = useRef<Record<string, any>>({});\n const [internalEmploymentId, setInternalEmploymentId] = useState<\n string | undefined\n >(employmentId);\n const { data: employment, isLoading: isLoadingEmployment } =\n useEmployment(employmentId);\n\n const { data: benefitOffers, isLoading: isLoadingBenefitOffers } =\n useBenefitOffers(internalEmploymentId);\n const {\n fieldValues,\n stepState,\n setFieldValues,\n previousStep,\n nextStep,\n goToStep,\n } = useStepState<keyof typeof STEPS>(STEPS);\n\n const createEmploymentMutation = useCreateEmployment();\n const updateEmploymentMutation = useUpdateEmployment();\n const updateBenefitsOffersMutation = useUpdateBenefitsOffers();\n const { mutateAsync: createEmploymentMutationAsync } = mutationToPromise(\n createEmploymentMutation,\n );\n const { mutateAsync: updateEmploymentMutationAsync } = mutationToPromise(\n updateEmploymentMutation,\n );\n const { mutateAsync: updateBenefitsOffersMutationAsync } = mutationToPromise(\n updateBenefitsOffersMutation,\n );\n\n const form: Record<keyof typeof STEPS, JSONSchemaFormType | null> = {\n basic_information: 'employment_basic_information',\n contract_details: 'contract_details',\n benefits: null,\n review: null,\n };\n\n const { data: onboardingForm, isLoading: isLoadingBasicInformation } =\n useJSONSchemaForm({\n countryCode: countryCode,\n form:\n form[stepState.currentStep.name as keyof typeof STEPS] ||\n 'employment_basic_information',\n fieldValues: {\n ...stepState.values?.[stepState.currentStep.name as keyof typeof STEPS], // Restore values for the current step\n ...fieldValues,\n },\n options: options,\n employment: employment?.data?.data?.employment,\n });\n\n const {\n data: benefitOffersSchema,\n isLoading: isLoadingBenefitsOffersSchema,\n } = useBenefitOffersSchema(\n internalEmploymentId as string,\n fieldValues,\n options,\n );\n\n const benefitsFormValues = {\n ...stepState.values?.[stepState.currentStep.name as keyof typeof STEPS], // Restore values for the current step\n ...fieldValues,\n };\n\n const initialValuesBenefitOffers =\n stepState.currentStep.name === 'benefits'\n ? mergeWith({}, benefitOffers, benefitsFormValues)\n : {};\n\n const stepFields: Record<keyof typeof STEPS, Fields> = {\n basic_information: onboardingForm?.fields || [],\n contract_details: onboardingForm?.fields || [],\n benefits: benefitOffersSchema?.fields || [],\n review: [],\n };\n\n const initialValues = {\n basic_information: getInitialValues(\n stepFields[stepState.currentStep.name],\n employment?.data?.data.employment?.basic_information || {},\n ),\n contract_details: getInitialValues(\n stepFields[stepState.currentStep.name],\n employment?.data?.data.employment?.contract_details || {},\n ),\n benefits: initialValuesBenefitOffers || {},\n };\n\n function parseFormValues(values: FieldValues) {\n if (onboardingForm) {\n return parseJSFToValidate(values, onboardingForm?.fields, {\n isPartialValidation: true,\n });\n }\n return {};\n }\n\n async function onSubmit(values: FieldValues) {\n // Prettify values for the current step\n fieldsMetaRef.current[stepState.currentStep.name] = prettifyFormValues(\n values,\n stepFields[stepState.currentStep.name],\n );\n\n const parsedValues = parseFormValues(values);\n switch (stepState.currentStep.name) {\n case 'basic_information': {\n if (!internalEmploymentId) {\n const payload: EmploymentCreateParams = {\n basic_information: parsedValues,\n type: type,\n country_code: countryCode,\n };\n try {\n const response = await createEmploymentMutationAsync(payload);\n setInternalEmploymentId(\n // @ts-expect-error the types from the response are not matching\n response.data?.data?.employment?.id,\n );\n return response;\n } catch (error) {\n console.error('Error creating onboarding:', error);\n throw error;\n }\n } else {\n return updateEmploymentMutationAsync({\n employmentId: internalEmploymentId,\n basic_information: parsedValues,\n pricing_plan_details: {\n frequency: 'monthly',\n },\n });\n }\n }\n\n case 'contract_details': {\n const payload: EmploymentFullParams = {\n contract_details: parsedValues,\n };\n return updateEmploymentMutationAsync({\n employmentId: internalEmploymentId as string,\n ...payload,\n });\n }\n\n case 'benefits': {\n return updateBenefitsOffersMutationAsync({\n employmentId: internalEmploymentId as string,\n ...values,\n });\n }\n }\n return;\n }\n\n function back() {\n previousStep();\n }\n\n function next() {\n nextStep();\n }\n\n function goTo(step: keyof typeof STEPS) {\n goToStep(step);\n }\n\n return {\n /**\n * Employment id passed useful to be used between components\n */\n employmentId,\n /**\n * Current step state containing the current step and total number of steps\n */\n stepState,\n /**\n * Array of form fields from the onboarding schema\n */\n fields: stepFields[stepState.currentStep.name],\n /**\n * Loading state indicating if the onboarding schema is being fetched\n */\n isLoading:\n isLoadingBasicInformation ||\n isLoadingEmployment ||\n isLoadingBenefitsOffersSchema ||\n isLoadingBenefitOffers,\n /**\n * Loading state indicating if the onboarding mutation is in progress\n */\n isSubmitting:\n createEmploymentMutation.isPending ||\n updateEmploymentMutation.isPending ||\n updateBenefitsOffersMutation.isPending,\n /**\n * Initial form values\n */\n initialValues,\n /**\n * Function to validate form values against the onboarding schema\n * @param values - Form values to validate\n * @returns Validation result or null if no schema is available\n */\n handleValidation: (values: FieldValues) => {\n if (stepState.currentStep.name === 'benefits' && benefitOffersSchema) {\n const parsedValues = parseJSFToValidate(\n values,\n benefitOffersSchema?.fields,\n );\n\n return benefitOffersSchema?.handleValidation(parsedValues);\n }\n if (onboardingForm) {\n const parsedValues = parseJSFToValidate(values, onboardingForm?.fields);\n\n return onboardingForm?.handleValidation(parsedValues);\n }\n return null;\n },\n /**\n * Function to update the current form field values\n * @param values - New form values to set\n */\n checkFieldUpdates: setFieldValues,\n\n /**\n * Function to parse form values before submission\n * @param values - Form values to parse\n * @returns Parsed form values\n */\n parseFormValues,\n\n /**\n * Function to handle form submission\n * @param values - Form values to submit\n * @returns Promise resolving to the mutation result\n */\n onSubmit,\n\n /**\n * Function to handle going back to the previous step\n * @returns {void}\n */\n back,\n\n /**\n * Function to handle going to the next step\n * @returns {void}\n */\n next,\n\n /**\n * Function to handle going to a specific step\n * @param step The step to go to.\n * @returns {void}\n */\n goTo,\n\n /**\n * Fields metadata for each step\n */\n meta: {\n fields: fieldsMetaRef.current,\n },\n };\n};\n"],"mappings":"uVAgBA,OACE,sBAAAA,EAEA,UAAAC,MACK,8BACP,OAAS,eAAAC,EAAa,YAAAC,MAAgB,wBAatC,OAAS,UAAAC,GAAQ,YAAAC,OAAgB,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AfkB,oBAoBlB,kBAAmB5B,EAOnB,gBAAAuB,EAOA,SAAAG,GAMA,KAAAI,GAMA,KAAAC,GAOA,KAAAC,GAKA,KAAM,CACJ,OAAQzC,EAAc,OACxB,CACF,CACF,EAnR6B","names":["createHeadlessForm","modify","useMutation","useQuery","useRef","useState","mergeWith","jsonSchemaToEmployment","useEmployment","__name","employmentId","client","useClient","useQuery","response","getShowEmployment","useBenefitOffers","getIndexBenefitOffer","data","acc","item","useEmploymentInvite","useMutation","payload","postInviteEmploymentInvitation","useJSONSchemaForm","countryCode","form","fieldValues","options","employment","jsonSchemaQueryParam","getShowFormCountry","jsfSchema","schema","modify","hasFieldValues","employmentField","employmentFieldData","createHeadlessForm","useBenefitOffersSchema","getShowSchema","useCreateEmployment","postCreateEmployment2","useUpdateEmployment","patchUpdateEmployment2","useUpdateBenefitsOffers","putUpdateBenefitOffer","useOnboarding","type","fieldsMetaRef","useRef","internalEmploymentId","setInternalEmploymentId","useState","isLoadingEmployment","benefitOffers","isLoadingBenefitOffers","stepState","setFieldValues","previousStep","nextStep","goToStep","useStepState","STEPS","createEmploymentMutation","updateEmploymentMutation","updateBenefitsOffersMutation","createEmploymentMutationAsync","mutationToPromise","updateEmploymentMutationAsync","updateBenefitsOffersMutationAsync","onboardingForm","isLoadingBasicInformation","benefitOffersSchema","isLoadingBenefitsOffersSchema","benefitsFormValues","initialValuesBenefitOffers","mergeWith","stepFields","initialValues","getInitialValues","parseFormValues","values","parseJSFToValidate","onSubmit","prettifyFormValues","parsedValues","error","back","next","goTo","step"]}
|
package/dist/chunk-7B32RZXH.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as l}from"./chunk-AYDF3IFZ.js";var d={basic_information:{index:0,name:"basic_information"},contract_details:{index:1,name:"contract_details"},benefits:{index:2,name:"benefits"},review:{index:3,name:"review"}};function o(s,a){return a?Object.fromEntries(Object.entries(s).map(([t,r])=>{if(r===void 0)return[t,void 0];let e=a.find(n=>n.name===t);if(e?.isVisible===!1||e?.deprecated)return[t,void 0];if(e?.type==="radio"||e?.type==="select"){let n=e.options.find(i=>i.value===r);return n?[t,{prettyValue:n?.label,label:e?.label}]:void 0}if(e?.type==="checkbox"&&e?.const)return[t,{prettyValue:!0,label:e.label}];if(e?.type==="countries"&&Array.isArray(r))return[t,{prettyValue:r.join(),label:e.label}];if(e?.type==="fieldset"){let n=o(r,e.fields);if(!n.label&&n.value){let i={...n.value,label:e.label};return[t,i]}return[t,n]}if(e)return[t,{prettyValue:r,label:e.label}]}).filter(Boolean)):{}}l(o,"prettifyFormValues");export{d as a,o as b};
|
|
2
|
-
//# sourceMappingURL=chunk-7B32RZXH.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/flows/Onboarding/utils.ts"],"sourcesContent":["import { Step } from '@/src/flows/useStepState';\nimport { Fields } from '@remoteoss/json-schema-form';\n\ntype StepKeys =\n | 'basic_information'\n | 'contract_details'\n | 'benefits'\n | 'review';\n\nexport const STEPS: Record<StepKeys, Step<StepKeys>> = {\n basic_information: { index: 0, name: 'basic_information' },\n contract_details: { index: 1, name: 'contract_details' },\n benefits: { index: 2, name: 'benefits' },\n review: { index: 3, name: 'review' },\n} as const;\n\n/**\n * Function to prettify form values. Returns a pretty value and label for each field.\n * @param values - Form values to prettify\n * @param fields - Form fields\n * @returns Prettified form values\n */\n// @ts-expect-error need to check function return type\nexport function prettifyFormValues(\n values: Record<string, unknown>,\n fields: Fields | undefined,\n) {\n if (!fields) {\n return {};\n }\n return Object.fromEntries(\n Object.entries(values)\n // @ts-expect-error need to check function return type\n .map(([key, value]) => {\n if (value === undefined) {\n return [key, undefined];\n }\n\n const field = fields.find((field) => field.name === key);\n\n if (field?.isVisible === false || field?.deprecated) {\n return [key, undefined];\n }\n\n if (field?.type === 'radio' || field?.type === 'select') {\n const option = (\n field.options as Array<{ value: string; label: string }>\n ).find((option) => option.value === value);\n\n if (option) {\n return [key, { prettyValue: option?.label, label: field?.label }];\n }\n return;\n }\n\n if (field?.type === 'checkbox' && field?.const) {\n return [key, { prettyValue: true, label: field.label }];\n }\n\n if (field?.type === 'countries' && Array.isArray(value)) {\n return [key, { prettyValue: value.join(), label: field.label }];\n }\n\n if (field?.type === 'fieldset') {\n // @ts-expect-error need to check function return type\n const prettiedFieldset = prettifyFormValues(\n value as Record<string, unknown>,\n field.fields as Fields,\n );\n\n // Handles benefits fieldset in specific\n if (!prettiedFieldset.label && prettiedFieldset.value) {\n const prettyValue: Record<string, unknown> = {\n ...prettiedFieldset.value,\n label: field.label,\n };\n return [key, prettyValue];\n }\n\n return [key, prettiedFieldset];\n }\n\n if (field) {\n return [key, { prettyValue: value, label: field.label }];\n }\n })\n .filter(Boolean),\n );\n}\n"],"mappings":"wCASO,IAAMA,EAA0C,CACrD,kBAAmB,CAAE,MAAO,EAAG,KAAM,mBAAoB,EACzD,iBAAkB,CAAE,MAAO,EAAG,KAAM,kBAAmB,EACvD,SAAU,CAAE,MAAO,EAAG,KAAM,UAAW,EACvC,OAAQ,CAAE,MAAO,EAAG,KAAM,QAAS,CACrC,EASO,SAASC,EACdC,EACAC,EACA,CACA,OAAKA,EAGE,OAAO,YACZ,OAAO,QAAQD,CAAM,EAElB,IAAI,CAAC,CAACE,EAAKC,CAAK,IAAM,CACrB,GAAIA,IAAU,OACZ,MAAO,CAACD,EAAK,MAAS,EAGxB,IAAME,EAAQH,EAAO,KAAMG,GAAUA,EAAM,OAASF,CAAG,EAEvD,GAAIE,GAAO,YAAc,IAASA,GAAO,WACvC,MAAO,CAACF,EAAK,MAAS,EAGxB,GAAIE,GAAO,OAAS,SAAWA,GAAO,OAAS,SAAU,CACvD,IAAMC,EACJD,EAAM,QACN,KAAMC,GAAWA,EAAO,QAAUF,CAAK,EAEzC,OAAIE,EACK,CAACH,EAAK,CAAE,YAAaG,GAAQ,MAAO,MAAOD,GAAO,KAAM,CAAC,EAElE,MACF,CAEA,GAAIA,GAAO,OAAS,YAAcA,GAAO,MACvC,MAAO,CAACF,EAAK,CAAE,YAAa,GAAM,MAAOE,EAAM,KAAM,CAAC,EAGxD,GAAIA,GAAO,OAAS,aAAe,MAAM,QAAQD,CAAK,EACpD,MAAO,CAACD,EAAK,CAAE,YAAaC,EAAM,KAAK,EAAG,MAAOC,EAAM,KAAM,CAAC,EAGhE,GAAIA,GAAO,OAAS,WAAY,CAE9B,IAAME,EAAmBP,EACvBI,EACAC,EAAM,MACR,EAGA,GAAI,CAACE,EAAiB,OAASA,EAAiB,MAAO,CACrD,IAAMC,EAAuC,CAC3C,GAAGD,EAAiB,MACpB,MAAOF,EAAM,KACf,EACA,MAAO,CAACF,EAAKK,CAAW,CAC1B,CAEA,MAAO,CAACL,EAAKI,CAAgB,CAC/B,CAEA,GAAIF,EACF,MAAO,CAACF,EAAK,CAAE,YAAaC,EAAO,MAAOC,EAAM,KAAM,CAAC,CAE3D,CAAC,EACA,OAAO,OAAO,CACnB,EA3DS,CAAC,CA4DZ,CAjEgBI,EAAAT,EAAA","names":["STEPS","prettifyFormValues","values","fields","key","value","field","option","prettiedFieldset","prettyValue","__name"]}
|
package/dist/chunk-DHRIURRT.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{a as t}from"./chunk-AYDF3IFZ.js";import{formDataBodySerializer as i}from"@hey-api/client-fetch";import{createClient as o,createConfig as n}from"@hey-api/client-fetch";var r=o(n({baseUrl:"https://gateway.remote.com/"}));var c=t(e=>(e?.client??r).post({security:[{scheme:"bearer",type:"http"}],url:"/v1/offboardings",...e,headers:{"Content-Type":"application/json",...e?.headers}}),"postCreateOffboarding");var h=t(e=>(e.client??r).get({security:[{scheme:"bearer",type:"http"}],url:"/v1/contract-amendments/schema",...e}),"getShowContractAmendmentSchema");var d=t(e=>(e.client??r).post({security:[{scheme:"bearer",type:"http"}],url:"/v1/employments",...e,headers:{"Content-Type":"application/json",...e?.headers}}),"postCreateEmployment2");var m=t(e=>(e.client??r).post({security:[{scheme:"bearer",type:"http"}],url:"/v1/cost-calculator/estimation",...e,headers:{"Content-Type":"application/json",...e?.headers}}),"postCreateEstimation");var u=t(e=>(e.client??r).get({security:[{scheme:"bearer",type:"http"}],url:"/v1/employments/{employment_id}/benefit-offers",...e}),"getIndexBenefitOffer"),E=t(e=>(e.client??r).put({security:[{scheme:"bearer",type:"http"}],url:"/v1/employments/{employment_id}/benefit-offers",...e,headers:{"Content-Type":"application/json",...e?.headers}}),"putUpdateBenefitOffer");var y=t(e=>(e?.client??r).post({security:[{scheme:"bearer",type:"http"}],url:"/v1/cost-calculator/estimation-pdf",...e,headers:{"Content-Type":"application/json",...e?.headers}}),"postCreateEstimationPdf");var w=t(e=>(e.client??r).post({security:[{scheme:"bearer",type:"http"}],url:"/v1/contract-amendments",...e,headers:{"Content-Type":"application/json",...e?.headers}}),"postCreateContractAmendment");var C=t(e=>(e.client??r).get({security:[{scheme:"bearer",type:"http"}],url:"/v1/countries/{country_code}/{form}",...e}),"getShowFormCountry");var O=t(e=>(e.client??r).get({security:[{scheme:"bearer",type:"http"}],url:"/v1/cost-calculator/countries",...e}),"getIndexCountry");var T=t(e=>(e.client??r).get({security:[{scheme:"bearer",type:"http"}],url:"/v1/employments/{employment_id}/benefit-offers/schema",...e}),"getShowSchema");var x=t(e=>(e.client??r).get({security:[{scheme:"bearer",type:"http"}],url:"/v1/employments/{employment_id}",...e}),"getShowEmployment"),f=t(e=>(e.client??r).patch({security:[{scheme:"bearer",type:"http"}],url:"/v1/employments/{employment_id}",...e,headers:{"Content-Type":"application/json",...e?.headers}}),"patchUpdateEmployment2");var R=t(e=>(e.client??r).get({security:[{scheme:"bearer",type:"http"}],url:"/v1/cost-calculator/regions/{slug}/fields",...e}),"getShowRegionField");var P=t(e=>(e.client??r).post({security:[{scheme:"bearer",type:"http"}],url:"/v1/contract-amendments/automatable",...e,headers:{"Content-Type":"application/json",...e?.headers}}),"postAutomatableContractAmendment");var b=t(e=>(e?.client??r).get({security:[{scheme:"bearer",type:"http"}],url:"/v1/company-currencies",...e}),"getIndexCompanyCurrency");var G=t(e=>(e.client??r).post({security:[{scheme:"bearer",type:"http"}],url:"/v1/employments/{employment_id}/invite",...e}),"postInviteEmploymentInvitation");var D=t(e=>(e.client??r).get({security:[{scheme:"bearer",type:"http"}],url:"/v1/timeoff",...e}),"getIndexTimeoff");export{r as a,c as b,h as c,d,m as e,u as f,E as g,y as h,w as i,C as j,O as k,T as l,x as m,f as n,R as o,P as p,b as q,G as r,D as s};
|
|
2
|
-
//# sourceMappingURL=chunk-DHRIURRT.js.map
|