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

Release UAT #809

Merged
merged 2 commits into from
Oct 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .env.test.local
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
REACT_APP_ENV=TEST

REACT_APP_URL_CDN=https://dev.selfcare.pagopa.it

REACT_APP_URL_FE_LOGIN=http://selfcare/auth/login
REACT_APP_URL_FE_LOGOUT=http://selfcare/auth/logout
REACT_APP_URL_FE_ONBOARDING=http://selfcare/onboarding
Expand Down
6 changes: 5 additions & 1 deletion openApi/dashboard-api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -3594,7 +3594,11 @@
},
"category" : {
"type" : "string",
"description" : "Institution's category"
"description" : "Institution's category description"
},
"categoryCode" : {
"type" : "string",
"description" : "Institution's category code"
},
"city" : {
"type" : "string",
Expand Down
6 changes: 5 additions & 1 deletion openApi/generated-dashboard/dashboard-swagger20.json
Original file line number Diff line number Diff line change
Expand Up @@ -3174,7 +3174,11 @@
"type": "string"
},
"category": {
"description": "Institution's category",
"description": "Institution's category description",
"type": "string"
},
"categoryCode": {
"description": "Institution's category code",
"type": "string"
},
"city": {
Expand Down
39 changes: 20 additions & 19 deletions src/components/DashboardHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import SessionModalInteropProduct from '../pages/dashboardOverview/components/ac
import { useAppSelector } from '../redux/hooks';
import { partiesSelectors } from '../redux/slices/partiesSlice';
import ROUTES from '../routes';
import { INTEROP_PRODUCT_ENUM, interopProductIdList } from '../utils/constants';
import { startWithProductInterop } from '../utils/helperFunctions';
import { ENV } from './../utils/env';

type Props = WithPartiesProps & {
Expand Down Expand Up @@ -54,23 +56,18 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => {
p.productId === productId && hasPermission(p.productId, Actions.AccessProductBackoffice)
);

const authorizedProdInterop = findAuthorizedProduct('prod-interop');
const authorizedProdAtst = findAuthorizedProduct('prod-interop-atst');
const authorizedProdColl = findAuthorizedProduct('prod-interop-coll');

const authorizedInteropProducts = [
authorizedProdInterop,
authorizedProdAtst,
authorizedProdColl,
].filter((product) => product);
const authorizedInteropProducts = interopProductIdList
.map(findAuthorizedProduct)
.filter(Boolean)
.map((p) => p?.productId ?? '');

const hasMoreThanOneInteropEnv = authorizedInteropProducts.length > 1;

const onboardedPartyProducts = party?.products.filter(
(pp) =>
pp.productOnBoardingStatus === 'ACTIVE' &&
(hasPermission(pp.productId ?? '', Actions.AccessProductBackoffice) ||
(hasMoreThanOneInteropEnv && pp.productId === 'prod-interop'))
(hasMoreThanOneInteropEnv && pp.productId === INTEROP_PRODUCT_ENUM.INTEROP))
);

const activeProducts: Array<Product> = useMemo(
Expand All @@ -94,13 +91,15 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => {
selectedPartyId={selectedParty?.partyId}
productsList={activeProducts
.filter((p) =>
hasMoreThanOneInteropEnv
? p.id !== 'prod-interop-coll' && p.id !== 'prod-interop-atst'
startWithProductInterop(p.id) && hasMoreThanOneInteropEnv
? p.id === authorizedInteropProducts[0]
: true
)
.map((p) => ({
id: p.id,
title: p.title,
title: startWithProductInterop(p.id)
? products?.find((pp) => pp.id === INTEROP_PRODUCT_ENUM.INTEROP)?.title ?? ''
: p.title,
productUrl: p.urlPublic ?? '',
linkType: p?.backOfficeEnvironmentConfigurations ? 'external' : 'internal',
}))}
Expand Down Expand Up @@ -143,7 +142,7 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => {
if (
actualSelectedParty.current &&
hasMoreThanOneInteropEnv &&
p.id.startsWith('prod-interop')
startWithProductInterop(p.id)
) {
setOpenCustomEnvInteropModal(true);
} else if (
Expand All @@ -153,7 +152,7 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => {
setOpenGenericEnvProductModal(true);
} else if (selectedProduct && selectedProduct.id !== 'prod-selfcare') {
void invokeProductBo(
selectedProduct as Product,
selectedProduct,
actualSelectedParty.current as Party,
undefined,
lang
Expand Down Expand Up @@ -181,7 +180,11 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => {
message={
<Trans
i18nKey="overview.activeProducts.activeProductsEnvModal.message"
values={{ productTitle: productSelected?.title }}
values={{
productTitle: startWithProductInterop(productSelected?.id)
? products?.find((pp) => pp.id === INTEROP_PRODUCT_ENUM.INTEROP)?.title
: productSelected?.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.`}
Expand All @@ -200,9 +203,7 @@ const DashboardHeader = ({ onExit, loggedUser, parties }: Props) => {
handleClose={() => {
setOpenCustomEnvInteropModal(false);
}}
authorizedProdInterop={!!authorizedProdInterop}
authorizedProdColl={!!authorizedProdColl}
authorizedProdAtst={!!authorizedProdAtst}
authorizedInteropProducts={authorizedInteropProducts}
products={products}
party={party}
/>
Expand Down
2 changes: 2 additions & 0 deletions src/model/Party.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export type Party = {
description: string;
digitalAddress?: string;
category?: string;
categoryCode?: string;
urlLogo?: string;
fiscalCode?: string;
registeredOffice: string;
Expand Down Expand Up @@ -75,6 +76,7 @@ export const institutionResource2Party = (institutionResource: InstitutionResour
description: institutionResource.name ?? '',
digitalAddress: institutionResource.mailAddress,
category: institutionResource.category,
categoryCode: institutionResource.categoryCode,
urlLogo,
fiscalCode: institutionResource.fiscalCode,
registeredOffice: institutionResource.address ?? '',
Expand Down
2 changes: 2 additions & 0 deletions src/model/__tests__/Party.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ test('Test institutionResource2Party', () => {
originId: 'originId1',
origin: 'IPA',
category: 'Ente locale',
categoryCode: 'L1',
mailAddress: 'address',
fiscalCode: 'fiscalCode',
institutionType: 'PA',
Expand All @@ -91,6 +92,7 @@ test('Test institutionResource2Party', () => {
fiscalCode: 'fiscalCode',
digitalAddress: 'address',
category: 'Ente locale',
categoryCode: 'L1',
urlLogo: 'http://checkout.selfcare/institutions/1/logo.png',
externalId: 'externalId1',
originId: 'originId1',
Expand Down
44 changes: 42 additions & 2 deletions src/pages/dashboardOverview/DashboardOverview.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { Box, Grid } from '@mui/material';
import { usePermissions } from '@pagopa/selfcare-common-frontend/lib';
import { Actions } from '@pagopa/selfcare-common-frontend/lib/utils/constants';
import { useState } from 'react';
import { useEffect, useState } from 'react';
import { Party } from '../../model/Party';
import { Product } from '../../model/Product';
import { mockedCategories } from '../../services/__mocks__/productService';
import { ENV } from '../../utils/env';
import ActiveProductsSection from './components/activeProductsSection/ActiveProductsSection';
import NotActiveProductsSection from './components/notActiveProductsSection/NotActiveProductsSection';
import { PartyDetailModal } from './components/partyDetailModal/PartyDetailModal';
Expand All @@ -16,6 +18,7 @@ type Props = {

const DashboardOverview = ({ party, products }: Props) => {
const [open, setOpen] = useState(false);
const [allowedCategoriesOnProdPN, setAllowedCategoriesOnProdPN] = useState<Array<string>>([]);
const { getAllProductsWithPermission } = usePermissions();

const showInfoBanner = party.institutionType === 'PA';
Expand All @@ -31,6 +34,37 @@ const DashboardOverview = ({ party, products }: Props) => {
const canSeeNotActiveProductsList =
getAllProductsWithPermission(Actions.ListAvailableProducts).length > 0;

const getCategoriesOnboardingAllowed = async () => {
if (process.env.REACT_APP_API_MOCK_PARTIES === 'true') {
await Promise.resolve(
mockedCategories.product['prod-pn']?.ipa.PA?.split(',').map((c: string) => c.trim())
);
} else {
try {
const response = await fetch(ENV.BASE_PATH_CDN_URL + '/assets/config.json');

if (!response.ok) {
console.error(`Failed to fetch config.json: ${response.status} - ${response.statusText}`);
return;
}

const categoriesAllowedJSON = await response.json();

const categoriesStringToArray = categoriesAllowedJSON?.product['prod-pn']?.ipa.PA?.split(
','
).map((c: string) => c.trim());

setAllowedCategoriesOnProdPN(categoriesStringToArray);
} catch (error) {
console.error(error);
}
}
};

useEffect(() => {
void getCategoriesOnboardingAllowed();
}, []);

return (
<Box p={3} sx={{ width: '100%' }}>
<PartyDetailModal
Expand All @@ -53,7 +87,13 @@ const DashboardOverview = ({ party, products }: Props) => {
party.products.map(
(us) => us.productId === product.id && us.productOnBoardingStatus !== 'ACTIVE'
)
) > -1 && <NotActiveProductsSection party={party} products={products} />}
) > -1 && (
<NotActiveProductsSection
party={party}
products={products}
allowedCategoriesOnProdPN={allowedCategoriesOnProdPN}
/>
)}
</Grid>
</Box>
);
Expand Down
Loading