UNPKG

@applicaster/zapp-react-native-ui-components

Version:

Applicaster Zapp React Native ui components for the Quick Brick App

40 lines (33 loc) 972 B
import * as R from "ramda"; import { getInflatedDataSourceUrl, getSearchContext, } from "@applicaster/zapp-react-native-utils/reactHooks"; import { ZappPipesEntryContext } from "../../../Contexts"; export const getDatasourceUrl: ( contexts: { screenData?: Record<string, any>; entryContext: ReturnType< typeof ZappPipesEntryContext.useZappPipesContext >[0]; searchContext: string; screenContext: ZappRiver; }, component?: ZappUIComponent ) => string | null = R.curry( ( { screenData, entryContext, searchContext, screenContext }, component: ZappUIComponent ) => { const { source, mapping } = R.propOr({}, ["data"], component); if (mapping) { const contexts = { entry: entryContext, screen: screenContext || screenData, search: getSearchContext(searchContext, mapping), }; return getInflatedDataSourceUrl({ source, mapping, contexts }); } return source; } );