Skip to content

Commit 7ecf115

Browse files
committed
small admin optimizations
1 parent 2cc8717 commit 7ecf115

7 files changed

Lines changed: 112 additions & 50 deletions

File tree

apps/web/app/(ee)/admin.dub.co/(dashboard)/commissions/client.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export default function CommissionsPageClient() {
171171
<div className="mx-auto flex w-full max-w-screen-xl flex-col space-y-6 p-6">
172172
<SimpleDateRangePicker defaultInterval="mtd" className="w-fit" />
173173
<div className="flex flex-col divide-y divide-neutral-200 rounded-lg border border-neutral-200 bg-white">
174-
<div className="scrollbar-hide grid w-full grid-cols-3 divide-x overflow-y-hidden">
174+
<div className="scrollbar-hide grid w-full grid-cols-2 divide-x overflow-y-hidden sm:grid-cols-3">
175175
{tabs.map(({ id, label, colorClassName }) => {
176176
return (
177177
<button

apps/web/app/(ee)/admin.dub.co/(dashboard)/components/ban-link.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ const Form = () => {
4848
disabled={pending}
4949
autoComplete="off"
5050
className={cn(
51-
"block w-full rounded-r-md border-neutral-300 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500",
51+
"block w-full rounded-r-md border-neutral-300 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-base",
5252
pending && "bg-neutral-100",
5353
)}
5454
placeholder="IG47WZs"

apps/web/app/(ee)/admin.dub.co/(dashboard)/components/impersonate-user.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export default function ImpersonateUser() {
3333
</form>
3434
{data && (
3535
<form
36-
action={async (formData) => {
36+
action={async () => {
3737
if (
3838
!confirm(
3939
`This will ban the user ${data.email} and delete all their workspaces and links. Are you sure?`,
@@ -79,7 +79,7 @@ const Form = () => {
7979
disabled={pending}
8080
autoComplete="off"
8181
className={cn(
82-
"block w-full rounded-md border-neutral-300 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500",
82+
"block w-full rounded-md border-neutral-300 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-base",
8383
pending && "bg-neutral-100",
8484
)}
8585
placeholder="stey@vercel.com"

apps/web/app/(ee)/admin.dub.co/(dashboard)/components/impersonate-workspace.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const Form = () => {
5252
disabled={pending}
5353
autoComplete="off"
5454
className={cn(
55-
"block w-full rounded-r-md border-neutral-300 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500",
55+
"block w-full rounded-r-md border-neutral-300 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-base",
5656
pending && "bg-neutral-100",
5757
)}
5858
placeholder="owd"

apps/web/app/(ee)/admin.dub.co/(dashboard)/components/refresh-domain.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ const Form = () => {
4545
disabled={pending}
4646
autoComplete="off"
4747
className={cn(
48-
"block w-full rounded-md border-neutral-300 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500",
48+
"block w-full rounded-md border-neutral-300 text-sm text-neutral-900 placeholder-neutral-400 focus:border-neutral-500 focus:outline-none focus:ring-neutral-500 sm:text-base",
4949
pending && "bg-neutral-100",
5050
)}
5151
placeholder="acme.com"
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
"use client";
2+
3+
import {
4+
ClientOnly,
5+
MaxWidthWrapper,
6+
NavWordmark,
7+
Popover,
8+
useMediaQuery,
9+
} from "@dub/ui";
10+
import Link from "next/link";
11+
import { useState } from "react";
12+
13+
const tabs = [
14+
{
15+
href: "/links",
16+
label: "Links",
17+
},
18+
{
19+
href: "/analytics",
20+
label: "Analytics",
21+
},
22+
{
23+
href: "/commissions",
24+
label: "Commissions",
25+
},
26+
{
27+
href: "/payouts",
28+
label: "Payouts",
29+
},
30+
];
31+
32+
export function AdminNav() {
33+
const [openPopover, setOpenPopover] = useState(false);
34+
const { isMobile } = useMediaQuery();
35+
36+
const NavContent = () => (
37+
<div className="flex w-full flex-col gap-1 p-2">
38+
{tabs.map((tab) => (
39+
<Link
40+
href={tab.href}
41+
key={tab.href}
42+
className="block w-full rounded-md px-4 py-2 text-left text-sm text-neutral-700 transition-colors hover:bg-neutral-100 active:bg-neutral-200"
43+
onClick={() => setOpenPopover(false)}
44+
>
45+
{tab.label}
46+
</Link>
47+
))}
48+
</div>
49+
);
50+
51+
return (
52+
<div className="sticky left-0 right-0 top-0 z-20 border-b border-neutral-200 bg-white">
53+
<MaxWidthWrapper>
54+
<div className="flex h-16 w-full items-center justify-between sm:justify-start sm:gap-12">
55+
<Link href="/">
56+
<NavWordmark className="h-6" />
57+
</Link>
58+
<ClientOnly>
59+
{isMobile ? (
60+
<div className="ml-auto">
61+
<Popover
62+
content={<NavContent />}
63+
openPopover={openPopover}
64+
setOpenPopover={setOpenPopover}
65+
mobileOnly
66+
>
67+
<button className="text-neutral-500">
68+
<svg
69+
width="24"
70+
height="24"
71+
viewBox="0 0 24 24"
72+
fill="none"
73+
stroke="currentColor"
74+
strokeWidth="2"
75+
strokeLinecap="round"
76+
strokeLinejoin="round"
77+
>
78+
<line x1="3" y1="12" x2="21" y2="12" />
79+
<line x1="3" y1="6" x2="21" y2="6" />
80+
<line x1="3" y1="18" x2="21" y2="18" />
81+
</svg>
82+
</button>
83+
</Popover>
84+
</div>
85+
) : (
86+
<div className="flex items-center gap-12">
87+
{tabs.map((tab) => (
88+
<Link
89+
href={tab.href}
90+
key={tab.href}
91+
className="text-sm text-neutral-500"
92+
>
93+
{tab.label}
94+
</Link>
95+
))}
96+
</div>
97+
)}
98+
</ClientOnly>
99+
</div>
100+
</MaxWidthWrapper>
101+
</div>
102+
);
103+
}

apps/web/app/(ee)/admin.dub.co/(dashboard)/layout.tsx

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,14 @@
1-
import { MaxWidthWrapper, NavWordmark } from "@dub/ui";
21
import { constructMetadata } from "@dub/utils";
3-
import Link from "next/link";
42
import { ReactNode } from "react";
3+
import { AdminNav } from "./layout-nav-client";
54

65
export const metadata = constructMetadata({ noIndex: true });
76

8-
const tabs = [
9-
{
10-
href: "/links",
11-
label: "Links",
12-
},
13-
{
14-
href: "/analytics",
15-
label: "Analytics",
16-
},
17-
{
18-
href: "/commissions",
19-
label: "Commissions",
20-
},
21-
{
22-
href: "/payouts",
23-
label: "Payouts",
24-
},
25-
];
26-
27-
export default async function AdminLayout({
28-
children,
29-
}: {
30-
children: ReactNode;
31-
}) {
7+
export default function AdminLayout({ children }: { children: ReactNode }) {
328
return (
339
<>
3410
<div className="min-h-screen w-full bg-neutral-50">
35-
<div className="sticky left-0 right-0 top-0 z-20 border-b border-neutral-200 bg-white">
36-
<MaxWidthWrapper>
37-
<div className="flex h-16 items-center gap-12">
38-
<Link href="/">
39-
<NavWordmark className="h-6" />
40-
</Link>
41-
{tabs.map((tab) => (
42-
<Link
43-
href={tab.href}
44-
key={tab.href}
45-
className="text-sm text-neutral-500"
46-
>
47-
{tab.label}
48-
</Link>
49-
))}
50-
</div>
51-
</MaxWidthWrapper>
52-
</div>
11+
<AdminNav />
5312
{children}
5413
</div>
5514
</>

0 commit comments

Comments
 (0)