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.

Revert "Fix social metrics bounty flow - no draft state" (#3729)

Kiran K5b0bd2a24818
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/[bountyId]/bounty-submissions-table.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/[bountyId]/bounty-submissions-table.tsx
index bbeef8f9ed..2eaf573050 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/[bountyId]/bounty-submissions-table.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/[bountyId]/bounty-submissions-table.tsx
@@ -5,6 +5,7 @@ import {
getSubmissionPeriods,
} from "@/lib/bounty/periods";
import { BOUNTY_SUBMISSION_STATUS_BADGES } from "@/lib/bounty/submission-status";
+import { resolveBountyDetails } from "@/lib/bounty/utils";
import { PartnerBountyProps, PartnerBountySubmission } from "@/lib/types";
import { useBountySubmissionDetailsSheet } from "@/ui/partners/bounties/bounty-submission-details-sheet";
import { useClaimBountySheet } from "@/ui/partners/bounties/claim-bounty-sheet";
@@ -140,15 +141,18 @@ export function BountySubmissionsTable({
size: 98,
cell: ({ row: { original } }) => {
const { status } = original;
+ const bountyInfo = resolveBountyDetails(bounty);
const isExpired =
bounty.endsAt !== null && new Date(bounty.endsAt) < new Date();
- const isActionable = status === "notSubmitted" || status === "draft";
+ const isActionable = bountyInfo?.hasSocialMetrics
+ ? status === "notSubmitted"
+ : status === "notSubmitted" || status === "draft";
let buttonText = "Submit";
- if (status === "draft") {
+ if (status === "draft" && !bountyInfo?.hasSocialMetrics) {
buttonText = "Continue";
- } else if (["submitted", "approved", "rejected"].includes(status)) {
+ } else if (status !== "notSubmitted") {
buttonText = "View";
}
diff --git a/apps/web/lib/bounty/api/create-bounty-submission.ts b/apps/web/lib/bounty/api/create-bounty-submission.ts
index fb0425ec5c..879f28c371 100644
--- a/apps/web/lib/bounty/api/create-bounty-submission.ts
+++ b/apps/web/lib/bounty/api/create-bounty-submission.ts
@@ -231,19 +231,8 @@ export class BountySubmissionHandler {
if (existingSubmission) {
if (
- existingSubmission.reviewedAt ||
- existingSubmission.status === "approved" ||
- existingSubmission.status === "rejected"
- ) {
- throw new DubApiError({
- code: "conflict",
- message: `You already have a ${existingSubmission.status} submission for this period.`,
- });
- }
-
- if (
- existingSubmission.status !== "draft" &&
- !bountyInfo?.hasSocialMetrics
+ existingSubmission.status !== "draft" ||
+ bountyInfo?.hasSocialMetrics
) {
throw new DubApiError({
code: "conflict",
@@ -519,10 +508,9 @@ export class BountySubmissionHandler {
});
}
- // Note: We don't allow draft submission for social metrics bounties.
this.submissionData = {
...this.submissionData,
- status: "submitted",
+ status: "draft",
completedAt: null,
};
diff --git a/apps/web/scripts/misc/mark-bounties-submitted.ts b/apps/web/scripts/misc/mark-bounties-submitted.ts
deleted file mode 100644
index d03f22ef0b..0000000000
--- a/apps/web/scripts/misc/mark-bounties-submitted.ts
+++ /dev/null
@@ -1,40 +0,0 @@
-import { prisma } from "@dub/prisma";
-import "dotenv-flow/config";
-
-async function main() {
- const bountySubmissions = await prisma.bountySubmission.findMany({
- where: {
- status: "draft",
- socialMetricCount: {
- not: null,
- },
- },
- select: {
- id: true,
- status: true,
- socialMetricCount: true,
- },
- });
-
- console.log(
- `Found ${bountySubmissions.length} bounty submissions to mark as submitted.`,
- );
-
- console.table(bountySubmissions);
-
- const { count } = await prisma.bountySubmission.updateMany({
- where: {
- id: {
- in: bountySubmissions.map(({ id }) => id),
- },
- status: "draft",
- },
- data: {
- status: "submitted",
- },
- });
-
- console.log(`Marked ${count} bounty submissions as submitted.`);
-}
-
-main();