Skip to content

Commit d6cacff

Browse files
subirjollySubir Jolly
andauthored
feat: add required routing after cancellation (#3063)
Co-authored-by: Subir Jolly <subirjolly@Subirs-MacBook-Pro.local>
1 parent c372c9d commit d6cacff

File tree

3 files changed

+28
-1
lines changed

3 files changed

+28
-1
lines changed

src/billing/components/PayAsYouGo/CancelServiceContext.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ export enum VariableItems {
1818
OTHER_REASON = 'Other reason',
1919
}
2020

21+
const RedirectLocations = {
22+
SWITCHING_ORGANIZATION: '/org_cancel',
23+
RE_SIGNUP: '/cancel',
24+
}
25+
const DEFAULT_REDIRECT_LOCATION = '/mkt_cancel'
26+
2127
export interface CancelServiceContextType {
2228
shortSuggestion: string
2329
isShortSuggestionEnabled: boolean
@@ -29,6 +35,7 @@ export interface CancelServiceContextType {
2935
setReason: (_: string) => void
3036
canContactForFeedback: boolean
3137
toggleCanContactForFeedback: () => void
38+
getRedirectLocation: () => string
3239
}
3340

3441
export const DEFAULT_CANCEL_SERVICE_CONTEXT: CancelServiceContextType = {
@@ -42,6 +49,7 @@ export const DEFAULT_CANCEL_SERVICE_CONTEXT: CancelServiceContextType = {
4249
setReason: (_: string) => null,
4350
canContactForFeedback: false,
4451
toggleCanContactForFeedback: () => null,
52+
getRedirectLocation: () => DEFAULT_REDIRECT_LOCATION,
4553
}
4654

4755
export const CancelServiceContext = createContext<CancelServiceContextType>(
@@ -67,6 +75,12 @@ const CancelServiceProvider: FC<Props> = ({children}) => {
6775
setCanContactForFeedback(prev => !prev)
6876
}
6977

78+
const getRedirectLocation = () => {
79+
const uri = RedirectLocations[reason] ?? '/mkt_cancel'
80+
81+
return `https://www.influxdata.com${uri}`
82+
}
83+
7084
return (
7185
<CancelServiceContext.Provider
7286
value={{
@@ -80,6 +94,7 @@ const CancelServiceProvider: FC<Props> = ({children}) => {
8094
setReason,
8195
canContactForFeedback,
8296
toggleCanContactForFeedback,
97+
getRedirectLocation,
8398
}}
8499
>
85100
{children}

src/billing/components/PayAsYouGo/CancellationOverlay.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {useSelector} from 'react-redux'
2121
import {getQuartzMe} from 'src/me/selectors'
2222
import {getOrg} from 'src/organizations/selectors'
2323
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
24+
import {postSignout} from 'src/client'
2425

2526
interface Props {
2627
onHideOverlay: () => void
@@ -35,6 +36,7 @@ const CancellationOverlay: FC<Props> = ({onHideOverlay}) => {
3536
canContactForFeedback,
3637
suggestions,
3738
shortSuggestion,
39+
getRedirectLocation,
3840
} = useContext(CancelServiceContext)
3941
const quartzMe = useSelector(getQuartzMe)
4042
const org = useSelector(getOrg)
@@ -64,6 +66,13 @@ const CancellationOverlay: FC<Props> = ({onHideOverlay}) => {
6466
}
6567

6668
handleCancelAccount()
69+
70+
if (isFlagEnabled('trackCancellations')) {
71+
postSignout({}).then(() => {
72+
window.location.href = getRedirectLocation()
73+
})
74+
}
75+
6776
event('Cancel Service Executed', payload)
6877
}
6978

src/billing/context/billing.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ import {
4646
} from 'src/types'
4747
import {CreditCardParams} from 'src/types/billing'
4848
import {getErrorMessage} from 'src/utils/api'
49+
import {isFlagEnabled} from 'src/shared/utils/featureFlag'
4950

5051
export type Props = {
5152
children: JSX.Element
@@ -185,7 +186,9 @@ export const BillingProvider: FC<Props> = React.memo(({children}) => {
185186
throw new Error(resp.data.message)
186187
}
187188

188-
history.push(`/logout`)
189+
if (!isFlagEnabled('trackCancellations')) {
190+
history.push(`/logout`)
191+
}
189192
} catch (error) {
190193
const message = getErrorMessage(error)
191194
console.error({error})

0 commit comments

Comments
 (0)