Skip to content

Commit

Permalink
[SELC-5886] Fix: handle ADMIN_EA from roles api response
Browse files Browse the repository at this point in the history
  • Loading branch information
OraldoDoci authored Oct 28, 2024
1 parent d935818 commit 377dd8b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 28 deletions.
4 changes: 2 additions & 2 deletions src/model/Party.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { InstitutionResource } from '../api/generated/b4f-dashboard/InstitutionR
import { ProductOnBoardingStatusEnum } from '../api/generated/b4f-dashboard/OnboardedProductResource';
import { ENV } from '../utils/env';

export type UserRole = 'ADMIN' | 'LIMITED';
export type PartyRole = 'DELEGATE' | 'MANAGER' | 'OPERATOR' | 'SUB_DELEGATE';
export type UserRole = 'ADMIN' | 'LIMITED' | 'ADMIN_EA';
export type PartyRole = 'DELEGATE' | 'MANAGER' | 'OPERATOR' | 'SUB_DELEGATE' | 'ADMIN_EA';
export type UserStatus = 'PENDING' | 'ACTIVE' | 'SUSPENDED' | 'TOBEVALIDATED';

type OnboardedProduct = {
Expand Down
7 changes: 4 additions & 3 deletions src/model/ProductRole.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { UserRole, PartyRole } from './Party';
import { PartyRole, UserRole } from "./Party";


export type ProductRole = {
productId: string;
Expand All @@ -20,9 +21,9 @@ export type ProductRolesLists = {

export const buildEmptyProductRolesLists = (): ProductRolesLists => ({
list: [],
groupBySelcRole: { ADMIN: [], LIMITED: [] },
groupBySelcRole: { ADMIN: [], LIMITED: [], ADMIN_EA: [] },
groupByProductRole: {},
groupByPartyRole: { MANAGER: [], DELEGATE: [], SUB_DELEGATE: [], OPERATOR: [] },
groupByPartyRole: { MANAGER: [], DELEGATE: [], SUB_DELEGATE: [], OPERATOR: [], ADMIN_EA: [] },
});

export type ProductRolesByProductRoleType = { [productRole: string]: ProductRole };
Expand Down
34 changes: 18 additions & 16 deletions src/model/__tests__/ProductRole.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mockedProductRoles } from '../../services/__mocks__/productService';
import { ProductRole, productRoles2ProductRolesList } from '../ProductRole';
import { productRoles2ProductRolesList } from '../ProductRole';

test('Test productRoles2ProductRolesList', () => {
const rolesList = productRoles2ProductRolesList(mockedProductRoles);
Expand All @@ -15,7 +15,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-legale',
title: 'Referente Legale',
description: 'Descrizione referente-legale',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
{
productId: 'PRODID',
Expand All @@ -25,7 +25,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-amministrativo',
title: 'Amministratore',
description: 'Descrizione referente-amministrativo',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
{
productId: 'PRODID',
Expand All @@ -35,7 +35,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'incaricato-ente-creditore',
title: 'Incaricato Ente Creditore',
description: 'Descrizione incaricato-ente-creditore',
phasesAdditionAllowed: ['dashboard-async']
phasesAdditionAllowed: ['dashboard-async'],
},
],
LIMITED: [
Expand All @@ -47,7 +47,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-dei-pagamenti',
title: 'Referente dei Pagamenti',
description: 'Descrizione referente-dei-pagamenti',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
{
productId: 'PRODID',
Expand All @@ -57,9 +57,10 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-tecnico',
title: 'Referente Tecnico',
description: 'Descrizione referente-tecnico',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
],
ADMIN_EA: [],
},
groupByPartyRole: {
DELEGATE: [
Expand All @@ -71,7 +72,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-amministrativo',
selcRole: 'ADMIN',
title: 'Amministratore',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
],
MANAGER: [
Expand All @@ -83,7 +84,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-legale',
selcRole: 'ADMIN',
title: 'Referente Legale',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
],
OPERATOR: [
Expand All @@ -95,7 +96,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-dei-pagamenti',
selcRole: 'LIMITED',
title: 'Referente dei Pagamenti',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
{
description: 'Descrizione referente-tecnico',
Expand All @@ -105,7 +106,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-tecnico',
selcRole: 'LIMITED',
title: 'Referente Tecnico',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
],
SUB_DELEGATE: [
Expand All @@ -117,9 +118,10 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'incaricato-ente-creditore',
selcRole: 'ADMIN',
title: 'Incaricato Ente Creditore',
phasesAdditionAllowed: ['dashboard-async']
phasesAdditionAllowed: ['dashboard-async'],
},
],
ADMIN_EA: [],
},
groupByProductRole: {
'referente-legale': {
Expand All @@ -130,7 +132,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-legale',
title: 'Referente Legale',
description: 'Descrizione referente-legale',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
'referente-amministrativo': {
productId: 'PRODID',
Expand All @@ -140,7 +142,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-amministrativo',
title: 'Amministratore',
description: 'Descrizione referente-amministrativo',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
'incaricato-ente-creditore': {
productId: 'PRODID',
Expand All @@ -150,7 +152,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'incaricato-ente-creditore',
title: 'Incaricato Ente Creditore',
description: 'Descrizione incaricato-ente-creditore',
phasesAdditionAllowed: ['dashboard-async']
phasesAdditionAllowed: ['dashboard-async'],
},
'referente-dei-pagamenti': {
productId: 'PRODID',
Expand All @@ -160,7 +162,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-dei-pagamenti',
title: 'Referente dei Pagamenti',
description: 'Descrizione referente-dei-pagamenti',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
'referente-tecnico': {
productId: 'PRODID',
Expand All @@ -170,7 +172,7 @@ test('Test productRoles2ProductRolesList', () => {
productRole: 'referente-tecnico',
title: 'Referente Tecnico',
description: 'Descrizione referente-tecnico',
phasesAdditionAllowed: ['dashboard']
phasesAdditionAllowed: ['dashboard'],
},
},
});
Expand Down
9 changes: 2 additions & 7 deletions src/pages/dashboard/Dashboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,8 @@ const Dashboard = () => {
)
);

const authorizedDelegableProducts: Array<Product> = activeProducts.filter((ap) =>
party?.products.some(
(p) =>
p.productId === ap.id &&
hasPermission(p.productId, Actions.AccessProductBackoffice) &&
ap.delegable
)
const authorizedDelegableProducts: Array<Product> = delegableProducts.filter((ap) =>
hasPermission(ap.id ?? '', Actions.AccessProductBackoffice)
);

const canAggregatorSeeHandleDelegations = useMemo(() => {
Expand Down

0 comments on commit 377dd8b

Please sign in to comment.