{"version":3,"file":"ContributionFormAnswers-Bd6b5Y4g.js","sources":["../../../node_modules/@mui/icons-material/esm/Info.js","../../../frontend/src/Components/Posts/AuditsModal/AuditDiff.tsx","../../../frontend/src/Utils/audits.ts","../../../frontend/src/Components/Posts/AuditsModal/AuditsList.tsx","../../../frontend/src/Components/Posts/AuditsModal/AuditsModal.tsx","../../../frontend/src/Components/Posts/AuditsModal/AuditsLink.tsx","../../../frontend/src/Components/Posts/Show/Participation/FormBuilder/ContributionFormAnswers.tsx"],"sourcesContent":["\"use client\";\n\nimport createSvgIcon from \"./utils/createSvgIcon.js\";\nimport { jsx as _jsx } from \"react/jsx-runtime\";\nexport default createSvgIcon(/*#__PURE__*/_jsx(\"path\", {\n d: \"M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2m1 15h-2v-6h2zm0-8h-2V7h2z\"\n}), 'Info');","import React from 'react';\nimport { Alert, Box } from '@mui/material';\nimport { FormattedMessage } from 'react-intl';\n\nfunction AuditDiff({ diff }: any) {\n const previousVersion = Array.isArray(diff) && diff[0];\n const newVersion = Array.isArray(diff) ? diff[1] : diff;\n\n // if the diff is an array it means it's a before and after\n return (\n \n {previousVersion && (\n \n \n \n \n
\n\n {previousVersion}\n \n )}\n {newVersion && (\n \n \n \n \n
\n\n {newVersion}\n \n )}\n \n );\n}\n\nexport default AuditDiff;\n","import { supportedLocales } from '../I18n';\n\nconst visibleFields = ['title', 'description', 'problematic', 'localisation_label', 'budget'];\n\nconst fieldNames: Record = {\n title: supportedLocales.map((locale: any) => `title_${locale}`),\n description: supportedLocales.map((locale: any) => `description_${locale}`),\n problematic: supportedLocales.map((locale: any) => `problematic_${locale}`),\n localisation_label: ['location'],\n};\n\nconst fieldNameFromKey = (key: any) => {\n return Object.keys(fieldNames).find((name) => fieldNames[name].includes(key)) || key;\n};\n\nconst filteredAudits = (audits: Array = []) => {\n // remove non displayed fields from audit changes\n // and then remove audits with no changes\n return audits\n .map((audit) => ({\n ...audit,\n changes: Object.entries(audit.changes)\n .filter(([key]) => visibleFields.includes(fieldNameFromKey(key)))\n .reduce((obj, [key, value]) => ({ ...obj, [key]: value }), {}),\n }))\n .filter((audit) => Object.keys(audit.changes).length > 0);\n};\n\nexport { fieldNameFromKey, filteredAudits };\n","import React from 'react';\nimport { FormattedMessage, useIntl } from 'react-intl';\nimport { Box, Divider, List, ListItem, ListItemText, Typography } from '@mui/material';\nimport Info from '@mui/icons-material/Info';\n\nimport CardHeader from '../../DesignSystem/CardHeader';\nimport { CloudinaryConfig, cloudinaryImageUrl } from '../../../Services/Cloudinary';\nimport Alert from '../../DesignSystem/Alert';\nimport AuditDiff from './AuditDiff';\nimport { moment } from '../../../I18n';\nimport { fieldNameFromKey } from '../../../Utils/audits';\n\nfunction AuditsList({ audits }: any) {\n const intl = useIntl();\n\n if (audits.length === 0) {\n return (\n \n }>\n \n \n \n );\n }\n\n return (\n \n {audits.map((audit: any, index: any) => (\n <>\n \n {audit.user && (\n \n )}\n\n \n {Object.entries(audit.changes || {})\n // get the proper name of the fields (translated fields for example: title_fr => title)\n .map(([key, value]) => [fieldNameFromKey(key), value])\n // sort the fields\n .map(([key, value]) => {\n return (\n \n \n \n \n }\n secondary={}\n />\n \n );\n })}\n
\n \n {index < audits.length - 1 && }\n >\n ))}\n
\n );\n}\n\nexport default AuditsList;\n","import React from 'react';\nimport { useSearchParams } from 'react-router-dom';\nimport { useIntl, FormattedMessage } from 'react-intl';\n\nimport AuditsList from './AuditsList';\nimport Dialog from '../../DesignSystem/Dialog';\n\nfunction AuditsModal({ audits }: any) {\n const intl = useIntl();\n const [searchParams, setSearchParams] = useSearchParams();\n const isOpen = searchParams.get('audits_modal') === 'true';\n\n return (\n }\n maxWidth=\"md\"\n onClose={() => setSearchParams({})}\n disableGutters\n fullWidth\n >\n \n \n );\n}\n\nexport default AuditsModal;\n","import React from 'react';\nimport { Link as MuiLink } from '@mui/material';\nimport { Link } from 'react-router-dom';\nimport { FormattedMessage } from 'react-intl';\nimport { useQuery } from 'react-query';\n\nimport { PostTypes } from '../../../Utils/Types';\nimport { moment } from '../../../I18n';\nimport { getPostAudits } from '../../../Services/Api';\nimport AuditsModal from './AuditsModal';\nimport { filteredAudits } from '../../../Utils/audits';\n\nfunction AuditsLink({ post }: any) {\n if (post.type !== PostTypes.IDEA) {\n return null;\n }\n\n const { data } = useQuery(['post-audits', post.id], () => getPostAudits(post.id), {\n enabled: !!window.spaceSlug,\n select: (response: any) => response.data,\n keepPreviousData: true,\n refetchOnWindowFocus: false,\n });\n\n const audits = filteredAudits(data?.data) || [];\n\n if (audits.length === 0) {\n return null;\n }\n\n return (\n <>\n {' - '}\n\n \n \n \n \n >\n );\n}\n\nexport default AuditsLink;\n","import React from 'react';\nimport { Box, Stack, Typography } from '@mui/material';\n\nimport useApiQuery from '../../../../../Hooks/useApiQuery';\nimport queriesConfig from '../../../../../Services/queriesConfig';\nimport { Post } from '../../../../../Utils/Types/Posts';\nimport { singletonQuestionTypes } from '../../../../../Utils/Types/FormBuilder';\nimport AnswerShow from './AnswerShow';\nimport { get } from 'lodash';\n\ninterface ContributionFormAnswersProps {\n post?: Post;\n hideConfidentialFields?: boolean;\n}\n\nexport default function ContributionFormAnswers({\n post,\n hideConfidentialFields = false,\n}: ContributionFormAnswersProps) {\n const { data: response = {} as any, isLoading } = useApiQuery({\n query: queriesConfig.getFormResponse(post?.id, post?.meta?.user_form_submission_id || 0),\n });\n const answersToRender = response?.answers?.filter(\n (answer: any) => !singletonQuestionTypes.includes(answer?.question?.field_type),\n );\n\n if (isLoading || !answersToRender) {\n return null;\n }\n\n return (\n \n {answersToRender?.map((answer: any) => {\n if (!answer.filled_in) {\n return null;\n }\n\n if (hideConfidentialFields && answer.question.confidential) {\n // Confidential fields are only returned to the admins and the owner of the post\n // but we still don't want to show them in the public post details to avoid any confusion\n return null;\n }\n\n return (\n \n \n {answer.question.title}\n \n\n \n \n );\n })}\n \n );\n}\n"],"names":["Info","createSvgIcon","_jsx","AuditDiff","_ref","diff","previousVersion","Array","isArray","newVersion","React","createElement","Box","component","sx","mt","display","flexDirection","gap","Alert","severity","icon","FormattedMessage","id","visibleFields","fieldNames","title","supportedLocales","map","locale","concat","description","problematic","localisation_label","fieldNameFromKey","key","Object","keys","find","name","includes","filteredAudits","audits","arguments","length","undefined","audit","_objectSpread","changes","entries","filter","_ref2","_slicedToArray","reduce","obj","_ref3","_ref4","value","_defineProperty","AuditsList","intl","useIntl","m","List","index","_audit$user","_audit$user2","Fragment","ListItem","created_at","width","user","CardHeader","profilePictureUrl","cloudinaryImageUrl","picture","s3_key","CloudinaryConfig","AVATAR_48","fullName","full_name","initials","subheader","formatMessage","action","toUpperCase","date","moment","fromNow","alt","_ref5","ListItemText","primary","Typography","variant","secondary","Divider","AuditsModal","_useSearchParams","useSearchParams","_useSearchParams2","searchParams","setSearchParams","isOpen","get","Dialog","label","open","maxWidth","onClose","disableGutters","fullWidth","AuditsLink","post","type","PostTypes","IDEA","_useQuery","useQuery","getPostAudits","enabled","window","spaceSlug","select","response","data","keepPreviousData","refetchOnWindowFocus","MuiLink","Link","to","underline","color","fontSize","fontWeight","textTransform","values","ContributionFormAnswers","_post$meta","_response$answers","_ref$hideConfidential","hideConfidentialFields","_useApiQuery","useApiQuery","query","queriesConfig","getFormResponse","meta","user_form_submission_id","_useApiQuery$data","isLoading","answersToRender","answers","answer","_answer$question","singletonQuestionTypes","question","field_type","Stack","spacing","mb","filled_in","confidential","gutterBottom","AnswerShow","showPreview","geojson"],"mappings":"ocAIA,MAAAA,GAAeC,EAA2BC,EAAI,IAAC,OAAQ,CACrD,EAAG,6FACL,CAAC,EAAG,MAAM,ECFV,SAASC,GAASC,EAAgB,CAAA,IAAbC,EAAID,EAAJC,KACbC,EAAkBC,MAAMC,QAAQH,CAAI,GAAKA,EAAK,CAAC,EAC/CI,EAAaF,MAAMC,QAAQH,CAAI,EAAIA,EAAK,CAAC,EAAIA,EAIjDK,OAAAA,EAAAC,cAACC,EAAG,CACFC,UAA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