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