feat: basic toggle post visibility

This commit is contained in:
2026-01-23 17:29:04 +00:00
parent e423497fd2
commit 6eae88f4e9
4 changed files with 343 additions and 362 deletions
+13 -8
View File
@@ -618,7 +618,7 @@
</template>
<script setup>
import { ref, computed, onMounted } from 'vue';
import { ref, computed, onMounted, watch } from 'vue';
import { useRouter } from 'vue-router';
import { useAuthStore } from "~/stores/auth-store.js";
import { storeToRefs } from "pinia";
@@ -765,6 +765,11 @@ async function fetchProfileData() {
avatarUrl: `https://ui-avatars.com/api/?name=${encodeURIComponent(userData.name)}&background=0D8ABC&color=fff`
};
if (authStore.user) {
authStore.user.name = userData.name;
authStore.user.email = userData.email;
}
userProfile.value.publications = (publicationsData).map(pub => {
const pubDate = new Date(pub.publicationDate);
@@ -837,21 +842,21 @@ const updateProfile = async () => {
const name = newUsername.value.trim();
const email = newEmail.value.trim();
if (name.length === 0 || email.length === 0) {
notifications.error("Name and email cannot be empty");
return;
}
await $fetch(`${api}/users/me`, {
method: 'PATCH',
headers: { Authorization: `Bearer ${token.value}` },
body: {
name: name,
email: email
name: name || userProfile.value.name,
email: email || userProfile.value.email
}
});
notifications.success("Profile updated successfully");
authStore.logout();
if (authStore.user) {
authStore.user.name = name || userProfile.value.name;
authStore.user.email = email || userProfile.value.email;
}
} catch (error) {
console.error("Profile update failed", error);