@kiwicom/smart-faq
Version:
46 lines (37 loc) • 1.02 kB
JavaScript
// @flow
import * as React from 'react';
import { graphql, createFragmentContainer } from 'react-relay';
import type { BookingInfo_booking as BookingInfoType } from './__generated__/BookingInfo_booking.graphql';
type Context = {|
onLoad: (upcomingLeg: ?BookingInfoType) => void,
|};
const bookingInfoContext: React.Context<Context> = React.createContext({
// eslint-disable-next-line no-unused-vars
onLoad: (upcomingLeg: ?BookingInfoType) => {},
});
type Props = {
booking: ?BookingInfoType,
};
const BookingInfo = ({ booking }: Props) => (
<Consumer>{({ onLoad }) => onLoad(booking)}</Consumer>
);
export const { Consumer, Provider } = bookingInfoContext;
export default createFragmentContainer(
BookingInfo,
graphql`
fragment BookingInfo_booking on BookingInterface {
bid: id(opaque: false)
upcoming: upcomingLeg {
arrival {
time
}
departure {
time
}
}
customerSupport {
hasGuaranteeChat
}
}
`,
);