32 lines
833 B
TypeScript
32 lines
833 B
TypeScript
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>
|
|
);
|
|
};
|