Skip to content
Open
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
55 changes: 25 additions & 30 deletions app/bounty/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,50 +4,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;
organizations?: string[];
}

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

const user = session?.user as ExtendedUser | undefined;
const isSponsorOrOrgMember = user && (
user.role === "sponsor" ||
(user.organizations && user.organizations.length > 0)
);
Comment on lines 20 to +26

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Expect either no direct `user.role` reads on ExtendedUser casts, or `role` declared on the shared/local user type.
rg -n 'interface ExtendedUser|const userRole|user\.role' app/bounty/create/page.tsx components/global-navbar.tsx components/bounty/bounty-create-form.tsx

Repository: boundlessfi/bounties

Length of output: 594


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## app/bounty/create/page.tsx\n'
sed -n '1,120p' app/bounty/create/page.tsx

printf '\n## components/global-navbar.tsx\n'
sed -n '1,120p' components/global-navbar.tsx

printf '\n## components/bounty/bounty-create-form.tsx\n'
sed -n '1,120p' components/bounty/bounty-create-form.tsx

Repository: boundlessfi/bounties

Length of output: 9089


🏁 Script executed:

#!/bin/bash
set -euo pipefail

printf '\n## app/bounty/create/page.tsx\n'
sed -n '1,120p' app/bounty/create/page.tsx

printf '\n## components/global-navbar.tsx\n'
sed -n '1,120p' components/global-navbar.tsx

printf '\n## components/bounty/bounty-create-form.tsx\n'
sed -n '1,120p' components/bounty/bounty-create-form.tsx

Repository: boundlessfi/bounties

Length of output: 9089


Use the existing userRole value instead of reading user.role.

ExtendedUser does not declare role, so user.role === "sponsor" will fail TypeScript here. Reuse userRole for the sponsor branch; the same user.role access also appears in components/global-navbar.tsx.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/bounty/create/page.tsx` around lines 20 - 26, The sponsor check in the
create page is reading user.role directly even though ExtendedUser does not
define that property, so update the logic in the create page to reuse the
existing userRole value for the sponsor branch and keep the organization
membership check on user.organizations. Also make the same user.role replacement
in components/global-navbar.tsx so both places use the role source that is
already available.


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