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.

small client-side tweaks for bounties

Steven Tey18037589de17
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 41a5ab1893..101e638bc3 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
@@ -6,7 +6,7 @@ import {
useBountySubmissionsCount,
} from "@/lib/swr/use-bounty-submissions-count";
import { BountyThumbnailImage } from "@/ui/partners/bounties/bounty-thumbnail-image";
-import { formatDate, pluralize } from "@dub/utils";
+import { formatDate, nFormatter, pluralize } from "@dub/utils";
import { CalendarDays, Users } from "lucide-react";
import { useMemo } from "react";
import { BountyActionButton } from "../bounty-action-button";
@@ -61,12 +61,12 @@ export function BountyInfo() {
<div className="h-5 w-32 animate-pulse rounded bg-neutral-200" />
) : (
<span className="font-medium text-neutral-700">
- {totalSubmissions}
+ {nFormatter(totalSubmissions, { full: true })}
</span>
)}{" "}
of{" "}
<span className="font-medium text-neutral-700">
- {bounty.partnersCount}
+ {nFormatter(bounty.partnersCount, { full: true })}
</span>{" "}
{pluralize("partner", bounty.partnersCount ?? 0)} completed
</div>
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 e018663c81..b1122e1004 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
@@ -63,7 +63,38 @@ export function BountySubmissionsTable() {
const { pagination, setPagination } = usePagination();
const { queryParams, searchParams, getQueryString } = useRouterStuff();
- const sortBy = searchParams.get("sortBy") || "createdAt";
+ // Decide the columns to show based on the bounty type
+ const showColumns = useMemo(() => {
+ const columns = ["partner", "group", "createdAt"];
+
+ if (!bounty) {
+ return columns;
+ }
+
+ if (bounty.type === "submission") {
+ columns.push(...["status", "reviewedAt"]);
+ } else if (bounty.type === "performance") {
+ columns.push(...["performanceMetrics"]);
+ }
+
+ return columns;
+ }, [bounty]);
+
+ // Performance based bounty columns
+ const performanceCondition = bounty?.performanceCondition;
+
+ const metricColumnId = performanceCondition?.attribute
+ ? PERFORMANCE_ATTRIBUTE_TO_SORTABLE_COLUMNS[performanceCondition.attribute]
+ : "leads";
+
+ const metricColumnLabel = performanceCondition?.attribute
+ ? WORKFLOW_ATTRIBUTE_LABELS[performanceCondition.attribute]
+ : "Progress";
+
+ const sortBy =
+ searchParams.get("sortBy") || bounty?.type === "performance"
+ ? metricColumnId
+ : "createdAt";
const sortOrder = searchParams.get("sortOrder") === "asc" ? "asc" : "desc";
const { filters, activeFilters, onSelect, onRemove, onRemoveAll } =
@@ -77,6 +108,7 @@ export function BountySubmissionsTable() {
workspaceId && bountyId
? `/api/bounties/${bountyId}/submissions${getQueryString({
workspaceId,
+ sortBy,
})}`
: null,
fetcher,
@@ -108,34 +140,6 @@ export function BountySubmissionsTable() {
}
}, [searchParams, submissions]);
- // Decide the columns to show based on the bounty type
- const showColumns = useMemo(() => {
- const columns = ["partner", "group", "createdAt"];
-
- if (!bounty) {
- return columns;
- }
-
- if (bounty.type === "submission") {
- columns.push(...["status", "reviewedAt"]);
- } else if (bounty.type === "performance") {
- columns.push(...["performanceMetrics"]);
- }
-
- return columns;
- }, [bounty]);
-
- // Performance based bounty columns
- const performanceCondition = bounty?.performanceCondition;
-
- const metricColumnId = performanceCondition?.attribute
- ? PERFORMANCE_ATTRIBUTE_TO_SORTABLE_COLUMNS[performanceCondition.attribute]
- : "leads";
-
- const metricColumnLabel = performanceCondition?.attribute
- ? WORKFLOW_ATTRIBUTE_LABELS[performanceCondition.attribute]
- : "Progress";
-
const columns = useMemo(
() => [
{
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx
index 2026c46f78..766a413a3e 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/bounties/bounty-card.tsx
@@ -3,7 +3,7 @@ import useWorkspace from "@/lib/swr/use-workspace";
import { BountyListProps } from "@/lib/types";
import { BountyThumbnailImage } from "@/ui/partners/bounties/bounty-thumbnail-image";
import { Calendar6, Users } from "@dub/ui/icons";
-import { formatDate, pluralize } from "@dub/utils";
+import { formatDate, nFormatter, pluralize } from "@dub/utils";
import Link from "next/link";
import { useMemo } from "react";
@@ -78,13 +78,13 @@ export function BountyCard({ bounty }: { bounty: BountyListProps }) {
) : (
<>
<span className="text-content-default">
- {bounty.submissionsCount}
+ {nFormatter(bounty.submissionsCount, { full: true })}
</span>{" "}
of
</>
)}{" "}
<span className="text-content-default">
- {totalPartnersForBounty}
+ {nFormatter(totalPartnersForBounty, { full: true })}
</span>{" "}
{pluralize("partner", totalPartnersForBounty)} completed
</div>