diff --git a/package.json b/package.json index 8d1b42d0..f2ed4234 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "@mui/x-data-grid": "^5.0.1", "@mui/x-data-grid-generator": "^5.0.1", "@pagopa/mui-italia": "^1.5.0", - "@pagopa/selfcare-common-frontend": "^1.34.43", + "@pagopa/selfcare-common-frontend": "^1.34.44", "@types/react": "^18.2.22", "@types/react-dom": "^18.2.7", "@types/react-router-dom": "^5.3.3", diff --git a/src/pages/dashboardOverview/components/activeProductsSection/ActiveProductsSection.tsx b/src/pages/dashboardOverview/components/activeProductsSection/ActiveProductsSection.tsx index be2d71c4..8db0c7a5 100644 --- a/src/pages/dashboardOverview/components/activeProductsSection/ActiveProductsSection.tsx +++ b/src/pages/dashboardOverview/components/activeProductsSection/ActiveProductsSection.tsx @@ -6,7 +6,6 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { Party } from '../../../../model/Party'; import { Product } from '../../../../model/Product'; -import { interopProductIdList } from '../../../../utils/constants'; import { startWithProductInterop } from '../../../../utils/helperFunctions'; import ActiveProductCardContainer from './components/ActiveProductCardContainer'; @@ -19,19 +18,35 @@ export default function ActiveProductsSection({ party, products }: Readonly - party?.products.find( - (p) => - p.productId === productId && hasPermission(p.productId, Actions.AccessProductBackoffice) - ); + const interopProducts = party?.products + .filter( + (product) => + startWithProductInterop(product.productId) && product.productOnBoardingStatus === 'ACTIVE' + ) + .map((p) => p.productId ?? ''); - const authorizedInteropProducts = interopProductIdList - .map(findAuthorizedProduct) - .filter(Boolean) - .map((p) => p?.productId ?? ''); + const authorizedInteropProducts = party?.products + .filter( + (product) => + startWithProductInterop(product.productId) && + hasPermission(product.productId ?? '', Actions.AccessProductBackoffice) + ) + .map((p) => p.productId ?? ''); const hasMoreThanOneInteropEnv = authorizedInteropProducts.length > 1; + const isRelevantInteropProduct = (productId: string) => { + if (startWithProductInterop(productId)) { + if (authorizedInteropProducts.length > 0) { + return productId === authorizedInteropProducts[0]; + } + if (interopProducts.length > 0) { + return productId === interopProducts[0]; + } + } + return true; + }; + return ( us.productOnBoardingStatus === 'ACTIVE' && - (startWithProductInterop(us.productId) && hasMoreThanOneInteropEnv - ? us.productId === authorizedInteropProducts[0] - : true) + isRelevantInteropProduct(us.productId ?? '') ) .sort((a, b) => { const aHasPermission = hasPermission( diff --git a/yarn.lock b/yarn.lock index acacda43..dccae70d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2034,10 +2034,10 @@ write-yaml-file "^4.1.3" yargs "^15.0.1" -"@pagopa/selfcare-common-frontend@^1.34.43": - version "1.34.43" - resolved "https://registry.yarnpkg.com/@pagopa/selfcare-common-frontend/-/selfcare-common-frontend-1.34.43.tgz#73c566ae9ee0d021260adbf347afa1bce3789b83" - integrity sha512-Wgb+PJQzZl9inIVhZKm/NwbARzJ/U9aZKtVU3wNfBTqP9kkbtSBogsNncBawRcsq1p7fVfwHRUSSVvbxcYm0Sg== +"@pagopa/selfcare-common-frontend@^1.34.44": + version "1.34.44" + resolved "https://registry.yarnpkg.com/@pagopa/selfcare-common-frontend/-/selfcare-common-frontend-1.34.44.tgz#d276cf4583526d9be6000e993f48a7b34d7663f2" + integrity sha512-Gv9KHHTZ1tYIDcqjx9vslpg23ei9fhbGAaNUkmKN3Pg1UunPkzeHpf/hcvJuBXRVW1C7yXj0TH92ZxYRNiWsxg== dependencies: "@emotion/react" "^11.11.1" "@emotion/styled" "^11.11.0"