From 83a28c3f8e3dbe0f917e3c29201acdcd1e40c9ba Mon Sep 17 00:00:00 2001 From: Thaddeus Jiang Date: Wed, 6 Sep 2023 13:34:48 +0900 Subject: [PATCH] feat: add toast ui for better UX (#33) --- components/ui/Avatar/AvatarCardWithMarkIcon.tsx | 4 ++++ components/ui/Avatar/AvatarProfileHeader.tsx | 5 +---- pages/settings/avatars/[username]/export.tsx | 5 +---- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/components/ui/Avatar/AvatarCardWithMarkIcon.tsx b/components/ui/Avatar/AvatarCardWithMarkIcon.tsx index 2912ea0..c5042ee 100644 --- a/components/ui/Avatar/AvatarCardWithMarkIcon.tsx +++ b/components/ui/Avatar/AvatarCardWithMarkIcon.tsx @@ -1,3 +1,5 @@ +import { toast } from "react-hot-toast" + import Link from "next/link" import { useRouter } from "next/router" @@ -23,6 +25,7 @@ export function AvatarCardWithMarkIcon({ avatar }: { avatar: Avatar & { isMarked return res.json() }, onSuccess: () => { + toast.success("Marked") router.replace(router.asPath) } }) @@ -39,6 +42,7 @@ export function AvatarCardWithMarkIcon({ avatar }: { avatar: Avatar & { isMarked return res.json() }, onSuccess: () => { + toast.success("Unmarked") router.replace(router.asPath) } }) diff --git a/components/ui/Avatar/AvatarProfileHeader.tsx b/components/ui/Avatar/AvatarProfileHeader.tsx index b905049..2813d95 100644 --- a/components/ui/Avatar/AvatarProfileHeader.tsx +++ b/components/ui/Avatar/AvatarProfileHeader.tsx @@ -48,10 +48,7 @@ export const AvatarProfileHeader = ({ username, isSetting = false }: { username: }, onSuccess: () => { toast.success("Status changed") - router.push({ - href: router.pathname, - query: router.query - }) + router.replace(router.asPath) } }) diff --git a/pages/settings/avatars/[username]/export.tsx b/pages/settings/avatars/[username]/export.tsx index 4a930b7..06f07b0 100644 --- a/pages/settings/avatars/[username]/export.tsx +++ b/pages/settings/avatars/[username]/export.tsx @@ -37,10 +37,7 @@ export default function AvatarExportPage({ archives }: { archives: any[] }) { }, onSuccess: () => { toast.success("Request sent") - router.push({ - href: router.pathname, - query: router.query - }) + router.replace(router.asPath) } })