/* @flow */ import { goToQuestion } from 'Actions/actions' import { T } from 'Components' import withLanguage from 'Components/utils/withLanguage' import { compose, contains, reject, toPairs } from 'ramda' import React, { Fragment } from 'react' import { connect } from 'react-redux' import { withRouter } from 'react-router' import { currentQuestionSelector } from 'Selectors/analyseSelectors' import type { Location } from 'react-router' type OwnProps = { quickLinks: { [string]: string } } type Props = OwnProps & { goToQuestion: string => void, location: Location, quickLinksToHide: Array, show: boolean } const QuickLinks = ({ goToQuestion, quickLinks, quickLinksToHide }: Props) => { if (!quickLinks) { return null } const links = compose( toPairs, reject(dottedName => contains(dottedName, quickLinksToHide)) )(quickLinks) return ( !!links.length && ( Autres questions : {' '} {links.map(([label, dottedName]) => ( {' '} /{' '} ))}{' '} {/* */} ) ) } export default (compose( withLanguage, withRouter, connect( (state, props) => ({ key: props.language, quickLinks: state.simulation?.config.questions?.["à l'affiche"], quickLinksToHide: [ ...state.conversationSteps.foldedSteps, currentQuestionSelector(state) ] }), { goToQuestion } ) )(QuickLinks): React$ComponentType)