up
This commit is contained in:
@@ -6,6 +6,10 @@ export class CreatePaymentMethodDto {
|
|||||||
@IsString()
|
@IsString()
|
||||||
name!: string;
|
name!: string;
|
||||||
|
|
||||||
|
@ApiProperty({ description: 'English Payment method name' })
|
||||||
|
@IsString()
|
||||||
|
keyName!: string;
|
||||||
|
|
||||||
@ApiProperty({ description: 'Payment method description', required: false })
|
@ApiProperty({ description: 'Payment method description', required: false })
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@IsString()
|
@IsString()
|
||||||
@@ -26,4 +30,3 @@ export class CreatePaymentMethodDto {
|
|||||||
@IsNumber()
|
@IsNumber()
|
||||||
order?: number;
|
order?: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,15 +48,30 @@ export class PermissionsService {
|
|||||||
// If not in cache, fetch from database
|
// If not in cache, fetch from database
|
||||||
const admin = await this.adminRepository.findOne(
|
const admin = await this.adminRepository.findOne(
|
||||||
{ id: adminId, roles: { restaurant: { id: restId } } },
|
{ id: adminId, roles: { restaurant: { id: restId } } },
|
||||||
{ populate: ['roles', 'roles.role'] },
|
{ populate: ['roles', 'roles.role', 'roles.role.permissions'] },
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!admin || !admin.roles) {
|
if (!admin || !admin.roles) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Ensure roles collection is loaded
|
||||||
|
await admin.roles.loadItems();
|
||||||
|
|
||||||
// Extract permission names as array of strings
|
// Extract permission names as array of strings
|
||||||
const permissions = admin.roles.map(r => r.role.permissions.getItems());
|
const permissions = await Promise.all(
|
||||||
|
admin.roles
|
||||||
|
.getItems()
|
||||||
|
.filter(r => r.role) // Filter out any null/undefined roles
|
||||||
|
.map(async r => {
|
||||||
|
// Ensure permissions collection is initialized
|
||||||
|
if (!r.role.permissions.isInitialized()) {
|
||||||
|
await r.role.permissions.loadItems();
|
||||||
|
}
|
||||||
|
return r.role.permissions.getItems();
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
return permissions.flat().map(p => p.name);
|
return permissions.flat().map(p => p.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user