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 (