feat: Implement initial core features including course browsing, authentication, user dashboard, and internationalization.
This commit is contained in:
parent
031ca5c984
commit
797e3db644
19 changed files with 401 additions and 399 deletions
|
|
@ -1,45 +1,4 @@
|
|||
|
||||
// Interface สำหรับข้อมูลผู้ใช้งาน (User)
|
||||
interface User {
|
||||
id: number
|
||||
username: string
|
||||
email: string
|
||||
email_verified_at?: string | null
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
role: {
|
||||
code: string // เช่น 'STUDENT', 'INSTRUCTOR', 'ADMIN'
|
||||
name: { th: string; en: string }
|
||||
}
|
||||
profile?: {
|
||||
prefix: { th: string; en: string }
|
||||
first_name: string
|
||||
last_name: string
|
||||
phone: string | null
|
||||
avatar_url: string | null
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Interface สำหรับข้อมูลตอบกลับตอน Login
|
||||
interface loginResponse {
|
||||
token: string
|
||||
refreshToken: string
|
||||
user: User
|
||||
profile: User['profile']
|
||||
}
|
||||
|
||||
// Interface สำหรับข้อมูลที่ใช้ลงทะเบียน
|
||||
interface RegisterPayload {
|
||||
username: string
|
||||
email: string
|
||||
password: string
|
||||
first_name: string
|
||||
last_name: string
|
||||
prefix: { th: string; en: string }
|
||||
phone: string
|
||||
}
|
||||
import type { User, LoginResponse, RegisterPayload } from '@/types/auth'
|
||||
|
||||
// ==========================================
|
||||
// Composable: useAuth
|
||||
|
|
|
|||
|
|
@ -1,151 +1,14 @@
|
|||
// Interface สำหรับข้อมูลคอร์สเรียน (Public Course Data)
|
||||
export interface Course {
|
||||
id: number
|
||||
title: string | { th: string; en: string } // รองรับ 2 ภาษา
|
||||
slug: string
|
||||
description: string | { th: string; en: string }
|
||||
thumbnail_url: string
|
||||
price: string
|
||||
is_free: boolean
|
||||
original_price?: string
|
||||
have_certificate: boolean
|
||||
status: string // DRAFT, PUBLISHED
|
||||
category_id: number
|
||||
created_at?: string
|
||||
updated_at?: string
|
||||
created_by?: number
|
||||
updated_by?: number
|
||||
approved_at?: string
|
||||
approved_by?: number
|
||||
rejection_reason?: string
|
||||
enrolled?: boolean
|
||||
total_lessons?: number
|
||||
|
||||
|
||||
rating?: string
|
||||
lessons?: number | string
|
||||
levelType?: 'neutral' | 'warning' | 'success' // ใช้สำหรับการแสดงผล Badge ระดับความยาก (Frontend Logic)
|
||||
|
||||
// โครงสร้างบทเรียน (Chapters & Lessons)
|
||||
chapters?: {
|
||||
id: number
|
||||
title: string | { th: string; en: string }
|
||||
lessons: {
|
||||
id: number
|
||||
title: string | { th: string; en: string }
|
||||
duration_minutes: number
|
||||
video_url?: string
|
||||
}[]
|
||||
}[]
|
||||
|
||||
// ข้อมูลผู้สอนและเจ้าของคอร์ส
|
||||
creator?: {
|
||||
id: number
|
||||
username: string
|
||||
email: string
|
||||
profile: {
|
||||
first_name: string
|
||||
last_name: string
|
||||
avatar_url: string
|
||||
}
|
||||
}
|
||||
instructors?: {
|
||||
user_id: number
|
||||
is_primary: boolean
|
||||
user: {
|
||||
id: number
|
||||
username: string
|
||||
email: string
|
||||
profile: {
|
||||
first_name: string
|
||||
last_name: string
|
||||
avatar_url: string
|
||||
}
|
||||
}
|
||||
}[]
|
||||
}
|
||||
|
||||
interface CourseResponse {
|
||||
code: number
|
||||
message: string
|
||||
data: Course[]
|
||||
total: number
|
||||
page?: number
|
||||
limit?: number
|
||||
totalPages?: number
|
||||
}
|
||||
|
||||
interface SingleCourseResponse {
|
||||
code: number
|
||||
message: string
|
||||
data: Course
|
||||
}
|
||||
|
||||
// Interface สำหรับคอร์สที่ผู้ใช้ลงทะเบียนเรียนแล้ว (My Course)
|
||||
export interface EnrolledCourse {
|
||||
id: number
|
||||
course_id: number
|
||||
course: Course
|
||||
status: 'ENROLLED' | 'IN_PROGRESS' | 'COMPLETED' | 'DROPPED'
|
||||
progress_percentage: number
|
||||
enrolled_at: string
|
||||
started_at?: string
|
||||
completed_at?: string
|
||||
last_accessed_at?: string
|
||||
}
|
||||
|
||||
interface EnrolledCourseResponse {
|
||||
code: number
|
||||
message: string
|
||||
data: EnrolledCourse[]
|
||||
total: number
|
||||
page: number
|
||||
limit: number
|
||||
}
|
||||
|
||||
// Interface สำหรับการส่งคำตอบแบบทดสอบ (Quiz Submission)
|
||||
export interface QuizAnswerSubmission {
|
||||
question_id: number
|
||||
choice_id: number
|
||||
}
|
||||
|
||||
export interface QuizSubmitRequest {
|
||||
answers: QuizAnswerSubmission[]
|
||||
}
|
||||
|
||||
// Interface สำหรับผลลัพธ์การสอบ (Quiz Result)
|
||||
export interface QuizResult {
|
||||
answers_review: {
|
||||
score: number
|
||||
is_correct: boolean
|
||||
correct_choice_id: number
|
||||
selected_choice_id: number
|
||||
question_id: number
|
||||
}[]
|
||||
completed_at: string
|
||||
started_at: string
|
||||
attempt_number: number
|
||||
passing_score: number
|
||||
is_passed: boolean
|
||||
correct_answers: number
|
||||
total_questions: number
|
||||
total_score: number
|
||||
score: number
|
||||
quiz_id: number
|
||||
attempt_id: number
|
||||
}
|
||||
|
||||
// Interface สำหรับ Certificate
|
||||
export interface Certificate {
|
||||
certificate_id: number
|
||||
course_id: number
|
||||
course_title: {
|
||||
en: string
|
||||
th: string
|
||||
}
|
||||
issued_at: string
|
||||
download_url: string
|
||||
}
|
||||
import type {
|
||||
Course,
|
||||
CourseResponse,
|
||||
SingleCourseResponse,
|
||||
EnrolledCourse,
|
||||
EnrolledCourseResponse,
|
||||
QuizAnswerSubmission,
|
||||
QuizSubmitRequest,
|
||||
QuizResult,
|
||||
Certificate
|
||||
} from '@/types/course'
|
||||
|
||||
// ==========================================
|
||||
// Composable: useCourse
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue