Skip to content

Commit ce0207e

Browse files
authored
FIX: Organisation profile view rights bug (#168)
Co-authored-by: Ivan Mitev <>
1 parent 852ab73 commit ce0207e

6 files changed

Lines changed: 207 additions & 144 deletions

File tree

src/app/app-routing.module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ const routes: Routes = [
7272
},
7373
{ path: 'profile',
7474
component: UserProfileComponent,
75-
canActivate: [AuthGuard], data: { roles: ['individual','orgAdmin'] }
75+
canActivate: [AuthGuard], data: { roles: [] }
7676
},
7777
{ path: 'my-offerings',
7878
component: SellerOfferingsComponent,

src/app/pages/user-profile/profile-sections/billing-info/billing-info.component.html

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,11 @@ <h2 class="md:text-3xl lg:text-4xl font-bold text-primary-100 ml-4 dark:text-whi
2626
<th scope="col" class="px-6 py-3">
2727
{{ 'BILLING._phone' | translate }}
2828
</th>
29-
<th scope="col" class="px-6 py-3">
30-
{{ 'BILLING._action' | translate }}
31-
</th>
29+
@if(!isReadOnly){
30+
<th scope="col" class="px-6 py-3">
31+
{{ 'BILLING._action' | translate }}
32+
</th>
33+
}
3234
</tr>
3335
</thead>
3436
<tbody>
@@ -49,18 +51,20 @@ <h2 class="md:text-3xl lg:text-4xl font-bold text-primary-100 ml-4 dark:text-whi
4951
<td class="px-6 py-4">
5052
({{bill.telephoneType}}) {{bill.telephoneNumber}}
5153
</td>
52-
<td class="px-6 py-4 inline-flex">
53-
<button data-cy="billingEdit" (click)="toggleEditBill(bill);$event.stopPropagation();" type="button" class="text-white bg-primary-100 hover:bg-primary-50 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-full text-sm p-1 lg:p-2.5 text-center inline-flex items-center me-2">
54-
<svg class="w-[18px] h-[18px] text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
55-
<path fill-rule="evenodd" d="M14 4.182A4.136 4.136 0 0 1 16.9 3c1.087 0 2.13.425 2.899 1.182A4.01 4.01 0 0 1 21 7.037c0 1.068-.43 2.092-1.194 2.849L18.5 11.214l-5.8-5.71 1.287-1.31.012-.012Zm-2.717 2.763L6.186 12.13l2.175 2.141 5.063-5.218-2.141-2.108Zm-6.25 6.886-1.98 5.849a.992.992 0 0 0 .245 1.026 1.03 1.03 0 0 0 1.043.242L10.282 19l-5.25-5.168Zm6.954 4.01 5.096-5.186-2.218-2.183-5.063 5.218 2.185 2.15Z" clip-rule="evenodd"/>
56-
</svg>
57-
</button>
58-
<!--<button (click)="toggleDeleteBill(bill);$event.stopPropagation();" type="button" class="text-white bg-red-800 hover:bg-red-900 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-full text-sm p-1 lg:p-2.5 text-center inline-flex items-center me-2">
59-
<svg class="w-[18px] h-[18px] text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
60-
<path fill-rule="evenodd" d="M8.586 2.586A2 2 0 0 1 10 2h4a2 2 0 0 1 2 2v2h3a1 1 0 1 1 0 2v12a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V8a1 1 0 0 1 0-2h3V4a2 2 0 0 1 .586-1.414ZM10 6h4V4h-4v2Zm1 4a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Zm4 0a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Z" clip-rule="evenodd"/>
54+
@if(!isReadOnly){
55+
<td class="px-6 py-4 inline-flex">
56+
<button data-cy="billingEdit" (click)="toggleEditBill(bill);$event.stopPropagation();" type="button" class="text-white bg-primary-100 hover:bg-primary-50 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-full text-sm p-1 lg:p-2.5 text-center inline-flex items-center me-2">
57+
<svg class="w-[18px] h-[18px] text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
58+
<path fill-rule="evenodd" d="M14 4.182A4.136 4.136 0 0 1 16.9 3c1.087 0 2.13.425 2.899 1.182A4.01 4.01 0 0 1 21 7.037c0 1.068-.43 2.092-1.194 2.849L18.5 11.214l-5.8-5.71 1.287-1.31.012-.012Zm-2.717 2.763L6.186 12.13l2.175 2.141 5.063-5.218-2.141-2.108Zm-6.25 6.886-1.98 5.849a.992.992 0 0 0 .245 1.026 1.03 1.03 0 0 0 1.043.242L10.282 19l-5.25-5.168Zm6.954 4.01 5.096-5.186-2.218-2.183-5.063 5.218 2.185 2.15Z" clip-rule="evenodd"/>
6159
</svg>
62-
</button>-->
63-
</td>
60+
</button>
61+
<!--<button (click)="toggleDeleteBill(bill);$event.stopPropagation();" type="button" class="text-white bg-red-800 hover:bg-red-900 focus:ring-4 focus:outline-none focus:ring-blue-300 font-medium rounded-full text-sm p-1 lg:p-2.5 text-center inline-flex items-center me-2">
62+
<svg class="w-[18px] h-[18px] text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24">
63+
<path fill-rule="evenodd" d="M8.586 2.586A2 2 0 0 1 10 2h4a2 2 0 0 1 2 2v2h3a1 1 0 1 1 0 2v12a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V8a1 1 0 0 1 0-2h3V4a2 2 0 0 1 .586-1.414ZM10 6h4V4h-4v2Zm1 4a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Zm4 0a1 1 0 1 0-2 0v8a1 1 0 1 0 2 0v-8Z" clip-rule="evenodd"/>
64+
</svg>
65+
</button>-->
66+
</td>
67+
}
6468
</tr>
6569
} @empty {
6670
<div class="flex justify-center w-full m-4">
@@ -77,9 +81,11 @@ <h2 class="md:text-3xl lg:text-4xl font-bold text-primary-100 ml-4 dark:text-whi
7781
</tbody>
7882
</table>
7983
</div>
80-
<h2 class="md:text-3xl lg:text-4xl font-bold text-primary-100 ml-4 dark:text-white m-4">{{ 'BILLING._add' | translate }}</h2>
81-
<hr class="h-px mr-4 ml-4 bg-primary-100 dark:bg-white border-0">
82-
<app-billing-account-form [preferred]="preferred"></app-billing-account-form>
84+
@if(!isReadOnly){
85+
<h2 class="md:text-3xl lg:text-4xl font-bold text-primary-100 ml-4 dark:text-white m-4">{{ 'BILLING._add' | translate }}</h2>
86+
<hr class="h-px mr-4 ml-4 bg-primary-100 dark:bg-white border-0">
87+
<app-billing-account-form [preferred]="preferred"></app-billing-account-form>
88+
}
8389
</div>
8490
}
8591

src/app/pages/user-profile/profile-sections/billing-info/billing-info.component.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ export class BillingInfoComponent implements OnInit{
4141
selectedDate:any;
4242
countries: any[] = countries;
4343
preferred:boolean=false;
44+
isReadOnly:boolean=false;
4445

4546
errorMessage:any='';
4647
showError:boolean=false;
@@ -105,6 +106,13 @@ export class BillingInfoComponent implements OnInit{
105106
href : this.partyId,
106107
role: "Owner"
107108
}
109+
110+
// Check if user has orgAdmin role for edit permission
111+
if(loggedOrg && loggedOrg.roles){
112+
const orgRoles = loggedOrg.roles.map((role: any) => role.name);
113+
const hasOrgAdminRole = orgRoles.some((role: any) => role === 'orgAdmin');
114+
this.isReadOnly = !hasOrgAdminRole;
115+
}
108116
} else {
109117
this.partyId = aux.partyId;
110118
console.log('init party info')
@@ -115,6 +123,7 @@ export class BillingInfoComponent implements OnInit{
115123
href : this.partyId,
116124
role: "Owner"
117125
}
126+
this.isReadOnly = false;
118127
}
119128
this.getBilling();
120129
}

0 commit comments

Comments
 (0)