diff --git a/src/helpers/account-data.js b/src/helpers/account-data.js deleted file mode 100644 index dd49376be..000000000 --- a/src/helpers/account-data.js +++ /dev/null @@ -1,36 +0,0 @@ -import { getAccountInfoService, getUserInfoService } from '@/services/account-services' -import { loadAccountJobRoleService } from '@/services/account-settings-services' -import { loadContractServicePlan } from '@/services/contract-services' -import { useAccountStore } from '@/stores/account' - -export const loadUserAndAccountInfo = async () => { - const accountStore = useAccountStore() - const [accountInfo, userInfo, accountJobRole] = await Promise.all([ - getAccountInfoService(), - getUserInfoService(), - loadAccountJobRoleService() - ]) - - accountInfo.is_account_owner = userInfo.results.is_account_owner - accountInfo.client_id = userInfo.results.client_id - accountInfo.timezone = userInfo.results.timezone - accountInfo.utc_offset = userInfo.results.utc_offset - accountInfo.first_name = userInfo.results.first_name - accountInfo.last_name = userInfo.results.last_name - accountInfo.permissions = userInfo.results.permissions - accountInfo.email = userInfo.results.email - accountInfo.user_id = userInfo.results.id - accountInfo.colorTheme = accountStore.theme - accountInfo.jobRole = accountJobRole.jobRole - accountInfo.isDeveloperSupportPlan = true - - if (accountInfo.client_id) { - const { isDeveloperSupportPlan, yourServicePlan } = await loadContractServicePlan({ - clientId: accountInfo.client_id - }) - accountInfo.isDeveloperSupportPlan = isDeveloperSupportPlan - accountInfo.yourServicePlan = yourServicePlan - } - - accountStore.setAccountData(accountInfo) -} diff --git a/src/router/hooks/guards/accountGuard.js b/src/router/hooks/guards/accountGuard.js index 3d53d51a2..3d17dc7db 100644 --- a/src/router/hooks/guards/accountGuard.js +++ b/src/router/hooks/guards/accountGuard.js @@ -1,14 +1,42 @@ +import { getAccountInfoService, getUserInfoService } from '@/services/account-services' +import { loadAccountJobRoleService } from '@/services/account-settings-services' import { setRedirectRoute } from '@/helpers' -import { loadUserAndAccountInfo } from '@/helpers/account-data' /** @type {import('vue-router').NavigationGuardWithThis} */ -export async function accountGuard({ to, accountStore, tracker }) { +export async function accountGuard({ to, accountStore, tracker, loadContractServicePlan }) { const isPrivateRoute = !to.meta.isPublic const userNotIsLoggedIn = !accountStore.hasActiveUserId if (userNotIsLoggedIn) { try { - await loadUserAndAccountInfo() + const [accountInfo, userInfo, accountJobRole] = await Promise.all([ + getAccountInfoService(), + getUserInfoService(), + loadAccountJobRoleService() + ]) + + accountInfo.is_account_owner = userInfo.results.is_account_owner + accountInfo.client_id = userInfo.results.client_id + accountInfo.timezone = userInfo.results.timezone + accountInfo.utc_offset = userInfo.results.utc_offset + accountInfo.first_name = userInfo.results.first_name + accountInfo.last_name = userInfo.results.last_name + accountInfo.permissions = userInfo.results.permissions + accountInfo.email = userInfo.results.email + accountInfo.user_id = userInfo.results.id + accountInfo.colorTheme = accountStore.theme + accountInfo.jobRole = accountJobRole.jobRole + accountInfo.isDeveloperSupportPlan = true + + if (accountInfo.client_id) { + const { isDeveloperSupportPlan, yourServicePlan } = await loadContractServicePlan({ + clientId: accountInfo.client_id + }) + accountInfo.isDeveloperSupportPlan = isDeveloperSupportPlan + accountInfo.yourServicePlan = yourServicePlan + } + + accountStore.setAccountData(accountInfo) if (!isPrivateRoute) { return '/' diff --git a/src/router/hooks/guards/billingGuard.js b/src/router/hooks/guards/billingGuard.js index 915a89c8b..76981b276 100644 --- a/src/router/hooks/guards/billingGuard.js +++ b/src/router/hooks/guards/billingGuard.js @@ -21,10 +21,6 @@ export async function billingGuard({ to, accountStore }) { if (to.name === 'billing-tabs') { return true } - - if (to.name === 'account-settings') { - return true - } } else if (paymentReviewPending) { return BILLING_REDIRECT_OPTIONS } diff --git a/src/templates/add-payment-method-block/index.vue b/src/templates/add-payment-method-block/index.vue index af0efbdec..eecff7444 100644 --- a/src/templates/add-payment-method-block/index.vue +++ b/src/templates/add-payment-method-block/index.vue @@ -1,6 +1,5 @@ @@ -239,19 +226,6 @@ title="Payment Method" > - - - Users must have a registered address before adding a payment method. - - - { - userWasInPayments.value = Boolean(router.currentRoute.value.query?.payment) || false - }) - const handleTrackSuccessEdit = () => { tracker.product .productEdited({ @@ -51,7 +41,6 @@ }) .track() } - const handleTrackFailEdit = (error) => { const { fieldName, message } = handleTrackerError(error) tracker.product @@ -79,20 +68,6 @@ isSocialLoginEnabled: yup.boolean(), isEnabledMfaToAllUsers: yup.boolean() }) - - const redirectUserOnSuccessEdit = async () => { - if (userWasInPayments.value) { - router.push({ path: '/billing/payment', query: { payment: true } }) - await loadUserAndAccountInfo() - } else { - router.push({ path: '/' }) - } - } - - const handleActionsSuccessEdit = async () => { - handleTrackSuccessEdit() - await redirectUserOnSuccessEdit() - } @@ -104,9 +79,9 @@ diff --git a/src/views/Billing/Drawer/DrawerPaymentMethod.vue b/src/views/Billing/Drawer/DrawerPaymentMethod.vue index 183569a29..015f26d61 100644 --- a/src/views/Billing/Drawer/DrawerPaymentMethod.vue +++ b/src/views/Billing/Drawer/DrawerPaymentMethod.vue @@ -39,13 +39,13 @@ } const showPaymentMethod = () => { - if (route.query.paymentSession || route.query.payment) { + if (route.query.paymentSession) { openDrawer() router.push({ query: {} }) } } - onMounted(() => { + onMounted(async () => { showPaymentMethod() })