From 5399ddfa72f9e26d4eb17a518f1e83554804a2f9 Mon Sep 17 00:00:00 2001 From: Nimit Date: Sun, 25 Aug 2024 14:58:44 +0530 Subject: [PATCH] fix: add refresh db to sidebar --- src/actions/refresh-db/index.ts | 2 +- src/components/sidebar/index.tsx | 25 ++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/actions/refresh-db/index.ts b/src/actions/refresh-db/index.ts index 3404999e2..900523b52 100644 --- a/src/actions/refresh-db/index.ts +++ b/src/actions/refresh-db/index.ts @@ -8,7 +8,7 @@ import { checkUserEmailForPurchase } from '@/utiles/appx-check-mail'; import { Course } from '@prisma/client'; import { getServerSession } from 'next-auth'; -type RefreshDbFn = (args: { userId: string; email: string }) => Promise<{ +type RefreshDbFn = () => Promise<{ error: boolean; message: string; }>; diff --git a/src/components/sidebar/index.tsx b/src/components/sidebar/index.tsx index 370b1f154..36af8734a 100644 --- a/src/components/sidebar/index.tsx +++ b/src/components/sidebar/index.tsx @@ -11,7 +11,10 @@ import { History, PanelRightOpen, LogOut, + RefreshCcw, } from 'lucide-react'; +import { toast } from 'sonner'; +import { refreshDb } from '@/actions/refresh-db'; export const menuOptions = [ { id: 1, name: 'My Courses', Component: Library, href: '/my-courses' }, @@ -23,6 +26,15 @@ export const menuOptions = [ export const MenuOptions = () => { const [expanded, setExpanded] = useState(true); + const handleRefresh = async () => { + const res = await refreshDb(); + if (res.error) { + toast.error(res.message); + } else { + toast.info(res.message); + } + }; + return (