feat: add new pages for authentication (register, forgot password) and course browsing (discovery, course detail)
This commit is contained in:
parent
acff387a9b
commit
d4f84667dc
4 changed files with 39 additions and 8 deletions
|
|
@ -47,6 +47,7 @@ const handleInput = (val: string | number | null) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const { requestPasswordReset } = useAuth()
|
const { requestPasswordReset } = useAuth()
|
||||||
|
const $q = useQuasar()
|
||||||
|
|
||||||
const sendResetLink = async () => {
|
const sendResetLink = async () => {
|
||||||
if (!validate(forgotForm, forgotRules)) return
|
if (!validate(forgotForm, forgotRules)) return
|
||||||
|
|
@ -60,8 +61,13 @@ const sendResetLink = async () => {
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
forgotStep.value = 'success'
|
forgotStep.value = 'success'
|
||||||
} else {
|
} else {
|
||||||
// Basic alert for now, could be improved with q-notify later
|
$q.notify({
|
||||||
alert(result.error || 'ไม่สามารถส่งลิงก์รีเซ็ตได้ กรุณาลองใหม่')
|
type: 'negative',
|
||||||
|
message: result.error || 'ไม่สามารถส่งลิงก์รีเซ็ตได้ กรุณาลองใหม่',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 3000,
|
||||||
|
actions: [{ icon: 'close', color: 'white' }]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ useHead({
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { register } = useAuth();
|
const { register } = useAuth();
|
||||||
|
const $q = useQuasar();
|
||||||
const { errors, validate, clearFieldError } = useFormValidation();
|
const { errors, validate, clearFieldError } = useFormValidation();
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
|
@ -181,10 +182,21 @@ const handleRegister = async () => {
|
||||||
isLoading.value = false;
|
isLoading.value = false;
|
||||||
|
|
||||||
if (result.success) {
|
if (result.success) {
|
||||||
alert('สมัครสมาชิกสำเร็จ! กรุณาเข้าสู่ระบบ');
|
$q.notify({
|
||||||
|
type: 'positive',
|
||||||
|
message: 'สมัครสมาชิกสำเร็จ! กรุณาเข้าสู่ระบบ',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 4000
|
||||||
|
});
|
||||||
router.push("/auth/login");
|
router.push("/auth/login");
|
||||||
} else {
|
} else {
|
||||||
alert(result.error || 'การลงทะเบียนล้มเหลว');
|
$q.notify({
|
||||||
|
type: 'negative',
|
||||||
|
message: result.error || 'การลงทะเบียนล้มเหลว',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 3000,
|
||||||
|
actions: [{ icon: 'close', color: 'white' }]
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ const itemsPerPage = 12;
|
||||||
|
|
||||||
const { t, locale } = useI18n();
|
const { t, locale } = useI18n();
|
||||||
const { currentUser } = useAuth();
|
const { currentUser } = useAuth();
|
||||||
|
const $q = useQuasar();
|
||||||
const { fetchCategories } = useCategory();
|
const { fetchCategories } = useCategory();
|
||||||
const { fetchCourses, fetchCourseById, enrollCourse, getLocalizedText } = useCourse();
|
const { fetchCourses, fetchCourseById, enrollCourse, getLocalizedText } = useCourse();
|
||||||
|
|
||||||
|
|
@ -109,7 +110,13 @@ const handleEnroll = async (id: number) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
return navigateTo('/dashboard/my-courses?enrolled=true');
|
return navigateTo('/dashboard/my-courses?enrolled=true');
|
||||||
} else {
|
} else {
|
||||||
alert(res.error || 'Failed to enroll');
|
$q.notify({
|
||||||
|
type: 'negative',
|
||||||
|
message: res.error || 'Failed to enroll',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 3000,
|
||||||
|
actions: [{ icon: 'close', color: 'white' }]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
isEnrolling.value = false;
|
isEnrolling.value = false;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,7 @@ const route = useRoute()
|
||||||
// ดึง courseId จาก URL params (แปลงเป็น integer)
|
// ดึง courseId จาก URL params (แปลงเป็น integer)
|
||||||
const courseId = computed(() => parseInt(route.params.id as string))
|
const courseId = computed(() => parseInt(route.params.id as string))
|
||||||
const { currentUser } = useAuth()
|
const { currentUser } = useAuth()
|
||||||
|
const $q = useQuasar()
|
||||||
const { fetchCourseById, enrollCourse, getLocalizedText } = useCourse()
|
const { fetchCourseById, enrollCourse, getLocalizedText } = useCourse()
|
||||||
|
|
||||||
// ใช้ useAsyncData ดึงข้อมูลคอร์ส Server-side rendering (SSR)
|
// ใช้ useAsyncData ดึงข้อมูลคอร์ส Server-side rendering (SSR)
|
||||||
|
|
@ -46,9 +47,14 @@ const handleEnroll = async () => {
|
||||||
course_id: String(targetId)
|
course_id: String(targetId)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
// กรณี error แสดง Toast notification แทน alert
|
||||||
// กรณี error แสดง alert (อนาคตอาจเปลี่ยนเป็น Toast notification)
|
$q.notify({
|
||||||
alert(res.error || 'Failed to enroll')
|
type: 'negative',
|
||||||
|
message: res.error || 'Failed to enroll',
|
||||||
|
position: 'top',
|
||||||
|
timeout: 3000,
|
||||||
|
actions: [{ icon: 'close', color: 'white' }]
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
isEnrolling.value = false
|
isEnrolling.value = false
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue