The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
fix the sorting again
Kiran K91ca50ca8f61
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.tsxindex 1501885a07..5401421221 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@@ -5,7 +5,6 @@ import useBounty from "@/lib/swr/use-bounty";import useGroups from "@/lib/swr/use-groups";import useWorkspace from "@/lib/swr/use-workspace";import { BountySubmissionProps } from "@/lib/types";-import { WORKFLOW_ATTRIBUTE_LABELS } from "@/lib/zod/schemas/workflows";import { GroupColorCircle } from "@/ui/partners/groups/group-color-circle";import { PartnerRowItem } from "@/ui/partners/partner-row-item";import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";@@ -46,6 +45,20 @@ export const BOUNTY_SUBMISSION_STATUS_BADGES = {},} as const;+const PERFORMANCE_ATTRIBUTE_TO_SORTABLE_COLUMNS = {+ totalLeads: "leads",+ totalConversions: "conversions",+ totalSaleAmount: "saleAmount",+ totalCommissions: "commissions",+} as const;++const PERFORMANCE_ATTRIBUTE_LABELS = {+ totalLeads: "Leads",+ totalConversions: "Conversions",+ totalSaleAmount: "Revenue",+ totalCommission: "Commissions",+} as const;+export function BountySubmissionsTable() {const { bounty, isLoading: isBountyLoading } = useBounty();const { groups } = useGroups();@@ -112,9 +125,15 @@ export function BountySubmissionsTable() {return columns;}, [bounty]);+ // Performance based bounty columnsconst performanceCondition = bounty?.performanceCondition;- const metricLabel = performanceCondition?.attribute- ? WORKFLOW_ATTRIBUTE_LABELS[performanceCondition.attribute]++ const metricColumnId = performanceCondition?.attribute+ ? PERFORMANCE_ATTRIBUTE_TO_SORTABLE_COLUMNS[performanceCondition.attribute]+ : "leads";++ const metricColumnLabel = performanceCondition?.attribute+ ? PERFORMANCE_ATTRIBUTE_LABELS[performanceCondition.attribute]: "Progress";const { table, ...tableProps } = useTable({@@ -191,8 +210,8 @@ export function BountySubmissionsTable() {...(columns.includes("performanceMetrics")? [{- id: performanceCondition?.attribute,- header: capitalize(metricLabel)!,+ id: metricColumnId,+ header: capitalize(metricColumnLabel)!,cell: ({ row }: { row: Row<BountySubmissionProps> }) => {if (!performanceCondition) {return "-";@@ -273,13 +292,7 @@ export function BountySubmissionsTable() {sortableColumns:bounty?.type === "submission"? ["createdAt"]- : [- "createdAt",- "totalLeads",- "totalConversions",- "totalSaleAmount",- "totalCommission",- ],+ : ["createdAt", "leads", "conversions", "saleAmount", "commissions"],sortBy,sortOrder,onSortChange: ({ sortBy, sortOrder }) =>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.tsindex de7a08040a..7bbb56ab73 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@@ -5,10 +5,10 @@ import { z } from "zod";const sortColumnsMap = {createdAt: "bs.createdAt",- totalLeads: "totalLeads",- totalConversions: "totalConversions",- totalSaleAmount: "totalSaleAmount",- totalCommissions: "totalCommissions",+ leads: "totalLeads",+ conversions: "totalConversions",+ saleAmount: "totalSaleAmount",+ commissions: "totalCommissions",};type SubmissionFilters = z.infer<typeof getBountySubmissionsQuerySchema> & {diff --git a/apps/web/lib/zod/schemas/bounties.ts b/apps/web/lib/zod/schemas/bounties.tsindex a32616e007..94f8c44752 100644--- a/apps/web/lib/zod/schemas/bounties.ts+++ b/apps/web/lib/zod/schemas/bounties.ts@@ -155,13 +155,7 @@ export const REJECT_BOUNTY_SUBMISSION_REASONS = {export const getBountySubmissionsQuerySchema = z.object({sortBy: z- .enum([- "createdAt",- "totalLeads",- "totalConversions",- "totalSaleAmount",- "totalCommissions",- ])+ .enum(["createdAt", "leads", "conversions", "saleAmount", "commissions"]).default("createdAt"),sortOrder: z.enum(["asc", "desc"]).default("desc"),})