Skip to content

Commit

Permalink
chore: split BandoView Text in different components (#391)
Browse files Browse the repository at this point in the history
* chore: split BandoView Text in different components

* fix: restored propTypes in BandoText
  • Loading branch information
SaraBianchi authored Nov 9, 2023
1 parent ba25d47 commit e787f38
Show file tree
Hide file tree
Showing 10 changed files with 128 additions and 56 deletions.
6 changes: 3 additions & 3 deletions locales/de/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -1021,7 +1021,7 @@ msgstr ""
msgid "bando_data_pubblicazione"
msgstr ""

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextDestinatari
# defaultMessage: Destinatari del bando
msgid "bando_destinatari"
msgstr ""
Expand All @@ -1032,7 +1032,7 @@ msgid "bando_effective"
msgstr ""

#: components/ItaliaTheme/Blocks/Listing/BandiInEvidenceTemplate
#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextEnte
# defaultMessage: Ente
msgid "bando_ente"
msgstr ""
Expand Down Expand Up @@ -3749,7 +3749,7 @@ msgstr ""
msgid "timeline_tempi_scadenze_validation_error"
msgstr ""

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextTipologia
# defaultMessage: Tipologia del bando
msgid "tipologia_bando"
msgstr ""
Expand Down
6 changes: 3 additions & 3 deletions locales/en/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ msgstr "Expired"
msgid "bando_data_pubblicazione"
msgstr "Publication date"

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextDestinatari
# defaultMessage: Destinatari del bando
msgid "bando_destinatari"
msgstr "Recipients of the competition notice"
Expand All @@ -1017,7 +1017,7 @@ msgid "bando_effective"
msgstr "Publication date"

#: components/ItaliaTheme/Blocks/Listing/BandiInEvidenceTemplate
#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextEnte
# defaultMessage: Ente
msgid "bando_ente"
msgstr "Supplying authority"
Expand Down Expand Up @@ -3734,7 +3734,7 @@ msgstr "Insert a value"
msgid "timeline_tempi_scadenze_validation_error"
msgstr ""

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextTipologia
# defaultMessage: Tipologia del bando
msgid "tipologia_bando"
msgstr "Type of call"
Expand Down
6 changes: 3 additions & 3 deletions locales/es/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -1015,7 +1015,7 @@ msgstr "Expirado"
msgid "bando_data_pubblicazione"
msgstr "Fecha de publicación"

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextDestinatari
# defaultMessage: Destinatari del bando
msgid "bando_destinatari"
msgstr "Destinatarios del anuncio de concurso"
Expand All @@ -1026,7 +1026,7 @@ msgid "bando_effective"
msgstr "Fecha de publicación"

#: components/ItaliaTheme/Blocks/Listing/BandiInEvidenceTemplate
#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextEnte
# defaultMessage: Ente
msgid "bando_ente"
msgstr "Autoridad proveedora"
Expand Down Expand Up @@ -3743,7 +3743,7 @@ msgstr "Insertar un valor"
msgid "timeline_tempi_scadenze_validation_error"
msgstr ""

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextTipologia
# defaultMessage: Tipologia del bando
msgid "tipologia_bando"
msgstr "Tipo de llamada"
Expand Down
6 changes: 3 additions & 3 deletions locales/fr/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -1023,7 +1023,7 @@ msgstr "Expiré"
msgid "bando_data_pubblicazione"
msgstr "Date de publication"

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextDestinatari
# defaultMessage: Destinatari del bando
msgid "bando_destinatari"
msgstr "Destinataires d'appels"
Expand All @@ -1034,7 +1034,7 @@ msgid "bando_effective"
msgstr "Date de publication"

#: components/ItaliaTheme/Blocks/Listing/BandiInEvidenceTemplate
#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextEnte
# defaultMessage: Ente
msgid "bando_ente"
msgstr "Autorité fournisseur"
Expand Down Expand Up @@ -3751,7 +3751,7 @@ msgstr "Entrez du texte"
msgid "timeline_tempi_scadenze_validation_error"
msgstr ""

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextTipologia
# defaultMessage: Tipologia del bando
msgid "tipologia_bando"
msgstr "Type d'appel"
Expand Down
6 changes: 3 additions & 3 deletions locales/it/LC_MESSAGES/volto.po
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ msgstr "Scaduto"
msgid "bando_data_pubblicazione"
msgstr "Pubblicato il"

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextDestinatari
# defaultMessage: Destinatari del bando
msgid "bando_destinatari"
msgstr "Destinatari del bando"
Expand All @@ -1017,7 +1017,7 @@ msgid "bando_effective"
msgstr "Data di pubblicazione"

#: components/ItaliaTheme/Blocks/Listing/BandiInEvidenceTemplate
#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextEnte
# defaultMessage: Ente
msgid "bando_ente"
msgstr "Ente erogatore"
Expand Down Expand Up @@ -3734,7 +3734,7 @@ msgstr "Inserisci un valore"
msgid "timeline_tempi_scadenze_validation_error"
msgstr ""

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextTipologia
# defaultMessage: Tipologia del bando
msgid "tipologia_bando"
msgstr "Tipologia del bando"
Expand Down
8 changes: 4 additions & 4 deletions locales/volto.pot
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
msgid ""
msgstr ""
"Project-Id-Version: Plone\n"
"POT-Creation-Date: 2023-11-07T09:01:50.705Z\n"
"POT-Creation-Date: 2023-11-07T16:35:33.634Z\n"
"Last-Translator: Plone i18n <[email protected]>\n"
"Language-Team: Plone i18n <[email protected]>\n"
"MIME-Version: 1.0\n"
Expand Down Expand Up @@ -1008,7 +1008,7 @@ msgstr ""
msgid "bando_data_pubblicazione"
msgstr ""

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextDestinatari
# defaultMessage: Destinatari del bando
msgid "bando_destinatari"
msgstr ""
Expand All @@ -1019,7 +1019,7 @@ msgid "bando_effective"
msgstr ""

#: components/ItaliaTheme/Blocks/Listing/BandiInEvidenceTemplate
#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextEnte
# defaultMessage: Ente
msgid "bando_ente"
msgstr ""
Expand Down Expand Up @@ -3736,7 +3736,7 @@ msgstr ""
msgid "timeline_tempi_scadenze_validation_error"
msgstr ""

#: components/ItaliaTheme/View/BandoView/BandoText
#: components/ItaliaTheme/View/BandoView/BandoTextTipologia
# defaultMessage: Tipologia del bando
msgid "tipologia_bando"
msgstr ""
Expand Down
44 changes: 7 additions & 37 deletions src/components/ItaliaTheme/View/BandoView/BandoText.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,15 @@ import {
richTextHasContent,
} from 'design-comuni-plone-theme/components/ItaliaTheme/View';

import BandoTextTipologia from 'design-comuni-plone-theme/components/ItaliaTheme/View/BandoView/BandoTextTipologia';
import BandoTextDestinatari from 'design-comuni-plone-theme/components/ItaliaTheme/View/BandoView/BandoTextDestinatari';
import BandoTextEnte from 'design-comuni-plone-theme/components/ItaliaTheme/View/BandoView/BandoTextEnte';

const messages = defineMessages({
descrizione: {
id: 'descrizione_bando',
defaultMessage: 'Descrizione',
},
tipologia_bando: {
id: 'tipologia_bando',
defaultMessage: 'Tipologia del bando',
},
destinatari: {
id: 'bando_destinatari',
defaultMessage: 'Destinatari del bando',
},
ente: {
id: 'bando_ente',
defaultMessage: 'Ente erogatore',
},
});

const BandoText = ({ content }) => {
Expand All @@ -40,33 +32,11 @@ const BandoText = ({ content }) => {
{/* DESCRIZIONE DEL BANDO */}
{richTextHasContent(content?.text) && <RichText data={content?.text} />}
{/* TIPOLOGIA DEL BANDO */}
{content?.tipologia_bando && (
<>
<h3 className="h5">{intl.formatMessage(messages.tipologia_bando)}</h3>
<span>{content.tipologia_bando.title}</span>
</>
)}
<BandoTextTipologia content={content} />
{/* DESTINATARI DEL BANDO */}
{content?.destinatari?.length > 0 && (
<>
<h3 className="h5">{intl.formatMessage(messages.destinatari)}</h3>
{content.destinatari.map((item, i) => (
<p key={'destinatari-' + i}>{item.title}</p>
))}
</>
)}
<BandoTextDestinatari content={content} />
{/* ENTE DEL BANDO */}
{content?.ente_bando?.length > 0 && (
<>
<h3 className="h5">{intl.formatMessage(messages.ente)}</h3>
{content.ente_bando.map((item, i) => (
<span key={'ente_' + i}>
{item}
{i < content.ente_bando.length - 1 ? ', ' : ''}
</span>
))}
</>
)}
<BandoTextEnte content={content} />
</RichTextSection>
) : (
<></>
Expand Down
36 changes: 36 additions & 0 deletions src/components/ItaliaTheme/View/BandoView/BandoTextDestinatari.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import PropTypes from 'prop-types';
import { defineMessages, useIntl } from 'react-intl';

const messages = defineMessages({
destinatari: {
id: 'bando_destinatari',
defaultMessage: 'Destinatari del bando',
},
});

const BandoTextDestinatari = ({ content }) => {
const intl = useIntl();
return content?.destinatari?.length > 0 ? (
<>
<h3 className="h5">{intl.formatMessage(messages.destinatari)}</h3>
{content.destinatari.map((item, i) => (
<p key={'destinatari-' + i}>{item.title}</p>
))}
</>
) : (
<></>
);
};

BandoTextDestinatari.propTypes = {
content: PropTypes.shape({
destinatari: PropTypes.arrayOf(
PropTypes.shape({
title: PropTypes.string,
token: PropTypes.string,
}),
),
}).isRequired,
};
export default BandoTextDestinatari;
34 changes: 34 additions & 0 deletions src/components/ItaliaTheme/View/BandoView/BandoTextEnte.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import React from 'react';
import PropTypes from 'prop-types';
import { defineMessages, useIntl } from 'react-intl';

const messages = defineMessages({
ente: {
id: 'bando_ente',
defaultMessage: 'Ente erogatore',
},
});

const BandoTextEnte = ({ content }) => {
const intl = useIntl();
return content?.ente_bando?.length > 0 ? (
<>
<h3 className="h5">{intl.formatMessage(messages.ente)}</h3>
{content.ente_bando.map((item, i) => (
<span key={'ente_' + i}>
{item}
{i < content.ente_bando.length - 1 ? ', ' : ''}
</span>
))}
</>
) : (
<></>
);
};

BandoTextEnte.propTypes = {
content: PropTypes.shape({
ente_bando: PropTypes.arrayOf(PropTypes.string),
}).isRequired,
};
export default BandoTextEnte;
32 changes: 32 additions & 0 deletions src/components/ItaliaTheme/View/BandoView/BandoTextTipologia.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import PropTypes from 'prop-types';
import { defineMessages, useIntl } from 'react-intl';

const messages = defineMessages({
tipologia_bando: {
id: 'tipologia_bando',
defaultMessage: 'Tipologia del bando',
},
});

const BandoTextTipologia = ({ content }) => {
const intl = useIntl();
return content?.tipologia_bando ? (
<>
<h3 className="h5">{intl.formatMessage(messages.tipologia_bando)}</h3>
<span>{content.tipologia_bando.title}</span>
</>
) : (
<></>
);
};

BandoTextTipologia.propTypes = {
content: PropTypes.shape({
tipologia_bando: PropTypes.shape({
title: PropTypes.string,
token: PropTypes.string,
}),
}).isRequired,
};
export default BandoTextTipologia;

0 comments on commit e787f38

Please sign in to comment.