feat: Add useCourse composable for course data management and a new discovery page.

This commit is contained in:
supalerk-ar66 2026-01-21 13:30:32 +07:00
parent 327f6ec7b5
commit 8f38f795e6
2 changed files with 13 additions and 6 deletions

View file

@ -138,6 +138,19 @@ export const useCourse = () => {
}
} catch (err: any) {
console.error('Enroll course failed:', err)
// Check for 409 Conflict (Already Enrolled)
// ofetch/h3 error properties might vary, check common ones
const status = err.statusCode || err.status || err.response?.status
if (status === 409) {
return {
success: false,
error: 'ท่านได้ลงทะเบียนไปแล้ว',
code: 409
}
}
return {
success: false,
error: err.data?.message || err.message || 'Error enrolling in course',