bug
This commit is contained in:
@@ -3,8 +3,7 @@
|
||||
* All permission names used in the system should be defined here
|
||||
*/
|
||||
export enum Permission {
|
||||
MANAGE_PAGER = 'manage_pager',
|
||||
// product Management
|
||||
|
||||
MANAGE_productS = 'manage_products',
|
||||
MANAGE_CATEGORIES = 'manage_categories',
|
||||
|
||||
@@ -19,16 +18,15 @@ export enum Permission {
|
||||
VIEW_REPORTS = 'view_reports',
|
||||
|
||||
|
||||
UPDATE_RESTAURANT = 'update_restaurant',
|
||||
|
||||
// Role Management
|
||||
MANAGE_ROLES = 'manage_roles',
|
||||
MANAGE_REVIEWS = 'manage_reviews',
|
||||
MANAGE_COUPONS = 'manage_coupons',
|
||||
|
||||
|
||||
MANAGE_PAYMENTS = 'manage_payments',
|
||||
MANAGE_DELIVERY = 'manage_delivery',
|
||||
|
||||
MANAGE_SETTINGS = 'manage_settings',
|
||||
MANAGE_SCHEDULES = 'manage_schedules',
|
||||
|
||||
MANAGE_REPORTS = 'manage_reports',
|
||||
MANAGE_CONTACTS = 'manage_contacts',
|
||||
}
|
||||
@@ -38,21 +36,15 @@ export enum Permission {
|
||||
* Maps permission names to their Farsi titles
|
||||
*/
|
||||
export const PermissionTitles: Record<Permission, string> = {
|
||||
[Permission.MANAGE_PAGER]: 'مدیریت پیجر',
|
||||
[Permission.MANAGE_productS]: 'مدیریت غذاها',
|
||||
[Permission.MANAGE_CATEGORIES]: 'مدیریت دستهبندیها',
|
||||
[Permission.MANAGE_ORDERS]: 'مدیریت سفارشات',
|
||||
[Permission.MANAGE_ADMINS]: 'مدیریت مدیران',
|
||||
[Permission.MANAGE_USERS]: 'مدیریت کاربران',
|
||||
[Permission.VIEW_REPORTS]: 'مشاهده گزارشات',
|
||||
[Permission.UPDATE_RESTAURANT]: 'ویرایش رستوران',
|
||||
[Permission.MANAGE_ROLES]: 'مدیریت نقشها',
|
||||
[Permission.MANAGE_REVIEWS]: 'مدیریت نظرات',
|
||||
[Permission.MANAGE_COUPONS]: 'مدیریت کوپنها',
|
||||
[Permission.MANAGE_PAYMENTS]: 'مدیریت پرداختها',
|
||||
[Permission.MANAGE_DELIVERY]: 'مدیریت تحویل',
|
||||
[Permission.MANAGE_SETTINGS]: 'مدیریت تنظیمات',
|
||||
[Permission.MANAGE_SCHEDULES]: 'مدیریت برنامهها',
|
||||
[Permission.MANAGE_REPORTS]: 'مدیریت گزارشات',
|
||||
[Permission.MANAGE_CONTACTS]: 'مدیریت تماسهای کاربران',
|
||||
};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Entity, OneToOne, PrimaryKey, Property } from '@mikro-orm/core';
|
||||
import { Entity, ManyToOne, OneToOne, PrimaryKey, Property } from '@mikro-orm/core';
|
||||
import { BaseEntity } from '../../../common/entities/base.entity';
|
||||
import { normalizePhone } from '../../util/phone.util';
|
||||
import { Role } from 'src/modules/roles/entities/role.entity';
|
||||
@@ -27,6 +27,6 @@ export class Admin extends BaseEntity {
|
||||
this._phone = normalizePhone(value);
|
||||
}
|
||||
|
||||
@OneToOne(() => Role)
|
||||
@ManyToOne(() => Role)
|
||||
role: Role
|
||||
}
|
||||
|
||||
@@ -34,10 +34,10 @@ export class DatabaseSeeder extends Seeder {
|
||||
// console.info(`[Seeder] Step 8/${TOTAL_STEPS}: Done`);
|
||||
|
||||
// 9. Create products
|
||||
console.info(`[Seeder] Step 9/${TOTAL_STEPS}: Creating products`);
|
||||
const productsSeeder = new ProductsSeeder();
|
||||
// console.info(`[Seeder] Step 9/${TOTAL_STEPS}: Creating products`);
|
||||
// const productsSeeder = new ProductsSeeder();
|
||||
// await productsSeeder.run(em, categoriesMap);
|
||||
console.info(`[Seeder] Step 9/${TOTAL_STEPS}: Done`);
|
||||
// console.info(`[Seeder] Step 9/${TOTAL_STEPS}: Done`);
|
||||
|
||||
|
||||
|
||||
@@ -45,21 +45,21 @@ export class DatabaseSeeder extends Seeder {
|
||||
// 12. Create Admins
|
||||
console.info(`[Seeder] Step 12/${TOTAL_STEPS}: Creating admins`);
|
||||
const adminsSeeder = new AdminsSeeder();
|
||||
|
||||
await adminsSeeder.run(em, rolesMap);
|
||||
console.info(`[Seeder] Step 12/${TOTAL_STEPS}: Done`);
|
||||
|
||||
// 13. Create Users
|
||||
console.info(`[Seeder] Step 13/${TOTAL_STEPS}: Creating users`);
|
||||
const usersSeeder = new UsersSeeder();
|
||||
await usersSeeder.run(em);
|
||||
console.info(`[Seeder] Step 13/${TOTAL_STEPS}: Done`);
|
||||
// console.info(`[Seeder] Step 13/${TOTAL_STEPS}: Creating users`);
|
||||
// const usersSeeder = new UsersSeeder();
|
||||
// await usersSeeder.run(em);
|
||||
// console.info(`[Seeder] Step 13/${TOTAL_STEPS}: Done`);
|
||||
|
||||
|
||||
// 15. Create Notifications for admins and users for all restaurants
|
||||
console.info(`[Seeder] Step 15/${TOTAL_STEPS}: (optional) creating notifications`);
|
||||
// console.info(`[Seeder] Step 15/${TOTAL_STEPS}: (optional) creating notifications`);
|
||||
// const notificationsSeeder = new NotificationsSeeder();
|
||||
// await notificationsSeeder.run(em);
|
||||
console.info(`[Seeder] Step 15/${TOTAL_STEPS}: Done`);
|
||||
// console.info(`[Seeder] Step 15/${TOTAL_STEPS}: Done`);
|
||||
|
||||
console.info('[Seeder] Database seed completed');
|
||||
}
|
||||
|
||||
@@ -11,28 +11,28 @@ export const adminsData: AdminData[] = [
|
||||
phone: '09362532122',
|
||||
firstName: 'مرتضی',
|
||||
lastName: 'مرتضایی',
|
||||
roleName: 'مدیر ( پلن ویژه)',
|
||||
roleName: 'admin',
|
||||
restaurantSlug: 'boote',
|
||||
},
|
||||
{
|
||||
phone: '09185290775',
|
||||
firstName: 'حمید',
|
||||
lastName: 'ضرقامی',
|
||||
roleName: 'مدیر ( پلن ویژه)',
|
||||
roleName: 'admin',
|
||||
restaurantSlug: 'boote',
|
||||
},
|
||||
{
|
||||
phone: '09129283395',
|
||||
firstName: 'مهرداد',
|
||||
lastName: 'مظفری',
|
||||
roleName: 'مدیر ( پلن ویژه)',
|
||||
roleName: 'admin',
|
||||
restaurantSlug: 'boote',
|
||||
},
|
||||
{
|
||||
phone: '09184317567',
|
||||
firstName: 'ادمین',
|
||||
lastName: 'هنر',
|
||||
roleName: 'مدیر ( پلن ویژه)',
|
||||
roleName: 'admin',
|
||||
restaurantSlug: 'boote',
|
||||
},
|
||||
];
|
||||
|
||||
@@ -2,36 +2,17 @@ import { Permission } from '../../common/enums/permission.enum';
|
||||
|
||||
export interface RoleConfig {
|
||||
name: string;
|
||||
title: string;
|
||||
isSystem: boolean;
|
||||
permissionFilter: (permissionName: Permission) => boolean;
|
||||
}
|
||||
|
||||
export const rolesData: RoleConfig[] = [
|
||||
{
|
||||
name: 'مدیر (پلن پایه)',
|
||||
isSystem: false,
|
||||
permissionFilter: (name: Permission) =>
|
||||
name === Permission.MANAGE_productS ||
|
||||
name === Permission.MANAGE_CATEGORIES ||
|
||||
name === Permission.MANAGE_SCHEDULES ||
|
||||
name === Permission.MANAGE_PAGER ||
|
||||
name === Permission.MANAGE_CONTACTS ||
|
||||
name === Permission.MANAGE_ROLES ||
|
||||
name: 'admin',
|
||||
title: 'مدیرکل',
|
||||
isSystem: true,
|
||||
permissionFilter: (name: Permission) => true
|
||||
},
|
||||
|
||||
name === Permission.MANAGE_SETTINGS ||
|
||||
name === Permission.MANAGE_ADMINS ||
|
||||
name == Permission.VIEW_REPORTS ||
|
||||
name == Permission.UPDATE_RESTAURANT
|
||||
},
|
||||
{
|
||||
name: 'مدیر ( پلن ویژه)',
|
||||
isSystem: false,
|
||||
permissionFilter: () => true, // All permissions for restaurant role
|
||||
},
|
||||
{
|
||||
name: 'حسابدار ',
|
||||
isSystem: false,
|
||||
permissionFilter: (name: Permission) =>
|
||||
name === Permission.VIEW_REPORTS || name === Permission.MANAGE_PAYMENTS || name === Permission.MANAGE_ORDERS,
|
||||
},
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user