UNPKG

@kiwicom/smart-faq

Version:

41 lines (31 loc) 967 B
// @flow import * as React from 'react'; import { graphql, createFragmentContainer } from 'react-relay'; import { CarrierLogo } from '@kiwicom/orbit-components'; import type { CarrierLogoWrapper_legs as CarrierLogoWrapperType } from './__generated__/CarrierLogoWrapper_legs.graphql'; type Props = { legs: CarrierLogoWrapperType, }; const CarrierLogoWrapper = ({ legs }: Props) => { const carriers = legs.reduce((acc, leg) => { const code = leg?.airline?.code; const name = leg?.airline?.name; if (code && name && !acc.find(e => e.code === code)) { return [...acc, { code, name }]; } return acc; }, []); return <CarrierLogo size="large" carriers={carriers} />; }; export const RawCarrierLogoWrapper = CarrierLogoWrapper; export default createFragmentContainer( CarrierLogoWrapper, graphql` fragment CarrierLogoWrapper_legs on Leg @relay(plural: true) { airline { name code } } `, );