From d2336b4a93b431fb9b43aed1be52b9bd56a9606a Mon Sep 17 00:00:00 2001 From: alten-dturus Date: Mon, 13 Jan 2025 16:46:07 +0100 Subject: [PATCH 1/4] Update ProviderAgreementDetailsContactDrawer.tsx --- .../ProviderAgreementDetailsContactDrawer.tsx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/pages/ProviderAgreementDetailsPage/components/ProviderAgreementDetailsGeneralInfoSection/ProviderAgreementDetailsContactDrawer.tsx b/src/pages/ProviderAgreementDetailsPage/components/ProviderAgreementDetailsGeneralInfoSection/ProviderAgreementDetailsContactDrawer.tsx index 37925be16..9df9d5fc2 100644 --- a/src/pages/ProviderAgreementDetailsPage/components/ProviderAgreementDetailsGeneralInfoSection/ProviderAgreementDetailsContactDrawer.tsx +++ b/src/pages/ProviderAgreementDetailsPage/components/ProviderAgreementDetailsGeneralInfoSection/ProviderAgreementDetailsContactDrawer.tsx @@ -9,17 +9,22 @@ type ProviderAgreementDetailsContactDrawerProps = { isOpen: boolean onClose: VoidFunction contact: Mail + isDelegatedConsumer?: boolean } export const ProviderAgreementDetailsContactDrawer: React.FC< ProviderAgreementDetailsContactDrawerProps -> = ({ isOpen, onClose, contact }) => { +> = ({ isOpen, onClose, contact, isDelegatedConsumer }) => { const { t } = useTranslation('agreement', { keyPrefix: 'providerRead.sections.generalInformations.contactDrawer', }) return ( - + Date: Mon, 13 Jan 2025 16:46:46 +0100 Subject: [PATCH 2/4] Add delegated info --- .../ProviderAgreementDetails.page.tsx | 7 ++++ ...iderAgreementDetailsGeneralInfoSection.tsx | 38 ++++++++++++++++--- 2 files changed, 40 insertions(+), 5 deletions(-) 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 && ( { 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 && ( + + )} Date: Mon, 13 Jan 2025 16:47:30 +0100 Subject: [PATCH 3/4] fix ByDelegationChip check for ProviderAgreementsTableRow --- .../components/ProviderAgreementsTableRow.tsx | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/src/pages/ProviderAgreementsListPage/components/ProviderAgreementsTableRow.tsx b/src/pages/ProviderAgreementsListPage/components/ProviderAgreementsTableRow.tsx index c88e3ec19..909c4f0fe 100644 --- a/src/pages/ProviderAgreementsListPage/components/ProviderAgreementsTableRow.tsx +++ b/src/pages/ProviderAgreementsListPage/components/ProviderAgreementsTableRow.tsx @@ -6,9 +6,8 @@ import { ByDelegationChip } from '@/components/shared/ByDelegationChip' import { ButtonSkeleton } from '@/components/shared/MUI-skeletons' import { StatusChip, StatusChipSkeleton } from '@/components/shared/StatusChip' import useGetAgreementsActions from '@/hooks/useGetAgreementsActions' -import { useGetDelegationUserRole } from '@/hooks/useGetDelegationUserRole' import { Link } from '@/router' -import { Box, Chip, Skeleton } from '@mui/material' +import { Box, Skeleton } from '@mui/material' import { TableRow } from '@pagopa/interop-fe-commons' import { useQueryClient } from '@tanstack/react-query' import React from 'react' @@ -29,13 +28,6 @@ export const ProviderAgreementsTableRow: React.FC<{ agreement: AgreementListEntr const eservice = agreement.eservice const descriptor = agreement.descriptor - const { isDelegator, isDelegate } = useGetDelegationUserRole({ - eserviceId: eservice.id, - organizationId: AuthHooks.useJwt().jwt?.organizationId, - }) - - const isDelegatedEservice = isDelegate || isDelegator - const handlePrefetch = () => { 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 && } ) From 01a352bd2219b0f361be72f5f419a386006ca97f Mon Sep 17 00:00:00 2001 From: alten-dturus Date: Mon, 13 Jan 2025 16:47:44 +0100 Subject: [PATCH 4/4] Add strings --- src/static/locales/en/agreement.json | 12 +++++++++++- src/static/locales/it/agreement.json | 12 +++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) 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" },