diff --git a/billing/src/components/AppSidebar.vue b/billing/src/components/AppSidebar.vue index b26e07510f..cfa36156b3 100644 --- a/billing/src/components/AppSidebar.vue +++ b/billing/src/components/AppSidebar.vue @@ -8,17 +8,19 @@
@@ -34,13 +36,18 @@ import CardIcon from '@/icons/CardIcon.vue' import Plans from '@/icons/PlansIcon.vue' import InvoiceIcon from '@/icons/InvoiceIcon.vue' import SidebarLink from '@/components/SidebarLink.vue' +import { createDialog } from '../dialogs' +import { call } from 'frappe-ui' import { useRouter } from 'vue-router' import { useStorage } from '@vueuse/core' -import { onMounted } from 'vue' +import { onMounted, inject } from 'vue' const router = useRouter() const previousRoute = useStorage('previousRoute', null) +const team = inject('team') +const currentSiteInfo = inject('currentSiteInfo') + onMounted(() => { if (document.referrer) { previousRoute.value = document.referrer @@ -68,6 +75,11 @@ const links = [ icon: CardIcon, to: 'Cards', }, + { + label: 'Support', + icon: 'life-buoy', + onClick: () => openSupport(), + }, ] function goBack() { @@ -77,4 +89,35 @@ function goBack() { router.go(-1) } } + +async function openSupport() { + await currentSiteInfo.reload() + if (!currentSiteInfo.data?.plan?.support_included) { + let supportPlan = await call( + 'frappe.integrations.frappe_providers.frappecloud_billing.api', + { + method: 'site.get_first_support_plan', + }, + ) + if (!supportPlan) return + let currency = team.data.currency == 'INR' ? '₹' : '$' + let price = currency === '₹' ? supportPlan.price_inr : supportPlan.price_usd + createDialog({ + title: `Upgrade to ${currency}${price}/mo Plan`, + message: `Please upgrade to the ${currency}${price}/mo plan to get support`, + actions: [ + { + label: 'Upgrade', + variant: 'solid', + onClick: (close) => { + router.push({ name: 'Plans' }) + close() + }, + }, + ], + }) + return + } + window.open('https://support.frappe.io', '_blank') +} diff --git a/billing/src/components/SidebarLink.vue b/billing/src/components/SidebarLink.vue index 550c27cac3..62bbac2b57 100644 --- a/billing/src/components/SidebarLink.vue +++ b/billing/src/components/SidebarLink.vue @@ -4,46 +4,39 @@ :class="isActive ? 'bg-white shadow-sm' : 'hover:bg-gray-100'" @click="handleClick" > -
+
- - - - - - - - - - - {{ label }} + + + + - + + + {{ label }} +
- + + +