import { Module } from "."; import { InstructorGender, ShuffleMap } from "./exam"; import { PermissionType } from "./permissions"; export type User = StudentUser | TeacherUser | CorporateUser | AgentUser | AdminUser | DeveloperUser | MasterCorporateUser; export type UserStatus = "active" | "disabled" | "paymentDue"; export interface BasicUser { email: string; name: string; profilePicture: string; id: string; isFirstLogin: boolean; focus: "academic" | "general"; levels: { [key in Module]: number }; desiredLevels: { [key in Module]: number }; type: Type; bio: string; isVerified: boolean; subscriptionExpirationDate?: null | Date; registrationDate?: Date; status: UserStatus; permissions: PermissionType[]; lastLogin?: Date; entities: { id: string; role: string }[]; } export interface StudentUser extends BasicUser { type: "student"; studentID?: string; preferredGender?: InstructorGender; demographicInformation?: DemographicInformation; preferredTopics?: string[]; } export interface TeacherUser extends BasicUser { type: "teacher"; demographicInformation?: DemographicInformation; } export interface CorporateUser extends BasicUser { type: "corporate"; corporateInformation: CorporateInformation; demographicInformation?: DemographicCorporateInformation; } export interface MasterCorporateUser extends BasicUser { type: "mastercorporate"; corporateInformation: CorporateInformation; demographicInformation?: DemographicCorporateInformation; } export interface AgentUser extends BasicUser { type: "agent"; agentInformation: AgentInformation; demographicInformation?: DemographicInformation; } export interface AdminUser extends BasicUser { type: "admin"; demographicInformation?: DemographicInformation; } export interface DeveloperUser extends BasicUser { type: "developer"; preferredGender?: InstructorGender; demographicInformation?: DemographicInformation; preferredTopics?: string[]; } export interface CorporateInformation { companyInformation: CompanyInformation; monthlyDuration: number; payment?: { value: number; currency: string; commission: number; }; referralAgent?: string; } export interface AgentInformation { companyName: string; commercialRegistration: string; companyArabName?: string; } export interface CompanyInformation { name: string; userAmount: number; } export interface DemographicInformation { country: string; phone: string; gender: Gender; employment: EmploymentStatus; passport_id?: string; timezone?: string; } export interface DemographicCorporateInformation { country: string; phone: string; gender: Gender; position: string; timezone?: string; } export type Gender = "male" | "female" | "other"; export type EmploymentStatus = "employed" | "student" | "self-employed" | "unemployed" | "retired" | "other"; export const EMPLOYMENT_STATUS: { status: EmploymentStatus; label: string }[] = [ { status: "student", label: "Student" }, { status: "employed", label: "Employed" }, { status: "unemployed", label: "Unemployed" }, { status: "self-employed", label: "Self-employed" }, { status: "retired", label: "Retired" }, { status: "other", label: "Other" }, ]; export interface Stat { id: string; user: string; exam: string; exercise: string; session: string; date: number; module: Module; solutions: any[]; type: string; timeSpent?: number; inactivity?: number; assignment?: string; score: { correct: number; total: number; missing: number; }; isDisabled?: boolean; shuffleMaps?: ShuffleMap[]; pdf?: { path: string; version: string; }; isPractice?: boolean } export interface Group { admin: string; name: string; participants: string[]; id: string; disableEditing?: boolean; entity?: string; } export interface GroupWithUsers extends Omit { admin: User; participants: User[]; } export interface Code { id: string; code: string; creator: string; expiryDate: Date; type: Type; creationDate?: string; userId?: string; email?: string; name?: string; passport_id?: string; } export type Type = "student" | "teacher" | "corporate" | "admin" | "developer" | "agent" | "mastercorporate"; export const userTypes: Type[] = ["student", "teacher", "corporate", "admin", "developer", "agent", "mastercorporate"]; export type WithUser = T extends { participants: string[] } ? Omit & { participants: User[] } : T;