From 1689d5cf5c84180e6da66b0368739b515d61c71c Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Tue, 28 Oct 2025 22:59:57 +0530 Subject: [PATCH] add fe changes --- .../dashboard/api/enterprise/account.js | 39 ++ app/javascript/dashboard/featureFlags.js | 1 + .../dashboard/i18n/locale/en/settings.json | 96 ++++ .../dashboard/settings/billing-v2/IndexV2.vue | 145 ++++++ .../settings/billing-v2/billing-v2.routes.js | 33 ++ .../components/CancelSubscriptionModal.vue | 94 ++++ .../billing-v2/components/CreditGrants.vue | 117 +++++ .../billing-v2/components/CreditsBalance.vue | 204 ++++++++ .../billing-v2/components/PricingPlans.vue | 469 ++++++++++++++++++ .../billing-v2/components/SubscribeModal.vue | 174 +++++++ .../billing-v2/components/TopupModal.vue | 114 +++++ .../billing-v2/components/TopupOptions.vue | 130 +++++ .../dashboard/settings/settings.routes.js | 2 + .../dashboard/store/modules/accounts.js | 221 +++++++++ .../dashboard/store/mutation-types.js | 7 + 15 files changed, 1846 insertions(+) create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing-v2/IndexV2.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing-v2/billing-v2.routes.js create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing-v2/components/CancelSubscriptionModal.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing-v2/components/CreditGrants.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing-v2/components/CreditsBalance.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing-v2/components/PricingPlans.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing-v2/components/SubscribeModal.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing-v2/components/TopupModal.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing-v2/components/TopupOptions.vue diff --git a/app/javascript/dashboard/api/enterprise/account.js b/app/javascript/dashboard/api/enterprise/account.js index 3f12dc007..18aafbaba 100644 --- a/app/javascript/dashboard/api/enterprise/account.js +++ b/app/javascript/dashboard/api/enterprise/account.js @@ -23,6 +23,45 @@ class EnterpriseAccountAPI extends ApiClient { action_type: action, }); } + + // V2 Billing APIs + creditsBalance() { + return axios.get(`${this.url}credits_balance`); + } + + creditGrants() { + return axios.get(`${this.url}credit_grants`); + } + + v2PricingPlans() { + return axios.get(`${this.url}v2_pricing_plans`); + } + + v2TopupOptions() { + return axios.get(`${this.url}v2_topup_options`); + } + + v2Topup(data) { + return axios.post(`${this.url}v2_topup`, data); + } + + v2Subscribe(data) { + return axios.post(`${this.url}v2_subscribe`, data); + } + + cancelSubscription(data = {}) { + return axios.post(`${this.url}cancel_subscription`, data); + } + + updateSubscriptionQuantity(quantity) { + return axios.post(`${this.url}update_subscription_quantity`, { + quantity, + }); + } + + changePricingPlan(data) { + return axios.post(`${this.url}change_pricing_plan`, data); + } } export default new EnterpriseAccountAPI(); diff --git a/app/javascript/dashboard/featureFlags.js b/app/javascript/dashboard/featureFlags.js index 87227e74b..461f03e95 100644 --- a/app/javascript/dashboard/featureFlags.js +++ b/app/javascript/dashboard/featureFlags.js @@ -41,6 +41,7 @@ export const FEATURE_FLAGS = { CAPTAIN_V2: 'captain_integration_v2', SAML: 'saml', QUOTED_EMAIL_REPLY: 'quoted_email_reply', + STRIPE_V2: 'stripe_v2', }; export const PREMIUM_FEATURES = [ diff --git a/app/javascript/dashboard/i18n/locale/en/settings.json b/app/javascript/dashboard/i18n/locale/en/settings.json index 812b0cd8b..de4d7d94f 100644 --- a/app/javascript/dashboard/i18n/locale/en/settings.json +++ b/app/javascript/dashboard/i18n/locale/en/settings.json @@ -397,6 +397,102 @@ }, "NO_BILLING_USER": "Your billing account is being configured. Please refresh the page and try again." }, + "BILLING_SETTINGS_V2": { + "TITLE": "Billing", + "DESCRIPTION": "Manage your usage-based subscription with flexible credit-based pricing. Top up anytime or subscribe to a plan.", + "VIEW_PRICING": "View Pricing", + "OPEN_STRIPE_DASHBOARD": "Open Stripe Dashboard", + "CREDITS_BALANCE": { + "TITLE": "Credits Balance", + "DESCRIPTION": "Your current credit balance and recent transactions.", + "CREDITS": "credits", + "CREDITS_SHORT": "cr", + "REFRESH": "Refresh", + "USAGE_BASED_INFO": "Usage-based pricing: Credits are consumed as you use Chatwoot features.", + "LEDGER_TITLE": "Recent Transactions", + "NO_TRANSACTIONS": "No transactions yet. Start by topping up or subscribing to a plan." + }, + "PRICING_PLANS": { + "TITLE": "Pricing Plans", + "DESCRIPTION": "Choose a plan that fits your team. All plans include credits that reset monthly.", + "CURRENT_PLAN": "Current Subscription", + "CURRENT": "Current Plan", + "RECOMMENDED": "Recommended", + "MONTH": "month", + "SEATS": "seats", + "CREDITS_PER_SEAT": "credits/month", + "CREDITS_INCLUDED": "credits included/month", + "PER_CREDIT_OVERAGE": "per additional credit", + "MIN_SEATS": "Minimum seats", + "SUBSCRIBE": "Subscribe", + "SWITCH_PLAN": "Switch Plan", + "CURRENT_PLAN": "Current Plan", + "CANCEL_SUBSCRIPTION": "Cancel Subscription", + "BLOCKED": "Blocked", + "CANCELLING_TITLE": "Subscription Ending", + "CANCELLING_MESSAGE": "Your subscription will be cancelled at the end of the current billing period. You can continue using your current plan until then.", + "ENDS_ON": "Subscription ends on", + "NO_PLANS": "No pricing plans available.", + "SUBSCRIBE_SUCCESS": "Successfully subscribed to the plan! Your credits have been updated.", + "CANCEL_SUCCESS": "Subscription cancelled successfully.", + "MANAGE_SEATS": "Adjust Seats", + "UPDATE": "Update", + "UPDATE_QUANTITY_SUCCESS": "Subscription quantity updated successfully!", + "CHANGE_PLAN_SUCCESS": "Successfully changed to the new plan! Your credits have been updated." + }, + "TOPUP_OPTIONS": { + "TITLE": "Top-up Credits", + "DESCRIPTION": "Need more credits? Purchase additional credits anytime to keep your team running.", + "CREDITS": "credits", + "BUY_NOW": "Buy Now", + "NO_OPTIONS": "No top-up options available.", + "TOPUP_SUCCESS": "Credits added successfully! Your new balance is available now.", + "NO_PAYMENT_METHOD_ERROR": "No payment method found. Please add a payment method in your Stripe dashboard before making a purchase. Click the 'Open Stripe Dashboard' button above to add one." + }, + "CREDIT_GRANTS": { + "TITLE": "Credit History", + "DESCRIPTION": "View all your credit grants including topups and monthly credits.", + "CREDITS": "credits", + "EXPIRES": "Expires", + "NO_EXPIRY": "Never expires", + "ADDED": "Added", + "NO_GRANTS": "No credit grants yet." + }, + "SUBSCRIBE_MODAL": { + "TITLE": "Confirm Subscription", + "NUMBER_OF_SEATS": "Number of seats", + "MIN": "Min", + "MAX": "Max", + "BASE_PRICE": "Base price per seat", + "INCLUDED_CREDITS": "Included credits", + "CREDITS": "credits", + "MONTHLY_TOTAL": "Monthly Total", + "OVERAGE_RATE": "Overage rate", + "CREDIT": "credit", + "CANCEL": "Cancel", + "CONFIRM": "Confirm Subscription" + }, + "TOPUP_MODAL": { + "TITLE": "Confirm Top-up", + "SELECTED_OPTION": "Selected Option", + "CREDITS": "credits", + "PRICE": "Price", + "INFO": "Credits will be added to your account immediately and never expire.", + "CANCEL": "Cancel", + "CONFIRM": "Confirm Top-up" + }, + "CANCEL_MODAL": { + "TITLE": "Cancel Subscription", + "WARNING_TITLE": "Are you sure?", + "WARNING_MESSAGE": "Cancelling your subscription will stop monthly credit renewals. Any remaining credits will still be available until used.", + "REASON_LABEL": "Reason for cancellation", + "OPTIONAL": "(optional)", + "REASON_PLACEHOLDER": "Help us improve by sharing why you're cancelling...", + "INFO": "You can resubscribe anytime to continue receiving monthly credits.", + "KEEP_SUBSCRIPTION": "Keep Subscription", + "CONFIRM_CANCEL": "Confirm Cancellation" + } + }, "SECURITY_SETTINGS": { "TITLE": "Security", "DESCRIPTION": "Manage your account security settings.", diff --git a/app/javascript/dashboard/routes/dashboard/settings/billing-v2/IndexV2.vue b/app/javascript/dashboard/routes/dashboard/settings/billing-v2/IndexV2.vue new file mode 100644 index 000000000..051d83b90 --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/settings/billing-v2/IndexV2.vue @@ -0,0 +1,145 @@ + + + diff --git a/app/javascript/dashboard/routes/dashboard/settings/billing-v2/billing-v2.routes.js b/app/javascript/dashboard/routes/dashboard/settings/billing-v2/billing-v2.routes.js new file mode 100644 index 000000000..5d34efb3a --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/settings/billing-v2/billing-v2.routes.js @@ -0,0 +1,33 @@ +import { frontendURL } from '../../../../helper/URLHelper'; +import { INSTALLATION_TYPES } from 'dashboard/constants/installationTypes'; +import SettingsWrapper from '../SettingsWrapper.vue'; +import IndexV2 from './IndexV2.vue'; + +export default { + routes: [ + { + path: frontendURL('accounts/:accountId/settings/billing-v2'), + meta: { + permissions: ['administrator'], + installationTypes: [INSTALLATION_TYPES.CLOUD], + }, + component: SettingsWrapper, + props: { + headerTitle: 'BILLING_SETTINGS_V2.TITLE', + icon: 'credit-card-person', + showNewButton: false, + }, + children: [ + { + path: '', + name: 'billing_settings_v2_index', + component: IndexV2, + meta: { + installationTypes: [INSTALLATION_TYPES.CLOUD], + permissions: ['administrator'], + }, + }, + ], + }, + ], +}; diff --git a/app/javascript/dashboard/routes/dashboard/settings/billing-v2/components/CancelSubscriptionModal.vue b/app/javascript/dashboard/routes/dashboard/settings/billing-v2/components/CancelSubscriptionModal.vue new file mode 100644 index 000000000..494557188 --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/settings/billing-v2/components/CancelSubscriptionModal.vue @@ -0,0 +1,94 @@ + + +