diff --git a/xroom-dashboard/src/pages/dashboard/ChangeAvatar.vue b/xroom-dashboard/src/pages/dashboard/ChangeAvatar.vue index 2b31c6a..b398573 100644 --- a/xroom-dashboard/src/pages/dashboard/ChangeAvatar.vue +++ b/xroom-dashboard/src/pages/dashboard/ChangeAvatar.vue @@ -82,15 +82,7 @@ - -
-

تصویر پروفایل

-

- این نماد در کنار نام شما و برای دیگران در واقعیت مجازی و در پلتفرم وب قابل مشاهده خواهد بود. -

- - -
+ @@ -164,37 +156,38 @@ export default { this.saving = true; this.selectedAvatar = avatar.id; - try { - const response = await axios.post(`${this.baseUrl}/editProfile`, { - profile_glb: avatar.src + // try { + await axios.post(`${this.baseUrl}/editProfile/`, { + profile_glb_url: avatar.src }, { headers: { 'Content-Type': 'application/json' } }); - print(response) + // print(response) // Update local storage if needed - const customer = JSON.parse(localStorage.getItem('customer') || '{}'); - customer.profile_glb = avatar.src; - localStorage.setItem('customer', JSON.stringify(customer)); + // const customer = JSON.parse(localStorage.getItem('customer') || '{}'); + // customer.profile_glb = avatar.src; + // localStorage.setItem('customer', JSON.stringify(customer)); // Show success message - this.$toast.success('آواتار با موفقیت انتخاب شد'); - + // this.$toast.success('آواتار با موفقیت انتخاب شد'); + alert('تغییرات با موفقیت ذخیره شد'); + // Optionally refresh user data - await this.fetchUserData(); + // await this.fetchUserData(); - } catch (error) { - console.error('Error selecting avatar:', error); - const errorMessage = error.response?.data?.detail || - error.response?.data?.message || - 'خطا در انتخاب آواتار'; - this.$toast.error(errorMessage); - } finally { - this.saving = false; - this.selectedAvatar = null; - } + // } catch (error) { + // console.error('Error selecting avatar:', error); + // const errorMessage = error.response?.data?.detail || + // error.response?.data?.message || + // 'خطا در انتخاب آواتار'; + // this.$toast.error(errorMessage); + // } finally { + // this.saving = false; + // this.selectedAvatar = null; + // } }, async fetchUserData() { diff --git a/xroom-dashboard/src/pages/dashboard/EditProfile.vue b/xroom-dashboard/src/pages/dashboard/EditProfile.vue index 8dbd545..06988dc 100644 --- a/xroom-dashboard/src/pages/dashboard/EditProfile.vue +++ b/xroom-dashboard/src/pages/dashboard/EditProfile.vue @@ -36,8 +36,9 @@

- تغییر آواتار | - ساخت مجدد آواتار + + تغییر آواتار +
@@ -79,11 +80,6 @@ - - - - - diff --git a/xroom-dashboard/src/router/index.js b/xroom-dashboard/src/router/index.js index 4071184..8c4aa10 100644 --- a/xroom-dashboard/src/router/index.js +++ b/xroom-dashboard/src/router/index.js @@ -89,6 +89,12 @@ router.beforeEach(async (to, from, next) => { return next('/dashboard'); } + // Check if profile_glb is empty and not already going to ChangeAvatar + const customer = response.data.customer || JSON.parse(localStorage.getItem('customer') || '{}'); + if (!customer.profile_glb && to.name !== 'ChangeAvatar') { + return next('/dashboard/ChangeAvatar'); + } + return next(); } catch (err) { // Invalid token, clear storage and redirect to login @@ -101,5 +107,4 @@ router.beforeEach(async (to, from, next) => { next(); }); - export default router \ No newline at end of file