UNPKG

react-native-unit-components

Version:

Unit React Native components

35 lines (29 loc) 1.04 kB
import WebView from 'react-native-webview'; import { RequestRefreshEvent } from '../../messages/webMessages/unitComponentsMessages'; import { UNWhiteLabelAppComponentProps } from './UNWhiteLabelAppComponent'; import { DISPATCH_REQUEST_REFRESH, LISTENERS } from '../../scripts/html/bodyScript'; export const getWhiteLabelAppParams = (props: UNWhiteLabelAppComponentProps) => { // customer token is the preferred way to authenticate if (props.customerToken) { return ` customer-token="${props.customerToken}" `; } if (props.jwtToken) { return ` jwt-token="${props.jwtToken}" `; } return ''; }; export const injectRefreshEventIfNeeded = (currentWeb: WebView | null, requestRefreshEvent: RequestRefreshEvent | null) => { if (requestRefreshEvent) { currentWeb?.injectJavaScript(`dispatchRefreshEvent('${JSON.stringify(requestRefreshEvent)}')`); } }; export const getWhiteLabelAppScript = () => { return ` ${DISPATCH_REQUEST_REFRESH} ${LISTENERS.unitWhiteLabelAppOnLoad} `; };