mirror of
https://github.com/velocitatem/cvfs.git
synced 2026-05-31 16:53:38 +00:00
Initial commit
This commit is contained in:
12
apps/webapp/src/app/dashboard/actions.ts
Normal file
12
apps/webapp/src/app/dashboard/actions.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
'use server'
|
||||
|
||||
import { revalidatePath } from 'next/cache'
|
||||
import { redirect } from 'next/navigation'
|
||||
import { createClient } from '@/utils/supabase/server'
|
||||
|
||||
export async function logout() {
|
||||
const supabase = await createClient()
|
||||
await supabase.auth.signOut()
|
||||
revalidatePath('/', 'layout')
|
||||
redirect('/login')
|
||||
}
|
||||
14
apps/webapp/src/app/dashboard/layout.tsx
Normal file
14
apps/webapp/src/app/dashboard/layout.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
export default function DashboardLayout({
|
||||
children,
|
||||
}: {
|
||||
children: React.ReactNode
|
||||
}) {
|
||||
return (
|
||||
<div>
|
||||
<nav>
|
||||
<h1>Dashboard</h1>
|
||||
</nav>
|
||||
<main>{children}</main>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
21
apps/webapp/src/app/dashboard/page.tsx
Normal file
21
apps/webapp/src/app/dashboard/page.tsx
Normal file
@@ -0,0 +1,21 @@
|
||||
import { redirect } from 'next/navigation'
|
||||
import { createClient } from '@/utils/supabase/server'
|
||||
import { logout } from './actions'
|
||||
|
||||
export default async function DashboardPage() {
|
||||
const supabase = await createClient()
|
||||
|
||||
const { data, error } = await supabase.auth.getUser()
|
||||
if (error || !data?.user) {
|
||||
redirect('/login')
|
||||
}
|
||||
|
||||
return (
|
||||
<div>
|
||||
<p>Welcome, {data.user.email}</p>
|
||||
<form>
|
||||
<button formAction={logout}>Logout</button>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user