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 the submission upload URL

Kiran K1539fb84b57d
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/bounty-card.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/bounty-card.tsx
index b584ea3151..8267d23472 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/bounty-card.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/bounty-card.tsx
@@ -47,7 +47,7 @@ export function BountyCard({ bounty }: { bounty: BountyWithSubmissionsProps }) {
<div className="flex h-7 w-fit items-center gap-1 rounded-lg bg-neutral-100 px-2.5">
<CircleCheckFill className="size-3 text-green-600" />
<span className="text-content-default text-xs font-medium">
- Completed
+ Completed{" "}
{submission.reviewedAt &&
formatDate(submission.reviewedAt, { month: "short" })}
</span>
@@ -55,7 +55,7 @@ export function BountyCard({ bounty }: { bounty: BountyWithSubmissionsProps }) {
) : (
<div className="flex h-7 w-fit items-center gap-1 rounded-lg bg-orange-100 px-2.5">
<span className="text-xs font-medium text-orange-600">
- Submitted
+ Submitted{" "}
{submission.createdAt &&
formatDate(submission.createdAt, { month: "short" })}
</span>
diff --git a/apps/web/lib/actions/partners/upload-bounty-submission-file.ts b/apps/web/lib/actions/partners/upload-bounty-submission-file.ts
index 305a4926e5..59f7f6d09f 100644
--- a/apps/web/lib/actions/partners/upload-bounty-submission-file.ts
+++ b/apps/web/lib/actions/partners/upload-bounty-submission-file.ts
@@ -1,5 +1,6 @@
"use server";
+import { getBountyOrThrow } from "@/lib/api/bounties/get-bounty-or-throw";
import { getProgramEnrollmentOrThrow } from "@/lib/api/programs/get-program-enrollment-or-throw";
import { storage } from "@/lib/storage";
import { nanoid, R2_URL } from "@dub/utils";
@@ -8,24 +9,36 @@ import { authPartnerActionClient } from "../safe-action";
const schema = z.object({
programId: z.string(),
+ bountyId: z.string(),
});
export const uploadBountySubmissionFileAction = authPartnerActionClient
.schema(schema)
.action(async ({ ctx, parsedInput }) => {
const { partner } = ctx;
+ const { programId, bountyId } = parsedInput;
+
+ // TODO:
+ // Limit the number of file a partner can upload for a bounty
+ // Allow upload only if there is a submissionRequirements exists for the given bounty (AND type submissions only)
+ // Rate limit the number of uploads per partner per bounty
+ // Prevent submission if there is an existing submission for the partner
+
const { program } = await getProgramEnrollmentOrThrow({
partnerId: partner.id,
- programId: parsedInput.programId,
+ programId,
});
- try {
- const key = `programs/${program.id}/bounties/submissions/${partner.id}/image_${nanoid(7)}`;
+ const bounty = await getBountyOrThrow({
+ bountyId,
+ programId,
+ });
+ try {
+ const key = `programs/${program.id}/bounties/${bounty.id}/submissions/${partner.id}/${nanoid(7)}`;
const signedUrl = await storage.getSignedUrl(key);
return {
- key,
signedUrl,
destinationUrl: `${R2_URL}/${key}`,
};
diff --git a/apps/web/ui/partners/bounties/claim-bounty-modal.tsx b/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
index e72a380be7..9b651282ea 100644
--- a/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
+++ b/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
@@ -50,6 +50,7 @@ function ClaimBountyModalContent({
// TODO: Partners upload URL
const result = await executeAsync({
programId: programEnrollment.programId,
+ bountyId: bounty.id,
});
if (!result?.data) throw new Error("Failed to get signed upload URL");