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.

simplify admin

Steven Teye69c515486f3
diff --git a/apps/web/app/admin.dub.co/(dashboard)/components/user-info.tsx b/apps/web/app/admin.dub.co/(dashboard)/components/user-info.tsx
index 3ca8b7dbe3..f8a96c4bf3 100644
--- a/apps/web/app/admin.dub.co/(dashboard)/components/user-info.tsx
+++ b/apps/web/app/admin.dub.co/(dashboard)/components/user-info.tsx
@@ -1,19 +1,19 @@
"use client";
-import { Badge, Copy, Globe2, Tick, useCopyToClipboard } from "@dub/ui";
+import { Badge, Copy, Tick, useCopyToClipboard } from "@dub/ui";
import { capitalize, nFormatter } from "@dub/utils";
import { toast } from "sonner";
export interface UserInfoProps {
email: string;
- defaultDomainLinks: Record<string, number>;
workspaces: {
id: string;
name: string;
slug: string;
plan: string;
clicks: number;
- domains: number;
links: number;
+ sales: number;
+ folders: number;
}[];
impersonateUrl: {
app: string;
@@ -33,19 +33,6 @@ export default function UserInfo({ data }: { data: UserInfoProps }) {
text="partners.dub.co login link"
url={data.impersonateUrl.partners}
/>
- {Object.keys(data.defaultDomainLinks).length > 0 && (
- <div className="grid divide-y divide-neutral-200">
- {Object.entries(data.defaultDomainLinks).map(([domain, count]) => (
- <div key={domain} className="flex justify-between py-2">
- <div className="flex items-center space-x-2">
- <Globe2 className="h-4 w-4" />
- <span className="font-semibold text-neutral-700">{domain}</span>
- </div>
- <span className="text-neutral-500">{count}</span>
- </div>
- ))}
- </div>
- )}
<div className="grid grid-cols-2 gap-4">
{data.workspaces.map((workspace) => (
<div
@@ -67,8 +54,10 @@ export default function UserInfo({ data }: { data: UserInfoProps }) {
</span>
</div>
<div className="flex justify-between text-sm">
- <span className="font-medium text-neutral-700">Domains</span>
- <span className="text-neutral-500">{workspace.domains}</span>
+ <span className="font-medium text-neutral-700">Folders</span>
+ <span className="text-neutral-500">
+ {nFormatter(workspace.folders, { full: true })}
+ </span>
</div>
<div className="flex justify-between text-sm">
<span className="font-medium text-neutral-700">Links</span>
@@ -82,6 +71,12 @@ export default function UserInfo({ data }: { data: UserInfoProps }) {
{nFormatter(workspace.clicks, { full: true })}
</span>
</div>
+ <div className="flex justify-between text-sm">
+ <span className="font-medium text-neutral-700">Sales</span>
+ <span className="text-neutral-500">
+ {nFormatter(workspace.sales, { full: true })}
+ </span>
+ </div>
</div>
))}
</div>
diff --git a/apps/web/app/api/admin/impersonate/route.ts b/apps/web/app/api/admin/impersonate/route.ts
index 721975e256..47019810ba 100644
--- a/apps/web/app/api/admin/impersonate/route.ts
+++ b/apps/web/app/api/admin/impersonate/route.ts
@@ -1,6 +1,6 @@
import { hashToken, withAdmin } from "@/lib/auth";
import { prisma } from "@dub/prisma";
-import { APP_DOMAIN, DUB_DOMAINS_ARRAY, PARTNERS_DOMAIN } from "@dub/utils";
+import { APP_DOMAIN, PARTNERS_DOMAIN } from "@dub/utils";
import { randomBytes } from "crypto";
import { NextResponse } from "next/server";
@@ -23,16 +23,6 @@ export const POST = withAdmin(async ({ req }) => {
},
select: {
email: true,
- links: {
- where: {
- domain: {
- in: DUB_DOMAINS_ARRAY,
- },
- },
- select: {
- domain: true,
- },
- },
projects: {
select: {
project: {
@@ -42,12 +32,9 @@ export const POST = withAdmin(async ({ req }) => {
slug: true,
plan: true,
usage: true,
- _count: {
- select: {
- domains: true,
- links: true,
- },
- },
+ linksUsage: true,
+ salesUsage: true,
+ foldersUsage: true,
},
},
},
@@ -61,24 +48,13 @@ export const POST = withAdmin(async ({ req }) => {
const data = {
email: response.email,
- // object with domain slugs as keys and the count of links as values
- defaultDomainLinks: response.links.reduce(
- (acc, { domain }) => {
- if (acc[domain]) {
- acc[domain]++;
- } else {
- acc[domain] = 1;
- }
- return acc;
- },
- {} as Record<string, number>,
- ),
workspaces: response.projects.map(({ project }) => ({
...project,
id: `ws_${project.id}`,
clicks: project.usage,
- domains: project._count.domains,
- links: project._count.links,
+ links: project.linksUsage,
+ sales: project.salesUsage,
+ folders: project.foldersUsage,
})),
impersonateUrl: await getImpersonateUrl(response.email),
};