diff --git a/src/app/share/[id].tsx b/src/app/share/[id].tsx new file mode 100644 index 0000000..81c88b2 --- /dev/null +++ b/src/app/share/[id].tsx @@ -0,0 +1,53 @@ +// pages/share/[id].tsx + +import Head from "next/head"; +import { GetServerSideProps } from "next"; + +interface FileDetails { + name: string; + size: number; + owner: string; + uploadDate: string; + id: string; + url: string; +} + +export const getServerSideProps: GetServerSideProps = async (context) => { + const id = context.query.id as string; + + const res = await fetch(`${process.env.NEXT_PUBLIC_BASE_URL}/api/share?id=${id}`); + if (!res.ok) { + return { + notFound: true, + }; + } + + const fileDetails: FileDetails = await res.json(); + + return { + props: { + fileDetails, + }, + }; +}; + +export default function SharePage({ fileDetails }: { fileDetails: FileDetails }) { + return ( + <> + + {fileDetails.name} + + + + + + + +
+

File: {fileDetails.name}

+

Size: {(fileDetails.size / 1024).toFixed(2)} KB

+

Uploaded by: {fileDetails.owner}

+
+ + ); +} diff --git a/src/app/share/page.tsx b/src/app/share/page.tsx index 9e5f7b7..6972539 100644 --- a/src/app/share/page.tsx +++ b/src/app/share/page.tsx @@ -4,6 +4,8 @@ import { Suspense } from "react"; import { useEffect, useState } from "react"; import { useSearchParams, useRouter } from "next/navigation"; import toast, { Toaster } from "react-hot-toast"; +import Head from "next/head"; + // import { SharePage } from "~/components/SharePage"; interface FileDetails { @@ -136,6 +138,15 @@ function UploadsPage() { return (
+ + + + + + + + +