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.

more bounty improvements

Steven Tey1353936da26d
diff --git a/apps/web/app/(ee)/api/bounties/route.ts b/apps/web/app/(ee)/api/bounties/route.ts
index 738476bbdf..74ae85f806 100644
--- a/apps/web/app/(ee)/api/bounties/route.ts
+++ b/apps/web/app/(ee)/api/bounties/route.ts
@@ -73,7 +73,13 @@ export const GET = withWorkspace(
},
_count: {
select: {
- submissions: true,
+ submissions: {
+ where: {
+ status: {
+ in: ["submitted", "approved"],
+ },
+ },
+ },
},
},
},
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/partner-bounty-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/partner-bounty-card.tsx
index 27c0fed9d3..38152aabc3 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/partner-bounty-card.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/partner-bounty-card.tsx
@@ -119,19 +119,9 @@ function renderSubmissionStatus({
case "submitted":
return (
<StatusBadge variant="new" icon={null}>
- {bounty.type === "performance" ? (
- <>
- Completed{" "}
- {submission.completedAt &&
- formatDate(submission.completedAt, { month: "short" })}
- </>
- ) : (
- <>
- Submitted{" "}
- {submission.createdAt &&
- formatDate(submission.createdAt, { month: "short" })}
- </>
- )}
+ {bounty.type === "performance" ? "Completed" : "Submitted"}{" "}
+ {submission.completedAt &&
+ formatDate(submission.completedAt, { month: "short" })}
</StatusBadge>
);
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx
index 1006be7391..67a782a94a 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx
@@ -22,7 +22,9 @@ export function BountyInfo() {
});
const totalSubmissions = useMemo(() => {
- return submissionsCount?.reduce((acc, curr) => acc + curr.count, 0);
+ return submissionsCount
+ ?.filter((s) => s.status === "submitted" || s.status === "approved")
+ ?.reduce((acc, curr) => acc + curr.count, 0);
}, [submissionsCount]);
if (loading) {
@@ -76,7 +78,8 @@ export function BountyInfo() {
<span className="font-medium text-neutral-700">
{nFormatter(bounty.partnersCount, { full: true })}
</span>{" "}
- {pluralize("partner", bounty.partnersCount ?? 0)} submitted
+ {pluralize("partner", bounty.partnersCount ?? 0)}{" "}
+ {bounty.type === "performance" ? "completed" : "submitted"}
</div>
</div>
</div>
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
index 4e012a313f..663abec290 100644
--- 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
@@ -51,6 +51,10 @@ export function BountyCard({ bounty }: { bounty: BountyListProps }) {
{/* {bounty.pendingSubmissions > 0 ? (
<SubmissionsCountBadge count={bounty.pendingSubmissions} />
) : null} */}
+
+ {bounty.endsAt && new Date(bounty.endsAt) < new Date() ? (
+ <BountyEndedBadge endsAt={bounty.endsAt} />
+ ) : null}
</div>
<div className="flex flex-col gap-1.5">
@@ -94,7 +98,8 @@ export function BountyCard({ bounty }: { bounty: BountyListProps }) {
<span className="text-content-default">
{nFormatter(totalPartnersForBounty, { full: true })}
</span>{" "}
- {pluralize("partner", totalPartnersForBounty)} submitted
+ {pluralize("partner", totalPartnersForBounty)}{" "}
+ {bounty.type === "performance" ? "completed" : "submitted"}
</div>
</div>
</div>
@@ -103,6 +108,16 @@ export function BountyCard({ bounty }: { bounty: BountyListProps }) {
);
}
+function BountyEndedBadge({ endsAt }: { endsAt: Date }) {
+ return (
+ <div className="absolute left-2 top-2 z-10">
+ <div className="flex h-5 items-center gap-1 rounded-md bg-neutral-200 px-2 py-1 text-xs font-semibold text-neutral-600">
+ Ended {formatDate(endsAt, { month: "short" })}
+ </div>
+ </div>
+ );
+}
+
function SubmissionsCountBadge({ count }: { count: number }) {
return (
<div className="absolute left-2 top-2 z-10">
diff --git a/apps/web/scripts/migrations/backfill-submission-completedat.ts b/apps/web/scripts/migrations/backfill-submission-completedat.ts
new file mode 100644
index 0000000000..749f27995c
--- /dev/null
+++ b/apps/web/scripts/migrations/backfill-submission-completedat.ts
@@ -0,0 +1,27 @@
+import { prisma } from "@dub/prisma";
+import { ACME_PROGRAM_ID } from "@dub/utils";
+import "dotenv-flow/config";
+
+async function main() {
+ const completedSubmissions = await prisma.bountySubmission.findMany({
+ where: {
+ status: { in: ["submitted", "approved"] },
+ programId: ACME_PROGRAM_ID,
+ completedAt: null,
+ },
+ });
+
+ console.log(`Found ${completedSubmissions.length} submissions to backfill`);
+
+ for (const submission of completedSubmissions) {
+ const res = await prisma.bountySubmission.update({
+ where: { id: submission.id },
+ data: { completedAt: submission.updatedAt },
+ });
+ console.log(
+ `Updated submission ${submission.id} to completedAt: ${res.completedAt}`,
+ );
+ }
+}
+
+main();
diff --git a/apps/web/ui/partners/bounties/claim-bounty-modal.tsx b/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
index 1ff86e41a0..07f04ddcb5 100644
--- a/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
+++ b/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
@@ -336,17 +336,15 @@ function ClaimBountyModalContent({ bounty }: ClaimBountyModalProps) {
}
>
{submission.status === "submitted" ? (
- bounty.type === "performance" ? (
- <>
- Completed{" "}
- {submission.completedAt &&
- formatDate(submission.completedAt, {
- month: "short",
- })}
- </>
- ) : (
- `Submitted ${formatDate(submission.createdAt, { month: "short" })}`
- )
+ <>
+ {bounty.type === "performance"
+ ? "Completed"
+ : "Submitted"}{" "}
+ {submission.completedAt &&
+ formatDate(submission.completedAt, {
+ month: "short",
+ })}
+ </>
) : submission.status === "approved" ? (
<>
Confirmed{" "}