Skip to content

Commit

Permalink
[SELC-5823] Feat: add check if delegation is present in getInstituion…
Browse files Browse the repository at this point in the history
…s list
  • Loading branch information
OraldoDoci authored Oct 29, 2024
1 parent ddef923 commit a1d50f3
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 8 deletions.
10 changes: 7 additions & 3 deletions src/pages/dashboardTechnologyPartnerPage/TechPartnersTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ export default function TechPartnersTable({ delegationsWithoutDuplicates }: Read
const [currentPage, setCurrentPage] = useState(1);
const [totalPages, setTotalPages] = useState(Math.ceil(tableData.length / itemsPerPage));
const products = useAppSelector(partiesSelectors.selectPartySelectedProducts);
const parties = useAppSelector(partiesSelectors.selectPartiesList);
const partyIdsSet = parties ? new Set(parties.map((party) => party.partyId)) : new Set();

useEffect(() => {
setTotalPages(Math.ceil(tableData.length / itemsPerPage));
Expand Down Expand Up @@ -210,9 +212,7 @@ export default function TechPartnersTable({ delegationsWithoutDuplicates }: Read
{getSortedData(tableData)
.slice((currentPage - 1) * itemsPerPage, currentPage * itemsPerPage)
.map((item, _index) => {
const isClickable =
(item.productId === 'prod-io' || item.productId === 'prod-pagopa') &&
item.type === 'EA';
const isClickable = item.type === 'EA' && partyIdsSet.has(item.institutionId);

return (
<>
Expand All @@ -223,6 +223,10 @@ export default function TechPartnersTable({ delegationsWithoutDuplicates }: Read
<ButtonNaked
color="primary"
component="button"
sx={{
fontWeight: 700,
fontSize: '16px',
}}
onClick={() => {
history.push(
resolvePathVariables(ROUTES.PARTY_DASHBOARD.path, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,25 @@ import TechPartnersTable from '../TechPartnersTable';
const mockedDelegation: DelegationWithPagination = {
delegations: [
{
brokerId: '123',
brokerId: '111',
brokerName: 'Broker 1',
id: '456',
institutionId: '789',
id: '1',
institutionId: '1111',
institutionName: 'Institution 1',
institutionRootName: 'Root Institution',
productId: '7890',
type: TypeEnum.AOO,
},
{
brokerId: '222',
brokerName: 'Broker EA',
id: '2',
institutionId: 'institutionId0',
institutionName: 'Institution EA',
institutionRootName: 'Root Institution',
productId: '7890',
type: TypeEnum.EA,
},
],
pageInfo: {
pageSize: 0,
Expand Down Expand Up @@ -80,3 +90,13 @@ test('test input field change and filter on click and search by name', async ()
expect(removeFiltersButton).toBeEnabled();
fireEvent.click(removeFiltersButton);
});

test('delegation of type EA should be clikable for same institution is present on instituionList', async () => {
renderDashboardTablePT();

const delegationOfTypeEA = await screen.findByText('Institution EA');

expect(delegationOfTypeEA).toBeInTheDocument();

fireEvent.click(delegationOfTypeEA);
});
4 changes: 2 additions & 2 deletions src/services/__mocks__/partyService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const mockedBaseParties: Array<BaseParty> = [
userRole: 'ADMIN',
},
{
partyId: '6',
partyId: 'institutionId0',
description: 'Scuola Media Oswald Von Wolkenstein di Bressa',
status: 'ACTIVE',
userRole: 'ADMIN',
Expand Down Expand Up @@ -601,7 +601,7 @@ export const mockedParties: Array<Party> = [
{
description: 'Scuola Media Oswald Von Wolkenstein di Bressa',
urlLogo: 'image',
partyId: '6',
partyId: 'institutionId0',
digitalAddress: '[email protected]',
fiscalCode: '111122211111',
category: 'Comuni e loro Consorzi e Associazioni',
Expand Down

0 comments on commit a1d50f3

Please sign in to comment.