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.

Update upsert-draft-bounty-submissions.ts

Kiran Kb8b3b89f110d
diff --git a/apps/web/lib/bounty/api/upsert-draft-bounty-submissions.ts b/apps/web/lib/bounty/api/upsert-draft-bounty-submissions.ts
index 1d35f80e85..7c5c05968d 100644
--- a/apps/web/lib/bounty/api/upsert-draft-bounty-submissions.ts
+++ b/apps/web/lib/bounty/api/upsert-draft-bounty-submissions.ts
@@ -1,7 +1,7 @@
import { createId } from "@/lib/api/create-id";
import { awardBountyConditionSchema } from "@/lib/api/workflows/award-bounty/schema";
import { evaluateWorkflowConditions } from "@/lib/api/workflows/evaluate-workflow-conditions";
-import { BountyPerformanceScope, BountyType, Prisma } from "@prisma/client";
+import { Bounty, BountyPerformanceScope, Prisma } from "@prisma/client";
import * as z from "zod/v4";
type AwardBountyCondition = z.infer<typeof awardBountyConditionSchema>;
@@ -34,20 +34,17 @@ export function shouldUpsertDraftSubmissionsOnReopen({
endsAt,
archivedAt,
now = new Date(),
-}: {
- type: BountyType;
+}: Pick<Bounty, "type" | "startsAt" | "endsAt" | "archivedAt"> & {
performanceScope: BountyPerformanceScope | null;
previousEndsAt: Date | null;
- startsAt: Date;
- endsAt: Date | null;
- archivedAt: Date | null;
now?: Date;
}): boolean {
if (type !== "performance") return false;
if (performanceScope !== "lifetime") return false;
const wasExpired = previousEndsAt != null && previousEndsAt < now;
- const stillExpired = endsAt != null && endsAt < now && startsAt <= now;
+ const stillExpired =
+ endsAt != null && endsAt < now && startsAt != null && startsAt <= now;
const nowOrSoonActive = !archivedAt && !stillExpired;
return wasExpired && nowOrSoonActive;