Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

add BountyHeaderTitle

Kiran Kbc8a3f2059a9
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-header.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-header.tsx
new file mode 100644
index 0000000000..d13aa632af
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-header.tsx
@@ -0,0 +1,40 @@
+"use client";
+
+import useBounty from "@/lib/swr/use-bounty";
+import useWorkspace from "@/lib/swr/use-workspace";
+import { ChevronRight, Trophy } from "@dub/ui";
+import Link from "next/link";
+import { redirect } from "next/navigation";
+
+export function BountyHeaderTitle() {
+ const { bounty, isLoading } = useBounty();
+ const { slug: workspaceSlug } = useWorkspace();
+
+ if (isLoading) {
+ return <div className="h-7 w-32 animate-pulse rounded-md bg-neutral-200" />;
+ }
+
+ if (!bounty) {
+ redirect(`/${workspaceSlug}/program/bounties`);
+ }
+
+ return (
+ <div className="flex items-center gap-1">
+ <Link
+ href={`/${workspaceSlug}/program/bounties`}
+ aria-label="Back to bounties"
+ title="Back to bounties"
+ className="bg-bg-subtle hover:bg-bg-emphasis flex size-8 shrink-0 items-center justify-center rounded-lg transition-[transform,background-color] duration-150 active:scale-95"
+ >
+ <Trophy className="size-4" />
+ </Link>
+
+ <div className="flex items-center gap-1.5">
+ <ChevronRight className="text-content-subtle size-2.5 shrink-0 [&_*]:stroke-2" />
+ <span className="text-lg font-semibold leading-7 text-neutral-900">
+ Bounty details
+ </span>
+ </div>
+ </div>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/page.tsx
index c5a6f98861..420af63659 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/page.tsx
@@ -1,36 +1,12 @@
import { PageContent } from "@/ui/layout/page-content";
import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
-import { ChevronRight } from "@dub/ui";
-import { Trophy } from "lucide-react";
-import Link from "next/link";
+import { BountyHeaderTitle } from "./bounty-header";
import { BountyInfo } from "./bounty-info";
import { BountySubmissionsTable } from "./bounty-submissions-table";
-export default function Page({ params }: { params: { slug: string } }) {
- const { slug } = params;
-
+export default function Page() {
return (
- <PageContent
- title={
- <div className="flex items-center gap-1">
- <Link
- href={`/${slug}/program/bounties`}
- aria-label="Back to bounties"
- title="Back to bounties"
- className="bg-bg-subtle hover:bg-bg-emphasis flex size-8 shrink-0 items-center justify-center rounded-lg transition-[transform,background-color] duration-150 active:scale-95"
- >
- <Trophy className="size-4" />
- </Link>
-
- <div className="flex items-center gap-1.5">
- <ChevronRight className="text-content-subtle size-2.5 shrink-0 [&_*]:stroke-2" />
- <span className="text-lg font-semibold leading-7 text-neutral-900">
- Bounty details
- </span>
- </div>
- </div>
- }
- >
+ <PageContent title={<BountyHeaderTitle />}>
<PageWidthWrapper>
<div className="flex flex-col gap-4">
<BountyInfo />