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.

address coderabbit feedback

Steven Teyb4e961302b03
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx
index 45e64139c2..1d19869316 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/[bountyId]/bounty-info.tsx
@@ -82,7 +82,8 @@ export function BountyInfo() {
<span className="font-medium text-neutral-700">
{nFormatter(bounty.partnersCount, { full: true })}
</span>{" "}
- {pluralize("submission", bounty.partnersCount ?? 0)}
+ {pluralize("partner", bounty.partnersCount ?? 0)}{" "}
+ {bounty.type === "performance" ? "completed" : "submitted"}
{readyForReviewSubmissions > 0 && (
<>
{" "}
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 2d467444b8..be951739af 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
@@ -43,13 +43,6 @@ import { BountySubmissionRowMenu } from "./bounty-submission-row-menu";
import { BOUNTY_SUBMISSION_STATUS_BADGES } from "./bounty-submission-status-badges";
import { useBountySubmissionFilters } from "./use-bounty-submission-filters";
-const PERFORMANCE_ATTRIBUTE_TO_SORTABLE_COLUMNS = {
- totalLeads: "leads",
- totalConversions: "conversions",
- totalSaleAmount: "saleAmount",
- totalCommissions: "commissions",
-} as const;
-
export function BountySubmissionsTable() {
const { bounty, loading: isBountyLoading } = useBounty();
const { groups } = useGroups();
@@ -76,16 +69,18 @@ export function BountySubmissionsTable() {
// Performance based bounty columns
const performanceCondition = bounty?.performanceCondition;
- const metricColumnId = performanceCondition?.attribute
- ? PERFORMANCE_ATTRIBUTE_TO_SORTABLE_COLUMNS[performanceCondition.attribute]
- : "leads";
-
const metricColumnLabel = performanceCondition?.attribute
? PERFORMANCE_BOUNTY_SCOPE_ATTRIBUTES[performanceCondition.attribute]
: "Progress";
- const status = (searchParams.get("status") ||
- "submitted") as BountySubmissionStatus;
+ const expiredBounty =
+ bounty?.endsAt && new Date(bounty.endsAt) < new Date() ? true : false;
+
+ const status = useMemo(() => {
+ return (searchParams.get("status") ??
+ (expiredBounty ? "approved" : "submitted")) as BountySubmissionStatus;
+ }, [searchParams, expiredBounty]);
+
const sortBy = searchParams.get("sortBy") || "completedAt";
const sortOrder = searchParams.get("sortOrder") === "desc" ? "desc" : "asc";
@@ -251,7 +246,7 @@ export function BountySubmissionsTable() {
...(showColumns.includes("performanceMetrics")
? [
{
- id: metricColumnId,
+ id: "performanceCount",
header: capitalize(metricColumnLabel)!,
cell: ({ row }: { row: Row<BountySubmissionProps> }) => {
if (!performanceCondition) {
@@ -325,7 +320,6 @@ export function BountySubmissionsTable() {
groups,
bounty,
showColumns,
- metricColumnId,
metricColumnLabel,
performanceCondition,
workspaceId,
@@ -350,9 +344,7 @@ export function BountySubmissionsTable() {
},
sortableColumns: [
"completedAt",
- ...(bounty?.type === "performance"
- ? ["leads", "conversions", "saleAmount", "commissions"]
- : []),
+ ...(bounty?.type === "performance" ? ["performanceCount"] : []),
],
sortBy,
sortOrder,
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx
index 4ea7dc1b28..9011265f0d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/page.tsx
@@ -14,7 +14,7 @@ export default function Page() {
}}
controls={<CreateBountyButton />}
>
- <PageWidthWrapper>
+ <PageWidthWrapper className="pb-10">
<BountyList />
</PageWidthWrapper>
</PageContent>
diff --git a/apps/web/lib/zod/schemas/bounties.ts b/apps/web/lib/zod/schemas/bounties.ts
index 5232099bc9..e5c4f43e40 100644
--- a/apps/web/lib/zod/schemas/bounties.ts
+++ b/apps/web/lib/zod/schemas/bounties.ts
@@ -28,14 +28,6 @@ export const REJECT_BOUNTY_SUBMISSION_REASONS = {
other: "Other",
} as const;
-export const BOUNTY_SUBMISSIONS_SORT_BY_COLUMNS = [
- "completedAt",
- "leads",
- "conversions",
- "saleAmount",
- "commissions",
-] as const;
-
export const submissionRequirementsSchema = z
.array(z.enum(SUBMISSION_REQUIREMENTS))
.min(0)
@@ -177,7 +169,7 @@ export const rejectBountySubmissionSchema = z.object({
export const getBountySubmissionsQuerySchema = z
.object({
- sortBy: z.enum(BOUNTY_SUBMISSIONS_SORT_BY_COLUMNS).default("completedAt"),
+ sortBy: z.enum(["completedAt", "performanceCount"]).default("completedAt"),
sortOrder: z.enum(["asc", "desc"]).default("asc"),
status: z.nativeEnum(BountySubmissionStatus).optional(),
groupId: z.string().optional(),