-
Notifications
You must be signed in to change notification settings - Fork 63
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix internal error 500 when navigating to dashboarad after signout (#33)
* add key to map child * page level route protection to prevent internal error from trpc * verification warning for non-verified users * max 2 posts on free tier
- Loading branch information
Showing
11 changed files
with
93 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
src/app/(main)/dashboard/_components/verificiation-warning.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { ExclamationTriangleIcon } from "@/components/icons"; | ||
|
||
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert"; | ||
import { Button } from "@/components/ui/button"; | ||
import { validateRequest } from "@/lib/auth/validate-request"; | ||
import Link from "next/link"; | ||
|
||
export async function VerificiationWarning() { | ||
const { user } = await validateRequest(); | ||
|
||
return user?.emailVerified === false ? ( | ||
<Alert className="rounded-lg bg-yellow-50 text-yellow-700 dark:bg-gray-800 dark:text-yellow-400"> | ||
<ExclamationTriangleIcon className="h-5 w-5 !text-yellow-700 dark:!text-yellow-400" /> | ||
<div className="flex lg:items-center"> | ||
<div className="w-full"> | ||
<AlertTitle>Account verification required</AlertTitle> | ||
<AlertDescription> | ||
A verification email has been sent to your email address. Please verify your account to | ||
access all features. | ||
</AlertDescription> | ||
</div> | ||
<Button size="sm" asChild> | ||
<Link href="/verify-email">Verify Email</Link> | ||
</Button> | ||
</div> | ||
</Alert> | ||
) : null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,20 @@ | ||
import { validateRequest } from "@/lib/auth/validate-request"; | ||
import { redirects } from "@/lib/constants"; | ||
import { redirect } from "next/navigation"; | ||
import * as React from "react"; | ||
import { DashboardNav } from "./_components/dashboard-nav"; | ||
import { VerificiationWarning } from "./_components/verificiation-warning"; | ||
|
||
interface Props { | ||
children: React.ReactNode; | ||
} | ||
|
||
export default async function DashboardLayout({ children }: Props) { | ||
const { user } = await validateRequest(); | ||
|
||
if (!user) redirect(redirects.toLogin); | ||
|
||
export default function DashboardLayout({ children }: Props) { | ||
return ( | ||
<div className="container flex min-h-[calc(100vh-180px)] flex-col gap-6 px-2 pt-6 md:flex-row md:px-4 lg:gap-10"> | ||
<DashboardNav className="flex flex-shrink-0 gap-2 md:w-48 md:flex-col lg:w-80" /> | ||
<main className="w-full">{children}</main> | ||
<div className="container min-h-[calc(100vh-180px)] px-2 pt-6 md:px-4"> | ||
<div className="flex flex-col gap-6 md:flex-row lg:gap-10"> | ||
<DashboardNav className="flex flex-shrink-0 gap-2 md:w-48 md:flex-col lg:w-80" /> | ||
<main className="w-full space-y-4"> | ||
<VerificiationWarning /> | ||
<div>{children}</div> | ||
</main> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters