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 filters

Tim Wilsonf0a8166f27e0
diff --git a/apps/web/app/(ee)/api/network/partners/count/route.ts b/apps/web/app/(ee)/api/network/partners/count/route.ts
index ab536c16f4..0501a83c77 100644
--- a/apps/web/app/(ee)/api/network/partners/count/route.ts
+++ b/apps/web/app/(ee)/api/network/partners/count/route.ts
@@ -8,7 +8,7 @@ import { NextResponse } from "next/server";
export const GET = withWorkspace(
async ({ workspace, searchParams }) => {
const programId = getDefaultProgramIdOrThrow(workspace);
- const { status, groupBy, country } =
+ const { status, groupBy, country, starred, industryInterests } =
getPartnerNetworkPartnersCountQuerySchema.parse(searchParams);
const commonWhere = {
@@ -21,7 +21,12 @@ export const GET = withWorkspace(
const statusWheres = {
discover: {
programs: { none: { programId } },
- discoveredPartners: { none: { programId, ignoredAt: { not: null } } },
+ discoveredPartners: {
+ none: { programId, ignoredAt: { not: null } },
+ ...(starred === true && {
+ some: { programId, starredAt: { not: null } },
+ }),
+ },
},
invited: {
programs: { some: { programId, status: "invited" } },
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/page-client.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/page-client.tsx
index 6c36f98cea..794a0b5dbe 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/page-client.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/page-client.tsx
@@ -121,6 +121,7 @@ export function ProgramPartnersDirectoryPageClient() {
onClick={() => {
queryParams({
set: { tab: tab.id },
+ del: ["page", "starred"],
});
}}
>
@@ -148,20 +149,22 @@ export function ProgramPartnersDirectoryPageClient() {
onSelect={onSelect}
onRemove={onRemove}
/>
- <label className="flex items-center gap-2">
- <Switch
- checked={searchParams.get("starred") == "true"}
- fn={(checked) => {
- queryParams({
- set: checked ? { starred: "true" } : undefined,
- del: ["page", ...(!checked ? ["starred"] : [])],
- });
- }}
- />
- <span className="text-content-emphasis text-sm font-medium">
- Starred
- </span>
- </label>
+ {status === "discover" && (
+ <label className="flex items-center gap-2">
+ <Switch
+ checked={searchParams.get("starred") == "true"}
+ fn={(checked) => {
+ queryParams({
+ set: checked ? { starred: "true" } : undefined,
+ del: ["page", ...(!checked ? ["starred"] : [])],
+ });
+ }}
+ />
+ <span className="text-content-emphasis text-sm font-medium">
+ Starred
+ </span>
+ </label>
+ )}
</div>
<AnimatedSizeContainer height>
<div>
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/use-partner-network-filters.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/use-partner-network-filters.tsx
index 08d6bf76dd..e30448d7e8 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/use-partner-network-filters.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/partners/directory/use-partner-network-filters.tsx
@@ -1,6 +1,7 @@
+import { industryInterests } from "@/lib/partners/partner-profile";
import usePartnerNetworkPartnersCount from "@/lib/swr/use-partner-network-partners-count";
import { useRouterStuff } from "@dub/ui";
-import { FlagWavy } from "@dub/ui/icons";
+import { FlagWavy, Heart } from "@dub/ui/icons";
import { COUNTRIES, nFormatter } from "@dub/utils";
import { useMemo } from "react";
@@ -27,30 +28,20 @@ export function usePartnerNetworkFilters({
const filters = useMemo(
() => [
- // {
- // key: "status",
- // icon: CircleDotted,
- // label: "Status",
- // options:
- // statusCount
- // ?.filter(({ status }) => !["pending", "rejected"].includes(status))
- // ?.map(({ status, _count }) => {
- // const Icon = PartnerStatusBadges[status].icon;
- // return {
- // value: status,
- // label: PartnerStatusBadges[status].label,
- // icon: (
- // <Icon
- // className={cn(
- // PartnerStatusBadges[status].className,
- // "size-4 bg-transparent",
- // )}
- // />
- // ),
- // right: nFormatter(_count || 0, { full: true }),
- // };
- // }) ?? [],
- // },
+ {
+ key: "industryInterests",
+ icon: Heart,
+ label: "Industry interest",
+ multiple: true,
+ options:
+ industryInterests?.map(({ id, icon: Icon, label }) => {
+ return {
+ value: id,
+ label,
+ icon: <Icon className="size-4" />,
+ };
+ }) ?? [],
+ },
{
key: "country",
icon: FlagWavy,
@@ -76,20 +67,33 @@ export function usePartnerNetworkFilters({
[countriesCount],
);
+ const selectedIndustryInterests = useMemo(
+ () => searchParamsObj.industryInterests?.split(",")?.filter(Boolean) ?? [],
+ [searchParamsObj.industryInterests],
+ );
+
const activeFilters = useMemo(() => {
const { status, country } = searchParamsObj;
return [
- ...(status ? [{ key: "status", value: status }] : []),
+ // Handle tagIds special case
+ ...(selectedIndustryInterests.length > 0
+ ? [{ key: "industryInterests", value: selectedIndustryInterests }]
+ : []),
...(country ? [{ key: "country", value: country }] : []),
];
- }, [searchParamsObj]);
+ }, [searchParamsObj, selectedIndustryInterests]);
const onSelect = (key: string, value: any) =>
queryParams({
- set: {
- [key]: value,
- },
+ set:
+ key === "industryInterests"
+ ? {
+ [key]: selectedIndustryInterests.concat(value).join(","),
+ }
+ : {
+ [key]: value,
+ },
del: "page",
});
@@ -100,7 +104,7 @@ export function usePartnerNetworkFilters({
const onRemoveAll = () =>
queryParams({
- del: ["status", "country"],
+ del: ["industryInterests", "country"],
});
const isFiltered = activeFilters.length > 0 || searchParamsObj.search;
diff --git a/apps/web/lib/zod/schemas/partner-network.ts b/apps/web/lib/zod/schemas/partner-network.ts
index 6e0fd574d2..0ea184d404 100644
--- a/apps/web/lib/zod/schemas/partner-network.ts
+++ b/apps/web/lib/zod/schemas/partner-network.ts
@@ -1,3 +1,4 @@
+import { IndustryInterest } from "@dub/prisma/client";
import { z } from "zod";
import { booleanQuerySchema, getPaginationQuerySchema } from "./misc";
import { PartnerSchema } from "./partners";
@@ -36,6 +37,7 @@ export const getPartnerNetworkPartnersQuerySchema = z
status: partnerNetworkPartnersStatusSchema.default("discover"),
country: z.string().optional(),
starred: booleanQuerySchema.nullish(),
+ industryInterests: z.array(z.nativeEnum(IndustryInterest)).optional(),
})
.merge(
getPaginationQuerySchema({