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.

move Submitted Leads to its own page

Steven Tey54af5436dbcb
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/layout.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/layout.tsx
deleted file mode 100644
index c5674b8110..0000000000
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/layout.tsx
+++ /dev/null
@@ -1,159 +0,0 @@
-"use client";
-
-import { SUBMITTED_LEADS_ENABLED_PROGRAM_IDS } from "@/lib/submitted-leads/constants";
-import usePartnerCustomersCount from "@/lib/swr/use-partner-customers-count";
-import { usePartnerSubmittedLeadsCount } from "@/lib/swr/use-partner-submitted-leads-count";
-import useProgramEnrollment from "@/lib/swr/use-program-enrollment";
-import { submittedLeadFormSchema } from "@/lib/zod/schemas/submitted-lead-form";
-import { PartnerCustomersMenuPopover } from "@/ui/customers/partner-customers-menu-popover";
-import { PageContent } from "@/ui/layout/page-content";
-import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
-import { SubmitLeadSheet } from "@/ui/submitted-leads/submit-lead-sheet";
-import { Button, InfoTooltip } from "@dub/ui";
-import { cn, nFormatter } from "@dub/utils";
-import Link from "next/link";
-import { useParams, usePathname } from "next/navigation";
-import { CSSProperties, ReactNode, useMemo, useState } from "react";
-import * as z from "zod/v4";
-
-export default function PartnerProgramCustomersLayout({
- children,
-}: {
- children: ReactNode;
-}) {
- const pathname = usePathname();
- const { programEnrollment } = useProgramEnrollment();
- const { programSlug } = useParams<{ programSlug: string }>();
- const [showLeadSheet, setShowLeadSheet] = useState(false);
-
- const { data: customersCount } = usePartnerCustomersCount<number>({
- includeParams: [],
- });
-
- const { data: leadsCount } = usePartnerSubmittedLeadsCount<number>({
- ignoreParams: true,
- });
-
- const leadFormDataRaw = programEnrollment?.program?.referralFormData;
- const programId = programEnrollment?.programId;
-
- const isEnabled = programId
- ? SUBMITTED_LEADS_ENABLED_PROGRAM_IDS.includes(programId)
- : false;
-
- const leadFormData = useMemo(() => {
- if (!leadFormDataRaw) {
- return null;
- }
- try {
- return submittedLeadFormSchema.parse(leadFormDataRaw) as z.infer<
- typeof submittedLeadFormSchema
- >;
- } catch {
- return null;
- }
- }, [leadFormDataRaw]);
-
- const isLeadsTab = pathname.endsWith("/customers/leads");
-
- const tabs = useMemo(() => {
- if (!isEnabled) {
- return [];
- }
-
- return [
- {
- label: "Customers",
- id: "customers",
- href: "",
- info: "Shows both your converted and non-converted customers.",
- count: customersCount,
- },
- {
- label: "Submitted leads",
- id: "leads",
- href: "leads",
- info: "Shows your submitted leads.",
- count: leadsCount,
- },
- ];
- }, [isEnabled, customersCount, leadsCount]);
-
- return (
- <PageContent
- title="Customers"
- controls={
- <>
- {isEnabled && (
- <Button
- text="Submit lead"
- className="h-9 w-fit rounded-lg"
- disabled={!leadFormData}
- disabledTooltip={
- leadFormData ? undefined : "Submitted leads are not offered."
- }
- onClick={() => {
- setShowLeadSheet(true);
- }}
- />
- )}
- {!isLeadsTab && <PartnerCustomersMenuPopover />}
- </>
- }
- >
- {isEnabled && leadFormData && programEnrollment?.programId && (
- <SubmitLeadSheet
- isOpen={showLeadSheet}
- setIsOpen={setShowLeadSheet}
- programId={programEnrollment.programId}
- leadFormData={leadFormData}
- />
- )}
-
- <PageWidthWrapper className="flex flex-col gap-3 pb-10">
- {tabs.length > 0 && (
- <div
- className={cn(
- "grid grid-cols-[repeat(var(--tabs),minmax(0,1fr))] gap-2",
- )}
- style={{ "--tabs": tabs.length } as CSSProperties}
- >
- {tabs.map((tab) => {
- const isActive = pathname.endsWith(
- `/customers${tab.href ? `/${tab.href}` : ""}`,
- );
-
- return (
- <Link
- key={tab.id}
- href={`/programs/${programSlug}/customers${tab.href ? `/${tab.href}` : ""}`}
- className={cn(
- "border-border-subtle flex flex-col gap-1 rounded-lg border p-4 text-left transition-colors duration-100",
- isActive
- ? "border-black ring-1 ring-black"
- : "hover:bg-bg-muted",
- )}
- >
- <div className="flex items-center gap-2">
- <span className="text-content-default text-xs font-semibold">
- {tab.label}
- </span>
- {tab.info && <InfoTooltip content={tab.info} />}
- </div>
- {tab.count !== undefined ? (
- <span className="text-content-emphasis text-base font-semibold">
- {nFormatter(tab.count, { full: true })}
- </span>
- ) : (
- <div className="h-6 w-12 animate-pulse rounded-md bg-neutral-200" />
- )}
- </Link>
- );
- })}
- </div>
- )}
- {children}
- </PageWidthWrapper>
- </PageContent>
- );
-}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx
index bab2f49044..c755d704c3 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/page.tsx
@@ -8,6 +8,9 @@ import usePartnerCustomers from "@/lib/swr/use-partner-customers";
import usePartnerCustomersCount from "@/lib/swr/use-partner-customers-count";
import useProgramEnrollment from "@/lib/swr/use-program-enrollment";
import { CustomerRowItem } from "@/ui/customers/customer-row-item";
+import { PartnerCustomersMenuPopover } from "@/ui/customers/partner-customers-menu-popover";
+import { PageContent } from "@/ui/layout/page-content";
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
import { AnimatedEmptyState } from "@/ui/shared/animated-empty-state";
import { CountryFlag } from "@/ui/shared/country-flag";
import { SearchBoxPersisted } from "@/ui/shared/search-box";
@@ -305,59 +308,63 @@ export default function PartnerProgramCustomersPage() {
});
return (
- <div className="flex flex-col gap-4">
- <div>
- <div className="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
- <Filter.Select
- className="w-full md:w-fit"
- filters={filters}
- activeFilters={activeFilters}
- onSelect={onSelect}
- onRemove={onRemove}
- onSelectedFilterChange={setSelectedFilter}
- />
- {Boolean(programEnrollment?.customerDataSharingEnabledAt) && (
- <SearchBoxPersisted
- placeholder="Search by email or name"
- inputClassName="md:w-[16rem]"
- />
- )}
- </div>
- <AnimatedSizeContainer height>
+ <PageContent title="Customers" controls={<PartnerCustomersMenuPopover />}>
+ <PageWidthWrapper className="flex flex-col gap-3 pb-10">
+ <div className="flex flex-col gap-4">
<div>
- {activeFilters.length > 0 && (
- <div className="pt-3">
- <Filter.List
- filters={filters}
- activeFilters={activeFilters}
- onSelect={onSelect}
- onRemove={onRemove}
- onRemoveAll={onRemoveAll}
+ <div className="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
+ <Filter.Select
+ className="w-full md:w-fit"
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ onSelectedFilterChange={setSelectedFilter}
+ />
+ {Boolean(programEnrollment?.customerDataSharingEnabledAt) && (
+ <SearchBoxPersisted
+ placeholder="Search by email or name"
+ inputClassName="md:w-[16rem]"
/>
+ )}
+ </div>
+ <AnimatedSizeContainer height>
+ <div>
+ {activeFilters.length > 0 && (
+ <div className="pt-3">
+ <Filter.List
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ onRemoveAll={onRemoveAll}
+ />
+ </div>
+ )}
</div>
- )}
+ </AnimatedSizeContainer>
</div>
- </AnimatedSizeContainer>
- </div>
- {customers?.length !== 0 ? (
- <Table {...tableProps} table={table} />
- ) : (
- <AnimatedEmptyState
- title={isFiltered ? "No customers found" : "No customers yet"}
- description={
- isFiltered
- ? "No customers found for the selected filters. Adjust your filters to refine your search results."
- : "No customers have been recorded for this program yet. Once customers start converting through your links, they'll appear here."
- }
- cardContent={() => (
- <>
- <User className="size-4 text-neutral-700" />
- <div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />
- </>
+ {customers?.length !== 0 ? (
+ <Table {...tableProps} table={table} />
+ ) : (
+ <AnimatedEmptyState
+ title={isFiltered ? "No customers found" : "No customers yet"}
+ description={
+ isFiltered
+ ? "No customers found for the selected filters. Adjust your filters to refine your search results."
+ : "No customers have been recorded for this program yet. Once customers start converting through your links, they'll appear here."
+ }
+ cardContent={() => (
+ <>
+ <User className="size-4 text-neutral-700" />
+ <div className="h-2.5 w-24 min-w-0 rounded-sm bg-neutral-200" />
+ </>
+ )}
+ />
)}
- />
- )}
- </div>
+ </div>
+ </PageWidthWrapper>
+ </PageContent>
);
}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx
index 10f09a6c1e..bc0771de58 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/[customerId]/page.tsx
@@ -9,7 +9,7 @@ export default async function PartnerProgramCustomerPage({
const { programSlug, customerId } = await params;
if (customerId === "referrals") {
- redirect(`/programs/${programSlug}/customers/leads`);
+ redirect(`/programs/${programSlug}/leads`);
}
return <ProgramCustomerPageClient />;
}
diff --git a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/leads/page.tsx b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/leads/page.tsx
similarity index 66%
rename from apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/leads/page.tsx
rename to apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/leads/page.tsx
index f5ecc6074d..58c36244cb 100644
--- a/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/customers/(index)/leads/page.tsx
+++ b/apps/web/app/(ee)/partners.dub.co/(dashboard)/programs/[programSlug]/(enrolled)/leads/page.tsx
@@ -1,16 +1,23 @@
"use client";
+import { SUBMITTED_LEADS_ENABLED_PROGRAM_IDS } from "@/lib/submitted-leads/constants";
import { usePartnerSubmittedLeads } from "@/lib/swr/use-partner-submitted-leads";
import { usePartnerSubmittedLeadsCount } from "@/lib/swr/use-partner-submitted-leads-count";
+import useProgramEnrollment from "@/lib/swr/use-program-enrollment";
import { PartnerProfileSubmittedLeadsCountByStatus } from "@/lib/types";
import { PartnerProfileSubmittedLead } from "@/lib/zod/schemas/partner-profile";
+import { submittedLeadFormSchema } from "@/lib/zod/schemas/submitted-lead-form";
+import { PageContent } from "@/ui/layout/page-content";
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
import { SearchBoxPersisted } from "@/ui/shared/search-box";
import { PartnerProfileSubmittedLeadSheet } from "@/ui/submitted-leads/partner-profile-submitted-lead-sheet";
import { PartnerProfileSubmittedLeadsEmptyState } from "@/ui/submitted-leads/partner-profile-submitted-leads-empty-state";
+import { SubmitLeadSheet } from "@/ui/submitted-leads/submit-lead-sheet";
import { SubmittedLeadStatusBadges } from "@/ui/submitted-leads/submitted-lead-status-badges";
import { getCompanyLogoUrl } from "@/ui/submitted-leads/submitted-lead-utils";
import {
AnimatedSizeContainer,
+ Button,
Filter,
StatusBadge,
Table,
@@ -25,10 +32,13 @@ import { cn, formatDate, nFormatter, OG_AVATAR_URL } from "@dub/utils";
import { SubmittedLeadStatus } from "@prisma/client";
import { Row } from "@tanstack/react-table";
import { useEffect, useMemo, useState } from "react";
+import * as z from "zod/v4";
export default function PartnerProgramSubmittedLeadsPage() {
- const { queryParams, searchParams } = useRouterStuff();
+ const { queryParams, searchParams, searchParamsObj } = useRouterStuff();
const { pagination, setPagination } = usePagination();
+ const { programEnrollment } = useProgramEnrollment();
+ const [showLeadSheet, setShowLeadSheet] = useState(false);
const leadIdFromUrl = searchParams.get("leadId");
@@ -40,10 +50,29 @@ export default function PartnerProgramSubmittedLeadsPage() {
open: !!leadIdFromUrl,
});
- const { searchParamsObj } = useRouterStuff();
const status = searchParamsObj.status as SubmittedLeadStatus | undefined;
const search = searchParamsObj.search as string | undefined;
+ const leadFormDataRaw = programEnrollment?.program?.referralFormData;
+ const programId = programEnrollment?.programId;
+
+ const isEnabled = programId
+ ? SUBMITTED_LEADS_ENABLED_PROGRAM_IDS.includes(programId)
+ : false;
+
+ const leadFormData = useMemo(() => {
+ if (!leadFormDataRaw) {
+ return null;
+ }
+ try {
+ return submittedLeadFormSchema.parse(leadFormDataRaw) as z.infer<
+ typeof submittedLeadFormSchema
+ >;
+ } catch {
+ return null;
+ }
+ }, [leadFormDataRaw]);
+
const { data: countByStatus } = usePartnerSubmittedLeadsCount<
PartnerProfileSubmittedLeadsCountByStatus[] | undefined
>({
@@ -277,77 +306,105 @@ export default function PartnerProgramSubmittedLeadsPage() {
}, [searchParams, detailsSheetState.leadId]);
return (
- <div className="flex flex-col gap-3">
- {detailsSheetState.leadId && currentLead && (
- <PartnerProfileSubmittedLeadSheet
- isOpen={detailsSheetState.open}
- setIsOpen={(open) =>
- setDetailsSheetState((s) => ({ ...s, open }) as any)
- }
- lead={currentLead}
- onPrevious={
- previousLeadId
- ? () => {
- queryParams({
- set: { leadId: previousLeadId },
- });
- setDetailsSheetState({
- leadId: previousLeadId,
- open: true,
- });
- }
- : undefined
- }
- onNext={
- nextLeadId
- ? () => {
- queryParams({
- set: { leadId: nextLeadId },
- });
- setDetailsSheetState({
- leadId: nextLeadId,
- open: true,
- });
- }
- : undefined
- }
+ <PageContent
+ title="Submitted Leads"
+ controls={
+ isEnabled ? (
+ <Button
+ text="Submit lead"
+ className="h-9 w-fit rounded-lg"
+ disabled={!leadFormData}
+ disabledTooltip={
+ leadFormData ? undefined : "Submitted leads are not offered."
+ }
+ onClick={() => {
+ setShowLeadSheet(true);
+ }}
+ />
+ ) : undefined
+ }
+ >
+ {isEnabled && leadFormData && programEnrollment?.programId && (
+ <SubmitLeadSheet
+ isOpen={showLeadSheet}
+ setIsOpen={setShowLeadSheet}
+ programId={programEnrollment.programId}
+ leadFormData={leadFormData}
/>
)}
- <div>
- <div className="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
- <Filter.Select
- className="w-full md:w-fit"
- filters={filters}
- activeFilters={activeFilters}
- onSelect={onSelect}
- onRemove={onRemove}
- />
- <SearchBoxPersisted
- placeholder="Search by email or name"
- inputClassName="md:w-[16rem]"
+
+ <PageWidthWrapper className="flex flex-col gap-3 pb-10">
+ {detailsSheetState.leadId && currentLead && (
+ <PartnerProfileSubmittedLeadSheet
+ isOpen={detailsSheetState.open}
+ setIsOpen={(open) =>
+ setDetailsSheetState((s) => ({ ...s, open }) as any)
+ }
+ lead={currentLead}
+ onPrevious={
+ previousLeadId
+ ? () => {
+ queryParams({
+ set: { leadId: previousLeadId },
+ });
+ setDetailsSheetState({
+ leadId: previousLeadId,
+ open: true,
+ });
+ }
+ : undefined
+ }
+ onNext={
+ nextLeadId
+ ? () => {
+ queryParams({
+ set: { leadId: nextLeadId },
+ });
+ setDetailsSheetState({
+ leadId: nextLeadId,
+ open: true,
+ });
+ }
+ : undefined
+ }
/>
- </div>
- <AnimatedSizeContainer height>
- <div>
- {activeFilters.length > 0 && (
- <div className="pt-3">
- <Filter.List
- filters={filters}
- activeFilters={activeFilters}
- onSelect={onSelect}
- onRemove={onRemove}
- onRemoveAll={onRemoveAll}
- />
- </div>
- )}
+ )}
+ <div>
+ <div className="flex flex-col gap-3 md:flex-row md:items-center md:justify-between">
+ <Filter.Select
+ className="w-full md:w-fit"
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ />
+ <SearchBoxPersisted
+ placeholder="Search by email or name"
+ inputClassName="md:w-[16rem]"
+ />
</div>
- </AnimatedSizeContainer>
- </div>
- {leads && leads.length !== 0 ? (
- <Table {...tableProps} table={table} />
- ) : !isLoading ? (
- <PartnerProfileSubmittedLeadsEmptyState />
- ) : null}
- </div>
+ <AnimatedSizeContainer height>
+ <div>
+ {activeFilters.length > 0 && (
+ <div className="pt-3">
+ <Filter.List
+ filters={filters}
+ activeFilters={activeFilters}
+ onSelect={onSelect}
+ onRemove={onRemove}
+ onRemoveAll={onRemoveAll}
+ />
+ </div>
+ )}
+ </div>
+ </AnimatedSizeContainer>
+ </div>
+ {leads && leads.length !== 0 ? (
+ <Table {...tableProps} table={table} />
+ ) : !isLoading ? (
+ <PartnerProfileSubmittedLeadsEmptyState />
+ ) : null}
+ </PageWidthWrapper>
+ </PageContent>
);
}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/(index)/layout.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/(index)/layout.tsx
deleted file mode 100644
index b76391e352..0000000000
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/(index)/layout.tsx
+++ /dev/null
@@ -1,116 +0,0 @@
-"use client";
-
-import { SUBMITTED_LEADS_ENABLED_PROGRAM_IDS } from "@/lib/submitted-leads/constants";
-import useCustomersCount from "@/lib/swr/use-customers-count";
-import { useProgramSubmittedLeadsCount } from "@/lib/swr/use-program-submitted-leads-count";
-import useWorkspace from "@/lib/swr/use-workspace";
-import { CustomersMenuPopover } from "@/ui/customers/customers-menu-popover";
-import { PageContent } from "@/ui/layout/page-content";
-import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
-import { InfoTooltip } from "@dub/ui";
-import { cn } from "@dub/utils";
-import Link from "next/link";
-import { usePathname } from "next/navigation";
-import { CSSProperties, ReactNode, useMemo } from "react";
-
-export default function PartnerCustomersLayout({
- children,
-}: {
- children: ReactNode;
-}) {
- const pathname = usePathname();
- const { slug, defaultProgramId } = useWorkspace();
-
- const { data: customersCount } = useCustomersCount<number>({
- includeParams: [],
- });
-
- const isReferralEnabled = defaultProgramId
- ? SUBMITTED_LEADS_ENABLED_PROGRAM_IDS.includes(defaultProgramId)
- : false;
-
- const { data: leadsCount } = useProgramSubmittedLeadsCount<number>({
- ignoreParams: true,
- enabled: isReferralEnabled,
- });
-
- const tabs = useMemo(() => {
- if (!isReferralEnabled) {
- return [];
- }
-
- return [
- {
- label: "Customers",
- id: "customers",
- href: "",
- info: "Shows both converted and non-converted customers.",
- count: customersCount,
- },
- {
- label: "Submitted leads",
- id: "leads",
- href: "leads",
- info: "Shows your partners' submitted leads.",
- count: leadsCount,
- },
- ];
- }, [isReferralEnabled, customersCount, leadsCount]);
-
- return (
- <PageContent
- title="Customers"
- titleInfo={{
- title:
- "Get deeper, real-time insights about your referred customers' demographics, purchasing behavior, and lifetime value (LTV).",
- href: "https://dub.co/help/article/customer-insights",
- }}
- controls={<CustomersMenuPopover />}
- >
- <PageWidthWrapper className="flex flex-col gap-3 pb-10">
- {tabs.length > 0 && (
- <div
- className={cn(
- "grid grid-cols-[repeat(var(--tabs),minmax(0,1fr))] gap-2",
- )}
- style={{ "--tabs": tabs.length } as CSSProperties}
- >
- {tabs.map((tab) => {
- const isActive = pathname.endsWith(
- `/customers${tab.href ? `/${tab.href}` : ""}`,
- );
-
- return (
- <Link
- key={tab.id}
- href={`/${slug}/program/customers${tab.href ? `/${tab.href}` : ""}`}
- className={cn(
- "border-border-subtle flex flex-col gap-1 rounded-lg border p-4 text-left transition-colors duration-100",
- isActive
- ? "border-black ring-1 ring-black"
- : "hover:bg-bg-muted",
- )}
- >
- <div className="flex items-center gap-2">
- <span className="text-content-default text-xs font-semibold">
- {tab.label}
- </span>
- {tab.info && <InfoTooltip content={tab.info} />}
- </div>
- {tab.count !== undefined ? (
- <span className="text-content-emphasis text-base font-semibold">
- {tab.count.toLocaleString()}
- </span>
- ) : (
- <div className="h-6 w-12 animate-pulse rounded-md bg-neutral-200" />
- )}
- </Link>
- );
- })}
- </div>
- )}
- {children}
- </PageWidthWrapper>
- </PageContent>
- );
-}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/(index)/leads/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/(index)/leads/page.tsx
deleted file mode 100644
index fd39273f9a..0000000000
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/(index)/leads/page.tsx
+++ /dev/null
@@ -1,7 +0,0 @@
-"use client";
-
-import { SubmittedLeadTable } from "@/ui/submitted-leads/submitted-lead-table";
-
-export default function SubmittedLeadsPage() {
- return <SubmittedLeadTable />;
-}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/(index)/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/(index)/page.tsx
index 49ef6c45d9..c4f6c6ad0d 100644
--- a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/(index)/page.tsx
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/customers/(index)/page.tsx
@@ -1,11 +1,26 @@
"use client";
import useWorkspace from "@/lib/swr/use-workspace";
+import { CustomersMenuPopover } from "@/ui/customers/customers-menu-popover";
import { CustomersTable } from "@/ui/customers/customers-table/customers-table";
+import { PageContent } from "@/ui/layout/page-content";
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
export default function ProgramCustomersPage() {
const { defaultProgramId } = useWorkspace();
return (
- <CustomersTable query={{ programId: defaultProgramId || undefined }} />
+ <PageContent
+ title="Customers"
+ titleInfo={{
+ title:
+ "Get deeper, real-time insights about your referred customers' demographics, purchasing behavior, and lifetime value (LTV).",
+ href: "https://dub.co/help/article/customer-insights",
+ }}
+ controls={<CustomersMenuPopover />}
+ >
+ <PageWidthWrapper className="flex flex-col gap-3 pb-10">
+ <CustomersTable query={{ programId: defaultProgramId || undefined }} />
+ </PageWidthWrapper>
+ </PageContent>
);
}
diff --git a/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/leads/page.tsx b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/leads/page.tsx
new file mode 100644
index 0000000000..fdc6ea49bb
--- /dev/null
+++ b/apps/web/app/app.dub.co/(dashboard)/[slug]/(ee)/program/leads/page.tsx
@@ -0,0 +1,19 @@
+import { PageContent } from "@/ui/layout/page-content";
+import { PageWidthWrapper } from "@/ui/layout/page-width-wrapper";
+import { SubmittedLeadTable } from "@/ui/submitted-leads/submitted-lead-table";
+
+export default function SubmittedLeadsPage() {
+ return (
+ <PageContent
+ title="Submitted Leads"
+ titleInfo={{
+ title:
+ "Review and manage leads submitted by your partners. [Learn more](https://dub.co/help/article/submitted-leads).",
+ }}
+ >
+ <PageWidthWrapper className="flex flex-col gap-3 pb-10">
+ <SubmittedLeadTable />
+ </PageWidthWrapper>
+ </PageContent>
+ );
+}
diff --git a/apps/web/lib/middleware/utils/app-redirect.ts b/apps/web/lib/middleware/utils/app-redirect.ts
index e3cc1f0376..99b1a5f80d 100644
--- a/apps/web/lib/middleware/utils/app-redirect.ts
+++ b/apps/web/lib/middleware/utils/app-redirect.ts
@@ -98,10 +98,15 @@ export const appRedirect = async (path: string) => {
"/$1/program/partners/$2/links?profile=true",
);
+ // Redirect "/[slug]/program/customers/leads" to "/[slug]/program/leads"
+ const programCustomersLeadsRegex =
+ /^\/([^\/]+)\/program\/customers\/leads$/;
+ if (programCustomersLeadsRegex.test(path))
+ return path.replace(programCustomersLeadsRegex, "/$1/program/leads");
+
// Redirect "/[slug]/[*]/customers/:customerId" to "/[slug]/[*]/customers/:customerId/sales"
- // Exclude "leads" since it's a tab route, not a customer ID
const customersPageRegex =
- /^\/([^\/]+)\/([^\/]+)\/customers\/(?!leads$)([^\/]+)$/;
+ /^\/([^\/]+)\/([^\/]+)\/customers\/([^\/]+)$/;
if (customersPageRegex.test(path))
return path.replace(customersPageRegex, "/$1/$2/customers/$3/sales");
diff --git a/apps/web/lib/middleware/utils/partners-redirect.ts b/apps/web/lib/middleware/utils/partners-redirect.ts
index b57d1684f9..d9b9678738 100644
--- a/apps/web/lib/middleware/utils/partners-redirect.ts
+++ b/apps/web/lib/middleware/utils/partners-redirect.ts
@@ -52,6 +52,13 @@ const PARTNERS_PROGRAM_REDIRECTS = {
};
export const partnersProgramRedirects = (path: string) => {
+ const customersLeadsMatch = path.match(
+ /^\/programs\/([^/]+)\/customers\/leads$/,
+ );
+ if (customersLeadsMatch) {
+ return `/programs/${customersLeadsMatch[1]}/leads`;
+ }
+
const programRedirect = Object.keys(PARTNERS_PROGRAM_REDIRECTS).find(
(redirect) => path === `/${redirect}` || path.includes(`/${redirect}/`),
);
diff --git a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
index 5133dedecc..82530fd667 100644
--- a/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/app-sidebar-nav.tsx
@@ -83,6 +83,7 @@ type SidebarNavData = {
unreadMessagesCount?: number;
pendingFraudEventsCount?: number;
pendingLeadsCount?: number;
+ submittedLeadsEnabled?: boolean;
partnerNetworkEnabled?: boolean;
};
@@ -132,6 +133,7 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {
unreadMessagesCount,
pendingFraudEventsCount,
pendingLeadsCount,
+ submittedLeadsEnabled,
partnerNetworkEnabled,
}) => ({
title: "Partner Program",
@@ -220,11 +222,6 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {
name: "Customers",
icon: User,
href: `/${slug}/program/customers`,
- badge: pendingLeadsCount
- ? pendingLeadsCount > 99
- ? "99+"
- : pendingLeadsCount
- : undefined,
},
{
name: "Commissions",
@@ -261,6 +258,20 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {
icon: PaperPlane,
href: `/${slug}/program/campaigns` as `/${string}`,
},
+ ...(submittedLeadsEnabled
+ ? [
+ {
+ name: "Submitted Leads",
+ icon: UserPlus,
+ href: `/${slug}/program/leads` as `/${string}`,
+ badge: pendingLeadsCount
+ ? pendingLeadsCount > 99
+ ? "99+"
+ : pendingLeadsCount
+ : undefined,
+ },
+ ]
+ : []),
{
name: "Resources",
icon: LifeRing,
@@ -673,6 +684,10 @@ export function AppSidebarNav({
unreadMessagesCount,
pendingFraudEventsCount,
pendingLeadsCount,
+ submittedLeadsEnabled: Boolean(
+ defaultProgramId &&
+ SUBMITTED_LEADS_ENABLED_PROGRAM_IDS.includes(defaultProgramId),
+ ),
partnerNetworkEnabled:
program && program.partnerNetworkEnabledAt !== null,
}}
diff --git a/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx b/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx
index a006712809..cb3630207e 100644
--- a/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx
+++ b/apps/web/ui/layout/sidebar/partners-sidebar-nav.tsx
@@ -1,6 +1,7 @@
"use client";
import { useProgramMessagesCount } from "@/lib/messages/hooks/use-program-messages-count";
+import { SUBMITTED_LEADS_ENABLED_PROGRAM_IDS } from "@/lib/submitted-leads/constants";
import usePartnerProfile from "@/lib/swr/use-partner-profile";
import { usePartnerProgramBounties } from "@/lib/swr/use-partner-program-bounties";
import useProgramEnrollment from "@/lib/swr/use-program-enrollment";
@@ -25,6 +26,7 @@ import {
SquareUserSparkle2,
Trophy,
UserCheck,
+ UserPlus,
Users2,
Webhook,
} from "@dub/ui/icons";
@@ -58,6 +60,7 @@ type SidebarNavData = {
showDetailedAnalytics?: boolean;
postbacksEnabled?: boolean;
hasReferralReward?: boolean;
+ submittedLeadsEnabled?: boolean;
newsContent?: ReactNode;
};
@@ -202,6 +205,7 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {
programBountiesCount,
showDetailedAnalytics,
hasReferralReward,
+ submittedLeadsEnabled,
}) => ({
title: <PartnerProgramDropdown />,
content: [
@@ -274,6 +278,16 @@ const NAV_AREAS: SidebarNavAreas<SidebarNavData> = {
: programBountiesCount || undefined,
locked: isUnapproved,
},
+ ...(submittedLeadsEnabled
+ ? [
+ {
+ name: "Submitted Leads",
+ icon: UserPlus as Icon,
+ href: `/programs/${programSlug}/leads` as `/${string}`,
+ locked: isUnapproved,
+ },
+ ]
+ : []),
...(hasReferralReward
? [
{
@@ -424,6 +438,11 @@ export function PartnersSidebarNav({
showDetailedAnalytics,
postbacksEnabled: partner?.featureFlags?.postbacks,
hasReferralReward: !!programEnrollment?.referralRewardId,
+ submittedLeadsEnabled: programEnrollment?.programId
+ ? SUBMITTED_LEADS_ENABLED_PROGRAM_IDS.includes(
+ programEnrollment.programId,
+ )
+ : false,
newsContent,
}}
toolContent={composedToolContent}
diff --git a/packages/email/src/templates/new-lead-submitted.tsx b/packages/email/src/templates/new-lead-submitted.tsx
index c9f6d4bdb9..d3df222031 100644
--- a/packages/email/src/templates/new-lead-submitted.tsx
+++ b/packages/email/src/templates/new-lead-submitted.tsx
@@ -58,7 +58,7 @@ export default function NewLeadSubmitted({
image: string | null;
};
}) {
- const leadUrl = `https://app.dub.co/${workspace.slug}/program/customers/leads?leadId=${lead.id}`;
+ const leadUrl = `https://app.dub.co/${workspace.slug}/program/leads?leadId=${lead.id}`;
return (
<Html>