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>
|
</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>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -164,37 +156,38 @@ export default {
|
||||||
this.saving = true;
|
this.saving = true;
|
||||||
this.selectedAvatar = avatar.id;
|
this.selectedAvatar = avatar.id;
|
||||||
|
|
||||||
try {
|
// try {
|
||||||
const response = await axios.post(`${this.baseUrl}/editProfile`, {
|
await axios.post(`${this.baseUrl}/editProfile/`, {
|
||||||
profile_glb: avatar.src
|
profile_glb_url: avatar.src
|
||||||
}, {
|
}, {
|
||||||
headers: {
|
headers: {
|
||||||
'Content-Type': 'application/json'
|
'Content-Type': 'application/json'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
print(response)
|
// print(response)
|
||||||
// Update local storage if needed
|
// Update local storage if needed
|
||||||
const customer = JSON.parse(localStorage.getItem('customer') || '{}');
|
// const customer = JSON.parse(localStorage.getItem('customer') || '{}');
|
||||||
customer.profile_glb = avatar.src;
|
// customer.profile_glb = avatar.src;
|
||||||
localStorage.setItem('customer', JSON.stringify(customer));
|
// localStorage.setItem('customer', JSON.stringify(customer));
|
||||||
|
|
||||||
// Show success message
|
// Show success message
|
||||||
this.$toast.success('آواتار با موفقیت انتخاب شد');
|
// this.$toast.success('آواتار با موفقیت انتخاب شد');
|
||||||
|
alert('تغییرات با موفقیت ذخیره شد');
|
||||||
|
|
||||||
// Optionally refresh user data
|
// Optionally refresh user data
|
||||||
await this.fetchUserData();
|
// await this.fetchUserData();
|
||||||
|
|
||||||
} catch (error) {
|
// } catch (error) {
|
||||||
console.error('Error selecting avatar:', error);
|
// console.error('Error selecting avatar:', error);
|
||||||
const errorMessage = error.response?.data?.detail ||
|
// const errorMessage = error.response?.data?.detail ||
|
||||||
error.response?.data?.message ||
|
// error.response?.data?.message ||
|
||||||
'خطا در انتخاب آواتار';
|
// 'خطا در انتخاب آواتار';
|
||||||
this.$toast.error(errorMessage);
|
// this.$toast.error(errorMessage);
|
||||||
} finally {
|
// } finally {
|
||||||
this.saving = false;
|
// this.saving = false;
|
||||||
this.selectedAvatar = null;
|
// this.selectedAvatar = null;
|
||||||
}
|
// }
|
||||||
},
|
},
|
||||||
|
|
||||||
async fetchUserData() {
|
async fetchUserData() {
|
||||||
|
|
|
@ -36,8 +36,9 @@
|
||||||
</p>
|
</p>
|
||||||
<img :src="userAvatarUrl" class="avatar-image" />
|
<img :src="userAvatarUrl" class="avatar-image" />
|
||||||
<div class="avatar-actions">
|
<div class="avatar-actions">
|
||||||
<a @click="changeAvatar">تغییر آواتار</a> |
|
|
||||||
<a @click="regenerateAvatar">ساخت مجدد آواتار</a>
|
<router-link to="/dashboard/ChangeAvatar">تغییر آواتار </router-link>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -79,11 +80,6 @@
|
||||||
|
|
||||||
<input type="file" @change="uploadProfileImage" class="upload-input" />
|
<input type="file" @change="uploadProfileImage" class="upload-input" />
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,12 @@ router.beforeEach(async (to, from, next) => {
|
||||||
return next('/dashboard');
|
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();
|
return next();
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// Invalid token, clear storage and redirect to login
|
// Invalid token, clear storage and redirect to login
|
||||||
|
@ -101,5 +107,4 @@ router.beforeEach(async (to, from, next) => {
|
||||||
|
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
export default router
|
export default router
|
Loading…
Reference in New Issue
Block a user