diff --git a/apps/web/app/api/bounties/route.ts b/apps/web/app/api/bounties/route.ts index 6562ebd..fdd17d0 100644 --- a/apps/web/app/api/bounties/route.ts +++ b/apps/web/app/api/bounties/route.ts @@ -30,7 +30,7 @@ export async function POST(req: NextRequest) { const did = await getSessionDid(); if (!did) return NextResponse.json({ error: 'Authentication required' }, { status: 401 }); - const { title, description, reward_usd, store_id, store_name } = await req.json(); + const { title, description, url, reward_usd, store_id, store_name } = await req.json(); if (!title?.trim()) return NextResponse.json({ error: 'Title is required' }, { status: 400 }); const reward = parseFloat(reward_usd); @@ -43,7 +43,7 @@ export async function POST(req: NextRequest) { // Insert bounty as 'open' with a non-sequential public id for URLs. await db.sql` - INSERT INTO bounties (public_id, creator_did, store_id, store_name, title, description, reward_usd, status) + INSERT INTO bounties (public_id, creator_did, store_id, store_name, title, description, url, reward_usd, status) VALUES ( ${publicId}, ${did}, @@ -51,6 +51,7 @@ export async function POST(req: NextRequest) { ${store_name?.trim() ?? null}, ${title.trim()}, ${description?.trim() ?? null}, + ${url?.trim() || null}, ${reward}, 'open' ) diff --git a/apps/web/app/api/coupons/route.ts b/apps/web/app/api/coupons/route.ts index d99fb4e..814bdf3 100644 --- a/apps/web/app/api/coupons/route.ts +++ b/apps/web/app/api/coupons/route.ts @@ -95,12 +95,9 @@ export async function POST(req: NextRequest) { image_url, } = body; - if (!url) { - return NextResponse.json({ error: 'url is required' }, { status: 400 }); - } if (!title) { return NextResponse.json( - { error: 'title is required (scrape the URL first)' }, + { error: 'title is required' }, { status: 400 } ); } @@ -125,7 +122,7 @@ export async function POST(req: NextRequest) { ) VALUES ( ${storeId}, ${code?.trim() || null}, ${title}, ${description ?? null}, ${discount}, - ${type}, ${value}, ${expiry_date || null}, ${url}, ${image_url ?? null} + ${type}, ${value}, ${expiry_date || null}, ${url?.trim() || null}, ${image_url ?? null} ) `; return NextResponse.json({ success: true }, { status: 201 }); diff --git a/apps/web/app/bounties/[id]/page.tsx b/apps/web/app/bounties/[id]/page.tsx index d4f0ba2..65bd6b6 100644 --- a/apps/web/app/bounties/[id]/page.tsx +++ b/apps/web/app/bounties/[id]/page.tsx @@ -12,6 +12,7 @@ interface Bounty { public_id: string; title: string; description: string | null; + url: string | null; reward_usd: number; status: string; store_id: number | null; @@ -103,6 +104,18 @@ export default async function BountyPage({ params }: { params: Promise<{ id: str
{bounty.description}
)} + {/* Reference link */} + {bounty.url && ( + + {bounty.url} ↗ + + )} + {/* Claimed coupon */} {bounty.coupon_code && (- Paste the product link and your coupon code — we'll pull the listing details for you. + Paste a product link to auto-fill the details — or enter them manually. The link is optional.