-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpage.tsx
More file actions
35 lines (30 loc) · 1.01 KB
/
page.tsx
File metadata and controls
35 lines (30 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { auth } from "@clerk/nextjs/server";
import { redirect } from "next/navigation";
import { Button } from "~/components/ui/button";
import * as mutations from "~/server/db/mutations";
import * as queries from "~/server/db/queries";
export default async function DrivePage() {
const session = await auth();
if (!session.userId) return redirect("/sign-in");
const rootFolder = await queries.getRootFolderForUser(session.userId);
if (!rootFolder) {
return (
<form
action={async () => {
"use server";
const rootFolderId = await mutations.onboardUser(session.userId);
return redirect(`/f/${rootFolderId}`);
}}
>
<Button
size="lg"
className="cursor-pointer rounded-full bg-white px-8 py-6 text-lg font-semibold text-black transition-all duration-200 hover:scale-105 hover:bg-gray-100"
type="submit"
>
Create Your Drive
</Button>
</form>
);
}
return redirect(`/f/${rootFolder.id}`);
}