feat: Implement initial landing pages, authentication flows, and course browsing functionality with i18n.

This commit is contained in:
supalerk-ar66 2026-02-02 11:11:25 +07:00
parent 7de5457170
commit b60a3853cd
12 changed files with 822 additions and 606 deletions

View file

@ -8,7 +8,7 @@ useHead({
title: 'ตั้งค่าบัญชี - e-Learning'
})
const { currentUser, updateUserProfile, changePassword, uploadAvatar } = useAuth()
const { currentUser, updateUserProfile, changePassword, uploadAvatar, sendVerifyEmail } = useAuth()
const { t } = useI18n()
// const { errors, validate, clearFieldError } = useFormValidation() // Unused
@ -16,6 +16,7 @@ const { t } = useI18n()
const isEditing = ref(false)
const isProfileSaving = ref(false)
const isPasswordSaving = ref(false)
const isSendingVerify = ref(false)
const isHydrated = ref(false)
const formatDate = (dateString?: string) => {
@ -48,6 +49,7 @@ const passwordForm = reactive({
confirmPassword: ''
})
const nameRules = [(val: string) => !!val || t('common.required')]
const emailRules = [
(val: string) => !!val || t('common.required'),
@ -139,6 +141,22 @@ const handleUpdateProfile = async () => {
isProfileSaving.value = false
}
const handleSendVerifyEmail = async () => {
isSendingVerify.value = true
const result = await sendVerifyEmail()
isSendingVerify.value = false
if (result.success) {
alert(result.message || t('profile.verifyEmailSuccess') || 'ส่งอีเมลยืนยันสำเร็จ')
} else {
if (result.code === 400) {
alert(t('profile.emailAlreadyVerified') || 'อีเมลของคุณได้รับการยืนยันแล้ว')
} else {
alert(result.error || t('profile.verifyEmailError') || 'ส่งอีเมลไม่สำเร็จ')
}
}
}
const handleUpdatePassword = async () => {
if (passwordForm.newPassword !== passwordForm.confirmPassword) {
alert('รหัสผ่านใหม่ไม่ตรงกัน')
@ -360,7 +378,19 @@ onMounted(() => {
</div>
<div>
<label class="text-xs font-bold text-slate-500 dark:text-slate-400 ml-1 uppercase">{{ $t('profile.email') }}</label>
<div class="flex justify-between items-end mb-1">
<label class="text-xs font-bold text-slate-500 dark:text-slate-400 ml-1 uppercase">{{ $t('profile.email') }}</label>
<q-btn
flat dense
color="primary"
size="sm"
no-caps
icon="mark_email_read"
:label="$t('profile.verifyEmail') || 'ยืนยันอีเมล'"
@click="handleSendVerifyEmail"
:loading="isSendingVerify"
/>
</div>
<q-input
v-model="userData.email"
type="email"