feat: Add user profile page for managing personal information, passwords, email verification, and viewing certificates, with internationalization support.
This commit is contained in:
parent
a7aee70263
commit
15794fab16
3 changed files with 21 additions and 11 deletions
|
|
@ -36,12 +36,13 @@
|
||||||
"certificate": "Certificate",
|
"certificate": "Certificate",
|
||||||
"available": "Available",
|
"available": "Available",
|
||||||
"continueLearning": "Continue Learning",
|
"continueLearning": "Continue Learning",
|
||||||
|
"startLearning": "Start Learning",
|
||||||
"studyAgain": "Study Again",
|
"studyAgain": "Study Again",
|
||||||
"downloadCertificate": "Download Certificate",
|
"downloadCertificate": "Download Certificate",
|
||||||
"completed": "Completed"
|
"completed": "Completed"
|
||||||
},
|
},
|
||||||
"sidebar": {
|
"sidebar": {
|
||||||
"overview": "Overview",
|
"overview": "Home",
|
||||||
"myCourses": "My Courses",
|
"myCourses": "My Courses",
|
||||||
"browseCourses": "Browse Courses",
|
"browseCourses": "Browse Courses",
|
||||||
"announcements": "Announcements",
|
"announcements": "Announcements",
|
||||||
|
|
@ -117,7 +118,10 @@
|
||||||
"verifyEmailSuccess": "Verification email sent successfully",
|
"verifyEmailSuccess": "Verification email sent successfully",
|
||||||
"verifyEmailError": "Failed to send verification email",
|
"verifyEmailError": "Failed to send verification email",
|
||||||
"emailAlreadyVerified": "Your email is already verified",
|
"emailAlreadyVerified": "Your email is already verified",
|
||||||
"emailVerified": "Email Verified"
|
"emailVerified": "Email Verified",
|
||||||
|
"myCertificates": "My Certificates",
|
||||||
|
"viewCertificate": "View Certificate",
|
||||||
|
"issuedAt": "Issued at"
|
||||||
},
|
},
|
||||||
"userMenu": {
|
"userMenu": {
|
||||||
"home": "Home",
|
"home": "Home",
|
||||||
|
|
@ -139,7 +143,8 @@
|
||||||
"emailVerified": "Email Verified Successfully!",
|
"emailVerified": "Email Verified Successfully!",
|
||||||
"emailVerifiedDesc": "Your account has been successfully verified.",
|
"emailVerifiedDesc": "Your account has been successfully verified.",
|
||||||
"invalidToken": "Invalid verification token",
|
"invalidToken": "Invalid verification token",
|
||||||
"tokenExpired": "Token expired or invalid"
|
"tokenExpired": "Token expired or invalid",
|
||||||
|
"logout": "Log Out"
|
||||||
},
|
},
|
||||||
"language": {
|
"language": {
|
||||||
"label": "Language / ภาษา",
|
"label": "Language / ภาษา",
|
||||||
|
|
@ -150,6 +155,7 @@
|
||||||
"newBadge": "New",
|
"newBadge": "New",
|
||||||
"popularBadge": "Popular",
|
"popularBadge": "Popular",
|
||||||
"save": "Save",
|
"save": "Save",
|
||||||
|
"close": "Close",
|
||||||
"cancel": "Cancel",
|
"cancel": "Cancel",
|
||||||
"required": "This field is required",
|
"required": "This field is required",
|
||||||
"invalidEmail": "Invalid email address",
|
"invalidEmail": "Invalid email address",
|
||||||
|
|
|
||||||
|
|
@ -118,7 +118,10 @@
|
||||||
"verifyEmailSuccess": "ส่งอีเมลยืนยันสำเร็จ",
|
"verifyEmailSuccess": "ส่งอีเมลยืนยันสำเร็จ",
|
||||||
"verifyEmailError": "ส่งอีเมลไม่สำเร็จ",
|
"verifyEmailError": "ส่งอีเมลไม่สำเร็จ",
|
||||||
"emailAlreadyVerified": "อีเมลของคุณได้รับการยืนยันแล้ว",
|
"emailAlreadyVerified": "อีเมลของคุณได้รับการยืนยันแล้ว",
|
||||||
"emailVerified": "ยืนยันอีเมลเสร็จสิ้น"
|
"emailVerified": "ยืนยันอีเมลเสร็จสิ้น",
|
||||||
|
"myCertificates": "ประกาศนียบัตรของฉัน",
|
||||||
|
"viewCertificate": "ดูประกาศนียบัตร",
|
||||||
|
"issuedAt": "ออกเมื่อ"
|
||||||
},
|
},
|
||||||
"userMenu": {
|
"userMenu": {
|
||||||
"home": "หน้าหลัก",
|
"home": "หน้าหลัก",
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ useHead({
|
||||||
|
|
||||||
const { currentUser, updateUserProfile, changePassword, uploadAvatar, sendVerifyEmail, fetchUserProfile } = useAuth()
|
const { currentUser, updateUserProfile, changePassword, uploadAvatar, sendVerifyEmail, fetchUserProfile } = useAuth()
|
||||||
const { fetchAllCertificates, getLocalizedText } = useCourse()
|
const { fetchAllCertificates, getLocalizedText } = useCourse()
|
||||||
const { t } = useI18n()
|
const { locale, t } = useI18n()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -28,7 +28,7 @@ const formatDate = (dateString?: string) => {
|
||||||
if (!dateString) return '-'
|
if (!dateString) return '-'
|
||||||
try {
|
try {
|
||||||
const date = new Date(dateString)
|
const date = new Date(dateString)
|
||||||
return new Intl.DateTimeFormat('th-TH', {
|
return new Intl.DateTimeFormat(locale.value === 'th' ? 'th-TH' : 'en-US', {
|
||||||
day: 'numeric',
|
day: 'numeric',
|
||||||
month: 'short',
|
month: 'short',
|
||||||
year: 'numeric'
|
year: 'numeric'
|
||||||
|
|
@ -43,7 +43,7 @@ const userData = ref({
|
||||||
lastName: currentUser.value?.lastName || '',
|
lastName: currentUser.value?.lastName || '',
|
||||||
email: currentUser.value?.email || '',
|
email: currentUser.value?.email || '',
|
||||||
phone: currentUser.value?.phone || '',
|
phone: currentUser.value?.phone || '',
|
||||||
createdAt: formatDate(currentUser.value?.createdAt),
|
createdAt: currentUser.value?.createdAt || '',
|
||||||
photoURL: currentUser.value?.photoURL || '',
|
photoURL: currentUser.value?.photoURL || '',
|
||||||
prefix: currentUser.value?.prefix?.th || '',
|
prefix: currentUser.value?.prefix?.th || '',
|
||||||
emailVerifiedAt: currentUser.value?.emailVerifiedAt
|
emailVerifiedAt: currentUser.value?.emailVerifiedAt
|
||||||
|
|
@ -190,6 +190,7 @@ watch(() => currentUser.value, (newUser) => {
|
||||||
userData.value.prefix = newUser.prefix?.th || ''
|
userData.value.prefix = newUser.prefix?.th || ''
|
||||||
userData.value.email = newUser.email
|
userData.value.email = newUser.email
|
||||||
userData.value.phone = newUser.phone || ''
|
userData.value.phone = newUser.phone || ''
|
||||||
|
userData.value.createdAt = newUser.createdAt || ''
|
||||||
userData.value.emailVerifiedAt = newUser.emailVerifiedAt
|
userData.value.emailVerifiedAt = newUser.emailVerifiedAt
|
||||||
}
|
}
|
||||||
}, { deep: true })
|
}, { deep: true })
|
||||||
|
|
@ -285,7 +286,7 @@ onMounted(async () => {
|
||||||
</div>
|
</div>
|
||||||
<div class="info-group">
|
<div class="info-group">
|
||||||
<span class="label">{{ $t('profile.joinedAt') }}</span>
|
<span class="label">{{ $t('profile.joinedAt') }}</span>
|
||||||
<p class="value">{{ userData.createdAt }}</p>
|
<p class="value">{{ formatDate(userData.createdAt) }}</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -295,7 +296,7 @@ onMounted(async () => {
|
||||||
<div v-if="!isEditing && certificates.length > 0" class="mt-12 fade-in" style="animation-delay: 0.1s;">
|
<div v-if="!isEditing && certificates.length > 0" class="mt-12 fade-in" style="animation-delay: 0.1s;">
|
||||||
<h2 class="text-2xl font-black mb-6 text-slate-900 dark:text-white flex items-center gap-3">
|
<h2 class="text-2xl font-black mb-6 text-slate-900 dark:text-white flex items-center gap-3">
|
||||||
<q-icon name="workspace_premium" color="warning" size="32px" />
|
<q-icon name="workspace_premium" color="warning" size="32px" />
|
||||||
ประกาศนียบัตรของฉัน
|
{{ $t('profile.myCertificates') }}
|
||||||
</h2>
|
</h2>
|
||||||
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||||
<div v-for="cert in certificates" :key="cert.certificate_id" class="card-premium p-6 hover:border-warning/50 transition-all group">
|
<div v-for="cert in certificates" :key="cert.certificate_id" class="card-premium p-6 hover:border-warning/50 transition-all group">
|
||||||
|
|
@ -306,14 +307,14 @@ onMounted(async () => {
|
||||||
<q-btn flat round color="primary" icon="download" @click="viewCertificate(cert.download_url)" class="opacity-0 group-hover:opacity-100 transition-opacity" />
|
<q-btn flat round color="primary" icon="download" @click="viewCertificate(cert.download_url)" class="opacity-0 group-hover:opacity-100 transition-opacity" />
|
||||||
</div>
|
</div>
|
||||||
<h3 class="font-bold text-slate-900 dark:text-white mb-1 line-clamp-1">{{ getLocalizedText(cert.course_title) }}</h3>
|
<h3 class="font-bold text-slate-900 dark:text-white mb-1 line-clamp-1">{{ getLocalizedText(cert.course_title) }}</h3>
|
||||||
<p class="text-xs text-slate-500 dark:text-slate-400 mb-4 italic">ออกเมื่อ: {{ formatDate(cert.issued_at) }}</p>
|
<p class="text-xs text-slate-500 dark:text-slate-400 mb-4 italic">{{ $t('profile.issuedAt') }}: {{ formatDate(cert.issued_at) }}</p>
|
||||||
<q-btn
|
<q-btn
|
||||||
unelevated
|
unelevated
|
||||||
rounded
|
rounded
|
||||||
color="warning"
|
color="warning"
|
||||||
text-color="dark"
|
text-color="dark"
|
||||||
class="w-full font-bold"
|
class="w-full font-bold"
|
||||||
label="ดูประกาศนียบัตร"
|
:label="$t('profile.viewCertificate')"
|
||||||
@click="viewCertificate(cert.download_url)"
|
@click="viewCertificate(cert.download_url)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue