{"version":3,"file":"Question-C0EE5UV5.js","sources":["../../../frontend/src/Components/DesignSystem/FormEmbed/FormIframe.tsx","../../../frontend/src/Components/FormResponses/Results/QuestionOptions.tsx","../../../frontend/src/Components/FormResponses/Results/Answers.tsx","../../../frontend/src/Components/FormResponses/Results/Question.tsx"],"sourcesContent":["import React from 'react';\nimport { Box, CircularProgress } from '@mui/material';\nimport { styled } from '@mui/material/styles';\n\nconst StyledIframe = styled('iframe')(() => ({\n width: '100%',\n height: '100vh',\n border: 'none',\n}));\n\nconst StyledCircularProgress = styled(CircularProgress)(() => ({\n position: 'absolute',\n top: '50%',\n left: '50%',\n zIndex: 1,\n}));\n\nfunction FormIframe({ url, title }: any) {\n const [ready, setReady] = React.useState(false);\n const iframeRef = React.useRef(null);\n\n if (!url) {\n return null;\n }\n\n React.useEffect(() => {\n if (iframeRef.current) {\n iframeRef.current.addEventListener('load', () => {\n setReady(true);\n });\n }\n\n return () => {\n if (iframeRef.current) {\n iframeRef.current.removeEventListener('load', () => {\n setReady(true);\n });\n }\n };\n }, [iframeRef.current]);\n\n return (\n \n {!ready && }\n \n \n );\n}\n\nexport default FormIframe;\n","import React from 'react';\nimport { FormattedMessage, FormattedNumber } from 'react-intl';\nimport { Box, Stack, Typography } from '@mui/material';\n\nimport LinearProgress from '../../DesignSystem/LinearProgress';\n\nfunction QuestionOptions({ questionId, questionOptions }: any) {\n return questionOptions.map((questionOption: any, index: number) => (\n \n \n \n {questionOption.label || }\n \n\n \n \n \n \n \n \n \n \n \n\n \n \n ));\n}\n\nexport default QuestionOptions;\n","import React from 'react';\nimport { Box, Divider, List, ListItem, ListItemText, Typography } from '@mui/material';\nimport { isEmpty } from 'lodash';\nimport { useIntl } from 'react-intl';\n\nimport AttachmentLink from '../../Posts/Shared/AttachmentLink';\nimport { moment } from '../../../I18n';\nimport LocationLink from '../../Maps/LocationLink';\n\nfunction AnswerLabel({ answer }: any) {\n const intl = useIntl();\n\n if (answer.lat) {\n return ;\n }\n\n if (answer.date) {\n return moment(answer.date).format(intl.formatMessage({ id: 'MOMENT.DATE.DEFAULT' }));\n }\n\n return ;\n}\n\nfunction hasDisplayableContent(answer: any) {\n return answer.date || answer.lat || answer?.attachments?.length > 0 || !isEmpty(answer.content);\n}\n\nfunction Answers({ questionId, answers }: any) {\n return (\n theme.palette.grey[500],\n },\n }}\n >\n {answers.filter(hasDisplayableContent).map((answer: any, index: number) => (\n
  • \n {answer?.attachments?.length > 0 && (\n \n {answer.attachments.map((attachment: any) => (\n \n \n \n ))}\n \n )}\n\n \n }\n secondary={moment(answer.created_at).fromNow()}\n sx={{ wordBreak: 'break-word' }}\n />\n \n\n {answers.length > index + 1 && }\n
  • \n ))}\n \n );\n}\n\nexport default Answers;\n","import React, { useRef } from 'react';\nimport { FormattedMessage, useIntl } from 'react-intl';\nimport { Box, Typography, Skeleton } from '@mui/material';\nimport { styled } from '@mui/material/styles';\nimport { get } from 'lodash';\n\nimport EmptyState from '../../DesignSystem/EmptyState';\nimport CustomIcon from '../../DesignSystem/CustomIcon';\nimport { icons } from '../../Posts/Forms/Common/FormBuilder/Inputs/TypeSelect';\nimport { Icons } from '../../../Themes';\nimport useIntersectionObserver from '../../../Hooks/useIntersectionObserver';\nimport useApiQuery from '../../../Hooks/useApiQuery';\nimport queriesConfig from '../../../Services/queriesConfig';\nimport QuestionOptions from './QuestionOptions';\nimport Answers from './Answers';\n\nconst IconWrapper = styled('span')({\n width: '40px',\n '& svg': {\n verticalAlign: 'bottom',\n },\n});\n\nfunction Question({ index, post, question, height = 350 }: any) {\n const intl = useIntl();\n const myRef = useRef(null);\n const isSectionVisible = useIntersectionObserver(myRef);\n const icon = icons[question?.field_type as keyof typeof icons];\n\n const { data: results, isLoading } = useApiQuery({\n query: queriesConfig.getQuestionResults(question?.id),\n options: {\n enabled: isSectionVisible,\n },\n });\n\n const noDataToRender =\n !isLoading && results?.question_options?.length === 0 && !results?.answers.length === 0;\n\n return (\n
    \n \n {icon}\n {index + 1}.\n\n \n \n {question?.title}\n \n\n \n {intl.formatMessage(\n { id: 'STATS.TOTAL_ANSWERS' },\n {\n answersCount: get(results, 'answers_count', 0),\n totalCount: get(post, 'post_contributions_stats.form_submissions_count', 0),\n },\n )}\n \n \n \n\n \n {!isLoading && noDataToRender && (\n }\n content={\n \n \n \n }\n />\n )}\n\n {isLoading && }\n\n {results?.question_options?.length > 0 && (\n \n )}\n\n {results?.answers?.length > 0 && (\n \n )}\n \n
    \n );\n}\n\nexport default Question;\n"],"names":["StyledIframe","styled","width","height","border","StyledCircularProgress","CircularProgress","position","top","left","zIndex","FormIframe","_ref","url","title","_React$useState","React","useState","_React$useState2","_slicedToArray","ready","setReady","iframeRef","useRef","useEffect","current","addEventListener","removeEventListener","createElement","Box","sx","minHeight","size","src","ref","QuestionOptions","questionId","questionOptions","map","questionOption","index","key","concat","id","mt","Stack","direction","spacing","justifyContent","alignItems","mb","Typography","component","fontWeight","wordBreak","label","FormattedMessage","variant","color","whiteSpace","values","count","FormattedNumber","value","percentage","style","minimumFractionDigits","LinearProgress","AnswerLabel","answer","intl","useIntl","lat","LocationLink","item","_objectSpread","content","date","moment","format","formatMessage","dangerouslySetInnerHTML","__html","hasDisplayableContent","_answer$attachments","attachments","length","isEmpty","Answers","_ref2","answers","List","overflowY","maxHeight","marginTop","borderRadius","backgroundColor","theme","palette","grey","filter","_answer$attachments2","role","attachment","AttachmentLink","ListItem","ListItemText","primary","secondary","created_at","fromNow","Divider","my","IconWrapper","verticalAlign","Question","_results$question_opt","_results$question_opt2","_results$answers","post","question","_ref$height","myRef","isSectionVisible","useIntersectionObserver","icon","icons","field_type","_useApiQuery","useApiQuery","query","queriesConfig","getQuestionResults","options","enabled","results","data","isLoading","noDataToRender","question_options","display","marginInlineEnd","answersCount","get","totalCount","px","py","EmptyState","CustomIcon","Icons","misc","searchOff","Skeleton"],"mappings":";u1BAIA,IAAMA,EAAeC,EAAO,QAAQ,EAAE,UAAA,CAAO,MAAA,CAC3CC,MAAO,OACPC,OAAQ,QACR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