First commit
This commit is contained in:
32
components/ui/ProfileMenuItem.tsx
Normal file
32
components/ui/ProfileMenuItem.tsx
Normal file
@@ -0,0 +1,32 @@
|
||||
import { DropdownMenuItem } from '@/components/ui/dropdown-menu';
|
||||
import { useToast } from '@/components/ui/use-toast';
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
interface ProfileMenuItemProps {
|
||||
isLoggedIn: boolean;
|
||||
setDialogOpen: (open: boolean) => void;
|
||||
}
|
||||
|
||||
export const ProfileMenuItem = ({ isLoggedIn, setDialogOpen }: ProfileMenuItemProps) => {
|
||||
const { toast } = useToast();
|
||||
const router = useRouter();
|
||||
|
||||
const handleClick = () => {
|
||||
if (!isLoggedIn) {
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Akses Ditolak",
|
||||
description: "Silakan login terlebih dahulu untuk mengakses profil",
|
||||
});
|
||||
setDialogOpen(true);
|
||||
} else {
|
||||
router.push('/mahasiswa/profile');
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<DropdownMenuItem onClick={handleClick}>
|
||||
Profile
|
||||
</DropdownMenuItem>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user