'use client' import { Card, CardContent, CardHeader } from '@/components/ui/card' import { RoleGate } from '@/components/auth/role-gate' import FormSuccess from '@/components/form-success' import { UserRole } from '@prisma/client' import { Button } from '@/components/ui/button' import { toast } from 'sonner' import { admin } from '@/actions/admin' const AdminPage = () => { const onServerActionClick = () => { admin() .then((data) => { if (data.error) { toast.error(data.error) } if (data.success) { toast.success(data.success) } }) } const onApiRouteClick = () => { fetch('/api/admin') .then((response) => { if (response.ok) { toast.success('Allow API Route') } else { toast.error('Forbidden API Route') } }) } return (

🔑 Admin

Admin-only API Route

Admin-only Server Action

) } export default AdminPage