import { Course, CourseApproval, User } from '@prisma/client';
import { MultiLanguageText } from './index';

// ============================================
// Admin Course Approval Types
// ============================================

export interface PendingCourseData {
    id: number;
    title: MultiLanguageText;
    slug: string;
    description: MultiLanguageText;
    thumbnail_url: string | null;
    status: string;
    created_at: Date;
    updated_at: Date | null;
    created_by: number;
    creator: {
        id: number;
        username: string;
        email: string;
    };
    instructors: {
        user_id: number;
        is_primary: boolean;
        user: {
            id: number;
            username: string;
            email: string;
        };
    }[];
    chapters_count: number;
    lessons_count: number;
    latest_submission: {
        id: number;
        submitted_by: number;
        created_at: Date;
        submitter: {
            id: number;
            username: string;
            email: string;
        };
    } | null;
}

export interface ListPendingCoursesResponse {
    code: number;
    message: string;
    data: PendingCourseData[];
    total: number;
}

export interface CourseDetailForAdmin {
    id: number;
    title: MultiLanguageText;
    slug: string;
    description: MultiLanguageText;
    thumbnail_url: string | null;
    price: number;
    is_free: boolean;
    have_certificate: boolean;
    status: string;
    created_at: Date;
    updated_at: Date | null;
    category: {
        id: number;
        name: MultiLanguageText;
    } | null;
    creator: {
        id: number;
        username: string;
        email: string;
    };
    instructors: {
        user_id: number;
        is_primary: boolean;
        user: {
            id: number;
            username: string;
            email: string;
        };
    }[];
    chapters: {
        id: number;
        title: MultiLanguageText;
        sort_order: number;
        is_published: boolean;
        lessons: {
            id: number;
            title: MultiLanguageText;
            type: string;
            sort_order: number;
            is_published: boolean;
        }[];
    }[];
    approval_history: {
        id: number;
        action: string;
        comment: string | null;
        created_at: Date;
        submitter: {
            id: number;
            username: string;
            email: string;
        };
        reviewer: {
            id: number;
            username: string;
            email: string;
        } | null;
    }[];
}

export interface GetCourseDetailForAdminResponse {
    code: number;
    message: string;
    data: CourseDetailForAdmin;
}

export interface ApproveCourseBody {
    comment?: string;
}

export interface ApproveCourseResponse {
    code: number;
    message: string;
}

export interface RejectCourseBody {
    comment: string;
}

export interface RejectCourseResponse {
    code: number;
    message: string;
}
