diff --git a/xroom-dashboard/src/components/AddUserModal.vue b/xroom-dashboard/src/components/AddUserModal.vue index 1f9ca1b..64722e8 100644 --- a/xroom-dashboard/src/components/AddUserModal.vue +++ b/xroom-dashboard/src/components/AddUserModal.vue @@ -142,7 +142,6 @@ export default { return; } this.$emit('add-user', { ...this.newUser }); - console.log('اطلاعات کاربر اضافه شده:', JSON.stringify(this.newUser, null, 2)); this.close(); }, }, diff --git a/xroom-dashboard/src/components/CreateSpaceModal.vue b/xroom-dashboard/src/components/CreateSpaceModal.vue index cd2aaa3..cc6fdf1 100644 --- a/xroom-dashboard/src/components/CreateSpaceModal.vue +++ b/xroom-dashboard/src/components/CreateSpaceModal.vue @@ -1,8 +1,8 @@ - - \ No newline at end of file diff --git a/xroom-dashboard/src/components/EditBillingModal.vue b/xroom-dashboard/src/components/EditBillingModal.vue index 0ca07b8..9172096 100644 --- a/xroom-dashboard/src/components/EditBillingModal.vue +++ b/xroom-dashboard/src/components/EditBillingModal.vue @@ -189,6 +189,8 @@ export default { .modal-content::-webkit-scrollbar { display: none; } + + .popUp-header { display: flex; align-items: center; diff --git a/xroom-dashboard/src/components/TeamUser.vue b/xroom-dashboard/src/components/TeamUser.vue index 77a0ea9..607bc00 100644 --- a/xroom-dashboard/src/components/TeamUser.vue +++ b/xroom-dashboard/src/components/TeamUser.vue @@ -67,21 +67,27 @@ - + \ No newline at end of file + diff --git a/xroom-dashboard/src/pages/dashboard/team.vue b/xroom-dashboard/src/pages/dashboard/team.vue index 0924295..dd2c94b 100644 --- a/xroom-dashboard/src/pages/dashboard/team.vue +++ b/xroom-dashboard/src/pages/dashboard/team.vue @@ -41,41 +41,47 @@
-
- -
- logout + +
+ lock

فعال‌سازی دسترسی XRoom

دسترسی کامل به امکانات XRoom بدون واترمارک

- -
- -
- + + +
+
+

وضعیت اشتراک تیم

+

+ ظرفیت کل تیم: {{ subscriptionCount }} کاربر
+ ظرفیت باقی‌مانده: {{ subscriptionCount - teamMemberCapacity}} کاربر
+ کاربران اضافه کرده: {{ teamMemberCapacity }} کاربر +

+

شما اشتراک فعالی ندارین , لطفا اشتراک جدیدی خریداری نمایید.

+ + +
+

جزئیات صورتحساب

@@ -88,24 +94,19 @@ ویرایش جزئیات صورتحساب

-
-

عضویت ها

+

عضویت‌ها

هنوز مجوزی فعال نیست. کاربران شما نمی‌توانند از XRoom با واترمارک استفاده کنند.

- +
-

روش پرداخت

هیچ روش پرداختی برای صورتحساب مرتبط نیست.

- +
@@ -265,16 +266,18 @@ export default { currentUploadType: 'image', dialogTitle: 'آپلود فایل جدید', fileAccept: '*/*', + teamMemberCapacity: 0, + subscriptionCount: 0, }; }, created() { this.fetchUserData(); + this.fetchTeamMemberInfo(); }, methods: { changeTab(tabName) { this.activeTab = tabName; }, - openBillingModal() { this.isBillingModalVisible = true; }, @@ -295,14 +298,111 @@ export default { total: base + tax, }; }, - pay() { - alert(`پرداخت با موفقیت انجام شد برای ${this.memberCount} کاربر`); - this.selectedPlan = null; + async pay() { + if (!this.selectedPlan) { + alert('لطفاً ابتدا یک طرح اشتراک انتخاب کنید.'); + return; + } + + try { + + const startTime = new Date().toISOString(); + let endTime; + if (this.selectedPlan.name === 'هفتگی') { + endTime = new Date(new Date().getTime() + 7 * 24 * 60 * 60 * 1000).toISOString(); + } else if (this.selectedPlan.name === 'ماهانه') { + endTime = new Date(new Date().getTime() + 30 * 24 * 60 * 60 * 1000).toISOString(); + } else if (this.selectedPlan.name === 'سالانه') { + endTime = new Date(new Date().getTime() + 365 * 24 * 60 * 60 * 1000).toISOString(); + } + + const subscriptionData = { + user_count: this.memberCount, + license_number: `ABC-${Math.random().toString(36).substr(2, 6).toUpperCase()}-XYZ`, + startTime: startTime, + endTime: endTime, + price: this.selectedPlan.total, + }; + + const token = localStorage.getItem('token'); + await axios.post(`${this.baseUrl}/add_subscription/`, subscriptionData, { + headers: { + Authorization: `Token ${token}`, + 'Content-Type': 'application/json', + }, + }); + + + await this.fetchTeamMemberInfo(); + + alert(`پرداخت با موفقیت انجام شد برای ${this.memberCount} کاربر`); + this.selectedPlan = null; + this.activeTab = 'membership'; + } catch (error) { + console.error('خطا در ارسال اطلاعات اشتراک:', error); + alert('خطا در ثبت اشتراک. لطفاً دوباره تلاش کنید.'); + } }, - submitNewUser(newUser) { - console.log('کاربر جدید:', newUser); - alert('کاربر با موفقیت اضافه شد'); - // می‌توانید اینجا کد مربوط به ارسال به API را اضافه کنید + async fetchTeamMemberInfo() { + try { + const token = localStorage.getItem('token'); + const response = await axios.get(`${this.baseUrl}/get_team_member_info`, { + headers: { + Authorization: `Token ${token}`, + 'Content-Type': 'application/json', + }, + }); + + this.teamMemberCapacity = response.data.data.team_member_capacity; + this.subscriptionCount = response.data.data.subscriptionCount; + } catch (error) { + console.error('خطا در دریافت اطلاعات اشتراک:', error); + alert('خطا در بارگذاری اطلاعات اشتراک. لطفاً دوباره تلاش کنید.'); + } + }, + async submitNewUser(newUser) { + + console.log('اطلاعات کاربر جدید:', newUser); + + this.teamMemberCapacity++ ; + + const remainingCapacity = this.subscriptionCount - this.teamMemberCapacity; + if (remainingCapacity <= 0) { + alert('ظرفیت تیم پر شده است. لطفاً اشتراک جدیدی خریداری کنید.'); + this.activeTab = 'buy-subscription'; + return; + } + + try { + const token = localStorage.getItem('token'); + + await axios.post( + `${this.baseUrl}/add_teamMember/`, + newUser, + { + headers: { + Authorization: `Token ${token}`, + 'Content-Type': 'application/json', + }, + } + ); + + + this.userList.push({ + ...newUser, + avatar: 'https://models.readyplayer.me/681f59760bc631a87ad25172.png', + role: newUser.role || 'کاربر', + version: newUser.version || 'نسخه آزمایشی', + }); + + + await this.fetchTeamMemberInfo(); + + alert('کاربر با موفقیت اضافه شد'); + } catch (error) { + console.error('خطا در اضافه کردن کاربر:', error); + alert('خطا در اضافه کردن کاربر. لطفاً دوباره تلاش کنید.'); + } }, handleBackdropClick(event) { if (event.target === this.$refs.filePreviewDialog) { @@ -1532,11 +1632,6 @@ export default { } - - - - - .plan-card { background-color: white; border: 1px solid #e2e8f0; @@ -1561,6 +1656,22 @@ export default { } +.invalid-subscription { + color: #f44336 !important; +} + + +.disable-button { + background-color: #EBEEFD; + color: #101010; + border: none; + padding: 10px 16px; + font-size: 14px; + font-weight: 600; + border-radius: 8px; + cursor: pointer; +} +