diff --git a/src/modules/payments/dto/create-payment-method.dto.ts b/src/modules/payments/dto/create-payment-method.dto.ts index 20c6076..49f95bc 100644 --- a/src/modules/payments/dto/create-payment-method.dto.ts +++ b/src/modules/payments/dto/create-payment-method.dto.ts @@ -6,6 +6,10 @@ export class CreatePaymentMethodDto { @IsString() name!: string; + @ApiProperty({ description: 'English Payment method name' }) + @IsString() + keyName!: string; + @ApiProperty({ description: 'Payment method description', required: false }) @IsOptional() @IsString() @@ -26,4 +30,3 @@ export class CreatePaymentMethodDto { @IsNumber() order?: number; } - diff --git a/src/modules/roles/providers/permissions.service.ts b/src/modules/roles/providers/permissions.service.ts index 421d320..fd7938b 100644 --- a/src/modules/roles/providers/permissions.service.ts +++ b/src/modules/roles/providers/permissions.service.ts @@ -48,15 +48,30 @@ export class PermissionsService { // If not in cache, fetch from database const admin = await this.adminRepository.findOne( { id: adminId, roles: { restaurant: { id: restId } } }, - { populate: ['roles', 'roles.role'] }, + { populate: ['roles', 'roles.role', 'roles.role.permissions'] }, ); if (!admin || !admin.roles) { return []; } + // Ensure roles collection is loaded + await admin.roles.loadItems(); + // 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); }