feat(roles): let each section decide who may assign work to others

Section access now only creates a record for yourself. Assigning it to a colleague requires a separate permission on that section.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-11-03 13:15:21 +03:30
co-authored by Cursor
parent 79733e6c96
commit 534dae45b2
25 changed files with 355 additions and 84 deletions
+34
View File
@@ -723,11 +723,18 @@ export function migrateVisibilityToCustomersAccess(
export type RolePermissionKey =
| "customers"
| "assign_customers"
| "leads"
| "assign_leads"
| "sales"
| "assign_sales"
| "billing"
| "products"
| "activities"
| "assign_activities"
| "assign_routines"
| "assign_projects"
| "assign_tickets"
| "notes"
| "reports"
| "audit"
@@ -737,16 +744,43 @@ export type RolePermissionKey =
| "treasury_payroll"
| "behavior";
/** بخشی که مسئولش را می‌شود به کاربر دیگری داد */
export type AssignSection =
| "customers"
| "leads"
| "sales"
| "activities"
| "routines"
| "projects"
| "tickets";
export const ASSIGN_SECTION_PERMISSION: Record<AssignSection, RolePermissionKey> = {
customers: "assign_customers",
leads: "assign_leads",
sales: "assign_sales",
activities: "assign_activities",
routines: "assign_routines",
projects: "assign_projects",
tickets: "assign_tickets",
};
export const ROLE_PERMISSION_ITEMS: Array<{
key: RolePermissionKey;
label: string;
}> = [
{ key: "customers", label: "مشتریان" },
{ key: "assign_customers", label: "تخصیص مشتری به دیگران" },
{ key: "leads", label: "لیدها" },
{ key: "assign_leads", label: "تخصیص لید به دیگران" },
{ key: "sales", label: "فروش و معاملات" },
{ key: "assign_sales", label: "تخصیص معامله به دیگران" },
{ key: "billing", label: "پیش‌فاکتورها و فاکتورها" },
{ key: "products", label: "محصولات و خدمات" },
{ key: "activities", label: "فعالیت‌ها" },
{ key: "assign_activities", label: "تخصیص فعالیت به دیگران" },
{ key: "assign_routines", label: "تخصیص کار روتین به دیگران" },
{ key: "assign_projects", label: "تخصیص کارت پروژه به دیگران" },
{ key: "assign_tickets", label: "تخصیص تیکت به دیگران" },
{ key: "notes", label: "یادداشت‌ها" },
{ key: "reports", label: "گزارش‌ها" },
{ key: "audit", label: "لاگ فعالیت کاربران" },