UNPKG

@kiwicom/smart-faq

Version:

71 lines (62 loc) 1.83 kB
// @flow import * as React from 'react'; import InitIntl from '@kiwicom/nitro/lib/components/InitIntl'; import * as intlContext from '@kiwicom/nitro/lib/services/intl/context'; import { langInfos } from '../translations/langInfos'; import fallbackTranslations from '../translations/enKeys.json'; import GuaranteeChatInfo from '../shared/context/GuaranteeChatInfo'; import ContactFormChat from './ContactFormChat'; type Props = { bid: ?number, loginToken: ?string, kwAuthToken: ?string, simpleToken: ?string, enableChat: boolean, translations: { [key: string]: string } | null, chatConfig: { [key: string]: string } | null, language: string, brand: string, }; class ContactFormChatApp extends React.Component<Props> { render() { const { language, loginToken, kwAuthToken, simpleToken, bid, brand, enableChat, } = this.props; const langInfo = langInfos[language]; const translations = this.props.translations ? this.props.translations : fallbackTranslations; if (!loginToken && !(simpleToken && bid)) { return null; } const intl = { language: langInfo, translations }; return ( <InitIntl raw={intl}> {intl => ( <intlContext.Provider value={intl}> <GuaranteeChatInfo enableChat={enableChat} chatConfig={this.props.chatConfig} > <ContactFormChat loginToken={loginToken} simpleToken={simpleToken} kwAuthToken={kwAuthToken} bid={bid} brand={brand} language={language} /> </GuaranteeChatInfo> </intlContext.Provider> )} </InitIntl> ); } } export default ContactFormChatApp;