File tree Expand file tree Collapse file tree 3 files changed +32
-4
lines changed
Expand file tree Collapse file tree 3 files changed +32
-4
lines changed Original file line number Diff line number Diff line change 1- export default function DrivePage ( ) {
2- return < div /> ;
1+ import { auth } from "@clerk/nextjs/server" ;
2+ import { redirect } from "next/navigation" ;
3+
4+ import * as queries from "~/server/db/queries" ;
5+
6+ export default async function DrivePage ( ) {
7+ const session = await auth ( ) ;
8+ if ( ! session . userId ) return redirect ( "/sign-in" ) ;
9+
10+ const rootFolder = await queries . getRootFolderForUser ( session . userId ) ;
11+ if ( ! rootFolder ) return redirect ( "/drive/create-root-folder" ) ;
12+
13+ return redirect ( `/f/${ rootFolder . id } ` ) ;
314}
Original file line number Diff line number Diff line change 11import { SignInButton } from "@clerk/nextjs" ;
22
3+ import { Button } from "~/components/ui/button" ;
4+
35export default function HomePage ( ) {
46 return (
57 < div className = "min-h-screen bg-gradient-to-br from-black via-gray-900 to-gray-800 text-white" >
@@ -18,7 +20,14 @@ export default function HomePage() {
1820 documents from any device, anywhere in the world.
1921 </ p >
2022
21- < SignInButton />
23+ < Button
24+ size = "lg"
25+ 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"
26+ type = "submit"
27+ asChild
28+ >
29+ < SignInButton forceRedirectUrl = "/drive" />
30+ </ Button >
2231 </ div >
2332 </ main >
2433 </ div >
Original file line number Diff line number Diff line change 11import "server-only" ; // Ensure this file is only run on the server
22
3- import { eq } from "drizzle-orm" ;
3+ import { and , eq , isNull } from "drizzle-orm" ;
44
55import { db } from "~/server/db" ;
66import {
@@ -27,6 +27,14 @@ export async function getAllParentsForFolder(folderId: number) {
2727 return parents ;
2828}
2929
30+ export async function getRootFolderForUser ( ownerId : string ) {
31+ const folders = await db
32+ . select ( )
33+ . from ( folderSchema )
34+ . where ( and ( eq ( folderSchema . ownerId , ownerId ) , isNull ( folderSchema . parent ) ) ) ;
35+ return folders [ 0 ] ;
36+ }
37+
3038export function getAllFolders ( folderId : number ) {
3139 return db
3240 . select ( )
You can’t perform that action at this time.
0 commit comments