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
41
Frontend-Learner/types/auth.ts
Normal file
41
Frontend-Learner/types/auth.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
/**
|
||||
* @file auth.ts
|
||||
* @description Type definitions for authentication and user profiles.
|
||||
*/
|
||||
|
||||
export 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
|
||||
}
|
||||
}
|
||||
|
||||
export interface LoginResponse {
|
||||
token: string
|
||||
refreshToken: string
|
||||
user: User
|
||||
profile: User['profile']
|
||||
}
|
||||
|
||||
export interface RegisterPayload {
|
||||
username: string
|
||||
email: string
|
||||
password: string
|
||||
first_name: string
|
||||
last_name: string
|
||||
prefix: { th: string; en: string }
|
||||
phone: string
|
||||
}
|
||||
142
Frontend-Learner/types/course.ts
Normal file
142
Frontend-Learner/types/course.ts
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
/**
|
||||
* @file course.ts
|
||||
* @description Type definitions for courses, enrollments, quizzes, and certificates.
|
||||
*/
|
||||
|
||||
export interface Course {
|
||||
id: number
|
||||
title: string | { th: string; en: string }
|
||||
slug: string
|
||||
description: string | { th: string; en: string }
|
||||
thumbnail_url: string
|
||||
price: string
|
||||
is_free: boolean
|
||||
original_price?: string
|
||||
have_certificate: boolean
|
||||
status: string
|
||||
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'
|
||||
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
|
||||
}
|
||||
}
|
||||
}[]
|
||||
}
|
||||
|
||||
export interface CourseResponse {
|
||||
code: number
|
||||
message: string
|
||||
data: Course[]
|
||||
total: number
|
||||
page?: number
|
||||
limit?: number
|
||||
totalPages?: number
|
||||
}
|
||||
|
||||
export interface SingleCourseResponse {
|
||||
code: number
|
||||
message: string
|
||||
data: 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
|
||||
}
|
||||
|
||||
export interface EnrolledCourseResponse {
|
||||
code: number
|
||||
message: string
|
||||
data: EnrolledCourse[]
|
||||
total: number
|
||||
page: number
|
||||
limit: number
|
||||
}
|
||||
|
||||
export interface QuizAnswerSubmission {
|
||||
question_id: number
|
||||
choice_id: number
|
||||
}
|
||||
|
||||
export interface QuizSubmitRequest {
|
||||
answers: QuizAnswerSubmission[]
|
||||
}
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
export interface Certificate {
|
||||
certificate_id: number
|
||||
course_id: number
|
||||
course_title: {
|
||||
en: string
|
||||
th: string
|
||||
}
|
||||
issued_at: string
|
||||
download_url: string
|
||||
}
|
||||
2
Frontend-Learner/types/index.ts
Normal file
2
Frontend-Learner/types/index.ts
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
export * from './auth'
|
||||
export * from './course'
|
||||
Loading…
Add table
Add a link
Reference in a new issue