edit: response.message
This commit is contained in:
parent
d7f824f353
commit
7de5457170
21 changed files with 227 additions and 127 deletions
|
|
@ -350,12 +350,19 @@ const getRoleLabel = (role: string) => {
|
|||
return labels[role] || role;
|
||||
};
|
||||
|
||||
const formatDate = (date: string) => {
|
||||
return new Date(date).toLocaleDateString('th-TH', {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: 'numeric'
|
||||
});
|
||||
const formatDate = (date: string, includeTime = true) => {
|
||||
const options: Intl.DateTimeFormatOptions = {
|
||||
day: 'numeric',
|
||||
month: 'short',
|
||||
year: '2-digit'
|
||||
};
|
||||
|
||||
if (includeTime) {
|
||||
options.hour = '2-digit';
|
||||
options.minute = '2-digit';
|
||||
}
|
||||
|
||||
return new Date(date).toLocaleDateString('th-TH', options);
|
||||
};
|
||||
|
||||
// Avatar upload
|
||||
|
|
@ -398,21 +405,21 @@ const handleAvatarUpload = async (event: Event) => {
|
|||
|
||||
uploadingAvatar.value = true;
|
||||
try {
|
||||
await userService.uploadAvatar(file);
|
||||
const response = await userService.uploadAvatar(file);
|
||||
|
||||
// Re-fetch profile to get presigned URL from backend
|
||||
await fetchProfile();
|
||||
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: 'อัพโหลดรูปโปรไฟล์สำเร็จ',
|
||||
message: response.message || 'อัพโหลดรูปโปรไฟล์สำเร็จ',
|
||||
position: 'top'
|
||||
});
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
console.error('Failed to upload avatar:', error);
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'เกิดข้อผิดพลาดในการอัพโหลดรูป',
|
||||
message: error.data?.message || 'เกิดข้อผิดพลาดในการอัพโหลดรูป',
|
||||
position: 'top'
|
||||
});
|
||||
} finally {
|
||||
|
|
@ -426,7 +433,7 @@ const handleUpdateProfile = async () => {
|
|||
|
||||
try {
|
||||
// Call real API to update profile
|
||||
await userService.updateProfile({
|
||||
const response = await userService.updateProfile({
|
||||
first_name: editForm.value.firstName,
|
||||
last_name: editForm.value.lastName,
|
||||
phone: editForm.value.phone || null
|
||||
|
|
@ -437,7 +444,7 @@ const handleUpdateProfile = async () => {
|
|||
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: 'อัพเดทโปรไฟล์สำเร็จ',
|
||||
message: response.message || 'อัพเดทโปรไฟล์สำเร็จ',
|
||||
position: 'top'
|
||||
});
|
||||
|
||||
|
|
@ -445,7 +452,7 @@ const handleUpdateProfile = async () => {
|
|||
} catch (error: any) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: 'เกิดข้อผิดพลาด กรุณาลองใหม่อีกครั้ง',
|
||||
message: error.data?.message || 'เกิดข้อผิดพลาด กรุณาลองใหม่อีกครั้ง',
|
||||
position: 'top'
|
||||
});
|
||||
} finally {
|
||||
|
|
@ -458,14 +465,14 @@ const handleChangePassword = async () => {
|
|||
|
||||
try {
|
||||
// Call real API to change password
|
||||
await userService.changePassword(
|
||||
const response = await userService.changePassword(
|
||||
passwordForm.value.currentPassword,
|
||||
passwordForm.value.newPassword
|
||||
);
|
||||
|
||||
$q.notify({
|
||||
type: 'positive',
|
||||
message: 'เปลี่ยนรหัสผ่านสำเร็จ',
|
||||
message: response.message || 'เปลี่ยนรหัสผ่านสำเร็จ',
|
||||
position: 'top'
|
||||
});
|
||||
|
||||
|
|
@ -478,9 +485,9 @@ const handleChangePassword = async () => {
|
|||
} catch (error: any) {
|
||||
$q.notify({
|
||||
type: 'negative',
|
||||
message: error.response?.status === 401
|
||||
message: error.data?.message || (error.response?.status === 401
|
||||
? 'รหัสผ่านปัจจุบันไม่ถูกต้อง'
|
||||
: 'เกิดข้อผิดพลาดในการเปลี่ยนรหัสผ่าน',
|
||||
: 'เกิดข้อผิดพลาดในการเปลี่ยนรหัสผ่าน'),
|
||||
position: 'top'
|
||||
});
|
||||
} finally {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue