From d87ccc02b43d56e6b4375643c4db3dfe22aa23d9 Mon Sep 17 00:00:00 2001 From: Giulia Ghisini Date: Thu, 21 Dec 2023 12:57:32 +0100 Subject: [PATCH] feat: view all children folder and pages of Persona as documents section --- .../View/PersonaView/PersonaDocumenti.jsx | 38 +++++++++++++++---- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/components/ItaliaTheme/View/PersonaView/PersonaDocumenti.jsx b/src/components/ItaliaTheme/View/PersonaView/PersonaDocumenti.jsx index 7aceb7578..9bec4ca18 100644 --- a/src/components/ItaliaTheme/View/PersonaView/PersonaDocumenti.jsx +++ b/src/components/ItaliaTheme/View/PersonaView/PersonaDocumenti.jsx @@ -55,18 +55,31 @@ const messages = defineMessages({ const PersonaDocumenti = ({ content }) => { const intl = useIntl(); + const default_content_folders = [ + 'curriculum-vitae', + 'compensi', + 'importi-di-viaggio-e-o-servizi', + 'altre-cariche', + 'situazione-patrimoniale', + 'dichiarazione-dei-redditi', + 'spese-elettorali', + 'variazione-situazione-patrimoniale', + ]; + + const other_folders = content.items.filter( + (i) => + default_content_folders.indexOf(i.id) < 0 && + i.id !== 'foto-e-attivita-politica' && + (i['@type'] === 'Document' || i['@type'] === 'Folder') && + contentFolderHasItems(content, i.id), + ); const showSection = content?.curriculum_vitae?.download || - contentFolderHasItems(content, 'curriculum-vitae') || - contentFolderHasItems(content, 'compensi') || - contentFolderHasItems(content, 'importi-di-viaggio-e-o-servizi') || - contentFolderHasItems(content, 'altre-cariche') || content.atto_nomina?.download || - contentFolderHasItems(content, 'situazione-patrimoniale') || - contentFolderHasItems(content, 'dichiarazione-dei-redditi') || - contentFolderHasItems(content, 'spese-elettorali') || - contentFolderHasItems(content, 'variazione-situazione-patrimoniale'); + default_content_folders.filter((f) => contentFolderHasItems(content, f)) + .length > 0 || + other_folders.length > 0; return showSection ? ( { title={intl.formatMessage(messages.variazione_situazione_patrimoniale)} as_article={false} /> + + {other_folders.map((f) => ( + + ))} ) : ( <>