From d96b313fba06320834176ae93b7fcf3a28692888 Mon Sep 17 00:00:00 2001 From: Shariq Ansari Date: Thu, 14 Nov 2024 19:53:14 +0530 Subject: [PATCH] refactor: moved team provide to App.vue --- billing/src/App.vue | 10 +++++ billing/src/components/AddressForm.vue | 4 +- billing/src/components/BuyCreditsRazorpay.vue | 6 +-- billing/src/components/BuyCreditsStripe.vue | 4 +- billing/src/components/CardForm.vue | 12 +++--- billing/src/components/CurrentPlan.vue | 7 +-- billing/src/components/PaymentDetails.vue | 43 ++++++++++--------- billing/src/components/PrepaidCreditsForm.vue | 20 ++++----- billing/src/pages/Billing.vue | 11 +---- billing/src/pages/BillingHistory.vue | 9 +--- billing/src/pages/Plans.vue | 12 ++---- 11 files changed, 66 insertions(+), 72 deletions(-) diff --git a/billing/src/App.vue b/billing/src/App.vue index 69356ae8dd..0b61001e99 100644 --- a/billing/src/App.vue +++ b/billing/src/App.vue @@ -17,6 +17,14 @@ import PageNotFound from './pages/PageNotFound.vue' import AppSidebar from '@/components/AppSidebar.vue' import { Dialogs } from '@/dialogs.js' import { Toasts, createResource } from 'frappe-ui' +import { provide } from 'vue' + +const team = createResource({ + url: 'frappe.integrations.frappe_providers.frappecloud_billing.api', + params: { method: 'team.info' }, + cache: 'team', + auto: true, +}) const isFCSite = createResource({ url: 'frappe.integrations.frappe_providers.frappecloud_billing.is_fc_site', @@ -24,4 +32,6 @@ const isFCSite = createResource({ auto: true, transform: (data) => Boolean(data), }) + +provide('team', team) diff --git a/billing/src/components/AddressForm.vue b/billing/src/components/AddressForm.vue index 066396ddca..39af9994ad 100644 --- a/billing/src/components/AddressForm.vue +++ b/billing/src/components/AddressForm.vue @@ -37,7 +37,7 @@ import { FormControl, ErrorMessage, createResource, toast } from 'frappe-ui' import { ref, computed, inject, watch } from 'vue' const emit = defineEmits(['success']) -const { team } = inject('billing') +const team = inject('team') const billingInformation = defineModel() @@ -135,7 +135,7 @@ const _countryList = createResource({ cache: 'countryList', auto: true, onSuccess: () => { - let userCountry = team.value?.country + let userCountry = team.data?.country if (userCountry) { let country = countryList.value?.find((d) => d.label === userCountry) if (country) { diff --git a/billing/src/components/BuyCreditsRazorpay.vue b/billing/src/components/BuyCreditsRazorpay.vue index 5d2f5c2e0d..bc4b17d0c8 100644 --- a/billing/src/components/BuyCreditsRazorpay.vue +++ b/billing/src/components/BuyCreditsRazorpay.vue @@ -1,7 +1,7 @@