From 1644d9f80c440de49581fbc07ff6f17bf993986f Mon Sep 17 00:00:00 2001 From: AfonsoCMSousa Date: Thu, 22 Jan 2026 21:04:46 +0000 Subject: [PATCH] feat: fixed admin page, settings on user --- app/pages/admin/users/index.vue | 23 +---- app/pages/profile/index.vue | 146 ++++++++++++++++++++++++++++---- 2 files changed, 129 insertions(+), 40 deletions(-) diff --git a/app/pages/admin/users/index.vue b/app/pages/admin/users/index.vue index a6f0777..5d99e42 100644 --- a/app/pages/admin/users/index.vue +++ b/app/pages/admin/users/index.vue @@ -499,28 +499,7 @@ const authStore = useAuthStore(); const { token } = storeToRefs(authStore); // State -const users = ref([ - { id: 1, name: 'Dr. Sarah Mitchell', email: 'sarah.mitchell@university.edu', role: 'ADMIN', is_active: true }, - { id: 2, name: 'Prof. James Anderson', email: 'james.anderson@university.edu', role: 'TEACHER', is_active: true }, - { id: 3, name: 'Dr. Emily Chen', email: 'emily.chen@university.edu', role: 'RESEARCHER', is_active: true }, - { id: 4, name: 'Michael Roberts', email: 'michael.roberts@university.edu', role: 'STUDENT', is_active: true }, - { id: 5, name: 'Dr. David Kim', email: 'david.kim@university.edu', role: 'COLLABORATOR', is_active: true }, - { id: 6, name: 'Prof. Maria Garcia', email: 'maria.garcia@university.edu', role: 'TEACHER', is_active: true }, - { id: 7, name: 'Jessica Thompson', email: 'jessica.thompson@university.edu', role: 'STUDENT', is_active: true }, - { id: 8, name: 'Dr. Robert Wilson', email: 'robert.wilson@university.edu', role: 'RESEARCHER', is_active: true }, - { id: 9, name: 'Amanda Foster', email: 'amanda.foster@university.edu', role: 'STUDENT', is_active: false }, - { id: 10, name: 'Prof. Thomas Lee', email: 'thomas.lee@university.edu', role: 'ADMIN', is_active: true }, - { id: 11, name: 'Dr. Lisa Martinez', email: 'lisa.martinez@university.edu', role: 'RESEARCHER', is_active: true }, - { id: 12, name: 'Daniel Brown', email: 'daniel.brown@university.edu', role: 'STUDENT', is_active: true }, - { id: 13, name: 'Prof. Jennifer Davis', email: 'jennifer.davis@university.edu', role: 'TEACHER', is_active: true }, - { id: 14, name: 'Christopher Taylor', email: 'christopher.taylor@university.edu', role: 'STUDENT', is_active: false }, - { id: 15, name: 'Dr. Patricia Johnson', email: 'patricia.johnson@university.edu', role: 'COLLABORATOR', is_active: true }, - { id: 16, name: 'Matthew White', email: 'matthew.white@university.edu', role: 'STUDENT', is_active: true }, - { id: 17, name: 'Prof. Elizabeth Moore', email: 'elizabeth.moore@university.edu', role: 'TEACHER', is_active: true }, - { id: 18, name: 'Dr. William Harris', email: 'william.harris@university.edu', role: 'RESEARCHER', is_active: true }, - { id: 19, name: 'Sophie Anderson', email: 'sophie.anderson@university.edu', role: 'STUDENT', is_active: true }, - { id: 20, name: 'Dr. Richard Clark', email: 'richard.clark@university.edu', role: 'ADMIN', is_active: true } -]); +const users = ref([]); const loading = ref(false); const showModal = ref(false); const showDetailsModal = ref(false); diff --git a/app/pages/profile/index.vue b/app/pages/profile/index.vue index 37682bc..ee7674c 100644 --- a/app/pages/profile/index.vue +++ b/app/pages/profile/index.vue @@ -427,17 +427,35 @@ -
+
+
-
-

No - publications yet

- + class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 w-48 h-48 bg-blue-500/10 dark:bg-blue-400/10 rounded-full blur-3xl opacity-0 group-hover:opacity-100 transition-opacity duration-500 pointer-events-none" /> + +
+
+ + +
+ +

+ No publications yet +

+ +
@@ -585,13 +603,67 @@
-

- Settings

-

- Nothing here but chickens! Settings coming soon. -

+ class="bg-white dark:bg-slate-900 rounded-2xl shadow-sm border border-slate-200 dark:border-slate-800 transition-colors"> + +
+

+ Edit Profile +

+

+ Update your personal information and account details. +

+
+ +
+
+ + +
+ +
+ + +

+ Dont worry, Your email is going to be sold to russian hackers. +

+
+ + + Reset Password + +
+ + +
+ +
@@ -625,6 +697,9 @@ const page = ref(1); const selectedPost = ref(null); const newCommentContent = ref(''); +const newUsername = ref(''); +const newEmail = ref(''); + interface Tag { id: number; name: string; @@ -668,8 +743,6 @@ const userProfile = ref({ role: '', is_active: false, avatarUrl: '', - biography: 'No biography provided.', - joinDate: new Date().toISOString(), publications: [] as any[] }); @@ -870,6 +943,39 @@ const confirmHide = async (post) => { } }; +const updateProfile = async () => { + if (!token.value) { + return; + } + + try { + const name = newUsername.value.trim(); + const email = newEmail.value.trim(); + + if (name.length === 0 || email.length === 0) { + alert("Name and email cannot be empty."); + return; + } + + await $fetch(`${api}/users/me`, { + method: 'PATCH', + headers: { Authorization: `Bearer ${token.value}` }, + body: { + name: name, + email: email + } + }); + alert("Profile updated successfully. Please log in again."); + authStore.logout(); + + } catch (error) { + console.error("Profile update failed", error); + alert("Failed to update profile."); + } + + fetchProfileData(); +}; + // --- Redirects --- const goToCreatePost = () => { console.log("Navigating to create post modal..."); @@ -879,6 +985,10 @@ const goToCreatePost = () => { }); }; +const openResetPassword = () => { + router.push({ path: '/profile/update-password' }); +}; + // --- Lifecycle --- onMounted(() => { fetchProfileData();