From 8787ed46c5b5aa6e72d71d638f277335ce1beafd Mon Sep 17 00:00:00 2001 From: Kamran Ahmed Date: Wed, 26 Jul 2023 20:01:03 +0100 Subject: [PATCH] Toast message on leaving team --- src/components/TeamMembers/LeaveTeamPopup.tsx | 2 +- src/components/Toast.tsx | 14 ++++++++++++++ src/layouts/BaseLayout.astro | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/components/TeamMembers/LeaveTeamPopup.tsx b/src/components/TeamMembers/LeaveTeamPopup.tsx index 153d21636..c84452f5a 100644 --- a/src/components/TeamMembers/LeaveTeamPopup.tsx +++ b/src/components/TeamMembers/LeaveTeamPopup.tsx @@ -45,7 +45,7 @@ export function LeaveTeamPopup(props: LeaveTeamPopupProps) { return; } - window.location.href = '/account'; + window.location.href = '/account?c=tl'; }; const handleClosePopup = () => { diff --git a/src/components/Toast.tsx b/src/components/Toast.tsx index a5b844a5d..372ba0d9d 100644 --- a/src/components/Toast.tsx +++ b/src/components/Toast.tsx @@ -6,12 +6,26 @@ import { ErrorIcon } from './ReactIcons/ErrorIcon'; import { WarningIcon } from './ReactIcons/WarningIcon'; import { InfoIcon } from './ReactIcons/InfoIcon'; import { Spinner } from './ReactIcons/Spinner'; +import { deleteUrlParam, getUrlParams, setUrlParams } from '../lib/browser'; export interface Props {} +const messageCodes: Record = { + tl: 'Successfully left the team', +}; + export function Toaster(props: Props) { const toastMessage = useStore($toastMessage); + const { c } = getUrlParams(); + if (c) { + deleteUrlParam('c'); + + if (messageCodes[c]) { + $toastMessage.set({ type: 'success', message: messageCodes[c] }); + } + } + useEffect(() => { if (toastMessage === undefined) { return; diff --git a/src/layouts/BaseLayout.astro b/src/layouts/BaseLayout.astro index 149fcb074..22ad7fa90 100644 --- a/src/layouts/BaseLayout.astro +++ b/src/layouts/BaseLayout.astro @@ -156,7 +156,7 @@ const gaPageIdentifier = Astro.url.pathname - +