Skip to content

Commit 73983cc

Browse files
committed
More cleanup
1 parent c1c7206 commit 73983cc

File tree

8 files changed

+177
-156
lines changed

8 files changed

+177
-156
lines changed

src/app/(authenticated)/dashboard/layout.tsx

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { useTranslations } from 'next-intl';
21
import { getLocale, getTranslations } from 'next-intl/server';
32

43
import { DashboardHeader } from '@/components/dashboard/DashboardHeader';
@@ -9,35 +8,21 @@ export async function generateMetadata() {
98
return { title: t('meta_title'), description: t('meta_description') };
109
}
1110

12-
export default function DashboardLayout(props: { children: React.ReactNode }) {
13-
const t = useTranslations('DashboardLayout');
14-
11+
export default function DashboardLayout({
12+
children,
13+
}: {
14+
children: React.ReactNode;
15+
}) {
1516
return (
1617
<>
1718
<div className="shadow-md">
1819
<div className="mx-auto flex max-w-screen-xl items-center justify-between px-3 py-4">
19-
<DashboardHeader
20-
menu={[
21-
{
22-
href: '/dashboard',
23-
label: t('home'),
24-
},
25-
{
26-
href: '/dashboard/organization-profile/organization-members',
27-
label: t('members'),
28-
},
29-
{
30-
href: '/dashboard/organization-profile',
31-
label: t('settings'),
32-
},
33-
]}
34-
/>
20+
<DashboardHeader />
3521
</div>
3622
</div>
37-
3823
<div className="min-h-[calc(100vh-72px)] bg-muted">
3924
<div className="mx-auto max-w-screen-xl px-3 pb-16 pt-6">
40-
{props.children}
25+
{children}
4126
</div>
4227
</div>
4328
</>

src/app/(authenticated)/dashboard/organization-profile/[[...organization-profile]]/page.tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,11 @@ export default function Page() {
1212
title={t('title_bar')}
1313
description={t('title_bar_description')}
1414
/>
15-
1615
<OrganizationProfile
1716
routing="path"
1817
path="/dashboard/organization-profile"
19-
afterLeaveOrganizationUrl="/onboarding/organization-selection"
20-
appearance={{
21-
elements: {
22-
rootBox: 'w-full',
23-
cardBox: 'w-full flex',
24-
},
25-
}}
18+
afterLeaveOrganizationUrl="/onboarding/select-org"
19+
appearance={{ elements: { rootBox: 'w-full', cardBox: 'w-full flex' } }}
2620
/>
2721
</>
2822
);

src/app/(authenticated)/onboarding/organization-selection/page.tsx

Lines changed: 0 additions & 29 deletions
This file was deleted.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { redirect } from 'next/navigation';
2+
import { CreateOrganization } from '@clerk/nextjs';
3+
import { auth as clerkAuth } from '@clerk/nextjs/server';
4+
import { getLocale, getTranslations } from 'next-intl/server';
5+
6+
export async function generateMetadata() {
7+
const locale = await getLocale();
8+
const t = await getTranslations({ locale, namespace: 'Dashboard' });
9+
return { title: t('meta_title'), description: t('meta_description') };
10+
}
11+
12+
export const dynamic = 'force-dynamic';
13+
14+
export default async function Page() {
15+
const auth = await clerkAuth();
16+
17+
if (!auth.userId) {
18+
redirect('/');
19+
}
20+
21+
return (
22+
<div className="flex min-h-screen items-center justify-center">
23+
<CreateOrganization
24+
// afterSelectOrganizationUrl="/dashboard"
25+
afterCreateOrganizationUrl="/dashboard"
26+
/>
27+
</div>
28+
);
29+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { redirect } from 'next/navigation';
2+
import { OrganizationList } from '@clerk/nextjs';
3+
import { auth as clerkAuth } from '@clerk/nextjs/server';
4+
import { getLocale, getTranslations } from 'next-intl/server';
5+
6+
export async function generateMetadata() {
7+
const locale = await getLocale();
8+
const t = await getTranslations({ locale, namespace: 'Dashboard' });
9+
return { title: t('meta_title'), description: t('meta_description') };
10+
}
11+
12+
export const dynamic = 'force-dynamic';
13+
14+
export default async function Page() {
15+
const auth = await clerkAuth();
16+
17+
if (!auth.userId) {
18+
redirect('/');
19+
}
20+
21+
return (
22+
<div className="flex min-h-screen items-center justify-center">
23+
<OrganizationList
24+
afterSelectOrganizationUrl="/dashboard"
25+
afterCreateOrganizationUrl="/dashboard"
26+
/>
27+
</div>
28+
);
29+
}
Lines changed: 96 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
'use client';
22

3-
import { OrganizationSwitcher, UserButton } from '@clerk/nextjs';
3+
import { useMemo } from 'react';
44
import Link from 'next/link';
5+
import {
6+
OrganizationSwitcher,
7+
UserButton,
8+
useOrganization,
9+
} from '@clerk/nextjs';
10+
import { useTranslations } from 'next-intl';
511

612
import { ActiveLink } from '@/components/ActiveLink';
713
import { LocaleSwitcher } from '@/components/LocaleSwitcher';
@@ -16,85 +22,94 @@ import {
1622
} from '@/components/ui';
1723
import { Logo } from '@/components/templates/Logo';
1824

19-
type DashboardHeaderProps = {
20-
menu: {
21-
href: string;
22-
label: string;
23-
}[];
24-
};
25+
export const DashboardHeader = () => {
26+
const t = useTranslations('DashboardLayout');
27+
const { organization } = useOrganization();
28+
29+
const menu = useMemo(() => {
30+
const menu = [{ href: '/dashboard', label: t('home') }];
2531

26-
export const DashboardHeader = (props: DashboardHeaderProps) => (
27-
<>
28-
<div className="flex items-center">
29-
<Link href="/dashboard" className="max-sm:hidden">
30-
<Logo />
31-
</Link>
32-
<svg
33-
className="size-8 stroke-muted-foreground max-sm:hidden"
34-
xmlns="http://www.w3.org/2000/svg"
35-
viewBox="0 0 24 24"
36-
fill="none"
37-
strokeLinecap="round"
38-
strokeLinejoin="round"
39-
>
40-
<path stroke="none" d="M0 0h24v24H0z" />
41-
<path d="M17 5 7 19" />
42-
</svg>
43-
<OrganizationSwitcher
44-
organizationProfileMode="navigation"
45-
organizationProfileUrl="/dashboard/organization-profile"
46-
afterCreateOrganizationUrl="/dashboard"
47-
hidePersonal
48-
skipInvitationScreen
49-
appearance={{
50-
elements: { organizationSwitcherTrigger: 'max-w-28 sm:max-w-52' },
51-
}}
52-
/>
53-
<nav className="ml-3 max-lg:hidden">
54-
<ul className="flex flex-row items-center gap-x-3 text-lg font-medium [&_a:hover]:opacity-100 [&_a]:opacity-75">
55-
{props.menu.map((item) => (
56-
<li key={item.href}>
57-
<ActiveLink href={item.href}>{item.label}</ActiveLink>
58-
</li>
59-
))}
32+
return organization
33+
? [
34+
...menu,
35+
{
36+
href: '/dashboard/organization-profile/organization-members',
37+
label: t('members'),
38+
},
39+
{ href: '/dashboard/organization-profile', label: t('settings') },
40+
]
41+
: menu;
42+
}, [organization, t]);
43+
44+
return (
45+
<>
46+
<div className="flex items-center">
47+
<Link href="/dashboard" className="max-sm:hidden">
48+
<Logo />
49+
</Link>
50+
<svg
51+
className="size-8 stroke-muted-foreground max-sm:hidden"
52+
xmlns="http://www.w3.org/2000/svg"
53+
viewBox="0 0 24 24"
54+
fill="none"
55+
strokeLinecap="round"
56+
strokeLinejoin="round"
57+
>
58+
<path stroke="none" d="M0 0h24v24H0z" />
59+
<path d="M17 5 7 19" />
60+
</svg>
61+
<OrganizationSwitcher
62+
organizationProfileMode="navigation"
63+
organizationProfileUrl="/dashboard/organization-profile"
64+
afterCreateOrganizationUrl="/dashboard"
65+
createOrganizationUrl="/onboarding/create-org"
66+
/>
67+
<nav className="ml-3 max-lg:hidden">
68+
<ul className="flex flex-row items-center gap-x-3 text-lg font-medium [&_a:hover]:opacity-100 [&_a]:opacity-75">
69+
{menu.map(({ href, label }) => (
70+
<li key={href}>
71+
<ActiveLink href={href}>{label}</ActiveLink>
72+
</li>
73+
))}
74+
</ul>
75+
</nav>
76+
</div>
77+
<div>
78+
<ul className="flex items-center gap-x-1.5 [&_li[data-fade]:hover]:opacity-100 [&_li[data-fade]]:opacity-60">
79+
<li data-fade>
80+
<div className="lg:hidden">
81+
<DropdownMenu>
82+
<DropdownMenuTrigger asChild>
83+
<ToggleMenuButton />
84+
</DropdownMenuTrigger>
85+
<DropdownMenuContent>
86+
{menu.map(({ href, label }) => (
87+
<DropdownMenuItem key={href} asChild>
88+
<Link href={href}>{label}</Link>
89+
</DropdownMenuItem>
90+
))}
91+
</DropdownMenuContent>
92+
</DropdownMenu>
93+
</div>
94+
</li>
95+
<li data-fade>
96+
<LocaleSwitcher />
97+
</li>
98+
<li data-fade>
99+
<ThemeSwitcher />
100+
</li>
101+
<li>
102+
<Separator orientation="vertical" className="h-4" />
103+
</li>
104+
<li>
105+
<UserButton
106+
userProfileMode="navigation"
107+
userProfileUrl="/dashboard/user-profile"
108+
appearance={{ elements: { rootBox: 'px-2 py-1.5' } }}
109+
/>
110+
</li>
60111
</ul>
61-
</nav>
62-
</div>
63-
<div>
64-
<ul className="flex items-center gap-x-1.5 [&_li[data-fade]:hover]:opacity-100 [&_li[data-fade]]:opacity-60">
65-
<li data-fade>
66-
<div className="lg:hidden">
67-
<DropdownMenu>
68-
<DropdownMenuTrigger asChild>
69-
<ToggleMenuButton />
70-
</DropdownMenuTrigger>
71-
<DropdownMenuContent>
72-
{props.menu.map((item) => (
73-
<DropdownMenuItem key={item.href} asChild>
74-
<Link href={item.href}>{item.label}</Link>
75-
</DropdownMenuItem>
76-
))}
77-
</DropdownMenuContent>
78-
</DropdownMenu>
79-
</div>
80-
</li>
81-
<li data-fade>
82-
<LocaleSwitcher />
83-
</li>
84-
<li data-fade>
85-
<ThemeSwitcher />
86-
</li>
87-
<li>
88-
<Separator orientation="vertical" className="h-4" />
89-
</li>
90-
<li>
91-
<UserButton
92-
userProfileMode="navigation"
93-
userProfileUrl="/dashboard/user-profile"
94-
appearance={{ elements: { rootBox: 'px-2 py-1.5' } }}
95-
/>
96-
</li>
97-
</ul>
98-
</div>
99-
</>
100-
);
112+
</div>
113+
</>
114+
);
115+
};
Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
export const DashboardSection = (props: {
1+
type DashboardSectionProps = {
22
title: string;
33
description: string;
44
children: React.ReactNode;
5-
}) => (
5+
};
6+
7+
export const DashboardSection = ({
8+
title,
9+
description,
10+
children,
11+
}: DashboardSectionProps) => (
612
<div className="rounded-md bg-card p-5">
713
<div className="max-w-3xl">
8-
<div className="text-lg font-semibold">{props.title}</div>
9-
14+
<div className="text-lg font-semibold">{title}</div>
1015
<div className="mb-4 text-sm font-medium text-muted-foreground">
11-
{props.description}
16+
{description}
1217
</div>
13-
14-
{props.children}
18+
{children}
1519
</div>
1620
</div>
1721
);

src/lib/server/Logger.ts

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,12 @@ if (Env.LOGTAIL_SOURCE_TOKEN) {
1111
stream = pino.multistream([
1212
await logtail({
1313
sourceToken: Env.LOGTAIL_SOURCE_TOKEN,
14-
options: {
15-
sendLogsToBetterStack: true,
16-
},
14+
options: { sendLogsToBetterStack: true },
1715
}),
18-
{
19-
stream: pretty(), // Prints logs to the console
20-
},
16+
{ stream: pretty() }, // Prints logs to the console
2117
]);
2218
} else {
23-
stream = pretty({
24-
colorize: true,
25-
});
19+
stream = pretty({ colorize: true });
2620
}
2721

2822
export const logger = pino({ base: undefined }, stream);

0 commit comments

Comments
 (0)