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.

more bounties improvements

Steven Teya0658aaf22d8
diff --git a/apps/web/app/(ee)/admin.dub.co/(dashboard)/components/impersonate-user.tsx b/apps/web/app/(ee)/admin.dub.co/(dashboard)/components/impersonate-user.tsx
index 5dd4d4e895..491b2cd16b 100644
--- a/apps/web/app/(ee)/admin.dub.co/(dashboard)/components/impersonate-user.tsx
+++ b/apps/web/app/(ee)/admin.dub.co/(dashboard)/components/impersonate-user.tsx
@@ -82,6 +82,16 @@ const Form = () => {
"block w-full rounded-md border-neutral-300 text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-sm",
pending && "bg-neutral-100",
)}
+ onPaste={(e: React.ClipboardEvent<HTMLInputElement>) => {
+ // remove mailto: on paste
+ e.preventDefault();
+ const text = e.clipboardData.getData("text/plain");
+ if (text.startsWith("mailto:")) {
+ e.currentTarget.value = text.replace("mailto:", "");
+ } else {
+ e.currentTarget.value = text;
+ }
+ }}
placeholder="[email protected]"
aria-invalid="true"
/>
diff --git a/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts b/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
index 2273289065..762b870343 100644
--- a/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
+++ b/apps/web/app/(ee)/api/bounties/[bountyId]/submissions/route.ts
@@ -79,7 +79,7 @@ async function getSubmissions({
const submissions = await prisma.bountySubmission.findMany({
where: {
bountyId,
- ...(status && { status }),
+ ...(status ? { status } : { status: { not: "rejected" } }),
...(groupId && {
programEnrollment: {
groupId,
diff --git a/apps/web/app/(ee)/api/cron/groups/create-default-links/route.ts b/apps/web/app/(ee)/api/cron/groups/create-default-links/route.ts
index cf5177855a..b0089d23ef 100644
--- a/apps/web/app/(ee)/api/cron/groups/create-default-links/route.ts
+++ b/apps/web/app/(ee)/api/cron/groups/create-default-links/route.ts
@@ -90,8 +90,6 @@ export async function POST(req: Request) {
},
});
- const { utmTemplate } = group;
-
let hasMore = true;
let currentCursor = cursor;
let processedBatches = 0;
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
index 6da9eb2113..80b6a408ee 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submission-details-sheet.tsx
@@ -5,6 +5,7 @@ import { mutatePrefix } from "@/lib/swr/mutate";
import useBounty from "@/lib/swr/use-bounty";
import useWorkspace from "@/lib/swr/use-workspace";
import { BountySubmissionProps } from "@/lib/types";
+import { REJECT_BOUNTY_SUBMISSION_REASONS } from "@/lib/zod/schemas/bounties";
import { useConfirmModal } from "@/ui/modals/confirm-modal";
import { PartnerInfoSection } from "@/ui/partners/partner-info-section";
import { useRejectBountySubmissionModal } from "@/ui/partners/reject-bounty-submission-modal";
@@ -17,7 +18,8 @@ import {
StatusBadge,
useRouterStuff,
} from "@dub/ui";
-import { currencyFormatter, formatDate } from "@dub/utils";
+import { currencyFormatter, formatDate, getPrettyUrl } from "@dub/utils";
+import Linkify from "linkify-react";
import { useAction } from "next-safe-action/hooks";
import { Dispatch, SetStateAction, useState } from "react";
import { toast } from "sonner";
@@ -139,12 +141,25 @@ function BountySubmissionDetailsSheetContent({
timeZone: "UTC",
}),
},
- {
- label: "Reward",
- value: commission?.earnings
- ? currencyFormatter(commission.earnings / 100)
- : "-",
- },
+ ...(submission.status === "rejected"
+ ? [
+ {
+ label: "Rejection reason",
+ value:
+ submission.rejectionReason &&
+ REJECT_BOUNTY_SUBMISSION_REASONS[
+ submission.rejectionReason as keyof typeof REJECT_BOUNTY_SUBMISSION_REASONS
+ ],
+ },
+ ]
+ : [
+ {
+ label: "Reward",
+ value: commission?.earnings
+ ? currencyFormatter(commission.earnings / 100)
+ : "-",
+ },
+ ]),
].map((item, index) => (
<div key={index} className="grid grid-cols-2 gap-6">
<span className="text-sm font-medium text-neutral-500">
@@ -156,6 +171,25 @@ function BountySubmissionDetailsSheetContent({
</div>
))}
</div>
+
+ {/* Rejection details for rejected submissions */}
+ {submission.status === "rejected" && submission.rejectionNote && (
+ <div className="mt-4 rounded-lg border border-red-200 bg-red-50 p-4">
+ <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>
{bounty?.type === "submission" && (
@@ -238,39 +272,41 @@ function BountySubmissionDetailsSheetContent({
)}
</div>
- <div className="flex items-center justify-between gap-2 border-t border-neutral-200 p-5">
- {submission.status === "approved" ? (
- <a
- href={`/${workspaceSlug}/program/commissions?partnerId=${partner.id}&type=custom`}
- target="_blank"
- className="w-full"
- >
- <Button variant="secondary" text="View commissions" />
- </a>
- ) : (
- <>
- <Button
- type="button"
- variant="danger"
- text="Reject"
- disabledTooltip={
- submission.status === "rejected"
- ? "Bounty submission already rejected."
- : undefined
- }
- disabled={isApprovingBountySubmission}
- onClick={() => setShowRejectModal(true)}
- />
+ <div className="sticky bottom-0 z-10 border-t border-neutral-200 bg-white">
+ <div className="flex items-center justify-between gap-2 p-5">
+ {submission.status === "approved" ? (
+ <a
+ href={`/${workspaceSlug}/program/commissions?partnerId=${partner.id}&type=custom`}
+ target="_blank"
+ className="w-full"
+ >
+ <Button variant="secondary" text="View commissions" />
+ </a>
+ ) : (
+ <>
+ <Button
+ type="button"
+ variant="danger"
+ text="Reject"
+ disabledTooltip={
+ submission.status === "rejected"
+ ? "Bounty submission already rejected."
+ : undefined
+ }
+ disabled={isApprovingBountySubmission}
+ onClick={() => setShowRejectModal(true)}
+ />
- <Button
- type="submit"
- variant="primary"
- text="Approve"
- loading={isApprovingBountySubmission}
- onClick={() => setShowApproveBountySubmissionModal(true)}
- />
- </>
- )}
+ <Button
+ type="submit"
+ variant="primary"
+ text="Approve"
+ loading={isApprovingBountySubmission}
+ onClick={() => setShowApproveBountySubmissionModal(true)}
+ />
+ </>
+ )}
+ </div>
</div>
</div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/use-bounty-submission-filters.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/use-bounty-submission-filters.tsx
index 58d3e559de..97808ddc98 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/use-bounty-submission-filters.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/use-bounty-submission-filters.tsx
@@ -27,35 +27,42 @@ export function useBountySubmissionFilters({
const filters = useMemo(
() => [
- {
- key: "status",
- icon: CircleDotted,
- label: "Status",
- options:
- bounty?.type === "submission" && submissionsCount
- ? submissionsCount.map(({ status, count }) => {
- {
- const {
- label,
- icon: Icon,
- iconClassName,
- } = BOUNTY_SUBMISSION_STATUS_BADGES[status];
- return {
- value: status,
- label,
- icon: (
- <Icon
- className={cn("size-4 bg-transparent", iconClassName)}
- />
- ),
- right: nFormatter(count, {
- full: true,
- }),
- };
- }
- })
- : null,
- },
+ ...(bounty?.type === "submission"
+ ? [
+ {
+ key: "status",
+ icon: CircleDotted,
+ label: "Status",
+ options:
+ bounty?.type === "submission" && submissionsCount
+ ? submissionsCount.map(({ status, count }) => {
+ {
+ const {
+ label,
+ icon: Icon,
+ iconClassName,
+ } = BOUNTY_SUBMISSION_STATUS_BADGES[status];
+ return {
+ value: status,
+ label,
+ icon: (
+ <Icon
+ className={cn(
+ "size-4 bg-transparent",
+ iconClassName,
+ )}
+ />
+ ),
+ right: nFormatter(count, {
+ full: true,
+ }),
+ };
+ }
+ })
+ : null,
+ },
+ ]
+ : []),
{
key: "groupId",
icon: Users6,
diff --git a/apps/web/lib/actions/partners/reject-bounty-submission.ts b/apps/web/lib/actions/partners/reject-bounty-submission.ts
index 06c929bfe3..6131db767f 100644
--- a/apps/web/lib/actions/partners/reject-bounty-submission.ts
+++ b/apps/web/lib/actions/partners/reject-bounty-submission.ts
@@ -104,6 +104,7 @@ export const rejectBountySubmissionAction = authActionClient
submission: {
rejectionReason:
REJECT_BOUNTY_SUBMISSION_REASONS[rejectionReason],
+ rejectionNote,
},
}),
}),
diff --git a/apps/web/lib/api/bounties/get-partners-with-bounty-submission.ts b/apps/web/lib/api/bounties/get-partners-with-bounty-submission.ts
index cb56eee796..358233f286 100644
--- a/apps/web/lib/api/bounties/get-partners-with-bounty-submission.ts
+++ b/apps/web/lib/api/bounties/get-partners-with-bounty-submission.ts
@@ -61,7 +61,7 @@ export async function getPartnersWithBountySubmission({
WHERE
pe.programId = ${programId}
${groupIds && groupIds.length > 0 ? Prisma.sql`AND pe.groupId IN (${Prisma.join(groupIds)})` : Prisma.sql``}
- ${status ? (status === "approved" ? Prisma.sql`AND bs.status = ${status}` : Prisma.sql`AND bs.status IS NULL`) : Prisma.sql``}
+ ${status ? Prisma.sql`AND bs.status = ${status}` : Prisma.sql`AND bs.status != 'rejected'`}
GROUP BY
p.id, pe.partnerId, pe.groupId, pe.totalCommissions, pe.status, bountySubmissionId, bountySubmissionStatus, bountySubmissionCreatedAt, bountySubmissionUpdatedAt, metrics.totalLeads, metrics.totalConversions, metrics.totalSaleAmount
ORDER BY ${Prisma.raw(sortColumnsMap[sortBy])} ${Prisma.raw(sortOrder)}
diff --git a/apps/web/scripts/partners/delete-program.ts b/apps/web/scripts/partners/delete-program.ts
index da691d8c71..687375cd42 100644
--- a/apps/web/scripts/partners/delete-program.ts
+++ b/apps/web/scripts/partners/delete-program.ts
@@ -11,13 +11,17 @@ async function main() {
});
if (program.defaultFolderId) {
- const deletedFolder = await prisma.folder.delete({
- where: {
- id: program.defaultFolderId,
- },
- });
-
- console.log("Deleted folder", deletedFolder);
+ try {
+ const deletedFolder = await prisma.folder.delete({
+ where: {
+ id: program.defaultFolderId,
+ },
+ });
+
+ console.log("Deleted folder", deletedFolder);
+ } catch (error) {
+ console.error("Failed to delete folder", error);
+ }
}
const deletedRewards = await prisma.reward.deleteMany({
diff --git a/apps/web/scripts/partners/get-largest-programs.ts b/apps/web/scripts/partners/get-largest-programs.ts
index 686b0cf9de..71e6d4f006 100644
--- a/apps/web/scripts/partners/get-largest-programs.ts
+++ b/apps/web/scripts/partners/get-largest-programs.ts
@@ -16,7 +16,7 @@ async function main() {
});
const filteredProgramsByEnrollmentCount = programsByEnrollmentCount.filter(
- (program) => program._count.programId > 1000,
+ (program) => program._count.programId > 500,
);
console.table(filteredProgramsByEnrollmentCount);
diff --git a/apps/web/ui/partners/bounties/claim-bounty-modal.tsx b/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
index 6ac75ac30c..ef7f077b25 100644
--- a/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
+++ b/apps/web/ui/partners/bounties/claim-bounty-modal.tsx
@@ -6,6 +6,7 @@ import { BountySubmissionProps, PartnerBountyProps } from "@/lib/types";
import {
MAX_SUBMISSION_FILES,
MAX_SUBMISSION_URLS,
+ REJECT_BOUNTY_SUBMISSION_REASONS,
} from "@/lib/zod/schemas/bounties";
import { X } from "@/ui/shared/icons";
import {
@@ -21,8 +22,9 @@ import {
useEnterSubmit,
useRouterStuff,
} from "@dub/ui";
-import { cn, formatDate } from "@dub/utils";
+import { cn, formatDate, getPrettyUrl } from "@dub/utils";
import { motion } from "framer-motion";
+import Linkify from "linkify-react";
import { useAction } from "next-safe-action/hooks";
import Link from "next/link";
import { Dispatch, SetStateAction, useState } from "react";
@@ -186,51 +188,92 @@ function ClaimBountyModalContent({
</div>
{submission ? (
- <div className="mt-3 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",
- )}
+ <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>
+ )}
+ <StatusBadge
+ className="rounded-lg py-1.5"
+ variant={
+ submission.status === "pending"
+ ? "pending"
+ : submission.status === "approved"
+ ? "success"
+ : "error"
+ }
+ icon={submission.status === "approved" ? undefined : null}
>
- View earnings
- </Link>
- )}
- <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, {
+ {submission.status === "pending" ? (
+ `Submitted ${formatDate(submission.createdAt, { month: "short" })}`
+ ) : submission.status === "approved" ? (
+ bounty.type === "performance" ? (
+ <>
+ Completed{" "}
+ {formatDate(submission.createdAt, {
month: "short",
})}
- </>
- )
- ) : (
- "Rejected"
- )}
- </StatusBadge>
+ </>
+ ) : (
+ <>
+ 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" && (
diff --git a/packages/email/src/templates/bounty-rejected.tsx b/packages/email/src/templates/bounty-rejected.tsx
index 4596fe2b60..8d1fd2df5c 100644
--- a/packages/email/src/templates/bounty-rejected.tsx
+++ b/packages/email/src/templates/bounty-rejected.tsx
@@ -25,6 +25,7 @@ export default function BountyRejected({
},
submission = {
rejectionReason: "Not a valid URL",
+ rejectionNote: "The URL is not a valid URL. Please provide a valid URL.",
},
email = "[email protected]",
}: {
@@ -38,6 +39,7 @@ export default function BountyRejected({
};
submission: {
rejectionReason: string;
+ rejectionNote?: string;
};
email: string;
}) {
@@ -61,10 +63,20 @@ export default function BountyRejected({
bounty has been rejected for the reason:
</Text>
- <Section className="flex h-[52px] items-center rounded-lg border border-solid border-neutral-200 bg-neutral-100 p-4">
- <span className="text-sm font-normal">
+ <Section className="flex items-center rounded-lg border border-solid border-neutral-200 bg-neutral-100 p-4">
+ <span className="text-sm font-semibold">
{submission.rejectionReason}
</span>
+
+ {submission.rejectionNote && (
+ <>
+ <br />
+ <br />
+ <span className="text-sm leading-5 text-neutral-600">
+ {submission.rejectionNote}
+ </span>
+ </>
+ )}
</Section>
<Text className="text-sm leading-5 text-neutral-600">