export type Role = 'admin' | 'inhaber' | 'buero';

/** Genau die Rechte, die das Backend in Permission.php fuehrt. */
export const Permission = {
    UsersManage: 'users.manage',
    OffersDelete: 'offers.delete',
    CustomersDelete: 'customers.delete',
    TasksDelete: 'tasks.delete',
    PurchasesCreate: 'purchases.create',
    PurchasesDelete: 'purchases.delete',
    PurchasesComplete: 'purchases.complete',
    InvoicesProcess: 'invoices.process',
} as const;

export type PermissionName = (typeof Permission)[keyof typeof Permission];

export type CurrentUser = {
    id: string;
    username: string;
    /** Anzeigename, z. B. "Svenja". Die Oberflaeche zeigt ausschliesslich diesen. */
    name: string;
    role: Role;
    roleLabel: string;
    permissions: PermissionName[];
    canManageUsers: boolean;
};

export type ManagedUser = {
    id: string;
    username: string;
    displayName: string;
    role: Role;
    roleLabel: string;
    isActive: boolean;
    createdAt: string;
    lastLoginAt: string | null;
    permissions: PermissionName[];
};

export type RoleOption = {
    value: Role;
    label: string;
    permissions: string[];
};
