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.

Improve bounty submissions review flow

Steven Teye7467806f456
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 dd38195a55..ebb913f504 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
@@ -14,9 +14,12 @@ import { AmountInput } from "@/ui/shared/amount-input";
import { X } from "@/ui/shared/icons";
import {
Button,
+ ChevronLeft,
+ ChevronRight,
CopyButton,
Sheet,
StatusBadge,
+ useKeyboardShortcut,
useRouterStuff,
} from "@dub/ui";
import { currencyFormatter, formatDate, getPrettyUrl } from "@dub/utils";
@@ -28,18 +31,22 @@ import { BOUNTY_SUBMISSION_STATUS_BADGES } from "./bounty-submission-status-badg
type BountySubmissionDetailsSheetProps = {
submission: BountySubmissionProps;
+ onNext?: () => void;
+ onPrevious?: () => void;
setIsOpen: Dispatch<SetStateAction<boolean>>;
};
function BountySubmissionDetailsSheetContent({
submission,
+ onPrevious,
+ onNext,
setIsOpen,
}: BountySubmissionDetailsSheetProps) {
const { bounty } = useBounty();
const { id: workspaceId, slug: workspaceSlug } = useWorkspace();
const { setShowRejectModal, RejectBountySubmissionModal } =
- useRejectBountySubmissionModal(submission);
+ useRejectBountySubmissionModal(submission, onNext);
const [rewardAmount, setRewardAmount] = useState<number | null>(null);
@@ -49,7 +56,7 @@ function BountySubmissionDetailsSheetContent({
} = useAction(approveBountySubmissionAction, {
onSuccess: async () => {
toast.success("Bounty submission approved successfully!");
- setIsOpen(false);
+ onNext ? onNext() : setIsOpen(false);
await mutatePrefix("/api/bounties");
},
onError({ error }) {
@@ -64,6 +71,8 @@ function BountySubmissionDetailsSheetContent({
title: "Approve Bounty Submission",
description: "Are you sure you want to approve this bounty submission?",
confirmText: "Approve",
+ confirmShortcut: "a",
+ confirmShortcutOptions: { sheet: true, modal: true },
onConfirm: async () => {
if (!workspaceId || !submission?.id) {
return;
@@ -77,6 +86,26 @@ function BountySubmissionDetailsSheetContent({
},
});
+ useKeyboardShortcut(
+ "a",
+ () => {
+ if (isValidForm && submission.status !== "draft") {
+ setShowApproveBountySubmissionModal(true);
+ }
+ },
+ { sheet: true },
+ );
+
+ useKeyboardShortcut(
+ "r",
+ () => {
+ if (submission.status !== "draft" && submission.status !== "rejected") {
+ setShowRejectModal(true);
+ }
+ },
+ { sheet: true },
+ );
+
const isValidForm = useMemo(() => {
if (bounty?.rewardAmount) {
return true;
@@ -100,13 +129,33 @@ function BountySubmissionDetailsSheetContent({
<Sheet.Title className="text-lg font-semibold">
Review bounty submission
</Sheet.Title>
- <Sheet.Close asChild>
- <Button
- variant="outline"
- icon={<X className="size-5" />}
- className="h-auto w-fit p-1"
- />
- </Sheet.Close>
+ <div className="flex items-center gap-4">
+ <div className="flex items-center">
+ <Button
+ type="button"
+ disabled={!onPrevious}
+ onClick={onPrevious}
+ variant="secondary"
+ className="size-9 rounded-l-lg rounded-r-none p-0"
+ icon={<ChevronLeft className="size-3.5" />}
+ />
+ <Button
+ type="button"
+ disabled={!onNext}
+ onClick={onNext}
+ variant="secondary"
+ className="-ml-px size-9 rounded-l-none rounded-r-lg p-0"
+ icon={<ChevronRight className="size-3.5" />}
+ />
+ </div>
+ <Sheet.Close asChild>
+ <Button
+ variant="outline"
+ icon={<X className="size-5" />}
+ className="h-auto w-fit p-1"
+ />
+ </Sheet.Close>
+ </div>
</div>
</div>
@@ -330,6 +379,7 @@ function BountySubmissionDetailsSheetContent({
type="button"
variant="danger"
text="Reject"
+ shortcut="R"
disabledTooltip={
submission.status === "draft"
? "Bounty submission is in progress."
@@ -348,6 +398,7 @@ function BountySubmissionDetailsSheetContent({
type="submit"
variant="primary"
text="Approve"
+ shortcut="A"
loading={isApprovingBountySubmission}
onClick={() => setShowApproveBountySubmissionModal(true)}
disabledTooltip={
@@ -389,9 +440,13 @@ export function BountySubmissionDetailsSheet({
}
export function useBountySubmissionDetailsSheet(
- props: { nested?: boolean } & Omit<
+ props: {
+ nested?: boolean;
+ onNext?: () => void;
+ onPrevious?: () => void;
+ } & Omit<
BountySubmissionDetailsSheetProps,
- "setIsOpen"
+ "setIsOpen" | "onNext" | "onPrevious"
>,
) {
const [isOpen, setIsOpen] = useState(false);
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
index 8dc54827db..bf38973e23 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-submissions-table.tsx
@@ -96,10 +96,13 @@ export function BountySubmissionsTable() {
data: submissions,
} = useSWR<BountySubmissionProps[]>(
workspaceId && bountyId
- ? `/api/bounties/${bountyId}/submissions${getQueryString({
- workspaceId,
- sortBy,
- })}`
+ ? `/api/bounties/${bountyId}/submissions${getQueryString(
+ {
+ workspaceId,
+ sortBy,
+ },
+ { exclude: ["submissionId"] },
+ )}`
: null,
fetcher,
{
@@ -128,6 +131,38 @@ export function BountySubmissionsTable() {
}
}, [searchParams, submissions]);
+ // Navigation functions for the details sheet
+ const navigateToSubmission = (direction: "next" | "previous") => {
+ if (!submissions || !detailsSheetState.submission) return;
+
+ const currentIndex = submissions.findIndex(
+ (s) => s.id === detailsSheetState.submission!.id,
+ );
+
+ if (currentIndex === -1) return;
+
+ let targetIndex: number;
+ if (direction === "next") {
+ targetIndex = currentIndex + 1;
+ if (targetIndex >= submissions.length) {
+ targetIndex = 0; // Wrap to first
+ }
+ } else {
+ targetIndex = currentIndex - 1;
+ if (targetIndex < 0) {
+ targetIndex = submissions.length - 1; // Wrap to last
+ }
+ }
+
+ const targetSubmission = submissions[targetIndex];
+ if (targetSubmission) {
+ queryParams({ set: { submissionId: targetSubmission.id } });
+ }
+ };
+
+ const onNext = () => navigateToSubmission("next");
+ const onPrevious = () => navigateToSubmission("previous");
+
const columns = useMemo(
() => [
{
@@ -356,6 +391,8 @@ export function BountySubmissionsTable() {
setDetailsSheetState((s) => ({ ...s, open }) as any)
}
submission={detailsSheetState.submission}
+ onNext={onNext}
+ onPrevious={onPrevious}
/>
)}
diff --git a/apps/web/lib/api/bounties/get-bounty-submissions.ts b/apps/web/lib/api/bounties/get-bounty-submissions.ts
index 5bb4dc1802..5f41689b3b 100644
--- a/apps/web/lib/api/bounties/get-bounty-submissions.ts
+++ b/apps/web/lib/api/bounties/get-bounty-submissions.ts
@@ -18,7 +18,7 @@ export async function getBountySubmissions({
const submissions = await prisma.bountySubmission.findMany({
where: {
bountyId,
- ...(status ? { status } : { status: { not: "rejected" } }),
+ ...(status ? { status } : { status: "submitted" }),
...(groupId && {
programEnrollment: {
groupId,
diff --git a/apps/web/ui/partners/reject-bounty-submission-modal.tsx b/apps/web/ui/partners/reject-bounty-submission-modal.tsx
index 97b84cde02..01c9ae0641 100644
--- a/apps/web/ui/partners/reject-bounty-submission-modal.tsx
+++ b/apps/web/ui/partners/reject-bounty-submission-modal.tsx
@@ -24,12 +24,14 @@ interface RejectBountySubmissionModalProps {
submission: BountySubmissionProps;
showModal: boolean;
setShowModal: (showModal: boolean) => void;
+ onReject?: () => void;
}
const RejectBountySubmissionModal = ({
submission,
showModal,
setShowModal,
+ onReject,
}: RejectBountySubmissionModalProps) => {
const { bounty } = useBounty();
const workspace = useWorkspace();
@@ -52,6 +54,7 @@ const RejectBountySubmissionModal = ({
onSuccess: async () => {
toast.success("Bounty submission rejected successfully!");
setShowModal(false);
+ onReject ? onReject() : null;
await mutatePrefix(`/api/bounties/${bounty?.id}/submissions`);
},
onError({ error }) {
@@ -178,6 +181,7 @@ export function useRejectBountySubmissionModal(
showModal={showRejectModal}
setShowModal={setShowRejectModal}
submission={submission}
+ onReject={onReject}
/>
);
}, [showRejectModal, setShowRejectModal, onReject, submission]);