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.

pending → submitted, improved modal

Steven Tey08e35cceda7f
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 eddc5a4ef5..ead86d8fa2 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
@@ -117,9 +117,9 @@ function renderSubmissionStatus({
</div>
);
- case "pending":
+ case "submitted":
return (
- <StatusBadge variant="pending" icon={null}>
+ <StatusBadge variant="new" icon={null}>
Submitted{" "}
{submission.createdAt &&
formatDate(submission.createdAt, { month: "short" })}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-status-badges.ts b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-status-badges.ts
index 7df461583f..8a80f4e159 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-status-badges.ts
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-status-badges.ts
@@ -1,16 +1,21 @@
-import { CircleCheck, CircleHalfDottedCheck, CircleXmark } from "@dub/ui/icons";
+import {
+ CircleCheck,
+ CircleHalfDottedCheck,
+ CircleHalfDottedClock,
+ CircleXmark,
+} from "@dub/ui/icons";
export const BOUNTY_SUBMISSION_STATUS_BADGES = {
draft: {
label: "In progress",
- variant: "new",
+ variant: "pending",
icon: CircleHalfDottedCheck,
iconClassName: "text-blue-600",
},
- pending: {
- label: "Pending",
- variant: "pending",
- icon: CircleHalfDottedCheck,
+ submitted: {
+ label: "Submitted",
+ variant: "new",
+ icon: CircleHalfDottedClock,
iconClassName: "text-orange-600",
},
approved: {
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
index e6517da6ad..3993cdc275 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/settings/billing/plan-usage.tsx
@@ -200,31 +200,29 @@ export default function PlanUsage() {
href={`/${slug}/settings/people`}
/>
</div>
- {defaultProgramId && (
- <div className="grid grid-cols-1 gap-[1px] overflow-hidden rounded-b-lg bg-neutral-200 md:grid-cols-3">
- <UsageCategory
- title="Partners"
- icon={Users6}
- usage={partnersCount}
- usageLimit={INFINITY_NUMBER}
- href={`/${slug}/program/partners`}
- />
- <UsageCategory
- title="Partner payouts"
- icon={CreditCard}
- usage={payoutsUsage}
- usageLimit={payoutsLimit}
- unit="$"
- href={`/${slug}/program/payouts`}
- />
- <UsageCategory
- title="Payout fees"
- icon={CirclePercentage}
- usage={plan && payoutFee && `${payoutFee * 100}%`}
- href="https://dub.co/help/article/partner-payouts#payout-fees-and-timing"
- />
- </div>
- )}
+ <div className="grid grid-cols-1 gap-[1px] overflow-hidden rounded-b-lg bg-neutral-200 md:grid-cols-3">
+ <UsageCategory
+ title="Partners"
+ icon={Users6}
+ usage={partnersCount}
+ usageLimit={INFINITY_NUMBER}
+ href={`/${slug}/program/partners`}
+ />
+ <UsageCategory
+ title="Partner payouts"
+ icon={CreditCard}
+ usage={payoutsUsage}
+ usageLimit={payoutsLimit}
+ unit="$"
+ href={`/${slug}/program/payouts`}
+ />
+ <UsageCategory
+ title="Payout fees"
+ icon={CirclePercentage}
+ usage={plan && payoutFee && `${payoutFee * 100}%`}
+ href="https://dub.co/help/article/partner-payouts#payout-fees-and-timing"
+ />
+ </div>
</div>
</div>
);
diff --git a/apps/web/lib/actions/partners/create-bounty-submission.ts b/apps/web/lib/actions/partners/create-bounty-submission.ts
index 08487605d2..47d5ac2702 100644
--- a/apps/web/lib/actions/partners/create-bounty-submission.ts
+++ b/apps/web/lib/actions/partners/create-bounty-submission.ts
@@ -12,7 +12,7 @@ import {
import { sendEmail } from "@dub/email";
import { resend } from "@dub/email/resend";
import { VARIANT_TO_FROM_MAP } from "@dub/email/resend/constants";
-import BountyPendingReview from "@dub/email/templates/bounty-pending-review";
+import NewBountySubmission from "@dub/email/templates/bounty-new-submission";
import BountySubmitted from "@dub/email/templates/bounty-submitted";
import { prisma } from "@dub/prisma";
import { BountySubmission, Role } from "@prisma/client";
@@ -143,7 +143,7 @@ export const createBountySubmissionAction = authPartnerActionClient
description,
...(requireImage && { files }),
...(requireUrl && { urls }),
- status: isDraft ? "draft" : "pending",
+ status: isDraft ? "draft" : "submitted",
},
});
}
@@ -181,8 +181,8 @@ export const createBountySubmissionAction = authPartnerActionClient
users.map((user) => ({
from: VARIANT_TO_FROM_MAP.notifications,
to: user.email,
- subject: "Pending bounty review",
- react: BountyPendingReview({
+ subject: "New bounty submission",
+ react: NewBountySubmission({
email: user.email,
workspace: {
slug: workspace.slug,
diff --git a/apps/web/ui/partners/bounties/claim-bounty-modal.tsx b/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
index cf36c2b2b2..8bcaa7261b 100644
--- a/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
+++ b/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
@@ -9,6 +9,7 @@ import {
MAX_SUBMISSION_URLS,
REJECT_BOUNTY_SUBMISSION_REASONS,
} from "@/lib/zod/schemas/bounties";
+import { useConfirmModal } from "@/ui/modals/confirm-modal";
import { X } from "@/ui/shared/icons";
import {
AnimatedSizeContainer,
@@ -21,7 +22,6 @@ import {
StatusBadge,
Trash,
buttonVariants,
- useEnterSubmit,
useRouterStuff,
} from "@dub/ui";
import { cn, formatDate, getPrettyUrl } from "@dub/utils";
@@ -60,7 +60,6 @@ function ClaimBountyModalContent({
}: ClaimBountyModalProps) {
const { programEnrollment } = useProgramEnrollment();
- const { handleKeyDown } = useEnterSubmit();
const [success, setSuccess] = useState(false);
const [isFormOpen, setIsFormOpen] = useState(false);
const [isDraft, setIsDraft] = useState<boolean | null>(null);
@@ -142,459 +141,502 @@ function ClaimBountyModalContent({
const urlRequired = bounty.submissionRequirements?.includes("url");
const fileUploading = files.some(({ uploading }) => uploading);
- return (
- <form
- onSubmit={async (e) => {
- e.preventDefault();
- if (!programEnrollment) return;
-
- // Determine which button was clicked
- const submitter = (e.nativeEvent as SubmitEvent)
- .submitter as HTMLButtonElement;
-
- const isDraft = submitter?.name === "draft";
-
- setIsDraft(isDraft);
-
- const finalFiles = files
- .filter(({ url }) => url)
- .map(({ file, url }) => ({
- url: url!,
- fileName: file?.name || "File",
- size: file?.size || 0,
- }));
-
- const finalUrls = urls.map(({ url }) => url).filter(Boolean);
-
- try {
- // Check the submission requirements are met for non-draft submissions
- if (!isDraft) {
- if (imageRequired && finalFiles.length === 0) {
- throw new Error("You must upload at least one image.");
- }
-
- if (urlRequired && finalUrls.length === 0) {
- throw new Error("You must provide at least one URL.");
- }
- }
+ // Confirmation modal for final submission
+ const { confirmModal, setShowConfirmModal } = useConfirmModal({
+ title: "Confirm submission",
+ description: (
+ <div className="space-y-2">
+ <p>
+ Are you sure you want to submit this bounty? Once submitted, you won't
+ be able to make any further changes.
+ </p>
+ <p>
+ If you need to make changes later, you can save your progress as a
+ draft instead.
+ </p>
+ </div>
+ ),
+ confirmText: "Confirm submission",
+ onConfirm: () => handleSubmission({ isDraft: false }),
+ });
- const result = await createSubmission({
- programId: programEnrollment.programId,
- bountyId: bounty.id,
- files: finalFiles,
- urls: finalUrls,
- description,
- ...(isDraft && { isDraft }),
- });
-
- if (!result?.data?.success) {
- throw new Error(
- isDraft
- ? "Failed to save progress."
- : "Failed to create submission.",
- );
- }
+ // Function to handle the actual submission
+ const handleSubmission = async ({ isDraft }: { isDraft: boolean }) => {
+ if (!programEnrollment) return;
+
+ setIsDraft(isDraft);
- toast.success(
- isDraft ? "Bounty progress saved." : "Bounty submitted.",
- );
-
- setSuccess(true);
- await mutatePrefix(
- `/api/partner-profile/programs/${programEnrollment.program.slug}/bounties`,
- );
- } catch (error) {
- toast.error(
- error instanceof Error
- ? error.message
- : "Failed to create submission. Please try again.",
- );
+ const finalFiles = files
+ .filter(({ url }) => url)
+ .map(({ file, url }) => ({
+ url: url!,
+ fileName: file?.name || "File",
+ size: file?.size || 0,
+ }));
+
+ const finalUrls = urls.map(({ url }) => url).filter(Boolean);
+
+ try {
+ // Check the submission requirements are met for non-draft submissions
+ if (!isDraft) {
+ setShowConfirmModal(false);
+ if (imageRequired && finalFiles.length === 0) {
+ throw new Error("You must upload at least one image.");
}
- }}
- className="scrollbar-hide max-h-[calc(100dvh-50px)] overflow-y-auto"
- >
- <div className="flex h-[132px] items-center justify-center bg-neutral-100 py-3">
- <div className="relative size-full">
- <BountyThumbnailImage bounty={bounty} />
- </div>
- </div>
- <AnimatedSizeContainer
- height={isFormOpen}
- transition={{ duration: 0.15, ease: "easeInOut" }}
+ if (urlRequired && finalUrls.length === 0) {
+ throw new Error("You must provide at least one URL.");
+ }
+ }
+
+ const result = await createSubmission({
+ programId: programEnrollment.programId,
+ bountyId: bounty.id,
+ files: finalFiles,
+ urls: finalUrls,
+ description,
+ ...(isDraft && { isDraft }),
+ });
+
+ if (!result?.data?.success) {
+ throw new Error(
+ isDraft ? "Failed to save progress." : "Failed to create submission.",
+ );
+ }
+
+ toast.success(isDraft ? "Bounty progress saved." : "Bounty submitted.");
+
+ setSuccess(true);
+ await mutatePrefix(
+ `/api/partner-profile/programs/${programEnrollment.program.slug}/bounties`,
+ );
+ } catch (error) {
+ toast.error(
+ error instanceof Error
+ ? error.message
+ : "Failed to create submission. Please try again.",
+ );
+ }
+ };
+
+ return (
+ <>
+ {confirmModal}
+ <form
+ onSubmit={async (e) => {
+ e.preventDefault();
+ if (!programEnrollment) return;
+
+ // Determine which button was clicked
+ const submitter = (e.nativeEvent as SubmitEvent)
+ .submitter as HTMLButtonElement;
+
+ const isDraft = submitter?.name === "draft";
+
+ if (isDraft) {
+ // Handle draft save directly
+ await handleSubmission({ isDraft: true });
+ } else {
+ // Show confirmation modal for final submission
+ setShowConfirmModal(true);
+ }
+ }}
>
- {success ? (
- <div className="mx-auto flex max-w-sm flex-col items-center gap-1 p-6 text-center max-sm:px-4">
- {isDraft ? (
- <>
- <span className="text-content-emphasis text-base font-semibold">
- Progress saved successfully.
- </span>
- <p className="text-content-subtle text-balance text-sm font-medium">
- You can continue working on your submission later.
- </p>
- </>
- ) : (
- <>
- <span className="text-content-emphasis text-base font-semibold">
- Congratulations! You've successfully submitted your bounty.
- </span>
- <p className="text-content-subtle text-balance text-sm font-medium">
- We'll let you know when your bounty has been reviewed.
- </p>
- </>
- )}
+ <div className="scrollbar-hide max-h-[calc(100dvh-150px)] overflow-y-auto">
+ <div className="flex h-[132px] items-center justify-center bg-neutral-100 py-3">
+ <div className="relative size-full">
+ <BountyThumbnailImage bounty={bounty} />
+ </div>
</div>
- ) : (
- <>
- <div className="flex flex-col gap-1 p-6 max-sm:px-4">
- <span className="text-content-emphasis truncate text-sm font-semibold">
- {bounty.name}
- </span>
-
- <div className="text-content-subtle flex items-center gap-2 text-sm font-medium">
- <Calendar6 className="size-3.5" />
- <span>
- {bounty.endsAt ? (
- <>Ends {formatDate(bounty.endsAt, { month: "short" })}</>
- ) : (
- "No end date"
- )}
- </span>
- </div>
- <div className="text-content-subtle flex items-center gap-2 text-sm font-medium">
- <Gift className="size-3.5 shrink-0" />
- <span className="truncate">
- {getBountyRewardDescription(bounty)}
- </span>
+ <AnimatedSizeContainer
+ height={isFormOpen}
+ transition={{ duration: 0.15, ease: "easeInOut" }}
+ >
+ {success ? (
+ <div className="mx-auto flex max-w-sm flex-col items-center gap-1 p-6 text-center max-sm:px-4">
+ {isDraft ? (
+ <>
+ <span className="text-content-emphasis text-base font-semibold">
+ Progress saved successfully.
+ </span>
+ <p className="text-content-subtle text-balance text-sm font-medium">
+ You can continue working on your submission later.
+ </p>
+ </>
+ ) : (
+ <>
+ <span className="text-content-emphasis text-base font-semibold">
+ Congratulations! You've successfully submitted your
+ bounty.
+ </span>
+ <p className="text-content-subtle text-balance text-sm font-medium">
+ We'll let you know when your bounty has been reviewed.
+ </p>
+ </>
+ )}
</div>
+ ) : (
+ <>
+ <div className="flex flex-col gap-1 p-6 max-sm:px-4">
+ <span className="text-content-emphasis truncate text-sm font-semibold">
+ {bounty.name}
+ </span>
+
+ <div className="text-content-subtle flex items-center gap-2 text-sm font-medium">
+ <Calendar6 className="size-3.5" />
+ <span>
+ {bounty.endsAt ? (
+ <>
+ Ends {formatDate(bounty.endsAt, { month: "short" })}
+ </>
+ ) : (
+ "No end date"
+ )}
+ </span>
+ </div>
- {submission ? (
- <div className="mt-3 grid gap-2">
- <div className="flex items-center gap-2">
- {submission.status === "approved" && (
- <Link
- href={`/programs/${programEnrollment?.program.slug}/earnings?type=custom`}
- target="_blank"
- className={cn(
- buttonVariants({ variant: "primary" }),
- "flex h-7 w-fit items-center whitespace-nowrap rounded-lg border px-2.5 text-sm",
- )}
- >
- View earnings
- </Link>
- )}
- {submission.status !== "draft" && (
- <StatusBadge
- className="rounded-lg py-1.5"
- variant={
- submission.status === "pending"
- ? "pending"
- : submission.status === "approved"
- ? "success"
- : "error"
- }
- icon={
- submission.status === "approved" ? undefined : null
- }
- >
- {submission.status === "pending" ? (
- `Submitted ${formatDate(submission.createdAt, { month: "short" })}`
- ) : submission.status === "approved" ? (
- bounty.type === "performance" ? (
- <>
- Completed{" "}
- {formatDate(submission.createdAt, {
- month: "short",
- })}
- </>
- ) : (
- <>
- Confirmed{" "}
- {submission.reviewedAt &&
- formatDate(submission.reviewedAt, {
- month: "short",
- })}
- </>
- )
- ) : (
- "Rejected"
- )}
- </StatusBadge>
- )}
+ <div className="text-content-subtle flex items-center gap-2 text-sm font-medium">
+ <Gift className="size-3.5 shrink-0" />
+ <span className="truncate">
+ {getBountyRewardDescription(bounty)}
+ </span>
</div>
- {/* Rejection details for rejected submissions */}
- {submission.status === "rejected" && (
- <div className="mt-3 flex flex-col gap-2 rounded-lg border border-red-200 bg-red-50 p-4">
- <div className="flex gap-1">
- <span className="text-sm font-medium text-red-900">
- Rejection reason:
- </span>
- <span className="text-sm text-red-800">
- {submission.rejectionReason &&
- REJECT_BOUNTY_SUBMISSION_REASONS[
- submission.rejectionReason as keyof typeof REJECT_BOUNTY_SUBMISSION_REASONS
- ]}
- </span>
- </div>
- {submission.rejectionNote && (
- <div className="mt-1">
- <span className="text-sm font-medium text-red-900">
- Note:
- </span>
- <Linkify
- as="p"
- options={{
- target: "_blank",
- rel: "noopener noreferrer nofollow",
- format: (href) => getPrettyUrl(href),
- className:
- "underline underline-offset-4 text-red-400 hover:text-red-700",
- }}
- className="mt-1 whitespace-pre-wrap text-sm text-red-800"
+ {submission ? (
+ <div className="mt-3 grid gap-2">
+ <div className="flex items-center gap-2">
+ {submission.status === "approved" && (
+ <Link
+ href={`/programs/${programEnrollment?.program.slug}/earnings?type=custom`}
+ target="_blank"
+ className={cn(
+ buttonVariants({ variant: "primary" }),
+ "flex h-7 w-fit items-center whitespace-nowrap rounded-lg border px-2.5 text-sm",
+ )}
>
- {submission.rejectionNote}
- </Linkify>
+ View earnings
+ </Link>
+ )}
+ {submission.status !== "draft" && (
+ <StatusBadge
+ className="rounded-lg py-1.5"
+ variant={
+ submission.status === "submitted"
+ ? "new"
+ : submission.status === "approved"
+ ? "success"
+ : "error"
+ }
+ icon={
+ submission.status === "approved"
+ ? undefined
+ : null
+ }
+ >
+ {submission.status === "submitted" ? (
+ `Submitted ${formatDate(submission.createdAt, { month: "short" })}`
+ ) : submission.status === "approved" ? (
+ bounty.type === "performance" ? (
+ <>
+ Completed{" "}
+ {formatDate(submission.createdAt, {
+ month: "short",
+ })}
+ </>
+ ) : (
+ <>
+ Confirmed{" "}
+ {submission.reviewedAt &&
+ formatDate(submission.reviewedAt, {
+ month: "short",
+ })}
+ </>
+ )
+ ) : (
+ "Rejected"
+ )}
+ </StatusBadge>
+ )}
+ </div>
+
+ {/* Rejection details for rejected submissions */}
+ {submission.status === "rejected" && (
+ <div className="mt-3 flex flex-col gap-2 rounded-lg border border-red-200 bg-red-50 p-4">
+ <div className="flex gap-1">
+ <span className="text-sm font-medium text-red-900">
+ Rejection reason:
+ </span>
+ <span className="text-sm text-red-800">
+ {submission.rejectionReason &&
+ REJECT_BOUNTY_SUBMISSION_REASONS[
+ submission.rejectionReason as keyof typeof REJECT_BOUNTY_SUBMISSION_REASONS
+ ]}
+ </span>
+ </div>
+ {submission.rejectionNote && (
+ <div className="mt-1">
+ <span className="text-sm font-medium text-red-900">
+ Note:
+ </span>
+ <Linkify
+ as="p"
+ options={{
+ target: "_blank",
+ rel: "noopener noreferrer nofollow",
+ format: (href) => getPrettyUrl(href),
+ className:
+ "underline underline-offset-4 text-red-400 hover:text-red-700",
+ }}
+ className="mt-1 whitespace-pre-wrap text-sm text-red-800"
+ >
+ {submission.rejectionNote}
+ </Linkify>
+ </div>
+ )}
</div>
)}
</div>
+ ) : (
+ bounty.type === "performance" && (
+ <div className="mt-5">
+ <BountyPerformance bounty={bounty} />
+ </div>
+ )
)}
</div>
- ) : (
- bounty.type === "performance" && (
- <div className="mt-5">
- <BountyPerformance bounty={bounty} />
- </div>
- )
- )}
- </div>
- {bounty.description && (
- <div className="border-border-subtle flex flex-col gap-2 border-t p-6 text-sm max-sm:px-4">
- <span className="text-content-emphasis font-semibold">
- Details
- </span>
- <p className="text-content-subtle whitespace-pre-wrap font-medium">
- {bounty.description}
- </p>
- </div>
- )}
+ {bounty.description && (
+ <div className="border-border-subtle flex flex-col gap-2 border-t p-6 text-sm max-sm:px-4">
+ <span className="text-content-emphasis font-semibold">
+ Details
+ </span>
+ <p className="text-content-subtle whitespace-pre-wrap font-medium">
+ {bounty.description}
+ </p>
+ </div>
+ )}
- {/* Form */}
- <motion.div
- initial={false}
- animate={{ height: isFormOpen ? "auto" : 0 }}
- transition={{ duration: 0.15 }}
- className={cn(
- "overflow-hidden transition-opacity",
- !isFormOpen && "opacity-0",
- )}
- >
- <div className="border-border-subtle flex flex-col gap-5 border-t p-6 max-sm:px-4">
- {/* Files */}
- {imageRequired && (
- <div>
- <label
- htmlFor="slug"
- className="flex items-center space-x-2"
- >
- <h2 className="text-sm font-medium text-neutral-900">
- Files
- {imageRequired && " (at least 1 required)"}
- </h2>
- </label>
- <div
- className={cn(
- "mt-2 flex h-12 items-center gap-2 transition-[height]",
- files.length === 0 && "h-24",
- )}
- >
- {files.map((file, idx) => (
+ {/* Form */}
+ <motion.div
+ initial={false}
+ animate={{ height: isFormOpen ? "auto" : 0 }}
+ transition={{ duration: 0.15 }}
+ className={cn(
+ "overflow-hidden transition-opacity",
+ !isFormOpen && "opacity-0",
+ )}
+ >
+ <div className="border-border-subtle flex flex-col gap-5 border-t p-6 max-sm:px-4">
+ {/* Files */}
+ {imageRequired && (
+ <div>
+ <label
+ htmlFor="slug"
+ className="flex items-center space-x-2"
+ >
+ <h2 className="text-sm font-medium text-neutral-900">
+ Files
+ {imageRequired && " (at least 1 required)"}
+ </h2>
+ </label>
<div
- key={file.id}
- className="border-border-subtle group relative flex aspect-square h-full items-center justify-center rounded-md border bg-white"
+ className={cn(
+ "mt-2 flex h-12 items-center gap-2 transition-[height]",
+ files.length === 0 && "h-24",
+ )}
>
- {file.uploading ? (
- <LoadingSpinner className="size-4" />
- ) : (
- <div className="relative size-full overflow-hidden rounded-md">
- <img src={file.url} alt="object-cover" />
+ {files.map((file, idx) => (
+ <div
+ key={file.id}
+ className="border-border-subtle group relative flex aspect-square h-full items-center justify-center rounded-md border bg-white"
+ >
+ {file.uploading ? (
+ <LoadingSpinner className="size-4" />
+ ) : (
+ <div className="relative size-full overflow-hidden rounded-md">
+ <img src={file.url} alt="object-cover" />
+ </div>
+ )}
+ <span className="sr-only">
+ {file.file?.name || `File ${idx + 1}`}
+ </span>
+ <button
+ type="button"
+ className={cn(
+ "absolute right-0 top-0 flex size-[1.125rem] -translate-y-1/2 translate-x-1/2 items-center justify-center",
+ "rounded-full border border-neutral-200 bg-white shadow-sm hover:bg-neutral-50 active:scale-95",
+ "scale-50 opacity-0 transition-[background-color,transform,opacity] group-hover:scale-100 group-hover:opacity-100",
+ )}
+ onClick={() => {
+ setFiles((prev) =>
+ prev.filter((s) => s.id !== file.id),
+ );
+ }}
+ >
+ <X className="size-2.5 text-neutral-400" />
+ </button>
</div>
- )}
- <span className="sr-only">
- {file.file?.name || `File ${idx + 1}`}
- </span>
- <button
- type="button"
+ ))}
+
+ <FileUpload
+ accept="images"
className={cn(
- "absolute right-0 top-0 flex size-[1.125rem] -translate-y-1/2 translate-x-1/2 items-center justify-center",
- "rounded-full border border-neutral-200 bg-white shadow-sm hover:bg-neutral-50 active:scale-95",
- "scale-50 opacity-0 transition-[background-color,transform,opacity] group-hover:scale-100 group-hover:opacity-100",
+ "border-border-subtle h-full w-auto rounded-md border",
+ files.length > 0
+ ? "aspect-square"
+ : "aspect-[unset] w-full",
)}
- onClick={() => {
- setFiles((prev) =>
- prev.filter((s) => s.id !== file.id),
- );
- }}
- >
- <X className="size-2.5 text-neutral-400" />
- </button>
- </div>
- ))}
-
- <FileUpload
- accept="images"
- className={cn(
- "border-border-subtle h-full w-auto rounded-md border",
- files.length > 0
- ? "aspect-square"
- : "aspect-[unset] w-full",
- )}
- iconClassName="size-5 shrink-0"
- variant="plain"
- content={
- files.length > 0
- ? null
- : "JPG or PNG, max size of 5MB"
- }
- onChange={async ({ file }) => await handleUpload(file)}
- disabled={files.length >= MAX_SUBMISSION_FILES}
- />
- </div>
- </div>
- )}
-
- {/* URLs */}
- {urlRequired && (
- <div>
- <label
- htmlFor="slug"
- className="flex items-center space-x-2"
- >
- <h2 className="text-sm font-medium text-neutral-900">
- URLs
- {urlRequired && " (at least 1 required)"}
- </h2>
- </label>
- <div className={cn("mt-2 flex flex-col gap-2")}>
- {urls.map(({ id, url }, idx) => (
- <div key={id} className="flex items-center gap-2">
- <input
- type="url"
- placeholder="https://"
- value={url}
- onChange={(e) =>
- setUrls((prev) =>
- prev.map((u) =>
- u.id === id
- ? { ...u, url: e.target.value }
- : u,
- ),
- )
+ iconClassName="size-5 shrink-0"
+ variant="plain"
+ content={
+ files.length > 0
+ ? null
+ : "JPG or PNG, max size of 5MB"
}
- className="block h-10 w-full rounded-md border-neutral-300 px-3 py-2 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"
+ onChange={async ({ file }) =>
+ await handleUpload(file)
+ }
+ disabled={files.length >= MAX_SUBMISSION_FILES}
/>
- {urls.length > 1 && (
+ </div>
+ </div>
+ )}
+
+ {/* URLs */}
+ {urlRequired && (
+ <div>
+ <label
+ htmlFor="slug"
+ className="flex items-center space-x-2"
+ >
+ <h2 className="text-sm font-medium text-neutral-900">
+ URLs
+ {urlRequired && " (at least 1 required)"}
+ </h2>
+ </label>
+ <div className={cn("mt-2 flex flex-col gap-2")}>
+ {urls.map(({ id, url }, idx) => (
+ <div key={id} className="flex items-center gap-2">
+ <input
+ type="url"
+ placeholder="https://"
+ value={url}
+ onChange={(e) =>
+ setUrls((prev) =>
+ prev.map((u) =>
+ u.id === id
+ ? { ...u, url: e.target.value }
+ : u,
+ ),
+ )
+ }
+ className="block h-10 w-full rounded-md border-neutral-300 px-3 py-2 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm"
+ />
+ {urls.length > 1 && (
+ <Button
+ variant="outline"
+ icon={<Trash className="size-4" />}
+ className="w-10 shrink-0 bg-red-50 p-0 text-red-700 hover:bg-red-100"
+ onClick={() =>
+ setUrls((prev) =>
+ prev.filter((s) => s.id !== id),
+ )
+ }
+ />
+ )}
+ </div>
+ ))}
+ {urls.length < MAX_SUBMISSION_URLS && (
<Button
- variant="outline"
- icon={<Trash className="size-4" />}
- className="w-10 shrink-0 bg-red-50 p-0 text-red-700 hover:bg-red-100"
+ variant="secondary"
+ text="Add URL"
+ className="h-8 rounded-lg"
onClick={() =>
- setUrls((prev) =>
- prev.filter((s) => s.id !== id),
- )
+ setUrls((prev) => [
+ ...prev,
+ { id: uuid(), url: "" },
+ ])
}
/>
)}
</div>
- ))}
- {urls.length < MAX_SUBMISSION_URLS && (
- <Button
- variant="secondary"
- text="Add URL"
- className="h-8 rounded-lg"
- onClick={() =>
- setUrls((prev) => [
- ...prev,
- { id: uuid(), url: "" },
- ])
- }
- />
- )}
+ </div>
+ )}
+
+ {/* Description */}
+ <div>
+ <label
+ htmlFor="slug"
+ className="flex items-center space-x-2"
+ >
+ <h2 className="text-sm font-medium text-neutral-900">
+ How did you complete this bounty?
+ </h2>
+ </label>
+ <ReactTextareaAutosize
+ className={cn(
+ "mt-2 block w-full resize-none rounded-md focus:outline-none sm:text-sm",
+ "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
+ )}
+ minRows={2}
+ value={description}
+ onChange={(e) => setDescription(e.target.value)}
+ />
</div>
</div>
- )}
+ </motion.div>
+ </>
+ )}
+ </AnimatedSizeContainer>
+ </div>
- {/* Description */}
- <div>
- <label htmlFor="slug" className="flex items-center space-x-2">
- <h2 className="text-sm font-medium text-neutral-900">
- How did you complete this bounty?
- </h2>
- </label>
- <ReactTextareaAutosize
- className={cn(
- "mt-2 block w-full resize-none rounded-md focus:outline-none sm:text-sm",
- "border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:ring-neutral-500",
- )}
- minRows={2}
- onKeyDown={handleKeyDown}
- value={description}
- onChange={(e) => setDescription(e.target.value)}
+ {/* Action buttons - outside scrollable area */}
+ {bounty.type !== "performance" &&
+ (!submission || submission.status === "draft") &&
+ !success && (
+ <div className="border-t border-neutral-200 bg-white p-4">
+ {isFormOpen ? (
+ <div className="flex items-center justify-between">
+ <Button
+ variant="outline"
+ text="Cancel"
+ className="h-9 w-fit rounded-lg px-3"
+ onClick={() => setIsFormOpen(false)}
/>
- </div>
- </div>
- </motion.div>
-
- {/* Action buttons */}
- {bounty.type !== "performance" &&
- (!submission || submission.status === "draft") && (
- <div className="border-border-subtle border-t p-5">
- {isFormOpen ? (
- <div className="flex items-center justify-between">
- <Button
- variant="outline"
- text="Cancel"
- className="w-fit rounded-lg"
- onClick={() => setIsFormOpen(false)}
- />
- <div className="flex gap-2">
- <Button
- variant="secondary"
- text="Save progress"
- className="rounded-lg"
- type="submit"
- name="draft"
- loading={isDraft === true}
- disabled={fileUploading || isDraft === false}
- />
- <Button
- variant="primary"
- text="Submit"
- className="rounded-lg"
- type="submit"
- name="submit"
- loading={isDraft === false}
- disabled={fileUploading || isDraft === true}
- />
- </div>
- </div>
- ) : (
+ <div className="flex gap-2">
+ <Button
+ variant="secondary"
+ text="Save progress"
+ className="h-9 rounded-lg px-3"
+ type="submit"
+ name="draft"
+ loading={isDraft === true}
+ disabled={fileUploading || isDraft === false}
+ />
<Button
variant="primary"
- text={submission ? "Continue submission" : "Claim bounty"}
- className="w-full rounded-lg"
- onClick={() => setIsFormOpen(true)}
+ text="Submit"
+ className="h-9 rounded-lg px-3"
+ type="submit"
+ name="submit"
+ loading={isDraft === false}
+ disabled={fileUploading || isDraft === true}
/>
- )}
+ </div>
</div>
+ ) : (
+ <Button
+ variant="primary"
+ text={submission ? "Continue submission" : "Claim bounty"}
+ className="w-full rounded-lg"
+ onClick={() => setIsFormOpen(true)}
+ />
)}
- </>
- )}
- </AnimatedSizeContainer>
- </form>
+ </div>
+ )}
+ </form>
+ </>
);
}
diff --git a/packages/email/src/templates/bounty-pending-review.tsx b/packages/email/src/templates/bounty-new-submission.tsx
similarity index 93%
rename from packages/email/src/templates/bounty-pending-review.tsx
rename to packages/email/src/templates/bounty-new-submission.tsx
index 39eee73668..4c85482c8e 100644
--- a/packages/email/src/templates/bounty-pending-review.tsx
+++ b/packages/email/src/templates/bounty-new-submission.tsx
@@ -14,7 +14,7 @@ import {
} from "@react-email/components";
import { Footer } from "../components/footer";
-export default function BountyPendingReview({
+export default function NewBountySubmission({
workspace = {
slug: "acme",
},
@@ -53,7 +53,7 @@ export default function BountyPendingReview({
return (
<Html>
<Head />
- <Preview>Pending bounty</Preview>
+ <Preview>New bounty submission</Preview>
<Tailwind>
<Body className="mx-auto my-auto bg-white font-sans">
<Container className="mx-auto my-8 max-w-[600px] px-8 py-8">
@@ -62,11 +62,11 @@ export default function BountyPendingReview({
</Section>
<Heading className="mx-0 mb-5 mt-10 p-0 text-lg font-medium text-black">
- Pending bounty
+ New bounty submission
</Heading>
<Text className="text-sm leading-5 text-neutral-600">
- A bounty has been completed for <strong>{bounty.name}</strong> and
+ A bounty has been submitted for <strong>{bounty.name}</strong> and
requires approval.
</Text>
diff --git a/packages/prisma/schema/bounty.prisma b/packages/prisma/schema/bounty.prisma
index 73ddad3eeb..09ac2e7bd6 100644
--- a/packages/prisma/schema/bounty.prisma
+++ b/packages/prisma/schema/bounty.prisma
@@ -5,7 +5,7 @@ enum BountyType {
enum BountySubmissionStatus {
draft
- pending
+ submitted
approved
rejected
}
@@ -62,7 +62,7 @@ model BountySubmission {
commissionId String? @unique
userId String?
description String? @db.Text
- status BountySubmissionStatus @default(pending)
+ status BountySubmissionStatus @default(draft)
rejectionReason BountySubmissionRejectionReason?
rejectionNote String? @db.Text
files Json?