fixed faq bugs

This commit is contained in:
HAM!DREZA
2024-07-02 18:19:51 +03:30
parent a8e723ddf0
commit d2f71b6b14
21 changed files with 205 additions and 307 deletions
+8 -15
View File
@@ -2,8 +2,8 @@
<div class="flex justify-between flex-col text-[#383E43]">
<div class="relative">
<img
v-if="profileImage"
:src="profileImage"
v-if="authUser.avatarMedia"
:src="authUser.avatarMedia"
class="w-[40.256vw] md:w-[8.177vw] h-[40.256vw] md:h-[8.177vw] rounded-[50%]"
alt="profile"
/>
@@ -153,8 +153,6 @@
<script setup>
const profileName = useState('profileName')
const profileImage = useState('profileImage')
import { useToast } from "vue-toastification";
const toast = useToast();
const { authUser } = useAuth();
@@ -162,11 +160,7 @@ const loading = ref(false);
const {data, refresh} = await useFetch('/api/auth/me')
const edit = async (formData) => {
if (formData.name !== authUser.value.name) {
profileName.value = formData.name
}
authUser.value.name = formData.name
try {
loading.value = true;
await $fetch("/api/user/update", {
@@ -184,27 +178,26 @@ const edit = async (formData) => {
};
//const token = getCookie(event, 'token');
async function changePhoto(val) {
const formData = new FormData();
formData.append("directoryName", "test");
formData.append("directoryName", "profileImage");
formData.append("file", val.target.files[0]);
const data = await useFetch("/api/uploader", {
method: "POST",
body: formData,
});
if (data.data.value.url) {
console.log('done');
await $fetch("/api/user/update", {
method: "PUT",
body: {
avatarMedia: data.data.value.url
},
});
profileImage.value = data.data.value.url
authUser.value.avatarMedia = data.data.value.url
// profileImage.value = data.data.value.url
toast.success('تصویر پروفایل تغییر کرد')
refresh()
}
}