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.

wip bounty card and list

Kiran K89d8e7809b7a
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx
new file mode 100644
index 0000000000..a08eaf755f
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx
@@ -0,0 +1,51 @@
+import { BountyProps } from "@/lib/types";
+import { ProgramOverviewCard } from "@/ui/partners/overview/program-overview-card";
+import { CalendarDays, Users } from "@dub/ui/icons";
+import { formatDate } from "@dub/utils";
+import { Trophy } from "lucide-react";
+
+export function BountyCard({ bounty }: { bounty: BountyProps }) {
+ const { name, startsAt, endsAt } = bounty;
+
+ const total = 1000;
+ const completed = 400;
+
+ return (
+ <ProgramOverviewCard className="cursor-pointer p-5 transition-shadow hover:shadow-lg">
+ <div className="flex flex-col gap-5">
+ <div className="flex items-center justify-center rounded-lg bg-neutral-50 px-32 py-4">
+ <div className="relative">
+ <Trophy className="size-14" />
+ </div>
+ </div>
+
+ <div className="flex flex-col gap-1.5">
+ <h3 className="line-clamp-1 text-sm font-semibold text-neutral-900">
+ {name}
+ </h3>
+
+ <div className="flex items-center space-x-2 text-sm text-neutral-500">
+ <CalendarDays className="size-4" />
+ <span>
+ {formatDate(startsAt, { month: "short" })}
+ {endsAt && (
+ <>
+ {" → "}
+ {formatDate(endsAt, { month: "short" })}
+ </>
+ )}
+ </span>
+ </div>
+
+ <div className="flex items-center space-x-2 text-sm text-neutral-700">
+ <Users className="size-4" />
+ <div>
+ <span className="font-medium">{completed}</span> of{" "}
+ <span className="font-medium">{total}</span> partners completed
+ </div>
+ </div>
+ </div>
+ </div>
+ </ProgramOverviewCard>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-list.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-list.tsx
new file mode 100644
index 0000000000..c9e0f7d821
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-list.tsx
@@ -0,0 +1,50 @@
+"use client";
+
+import useWorkspace from "@/lib/swr/use-workspace";
+import { BountyProps } from "@/lib/types";
+import { fetcher } from "@dub/utils";
+import useSWR from "swr";
+import { BountyCard } from "./bounty-card";
+
+// TODO:
+// Fix loading state
+// Fix error state
+// Fix no bounties state
+
+export function BountyList() {
+ const { id: workspaceId, defaultProgramId } = useWorkspace();
+
+ const {
+ data: bounties,
+ isLoading,
+ error,
+ } = useSWR<BountyProps[]>(
+ workspaceId && defaultProgramId
+ ? `/api/bounties?workspaceId=${workspaceId}&programId=${defaultProgramId}`
+ : null,
+ fetcher,
+ {
+ keepPreviousData: true,
+ },
+ );
+
+ if (isLoading) {
+ return <></>;
+ }
+
+ if (error) {
+ return <></>;
+ }
+
+ if (!bounties || bounties.length === 0) {
+ return <></>;
+ }
+
+ return (
+ <div className="grid grid-cols-1 gap-6 md:grid-cols-2 xl:grid-cols-3">
+ {bounties.map((bounty) => (
+ <BountyCard key={bounty.id} bounty={bounty} />
+ ))}
+ </div>
+ );
+}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx
index f95d6ce366..bb457946e4 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx
@@ -2,7 +2,7 @@
import { PageContent } from "@/ui/layout/page-content";
import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
-import { CommissionTable } from "../commissions/commission-table";
+import { BountyList } from "./bounty-list";
import { CreateBountyButton } from "./create-bounty-button";
export default function ProgramCommissions() {
@@ -17,7 +17,7 @@ export default function ProgramCommissions() {
controls={<CreateBountyButton />}
>
<PageWidthWrapper>
- <CommissionTable />
+ <BountyList />
</PageWidthWrapper>
</PageContent>
);
diff --git a/apps/web/lib/types.ts b/apps/web/lib/types.ts
index 32828f8cca..d81f424de2 100644
--- a/apps/web/lib/types.ts
+++ b/apps/web/lib/types.ts
@@ -87,6 +87,7 @@ import {
WebhookSchema,
} from "./zod/schemas/webhooks";
import { workspacePreferencesSchema } from "./zod/schemas/workspace-preferences";
+import { BountySchema } from "./zod/schemas/bounties";
export type LinkProps = Link;
@@ -513,3 +514,5 @@ export type RewardConditionsArray = z.infer<typeof rewardConditionsArraySchema>;
export type ClickEventTB = z.infer<typeof clickEventSchemaTB>;
export type LeadEventTB = z.infer<typeof leadEventSchemaTB>;
+
+export type BountyProps = z.infer<typeof BountySchema>;
diff --git a/apps/web/scripts/bounty.ts b/apps/web/scripts/bounty.ts
new file mode 100644
index 0000000000..46e991acc8
--- /dev/null
+++ b/apps/web/scripts/bounty.ts
@@ -0,0 +1,21 @@
+import { createId } from "@/lib/api/create-id";
+import { prisma } from "@dub/prisma";
+import "dotenv-flow/config";
+
+async function main() {
+ const bounty = await prisma.bounty.create({
+ data: {
+ id: createId({ prefix: "bounty_" }),
+ programId: "prog_1K21SX1XVES0B7PJCCSQ099ZF",
+ name: "Very long name for a bounty that will be truncated after certain length",
+ type: "submission",
+ startsAt: new Date(),
+ // endsAt: new Date(),
+ rewardAmount: 1000,
+ },
+ });
+
+ console.log(bounty);
+}
+
+main();