Skip to content

Commit f3a10f7

Browse files
subirjollySubir Jolly
andauthored
feat: add appropriate routing after account deletion (#3186)
Co-authored-by: Subir Jolly <subirjolly@Subirs-MacBook-Pro.local>
1 parent d055ea4 commit f3a10f7

File tree

2 files changed

+27
-3
lines changed

2 files changed

+27
-3
lines changed

src/organizations/components/DeleteOrgContext.tsx

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export enum VariableItems {
1717
RE_SIGNUP = 'I want to sign up for a new account using a marketplace option',
1818
OTHER_REASON = 'Other reason',
1919
}
20+
2021
export interface DeleteOrgContextType {
2122
shortSuggestion: string
2223
isShortSuggestionEnabled: boolean
@@ -26,6 +27,7 @@ export interface DeleteOrgContextType {
2627
setSuggestions: (_: string) => void
2728
reason: string
2829
setReason: (_: string) => void
30+
getRedirectLocation: () => string
2931
}
3032

3133
export const DEFAULT_DELETE_ORG_CONTEXT: DeleteOrgContextType = {
@@ -37,7 +39,14 @@ export const DEFAULT_DELETE_ORG_CONTEXT: DeleteOrgContextType = {
3739
setSuggestions: (_: string) => null,
3840
reason: 'NO_OPTION',
3941
setReason: (_: string) => null,
42+
getRedirectLocation: () => DEFAULT_REDIRECT_LOCATION,
43+
}
44+
45+
const RedirectLocations = {
46+
SWITCHING_ORGANIZATION: '/org_cancel',
47+
RE_SIGNUP: '/cancel',
4048
}
49+
const DEFAULT_REDIRECT_LOCATION = '/mkt_cancel'
4150

4251
export const DeleteOrgContext = createContext<DeleteOrgContextType>(
4352
DEFAULT_DELETE_ORG_CONTEXT
@@ -55,6 +64,12 @@ const DeleteOrgProvider: FC<Props> = ({children}) => {
5564
)
5665
const [reason, setReason] = useState(DEFAULT_DELETE_ORG_CONTEXT.reason)
5766

67+
const getRedirectLocation = () => {
68+
const uri = RedirectLocations[reason] ?? '/mkt_cancel'
69+
70+
return `https://www.influxdata.com${uri}`
71+
}
72+
5873
return (
5974
<DeleteOrgContext.Provider
6075
value={{
@@ -66,6 +81,7 @@ const DeleteOrgProvider: FC<Props> = ({children}) => {
6681
setSuggestions,
6782
reason,
6883
setReason,
84+
getRedirectLocation,
6985
}}
7086
>
7187
{children}

src/organizations/components/DeleteOrgOverlay.tsx

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,12 @@ const DeleteOrgOverlay: FC = () => {
4040
const history = useHistory()
4141
const [hasAgreedToTerms, setHasAgreedToTerms] = useState(false)
4242
const dispatch = useDispatch()
43-
const {reason, shortSuggestion, suggestions} = useContext(DeleteOrgContext)
43+
const {
44+
reason,
45+
shortSuggestion,
46+
suggestions,
47+
getRedirectLocation,
48+
} = useContext(DeleteOrgContext)
4449
const quartzMe = useSelector(getQuartzMe)
4550
const org = useSelector(getOrg)
4651

@@ -83,8 +88,11 @@ const DeleteOrgOverlay: FC = () => {
8388
if (resp.status !== 204) {
8489
throw new Error(resp.data.message)
8590
}
86-
87-
window.location.href = `https://www.influxdata.com/free_cancel/`
91+
if (isFlagEnabled('trackCancellations')) {
92+
window.location.href = getRedirectLocation()
93+
} else {
94+
window.location.href = `https://www.influxdata.com/free_cancel/`
95+
}
8896
} catch {
8997
dispatch(notify(accountSelfDeletionFailed()))
9098
}

0 commit comments

Comments
 (0)