feat: del mock , crud add instructor , VerifyEmail

This commit is contained in:
Missez 2026-02-03 11:55:26 +07:00
parent b2365a4c6a
commit 278bc17fa0
8 changed files with 345 additions and 1566 deletions

View file

@ -50,7 +50,11 @@
<div>
<div class="text-sm text-gray-600 mb-1">เมล</div>
<div class="text-lg text-gray-900">{{ profile.email }}</div>
<div class="text-lg text-gray-900 flex items-center gap-2">
{{ profile.email }}
<q-badge v-if="profile.emailVerified" color="positive" label="ยืนยันแล้ว" />
<q-badge v-else color="warning" label="ยังไม่ยืนยัน" />
</div>
</div>
<div>
@ -75,7 +79,7 @@
</div>
<!-- Action Buttons -->
<div class="flex gap-3 mt-6">
<div class="flex flex-wrap gap-3 mt-6">
<q-btn
color="primary"
label="แก้ไขโปรไฟล์"
@ -89,6 +93,15 @@
icon="lock"
@click="showPasswordModal = true"
/>
<q-btn
v-if="!profile.emailVerified"
outline
color="orange"
label="ขอยืนยันอีเมล"
icon="mark_email_unread"
:loading="sendingVerification"
@click="handleSendVerificationEmail"
/>
</div>
</div>
</div>
@ -289,6 +302,7 @@
<script setup lang="ts">
import { useQuasar } from 'quasar';
import { userService, type UserProfileResponse } from '~/services/user.service';
import { authService } from '~/services/auth.service';
definePageMeta({
layout: 'instructor',
@ -305,11 +319,12 @@ const loading = ref(true);
const profile = ref({
fullName: '',
email: '',
emailVerified: false,
username: '',
phone: '',
role: '',
roleName: '',
avatar: '👨‍🏫',
avatar: '',
avatarUrl: '' as string | null,
createdAt: ''
});
@ -340,6 +355,9 @@ const passwordForm = ref({
confirmPassword: ''
});
// Email verification
const sendingVerification = ref(false);
// Methods
const getRoleLabel = (role: string) => {
const labels: Record<string, string> = {
@ -495,6 +513,26 @@ const handleChangePassword = async () => {
}
};
const handleSendVerificationEmail = async () => {
sendingVerification.value = true;
try {
const response = await authService.sendVerifyEmail();
$q.notify({
type: 'positive',
message: response.message || 'ส่งอีเมลยืนยันไปยังอีเมลของคุณแล้ว',
position: 'top'
});
} catch (error: any) {
$q.notify({
type: 'negative',
message: error.data?.message || 'เกิดข้อผิดพลาดในการส่งอีเมลยืนยัน',
position: 'top'
});
} finally {
sendingVerification.value = false;
}
};
// Watch edit modal
watch(showEditModal, (newVal) => {
if (newVal) {
@ -518,11 +556,12 @@ const fetchProfile = async () => {
profile.value = {
fullName: `${data.profile.first_name} ${data.profile.last_name}`,
email: data.email,
emailVerified: !!data.email_verified_at,
username: data.username,
phone: data.profile.phone || '',
role: data.role.code,
roleName: data.role.name.th,
avatar: '👨‍🏫',
avatar: '',
avatarUrl: data.profile.avatar_url,
createdAt: data.created_at
};