Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: new BandoStatus component to manage the current status translations #390

Merged
merged 5 commits into from
Nov 7, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import {
} from 'design-comuni-plone-theme/components/ItaliaTheme';
import { viewDate } from 'design-comuni-plone-theme/helpers';

import { BandoStatus } from 'design-comuni-plone-theme/components/ItaliaTheme/View';

const messages = defineMessages({
vedi: {
id: 'bando_vedi',
Expand All @@ -40,22 +42,6 @@ const messages = defineMessages({
id: 'bando_stato',
defaultMessage: 'Stato:',
},
open: {
id: 'bando_open',
defaultMessage: 'Attivo',
},
scheduled: {
id: 'bando_scheduled',
defaultMessage: 'Programmato',
},
closed: {
id: 'bando_closed',
defaultMessage: 'Scaduto',
},
inProgress: {
id: 'bando_inProgress',
defaultMessage: 'In corso',
},
ente: {
id: 'bando_ente',
defaultMessage: 'Ente',
Expand Down Expand Up @@ -215,7 +201,7 @@ const BandiInEvidenceTemplate = ({
),
})}
>
{intl.formatMessage(messages[item.bando_state[0]])}
<BandoStatus content={item} />
</div>
</span>
</span>
Expand Down
38 changes: 38 additions & 0 deletions src/components/ItaliaTheme/View/Commons/BandoStatus.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Importante: (06/11/2023)
* Component creato per essere possibile customizzare in modo più efficiente le traduzioni per lo status dei bandi.
* Deve essere cancellato dopo l'aggiornamento di Volto
*/

import { defineMessages, useIntl } from 'react-intl';

const messages = defineMessages({
open: {
id: 'bando_open',
defaultMessage: 'attivo',
Wagner3UB marked this conversation as resolved.
Show resolved Hide resolved
},
closed: {
id: 'bando_closed',
defaultMessage: 'scaduto',
},
inProgress: {
id: 'bando_inProgress',
defaultMessage: 'in corso',
},
scheduled: {
id: 'bando_scheduled',
defaultMessage: 'programmato',
},
});

/**
* BandoStatus view component class.
* @function BandoStatus
*/

const BandoStatus = ({ content }) => {
const intl = useIntl();
return <>{intl.formatMessage(messages[content.bando_state[0]])}</>;
};

export default BandoStatus;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import PropTypes from 'prop-types';

import { Icon } from 'design-comuni-plone-theme/components/ItaliaTheme';

import { BandoStatus } from 'design-comuni-plone-theme/components/ItaliaTheme/View';

/**
* PageHeaderBando view component class.
* @function PageHeaderBando
Expand Down Expand Up @@ -64,7 +66,7 @@ const PageHeaderBando = ({ content }) => {
size=""
/>
{intl.formatMessage(messages.bando)}{' '}
{intl.formatMessage(messages[content.bando_state[0]])}
<BandoStatus content={content} />
</div>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/components/ItaliaTheme/View/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export Sponsors from 'design-comuni-plone-theme/components/ItaliaTheme/View/Comm
export RelatedItems from 'design-comuni-plone-theme/components/ItaliaTheme/View/Commons/RelatedItems';
export RelatedItemInEvidence from 'design-comuni-plone-theme/components/ItaliaTheme/View/Commons/RelatedItemInEvidence/RelatedItemInEvidence';
export DownloadFileFormat from 'design-comuni-plone-theme/components/ItaliaTheme/View/Commons/DownloadFileFormat';
export BandoStatus from 'design-comuni-plone-theme/components/ItaliaTheme/View/Commons/BandoStatus';
export BandoDates from 'design-comuni-plone-theme/components/ItaliaTheme/View/Commons/BandoDates';

/* --- View --- */
Expand Down