diff --git a/src/pages/ProviderAgreementDetailsPage/ProviderAgreementDetails.page.tsx b/src/pages/ProviderAgreementDetailsPage/ProviderAgreementDetails.page.tsx index 86ff2b771..692029287 100644 --- a/src/pages/ProviderAgreementDetailsPage/ProviderAgreementDetails.page.tsx +++ b/src/pages/ProviderAgreementDetailsPage/ProviderAgreementDetails.page.tsx @@ -38,6 +38,8 @@ const ProviderAgreementDetailsPageContent: React.FC = () => { .with({ suspendedByPlatform: true }, () => 'byPlatform' as const) .otherwise(() => undefined) + const isDelegated = Boolean('delegation' in agreement) + return ( { agreement, }} > + {agreement.state === 'PENDING' && isDelegated && ( + + {t('providerRead.delegatedAlert')} + + )} {suspendedBy && ( = ({ isOpen, onClose, contact }) => { +> = ({ isOpen, onClose, contact, isDelegatedConsumer }) => { const { t } = useTranslation('agreement', { keyPrefix: 'providerRead.sections.generalInformations.contactDrawer', }) return ( - + { const { agreement } = useProviderAgreementDetailsContext() const downloadContract = AgreementDownloads.useDownloadContract() + const isDelegated = Boolean('delegation' in agreement) + const { isOpen: isContactDrawerOpen, openDrawer: openContactDrawer, closeDrawer: closeContactDrawer, } = useDrawerState() + const { + isOpen: isDelegatedContactDrawerOpen, + openDrawer: openDelegatedContactDrawer, + closeDrawer: closeDelegatedContactDrawer, + } = useDrawerState() + const [attributesDrawerData, setAttributesDrawerData] = React.useState<{ isOpen: boolean attributeType: 'certified' | 'declared' @@ -34,10 +42,6 @@ export const ProviderAgreementDetailsGeneralInfoSection: React.FC = () => { attributeType: 'certified', }) - const handleOpenContactDrawer = () => { - openContactDrawer() - } - const handleOpenAttributesDrawer = (type: 'certified' | 'declared') => { setAttributesDrawerData({ isOpen: true, @@ -92,7 +96,17 @@ export const ProviderAgreementDetailsGeneralInfoSection: React.FC = () => { label: t('consumerDetailsLink.label'), component: 'button', type: 'button', - onClick: handleOpenContactDrawer, + onClick: openContactDrawer, + }) + } + + if (isDelegated && agreement.delegation?.delegate.contactMail) { + actions.push({ + startIcon: , + label: t('delegatedConsumerDetailsLink.label'), + component: 'button', + type: 'button', + onClick: openDelegatedContactDrawer, }) } @@ -121,6 +135,12 @@ export const ProviderAgreementDetailsGeneralInfoSection: React.FC = () => { label={t('consumerField.label')} content={agreement.consumer.name} /> + {isDelegated && ( + + )} {agreement.state === 'REJECTED' && agreement.rejectionReason && ( { contact={agreement.consumer.contactMail} /> )} + {agreement.delegation?.delegate.contactMail && ( + + )} { queryClient.prefetchQuery(AgreementQueries.getSingle(agreement.id)) } @@ -46,7 +38,7 @@ export const ProviderAgreementsTableRow: React.FC<{ agreement: AgreementListEntr name: eservice.name, version: descriptor.version, })}{' '} - {isDelegatedEservice && } + {agreement.isDelegated && } ) diff --git a/src/static/locales/en/agreement.json b/src/static/locales/en/agreement.json index d0e95b320..3d1f0da3e 100644 --- a/src/static/locales/en/agreement.json +++ b/src/static/locales/en/agreement.json @@ -2,6 +2,7 @@ "backToRequestsBtn": "Go back to requests", "providerRead": { "title": "Manage agreement", + "delegatedAlert": "This agreement relates to a delegation.", "suspendedAlert": { "byProducer": "This agreement has been suspended by the PROVIDER. Until it is reactivated it will not be possible to access the data.", "byConsumer": "This agreement has been suspended by the CONSUMER. Until it is reactivated it will not be possible to access the data.", @@ -17,6 +18,9 @@ "consumerField": { "label": "Consumer" }, + "delegatedConsumerField": { + "label": "Delegated Consumer" + }, "rejectionMessageField": { "label": "Reason for rejection" }, @@ -35,8 +39,14 @@ "consumerDetailsLink": { "label": "View consumer details" }, + "delegatedConsumerDetailsLink": { + "label": "View delegated consumer details" + }, "contactDrawer": { - "title": "Consumer contacts", + "title": { + "delegatedConsumer": "Delegated consumer contacts", + "consumer": "Consumer contacts" + }, "emailField": { "label": "Contact email" }, diff --git a/src/static/locales/it/agreement.json b/src/static/locales/it/agreement.json index 863869ead..8b11cd13d 100644 --- a/src/static/locales/it/agreement.json +++ b/src/static/locales/it/agreement.json @@ -2,6 +2,7 @@ "backToRequestsBtn": "Torna alle richieste", "providerRead": { "title": "Gestisci richiesta di fruizione", + "delegatedAlert": "Questa richiesta di fruizione è relativa a una delega.", "suspendedAlert": { "byProducer": "Questa richiesta di fruizione è stata sospesa da erogatore. Fino alla sua riattivazione non sarà possibile accedere ai dati.", "byConsumer": "Questa richiesta di fruizione è stata sospesa da fruitore. Fino alla sua riattivazione non sarà possibile accedere ai dati.", @@ -17,6 +18,9 @@ "consumerField": { "label": "Fruitore" }, + "delegatedConsumerField": { + "label": "Delegato alla fruizione" + }, "rejectionMessageField": { "label": "Motivazione del rifiuto" }, @@ -35,8 +39,14 @@ "consumerDetailsLink": { "label": "Visualizza dettagli fruitore" }, + "delegatedConsumerDetailsLink": { + "label": "Visualizza dettagli del delegato alla fruizione" + }, "contactDrawer": { - "title": "Contatti del fruitore", + "title": { + "delegatedConsumer": "Contatti del delegato alla fruizione", + "consumer": "Contatti del fruitore" + }, "emailField": { "label": "Email di contatto" },