mirror of
https://github.com/Dadechin/XRoomDashboardFront.git
synced 2025-07-04 17:24:35 +00:00
added choose avatar page
This commit is contained in:
parent
251096cecc
commit
74afb1f48d
|
@ -82,15 +82,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- Profile Picture Section -->
|
||||
<div class="profile-picture-section mt-5">
|
||||
<h3>تصویر پروفایل</h3>
|
||||
<p class="section-description">
|
||||
این نماد در کنار نام شما و برای دیگران در واقعیت مجازی و در پلتفرم وب قابل مشاهده خواهد بود.
|
||||
</p>
|
||||
<img :src="userProfilePicUrl" class="profile-image" />
|
||||
<input type="file" @change="uploadProfileImage" class="upload-input" />
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
@ -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() {
|
||||
|
|
|
@ -36,8 +36,9 @@
|
|||
</p>
|
||||
<img :src="userAvatarUrl" class="avatar-image" />
|
||||
<div class="avatar-actions">
|
||||
<a @click="changeAvatar">تغییر آواتار</a> |
|
||||
<a @click="regenerateAvatar">ساخت مجدد آواتار</a>
|
||||
|
||||
<router-link to="/dashboard/ChangeAvatar">تغییر آواتار </router-link>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -79,11 +80,6 @@
|
|||
|
||||
<input type="file" @change="uploadProfileImage" class="upload-input" />
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
|
|
|
@ -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
|
Loading…
Reference in New Issue
Block a user