/**
 * File: auth.ts
 * Created by: AI Assistant
 * Date: 2025-11-29
 * Purpose: Authentication type definitions for kreatiVortex platform
 * Part of: kreatiVortex - Platform Pembelajaran Tari Online
 */

export interface AuthUser {
  id: string;
  name: string;
  email: string;
  role: 'ADMINISTRATOR' | 'PENDIDIK' | 'CALON_PENDIDIK' | 'UMUM';
  image?: string;
  profile?: {
    nim?: string;
    phone?: string;
    bio?: string;
    avatar?: string;
  };
}

export interface LoginCredentials {
  email: string;
  password: string;
}

export interface RegisterData {
  name: string;
  email: string;
  password: string;
  confirmPassword: string;
  role?: 'CALON_PENDIDIK' | 'UMUM';
}

export interface RoleUpgradeData {
  role: 'PENDIDIK' | 'CALON_PENDIDIK';
  additionalInfo?: {
    institution?: string;
    experience?: string;
    specialization?: string;
    nim?: string;
  };
}

export interface AuthResponse {
  user: AuthUser;
  token?: string;
  message: string;
  success: boolean;
}

export interface Permission {
  canViewUsers: boolean;
  canCreateUsers: boolean;
  canUpdateUsers: boolean;
  canDeleteUsers: boolean;
  canManageClasses: boolean;
  canManageVideos: boolean;
  canManageForums: boolean;
  canManageAssignments: boolean;
  canViewReports: boolean;
}

export const ROLE_PERMISSIONS: Record<string, Permission> = {
  ADMINISTRATOR: {
    canViewUsers: true,
    canCreateUsers: true,
    canUpdateUsers: true,
    canDeleteUsers: true,
    canManageClasses: true,
    canManageVideos: true,
    canManageForums: true,
    canManageAssignments: true,
    canViewReports: true,
  },
  PENDIDIK: {
    canViewUsers: false,
    canCreateUsers: false,
    canUpdateUsers: false,
    canDeleteUsers: false,
    canManageClasses: true,
    canManageVideos: true,
    canManageForums: true,
    canManageAssignments: true,
    canViewReports: false,
  },
  CALON_PENDIDIK: {
    canViewUsers: false,
    canCreateUsers: false,
    canUpdateUsers: false,
    canDeleteUsers: false,
    canManageClasses: false,
    canManageVideos: false,
    canManageForums: true,
    canManageAssignments: false,
    canViewReports: false,
  },
  UMUM: {
    canViewUsers: false,
    canCreateUsers: false,
    canUpdateUsers: false,
    canDeleteUsers: false,
    canManageClasses: false,
    canManageVideos: false,
    canManageForums: true,
    canManageAssignments: false,
    canViewReports: false,
  },
};