|
1 | | -"use client"; |
2 | | - |
3 | | -import { ChevronRight, Upload } from "lucide-react"; |
4 | | -import { useMemo, useState } from "react"; |
5 | | - |
6 | | -import { Button } from "~/components/ui/button"; |
7 | | -import { mockFiles, mockFolders } from "~/lib/mock-data"; |
8 | | -import { FileRow, FolderRow } from "./file-row"; |
9 | | - |
10 | | -export default function GoogleDriveClone() { |
11 | | - const [currentFolder, setCurrentFolder] = useState("root"); |
12 | | - |
13 | | - const getCurrentFiles = () => { |
14 | | - return mockFiles.filter((file) => file.parent === currentFolder); |
15 | | - }; |
16 | | - |
17 | | - const getCurrentFolders = () => { |
18 | | - return mockFolders.filter((folder) => folder.parent === currentFolder); |
19 | | - }; |
20 | | - |
21 | | - const handleFolderClick = (folderId: string) => { |
22 | | - setCurrentFolder(folderId); |
23 | | - }; |
24 | | - |
25 | | - const breadcrumbs = useMemo(() => { |
26 | | - const breadcrumbs = []; |
27 | | - let currentId = currentFolder; |
28 | | - |
29 | | - while (currentId !== "root") { |
30 | | - const folder = mockFolders.find((file) => file.id === currentId); |
31 | | - if (folder) { |
32 | | - breadcrumbs.unshift(folder); |
33 | | - currentId = folder.parent ?? "root"; |
34 | | - } else { |
35 | | - break; |
36 | | - } |
37 | | - } |
38 | | - |
39 | | - return breadcrumbs; |
40 | | - }, [currentFolder]); |
41 | | - |
42 | | - const handleUpload = () => { |
43 | | - alert("Upload functionality would be implemented here"); |
44 | | - }; |
45 | | - |
46 | | - return ( |
47 | | - <div className="min-h-screen bg-gray-900 p-8 text-gray-100"> |
48 | | - <div className="mx-auto max-w-6xl"> |
49 | | - <div className="mb-6 flex items-center justify-between"> |
50 | | - <div className="flex items-center"> |
51 | | - <Button |
52 | | - onClick={() => setCurrentFolder("root")} |
53 | | - variant="ghost" |
54 | | - className="mr-2 text-gray-300 hover:text-white" |
55 | | - > |
56 | | - My Drive |
57 | | - </Button> |
58 | | - {breadcrumbs.map((folder) => ( |
59 | | - <div key={folder.id} className="flex items-center"> |
60 | | - <ChevronRight className="mx-2 text-gray-500" size={16} /> |
61 | | - <Button |
62 | | - onClick={() => handleFolderClick(folder.id)} |
63 | | - variant="ghost" |
64 | | - className="text-gray-300 hover:text-white" |
65 | | - > |
66 | | - {folder.name} |
67 | | - </Button> |
68 | | - </div> |
69 | | - ))} |
70 | | - </div> |
71 | | - <Button |
72 | | - onClick={handleUpload} |
73 | | - className="bg-blue-600 text-white hover:bg-blue-700" |
74 | | - > |
75 | | - <Upload className="mr-2" size={20} /> |
76 | | - Upload |
77 | | - </Button> |
78 | | - </div> |
79 | | - <div className="rounded-lg bg-gray-800 shadow-xl"> |
80 | | - <div className="border-b border-gray-700 px-6 py-4"> |
81 | | - <div className="grid grid-cols-12 gap-4 text-sm font-medium text-gray-400"> |
82 | | - <div className="col-span-6">Name</div> |
83 | | - <div className="col-span-3">Type</div> |
84 | | - <div className="col-span-3">Size</div> |
85 | | - </div> |
86 | | - </div> |
87 | | - <ul> |
88 | | - {getCurrentFolders().map((folder) => ( |
89 | | - <FolderRow |
90 | | - key={folder.id} |
91 | | - folder={folder} |
92 | | - onFolderClick={() => handleFolderClick(folder.id)} |
93 | | - /> |
94 | | - ))} |
95 | | - {getCurrentFiles().map((file) => ( |
96 | | - <FileRow key={file.id} file={file} /> |
97 | | - ))} |
98 | | - </ul> |
99 | | - </div> |
100 | | - </div> |
101 | | - </div> |
102 | | - ); |
| 1 | +export default async function HomePage() { |
| 2 | + return <h1>Welcome to your Drive</h1>; |
103 | 3 | } |
0 commit comments