Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[UXE-6007] fix: Billing/Payment - add message to alert user to complete address" #2129

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions src/helpers/account-data.js

This file was deleted.

34 changes: 31 additions & 3 deletions src/router/hooks/guards/accountGuard.js
Original file line number Diff line number Diff line change
@@ -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 '/'
Expand Down
4 changes: 0 additions & 4 deletions src/router/hooks/guards/billingGuard.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
26 changes: 0 additions & 26 deletions src/templates/add-payment-method-block/index.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup>
import { computed, ref, onMounted } from 'vue'
import { useRouter } from 'vue-router'
import { useToast } from 'primevue/usetoast'
import ActionBarBlock from '@/templates/action-bar-block'
import Sidebar from 'primevue/sidebar'
Expand All @@ -11,15 +10,12 @@
import LabelBlock from '@/templates/label-block'
import { useScrollToError } from '@/composables/useScrollToError'
import InputText from 'primevue/inputtext'
import PrimeButton from 'primevue/button'
import { useField } from 'vee-validate'
import * as yup from 'yup'

defineOptions({ name: 'add-payment-method-block' })

const router = useRouter()
const accountStore = useAccountStore()

const stripe = ref(null)
const isSubmitting = ref(false)
const stripeComponents = ref(null)
Expand Down Expand Up @@ -143,10 +139,6 @@
cardCvc.value?.on('blur', handleBlur)
}

const redirectUserToAccountSettings = () => {
router.push({ name: 'account-settings', query: { payment: true } })
}

const visibleDrawer = computed({
get: () => props.visible,
set: (value) => {
Expand Down Expand Up @@ -210,11 +202,6 @@
isSubmitting.value = false
}
}

const userContainAdress = computed(() => {
const accountData = accountStore.account
return !accountData.postal_code && !accountData.address
})
</script>

<template>
Expand All @@ -239,19 +226,6 @@
title="Payment Method"
>
<template #inputs>
<div v-if="userContainAdress">
<InlineMessage severity="warn">
Users must have a registered address before adding a payment method.
<PrimeButton
label="Register address now."
@click="redirectUserToAccountSettings"
iconPos="right"
class="p-0"
size="small"
link
/>
</InlineMessage>
</div>
<div class="max-w-3xl w-full flex flex-col gap-8 max-md:gap-6">
<form
ref="form"
Expand Down
31 changes: 3 additions & 28 deletions src/views/AccountSettings/AccountSettingsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
import { handleTrackerError } from '@/utils/errorHandlingTracker'
import * as yup from 'yup'
import FormFieldsAccountSettings from './FormFields/FormFieldsAccountSettings'
import { inject, onMounted, ref } from 'vue'
import { useRouter } from 'vue-router'
import { loadUserAndAccountInfo } from '@/helpers/account-data'
import { inject } from 'vue'

/**@type {import('@/plugins/analytics/AnalyticsTrackerAdapter').AnalyticsTrackerAdapter} */
const tracker = inject('tracker')
Expand Down Expand Up @@ -36,22 +34,13 @@
}
})

const router = useRouter()

const userWasInPayments = ref(false)

onMounted(() => {
userWasInPayments.value = Boolean(router.currentRoute.value.query?.payment) || false
})

const handleTrackSuccessEdit = () => {
tracker.product
.productEdited({
productName: 'Account Settings'
})
.track()
}

const handleTrackFailEdit = (error) => {
const { fieldName, message } = handleTrackerError(error)
tracker.product
Expand Down Expand Up @@ -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()
}
</script>

<template>
Expand All @@ -104,9 +79,9 @@
<EditFormBlock
:editService="updateAccountSettingsService"
:loadService="getAccountSettingsService"
@on-edit-success="handleActionsSuccessEdit"
@on-edit-success="handleTrackSuccessEdit"
@on-edit-fail="handleTrackFailEdit"
disableRedirect
updatedRedirect="home"
:schema="validationSchema"
>
<template #form>
Expand Down
4 changes: 2 additions & 2 deletions src/views/Billing/Drawer/DrawerPaymentMethod.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

Expand Down
Loading