page.tsx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. "use client";
  2. import Image from "next/image";
  3. import Link from "next/link";
  4. import { UploadForm } from "../components/uploadForm";
  5. import { FilesTable } from "../components/filesTable";
  6. import { useState } from "react";
  7. interface FileData {
  8. id: string;
  9. filename: string;
  10. mimetype: string;
  11. size: number;
  12. createdAt: string;
  13. updatedAt: string;
  14. }
  15. export default function FilesPage() {
  16. const [newFile, setNewFile] = useState<FileData | null>(null);
  17. const handleFileUploaded = (file: FileData) => {
  18. // This will trigger the FilesTable to add the new file
  19. setNewFile(file);
  20. };
  21. return (
  22. <div className="grid grid-rows-[20px_1fr_20px] items-center justify-items-center min-h-screen p-8 pb-20 gap-16 sm:p-20 font-[family-name:var(--font-geist-sans)]">
  23. <main className="flex flex-col gap-8 row-start-2 items-center sm:items-start">
  24. <Image
  25. className="dark:invert"
  26. src="/vtorio.svg"
  27. alt="Vtor.io logo"
  28. width={180}
  29. height={38}
  30. priority
  31. />
  32. <h1 className="text-3xl font-bold text-center sm:text-left">
  33. File Management
  34. </h1>
  35. <p className="text-sm text-center sm:text-left max-w-[600px]">
  36. Upload and manage your media files here. Select files to upload them to the server.
  37. </p>
  38. <div className="flex flex-col gap-4 items-center sm:items-start">
  39. <h2 className="text-xl font-semibold">Upload Files</h2>
  40. <UploadForm onFileUploaded={handleFileUploaded} />
  41. </div>
  42. <div className="w-full max-w-6xl">
  43. <h2 className="text-2xl font-semibold mb-4">Files in Database</h2>
  44. <FilesTable onFileAdded={handleFileUploaded} />
  45. </div>
  46. <div className="flex gap-4 items-center flex-col sm:flex-row">
  47. <Link
  48. className="rounded-full border border-solid border-transparent transition-colors flex items-center justify-center bg-foreground text-background gap-2 hover:bg-[#383838] dark:hover:bg-[#ccc] text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5"
  49. href="/"
  50. >
  51. Back to Home
  52. </Link>
  53. <Link
  54. className="rounded-full border border-solid border-black/[.08] dark:border-white/[.145] transition-colors flex items-center justify-center hover:bg-[#f2f2f2] dark:hover:bg-[#1a1a1a] hover:border-transparent text-sm sm:text-base h-10 sm:h-12 px-4 sm:px-5"
  55. href="/api-docs"
  56. >
  57. API Documentation
  58. </Link>
  59. </div>
  60. </main>
  61. </div>
  62. );
  63. }