Skip to content

Commit

Permalink
Merge branch 'release-uat'
Browse files Browse the repository at this point in the history
  • Loading branch information
manuraf committed Mar 13, 2024
2 parents 300f66a + 8eafc0f commit 5973b68
Show file tree
Hide file tree
Showing 9 changed files with 491 additions and 111 deletions.
61 changes: 40 additions & 21 deletions src/components/DashboardHeader.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
import { PartySwitchItem } from '@pagopa/mui-italia/dist/components/PartySwitch';
import { Header, SessionModal } from '@pagopa/selfcare-common-frontend';
import { Header } from '@pagopa/selfcare-common-frontend';
import { User } from '@pagopa/selfcare-common-frontend/model/User';
import { trackEvent } from '@pagopa/selfcare-common-frontend/services/analyticsService';
import { roleLabels } from '@pagopa/selfcare-common-frontend/utils/constants';
import { resolvePathVariables } from '@pagopa/selfcare-common-frontend/utils/routes-utils';
import { useMemo, useRef, useState } from 'react';
import { Trans, useTranslation } from 'react-i18next';
import { useHistory } from 'react-router-dom';
import { useTranslation, Trans } from 'react-i18next';
import { roleLabels } from '@pagopa/selfcare-common-frontend/utils/constants';
import SessionModalInteropProduct from '../pages/dashboardOverview/components/activeProductsSection/components/SessionModalInteropProduct';
import withParties, { WithPartiesProps } from '../decorators/withParties';
import { useTokenExchange } from '../hooks/useTokenExchange';
import { Product } from '../model/Product';
import { Party } from '../model/Party';
import { Product } from '../model/Product';
import GenericEnvProductModal from '../pages/dashboardOverview/components/activeProductsSection/components/GenericEnvProductModal';
import SessionModalInteropProduct from '../pages/dashboardOverview/components/activeProductsSection/components/SessionModalInteropProduct';
import { useAppSelector } from '../redux/hooks';
import { partiesSelectors } from '../redux/slices/partiesSlice';
import ROUTES, { DASHBOARD_ROUTES } from '../routes';
Expand Down Expand Up @@ -40,8 +41,28 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => {

const parties2Show = parties.filter((party) => party.status === 'ACTIVE');

const authorizedProdInterop = party?.products.find(
(p) => p.productId === 'prod-interop' && p.authorized === true
);

const authorizedProdAtst = party?.products?.find(
(p) => p.productId === 'prod-interop-atst' && p.authorized === true
);

const authorizedProdColl = party?.products?.find(
(p) => p.productId === 'prod-interop-coll' && p.authorized === true
);

const authorizedInteropProducts = [authorizedProdInterop, authorizedProdAtst, authorizedProdColl].filter(
(product) => product
);

const hasMoreThanOneInteropEnv = authorizedInteropProducts.length > 1;

const onboardedPartyProducts = party?.products.filter(
(pp) => pp.productOnBoardingStatus === 'ACTIVE' && pp.authorized
(pp) =>
pp.productOnBoardingStatus === 'ACTIVE' &&
(pp.authorized || (hasMoreThanOneInteropEnv && pp.productId === 'prod-interop'))
);

const activeProducts: Array<Product> = useMemo(
Expand All @@ -55,12 +76,6 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => {
// eslint-disable-next-line functional/immutable-data
actualSelectedParty.current = selectedParty;

const prodInteropAndProdInteropColl =
onboardedPartyProducts?.find(
(p) => p.productId === 'prod-interop-coll' && p.authorized === true
) &&
onboardedPartyProducts.find((p) => p.productId === 'prod-interop' && p.authorized === true);

return (
<div tabIndex={0}>
<Header
Expand All @@ -69,7 +84,9 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => {
selectedPartyId={selectedParty?.partyId}
productsList={activeProducts
.filter((p) =>
prodInteropAndProdInteropColl ? p.id !== 'prod-interop-coll' : 'prod-interop'
hasMoreThanOneInteropEnv
? p.id !== 'prod-interop-coll' && p.id !== 'prod-interop-atst'
: true
)
.map((p) => ({
id: p.id,
Expand Down Expand Up @@ -111,8 +128,8 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => {
setProductSelected(selectedProduct);
if (
actualSelectedParty.current &&
prodInteropAndProdInteropColl &&
p.id === 'prod-interop'
hasMoreThanOneInteropEnv &&
p.id.startsWith('prod-interop')
) {
setOpenCustomEnvInteropModal(true);
} else if (
Expand Down Expand Up @@ -157,31 +174,33 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => {
{`Sei stato abilitato ad operare in entrambi gli ambienti. Ti ricordiamo che l’ambiente di collaudo ti permette di conoscere <1>{{productTitle}}</1> e fare prove in tutta sicurezza. L’ambiente di produzione è il prodotto in esercizio.`}
</Trans>
}
onConfirmLabel={t('overview.activeProducts.activeProductsEnvModal.envProdButton')}
onConfirmLabel={t('overview.activeProducts.activeProductsEnvModal.enterButton')}
onCloseLabel={t('overview.activeProducts.activeProductsEnvModal.backButton')}
onConfirm={() =>
invokeProductBo(productSelected as Product, actualSelectedParty.current as Party)
}
handleClose={() => {
setOpenCustomEnvInteropModal(false);
}}
prodInteropAndProdInteropColl={!!prodInteropAndProdInteropColl}
authorizedProdInterop={!!authorizedProdInterop}
authorizedProdColl={!!authorizedProdColl}
authorizedProdAtst={!!authorizedProdAtst}
products={products}
party={party}
/>
<SessionModal
<GenericEnvProductModal
open={openGenericEnvProductModal}
title={t('overview.activeProducts.activeProductsEnvModal.title')}
message={
<Trans
i18nKey="overview.activeProducts.activeProductsEnvModal.messageProduct"
i18nKey="overview.activeProducts.activeProductsEnvModal.message"
values={{ productTitle: productSelected?.title }}
components={{ 1: <strong /> }}
>
{`L’ambiente di test ti permette di conoscere <1>{{productTitle}}</1> e fare prove in tutta sicurezza. L’ambiente di Produzione è il prodotto in esercizio effettivo.`}
{`Sei stato abilitato ad operare negli ambienti riportati di seguito per il prodotto <1>{{productTitle}}</1>.`}
</Trans>
}
onConfirmLabel={t('overview.activeProducts.activeProductsEnvModal.envProdButton')}
onConfirmLabel={t('overview.activeProducts.activeProductsEnvModal.enterButton')}
onCloseLabel={t('overview.activeProducts.activeProductsEnvModal.backButton')}
onConfirm={(e) =>
invokeProductBo(
Expand Down
13 changes: 11 additions & 2 deletions src/locale/it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,18 @@ export default {
manageButton: 'Gestisci',
activeProductsEnvModal: {
title: 'In quale ambiente vuoi entrare?',
message: `Sei stato abilitato ad operare in entrambi gli ambienti. Ti ricordiamo che l’ambiente di collaudo ti permette di conoscere <1>{{productTitle}}</1> e fare prove in tutta sicurezza. L’ambiente di produzione è il prodotto in esercizio.`,
message: `Sei stato abilitato ad operare negli ambienti riportati di seguito per il prodotto <1>{{productTitle}}</1>.`,
messageProduct:
'L’ambiente di test ti permette di conoscere <1>{{productTitle}}</1> e fare prove in tutta sicurezza. L’ambiente di Produzione è il prodotto in esercizio effettivo.',
envProdButton: 'Produzione',
devEnviromentMessage:
'Ti permettere di conoscere il prodotto e fare prove in tutta sicurezza',
uatEnviromentMessage: 'Ti permette di esplorare il prodotto',
prodEnviromentMessage: 'Prodotto in uso',
envDevButton: 'Ambiente di Collaudo',
envLocalButton: 'Ambiente Locale',
envUatButton: 'Ambiente di Attestazione',
envProdButton: 'Ambiente di Produzione',
enterButton: 'Entra',
backButton: 'Annulla',
},
},
Expand Down Expand Up @@ -269,5 +277,6 @@ export default {
closeButton: 'Annulla',
confirmButton: 'Riprova',
testLabel: 'Collaudo',
uatLabel: 'Attestazione',
},
};
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from 'react';
import { Grid } from '@mui/material';
import TitleBox from '@pagopa/selfcare-common-frontend/components/TitleBox';
import React from 'react';
import { useTranslation } from 'react-i18next';
import { Product } from '../../../../model/Product';
import { Party } from '../../../../model/Party';
import { Product } from '../../../../model/Product';
import ActiveProductCardContainer from './components/ActiveProductCardContainer';

type Props = {
Expand All @@ -14,9 +14,25 @@ type Props = {
export default function ActiveProductsSection({ party, products }: Props) {
const { t } = useTranslation();

const prodInterop = party.products.find((p) => p.productId === 'prod-interop');
const authorizedProdInterop = party.products.find(
(p) => p.productId === 'prod-interop' && p.authorized === true
);

const authorizedProdAtst = party.products.find(
(p) => p.productId === 'prod-interop-atst' && p.authorized === true
);

const authorizedProdColl = party.products.find(
(p) => p.productId === 'prod-interop-coll' && p.authorized === true
);

const authorizedInteropProducts = [
authorizedProdInterop,
authorizedProdAtst,
authorizedProdColl,
].filter((product) => product);

const prodInteropColl = party.products.find((p) => p.productId === 'prod-interop-coll');
const hasMoreThanOneInteropEnv = authorizedInteropProducts.length > 1;

return (
<React.Fragment>
Expand All @@ -26,11 +42,16 @@ export default function ActiveProductsSection({ party, products }: Props) {
.filter(
(us) =>
us.productOnBoardingStatus === 'ACTIVE' &&
(prodInterop?.authorized ||
prodInteropColl?.authorized === false ||
(prodInterop?.authorized === false && !prodInteropColl)
? us.productId !== 'prod-interop-coll'
: us.productId !== 'prod-interop')
(hasMoreThanOneInteropEnv
? us.productId !== 'prod-interop-coll' && us.productId !== 'prod-interop-atst'
: true) &&
(!authorizedProdColl ? us.productId !== 'prod-interop-coll' : true) &&
(!authorizedProdAtst ? us.productId !== 'prod-interop-atst' : true) &&
(authorizedInteropProducts.length === 0
? true
: !authorizedProdInterop && !hasMoreThanOneInteropEnv
? us.productId !== 'prod-interop'
: true)
)
.sort((a, b) =>
a.authorized === false && b.authorized !== false
Expand All @@ -44,9 +65,10 @@ export default function ActiveProductsSection({ party, products }: Props) {
key={product.productId}
party={party}
product={product}
haveProdInteropAndEnvProduct={
!!(prodInterop?.authorized && prodInteropColl?.authorized)
}
authorizedProdColl={!!authorizedProdColl}
authorizedProdAtst={!!authorizedProdAtst}
authorizedProdInterop={!!authorizedProdInterop}
hasMoreThanOneInteropEnv={hasMoreThanOneInteropEnv}
products={products}
/>
))}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
import { Grid } from '@mui/material';
import { useState } from 'react';
import { useTranslation, Trans } from 'react-i18next';
import { SessionModal } from '@pagopa/selfcare-common-frontend';
import { Trans, useTranslation } from 'react-i18next';
import { OnboardedProduct } from '../../../../../api/generated/b4f-dashboard/OnboardedProduct';
import { useTokenExchange } from '../../../../../hooks/useTokenExchange';
import { Party } from '../../../../../model/Party';
import { Product } from '../../../../../model/Product';
import { OnboardedProduct } from '../../../../../api/generated/b4f-dashboard/OnboardedProduct';
import ActiveProductCard from './ActiveProductCard';
import GenericEnvProductModal from './GenericEnvProductModal';
import SessionModalInteropProduct from './SessionModalInteropProduct';

type Props = {
party: Party;
product: OnboardedProduct;
haveProdInteropAndEnvProduct: boolean;
authorizedProdColl: boolean;
authorizedProdAtst: boolean;
authorizedProdInterop: boolean;
hasMoreThanOneInteropEnv: boolean;
products: Array<Product>;
};

export default function ActiveProductCardContainer({
party,
product,
haveProdInteropAndEnvProduct,
authorizedProdColl,
authorizedProdAtst,
authorizedProdInterop,
hasMoreThanOneInteropEnv,
products,
}: Props) {
const { t } = useTranslation();
Expand All @@ -38,12 +44,12 @@ export default function ActiveProductCardContainer({
<>
<Grid item xs={6} lg={4}>
<ActiveProductCard
disableBtn={isDisabled}
disableBtn={isDisabled && !hasMoreThanOneInteropEnv}
cardTitle={productOnboarded?.title ?? ''}
buttonLabel={t('overview.activeProducts.manageButton')}
urlLogo={productOnboarded?.logo ?? ''}
btnAction={() =>
haveProdInteropAndEnvProduct && productOnboarded.id === 'prod-interop'
hasMoreThanOneInteropEnv && productOnboarded.id.startsWith('prod-interop')
? setOpenCustomEnvInteropModal(true)
: productOnboarded?.backOfficeEnvironmentConfigurations &&
productOnboarded.id !== 'prod-interop'
Expand All @@ -63,33 +69,35 @@ export default function ActiveProductCardContainer({
values={{ productTitle: productOnboarded.title }}
components={{ 1: <strong /> }}
>
{`Sei stato abilitato ad operare in entrambi gli ambienti. Ti ricordiamo che l’ambiente di collaudo ti permette di conoscere <1>{{productTitle}}</1> e fare prove in tutta sicurezza. L’ambiente di produzione è il prodotto in esercizio.`}
{`Sei stato abilitato ad operare negli ambienti riportati di seguito per il prodotto <1>{{productTitle}}</1>.`}
</Trans>
}
onConfirmLabel={t('overview.activeProducts.activeProductsEnvModal.envProdButton')}
onConfirmLabel={t('overview.activeProducts.activeProductsEnvModal.enterButton')}
onCloseLabel={t('overview.activeProducts.activeProductsEnvModal.backButton')}
onConfirm={() => invokeProductBo(productOnboarded, party)}
handleClose={() => {
setOpenCustomEnvInteropModal(false);
}}
prodInteropAndProdInteropColl={haveProdInteropAndEnvProduct}
authorizedProdColl={authorizedProdColl}
authorizedProdAtst={authorizedProdAtst}
authorizedProdInterop={authorizedProdInterop}
products={products}
party={party}
/>

<SessionModal
<GenericEnvProductModal
open={openGenericEnvProductModal}
title={t('overview.activeProducts.activeProductsEnvModal.title')}
message={
<Trans
i18nKey="overview.activeProducts.activeProductsEnvModal.messageProduct"
i18nKey="overview.activeProducts.activeProductsEnvModal.message"
values={{ productTitle: productOnboarded.title }}
components={{ 1: <strong /> }}
>
{`L’ambiente di test ti permette di conoscere <1>{{productTitle}}</1> e fare prove in tutta sicurezza. L’ambiente di Produzione è il prodotto in esercizio effettivo.`}
{`Sei stato abilitato ad operare negli ambienti riportati di seguito per il prodotto <1>{{productTitle}}</1>.`}
</Trans>
}
onConfirmLabel={t('overview.activeProducts.activeProductsEnvModal.envProdButton')}
onConfirmLabel={t('overview.activeProducts.activeProductsEnvModal.enterButton')}
onCloseLabel={t('overview.activeProducts.activeProductsEnvModal.backButton')}
onConfirm={(e) =>
invokeProductBo(productOnboarded, party, (e.target as HTMLInputElement).value)
Expand Down
Loading

0 comments on commit 5973b68

Please sign in to comment.