@kiwicom/smart-faq
Version:
48 lines (41 loc) • 1.28 kB
JavaScript
// @flow
import * as React from 'react';
import { withRouter } from 'react-router-dom';
import type { ContextRouter } from 'react-router-dom';
import { BookingState } from '../../context/BookingState';
import { SearchState } from '../../context/SearchState';
import LogClick from '../../../components/Log/LogClick';
import Link from './Link';
import { events } from '../../../const/events';
type Props = {|
...ContextRouter,
translationKey?: string,
type?: 'primary' | 'secondary',
justify?: 'start' | 'center',
|};
const ContactUsLink = (props: Props) => {
const { FAQSection } = React.useContext(BookingState);
const { searchText } = React.useContext(SearchState);
const { match, translationKey, type, justify } = props;
const articleId = match?.params?.articleId ?? '';
const categoryId = match?.params?.categoryId ?? '';
const trackProps = {
section: FAQSection ?? '',
searchText,
articleId,
categoryId,
};
return (
<LogClick event={events.LINK_CONTACT_US_CLICKED} props={trackProps}>
{({ onClick }) => (
<Link
translationKey={translationKey}
type={type}
justify={justify}
onClick={onClick}
/>
)}
</LogClick>
);
};
export default withRouter(ContactUsLink);