Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 26 additions & 32 deletions app/bounty/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,51 +3,45 @@
import { useEffect } from "react";
import { useRouter } from "next/navigation";
import { authClient } from "@/lib/auth-client";
import { useUserRole } from "@/hooks/use-user-role";
import {
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { AlertCircle } from "lucide-react";
import { BountyCreateForm } from "@/components/bounty/bounty-create-form";

interface ExtendedUser {
id: string;
name?: string | null;
email?: string | null;
image?: string | null;
role?: string | null;
organizations?: string[];
}

export default function CreateBountyPage() {
const router = useRouter();
const { isPending } = authClient.useSession();
const userRole = useUserRole();
const { data: session, isPending } = authClient.useSession();

const user = session?.user as ExtendedUser | undefined;
const isSponsorOrOrgMember =
user &&
(user.role === "sponsor" ||
(user.organizations && user.organizations.length > 0));

useEffect(() => {
// Redirect to /bounty if the user is not a sponsor
if (!isPending && userRole !== "sponsor") {
// Redirect to /bounty if the user is not authorized as a sponsor or organization member
if (!isPending && !isSponsorOrOrgMember) {
router.push("/bounty");
}
}, [userRole, isPending, router]);
}, [isSponsorOrOrgMember, isPending, router]);

// Show nothing while checking auth or redirecting
if (isPending || userRole !== "sponsor") {
if (isPending || !isSponsorOrOrgMember) {
return null;
}

return (
<div className="container max-w-2xl py-8">
<h1 className="text-3xl font-bold mb-8">Create a Bounty</h1>
<Card className="border-amber-200 bg-amber-50">
<CardHeader>
<div className="flex items-center gap-2">
<AlertCircle className="h-5 w-5 text-amber-600" />
<CardTitle className="text-amber-900">Coming Soon</CardTitle>
</div>
<CardDescription className="text-amber-800">
The bounty creation form is under development
</CardDescription>
</CardHeader>
<CardContent className="text-sm text-amber-900">
We&apos;re building a powerful form to help you create bounties. Check
back soon!
</CardContent>
</Card>
<div className="container max-w-3xl py-8">
<h1 className="text-3xl font-extrabold tracking-tight mb-8">
Bounty Creation Portal
</h1>
<BountyCreateForm />
</div>
);
}
Loading
Loading