The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Bounty submission success
Tim Wilson199021dc50ac
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/page-client.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/page-client.tsxindex 347fd54fcc..f31f58876e 100644--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/page-client.tsx+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/bounties/page-client.tsx@@ -28,12 +28,12 @@ export function BountiesPageClient() {<PageWidthWrapper className="pb-10">{bounties?.length !== 0 || isLoading ? (<div className="grid grid-cols-1 gap-6 md:grid-cols-2 xl:grid-cols-3">- {isLoading- ? Array.from({ length: 3 }, (_, index) => (- <BountyCardSkeleton key={index} />- ))- : bounties?.map((bounty) => (+ {bounties?.length+ ? bounties?.map((bounty) => (<BountyCard key={bounty.id} bounty={bounty} />+ ))+ : Array.from({ length: 3 }, (_, index) => (+ <BountyCardSkeleton key={index} />))}</div>) : (diff --git a/apps/web/ui/partners/bounties/claim-bounty-modal.tsx b/apps/web/ui/partners/bounties/claim-bounty-modal.tsxindex 4dcbaaeecb..3f31eaa1bd 100644--- a/apps/web/ui/partners/bounties/claim-bounty-modal.tsx+++ b/apps/web/ui/partners/bounties/claim-bounty-modal.tsx@@ -5,6 +5,7 @@ import useProgramEnrollment from "@/lib/swr/use-program-enrollment";import { BountyProps } from "@/lib/types";import { X } from "@/ui/shared/icons";import {+ AnimatedSizeContainer,Button,Calendar6,FileUpload,@@ -101,6 +102,8 @@ function ClaimBountyModalContent({createBountySubmissionAction,);+ const [success, setSuccess] = useState(false);+const imageRequired = bounty.submissionRequirements?.includes("image");const urlRequired = bounty.submissionRequirements?.includes("url");@@ -132,7 +135,7 @@ function ClaimBountyModalContent({`/api/partner-profile/programs/${programEnrollment.program.slug}/bounties`,);toast.success("Submission created successfully!");- setShowModal(false);+ setSuccess(true);} catch (e) {toast.error("Failed to create submission. Please try again.");}@@ -145,213 +148,237 @@ function ClaimBountyModalContent({</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"+ <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">+ <span className="text-content-emphasis text-base font-semibold">+ Congratulations! You've successfully submitted your bounty!+ </span>+ <p className="text-content-subtle text-sm font-medium">+ We'll let you know when your bounty has been approved.+ </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>+ </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 font-medium">+ {bounty.description}+ </p>+ </div>)}- </span>- </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 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 */}- <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+ {/* Form */}+ <motion.div+ initial={false}+ animate={{ height: isFormOpen ? "auto" : 0 }}+ transition={{ duration: 0.15 }}className={cn(- "mt-2 flex h-12 items-center gap-2 transition-[height]",- files.length === 0 && "h-24",+ "overflow-hidden transition-opacity",+ !isFormOpen && "opacity-0",)}>- {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"+ <div className="border-border-subtle flex flex-col gap-5 border-t p-6 max-sm:px-4">+ {/* Files */}+ <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>+ <divclassName={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",+ "mt-2 flex h-12 items-center gap-2 transition-[height]",+ files.length === 0 && "h-24",)}- onClick={() => {- setFiles((prev) => prev.filter((s) => s.id !== file.id));- }}>- <X className="size-2.5 text-neutral-400" />- </button>+ {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>+ ))}++ <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_FILES}+ />+ </div></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_FILES}- />- </div>- </div>+ {/* URLs */}+ <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_URLS && (+ <Button+ variant="secondary"+ text="Add URL"+ className="h-8 rounded-lg"+ onClick={() =>+ setUrls((prev) => [...prev, { id: uuid(), url: "" }])+ }+ />+ )}+ </div>+ </div>- {/* URLs */}- <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"+ {/* 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)}/>- {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>+ </div>+ </motion.div>++ {/* Action buttons */}+ <div className="border-border-subtle border-t p-5">+ <div+ className={cn(+ "flex items-center transition-all",+ isFormOpen ? "gap-4" : "gap-0",+ )}+ >+ <div+ className={cn(+ "shrink-0 overflow-hidden transition-[width]",+ isFormOpen ? "w-[calc(50%-1rem)]" : "w-0",)}+ >+ <Button+ variant="secondary"+ text="Cancel"+ className="rounded-lg"+ onClick={() => setIsFormOpen(false)}+ /></div>- ))}- {urls.length < MAX_URLS && (<Button- variant="secondary"- text="Add URL"- className="h-8 rounded-lg"- onClick={() =>- setUrls((prev) => [...prev, { id: uuid(), url: "" }])+ variant="primary"+ text={isFormOpen ? "Submit proof" : "Claim bounty"}+ className="grow rounded-lg"+ onClick={isFormOpen ? undefined : () => setIsFormOpen(true)}+ loading={isPending}+ disabled={+ isFormOpen &&+ ((imageRequired && !files.length) ||+ (urlRequired && !urls.filter(({ url }) => url).length))}/>- )}+ </div></div>- </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)}- />- </div>- </div>- </motion.div>-- {/* Action buttons */}- <div className="border-border-subtle border-t p-5">- <div- className={cn(- "flex items-center transition-all",- isFormOpen ? "gap-4" : "gap-0",- )}- >- <div- className={cn(- "shrink-0 overflow-hidden transition-[width]",- isFormOpen ? "w-[calc(50%-1rem)]" : "w-0",- )}- >- <Button- variant="secondary"- text="Cancel"- className="rounded-lg"- onClick={() => setIsFormOpen(false)}- />- </div>- <Button- variant="primary"- text={isFormOpen ? "Submit proof" : "Claim bounty"}- className="grow rounded-lg"- onClick={isFormOpen ? undefined : () => setIsFormOpen(true)}- loading={isPending}- disabled={- isFormOpen &&- ((imageRequired && !files.length) ||- (urlRequired && !urls.filter(({ url }) => url).length))- }- />- </div>- </div>+ </>+ )}+ </AnimatedSizeContainer></form>);}