import React, { Fragment } from 'react'; import Config from 'react-native-config'; import { Answer, Question as QuestionT } from 'libs/graphql'; import { useVariables } from 'libs/native-base'; import buildURL from 'utils/buildURL'; import { Linking, StyleSheet } from 'react-native'; import { Button, H1, Text } from 'native-base'; import Content from '../Content/Content'; import Image from './Image'; import Alert, { AlertVariant } from './Alert'; export type QuestionProps = { question: QuestionT; reviewMode: boolean; selectedAnswer: Answer; selectAnswer: (a: Answer) => void; }; const ANSWERS = Object.values(Answer); const Question = ({ question, selectedAnswer, reviewMode, selectAnswer, }: QuestionProps) => { const variables = useVariables(); return ( {reviewMode && ( Linking.openURL(buildURL('email', Config.CONTACT_EMAIL)) } > Zgłoś go. } /> )} {question.from && {question.from}}

{question.content}

{question.image ? ( ) : null} {reviewMode && ( {!selectedAnswer ? ( ) : null} {question.explanation ? ( ) : null} )} {ANSWERS.map((answer, index) => { const upper = answer.toUpperCase(); const image = question[ `answer${upper}Image` as keyof QuestionT ] as string; const answerContent = question[ `answer${upper}` as keyof QuestionT ] as string; const isCorrect = answer === question.correctAnswer; const isSelected = selectedAnswer === answer; return ( ); })}
); }; const styles = StyleSheet.create({ mb: { marginBottom: 15, }, button: { height: 'auto', }, answerContent: { alignSelf: 'flex-start', }, answerImage: { marginTop: 5, }, }); export default Question;