diff --git a/src/app/share/page.tsx b/src/app/share/page.tsx index 7f66921..b884e09 100644 --- a/src/app/share/page.tsx +++ b/src/app/share/page.tsx @@ -24,9 +24,10 @@ interface FileDetails { export async function generateMetadata({ searchParams, }: { - searchParams: { id?: string }; + searchParams: Promise<{ id?: string }>; }): Promise { - const fileId = searchParams.id; + const resolvedSearchParams = await searchParams; // Resolve the promise + const fileId = resolvedSearchParams.id; if (!fileId) { return { @@ -84,9 +85,10 @@ async function fetchFileDetails(fileId: string): Promise { export default async function FilePreviewContainer({ searchParams, }: { - searchParams: { id?: string }; + searchParams: Promise<{ id?: string }>; }) { - const fileId = searchParams.id; + const resolvedSearchParams = await searchParams; // Resolve the promise + const fileId = resolvedSearchParams.id; if (!fileId) { notFound(); diff --git a/src/server/api/routers/post.ts b/src/server/api/routers/post.ts index b602dd5..159b286 100644 --- a/src/server/api/routers/post.ts +++ b/src/server/api/routers/post.ts @@ -18,18 +18,20 @@ export const postRouter = createTRPCRouter({ create: protectedProcedure .input(z.object({ name: z.string().min(1) })) .mutation(async ({ ctx, input }) => { - return ctx.db.post.create({ + return ctx.db.file.create({ data: { name: input.name, - createdBy: { connect: { id: ctx.session.user.id } }, + url: "default-url", // Replace with actual URL logic + size: 0, // Replace with actual size logic + extension: "txt", // Replace with actual extension logic }, }); }), getLatest: protectedProcedure.query(async ({ ctx }) => { - const post = await ctx.db.post.findFirst({ - orderBy: { createdAt: "desc" }, - where: { createdBy: { id: ctx.session.user.id } }, + const post = await ctx.db.file.findFirst({ + orderBy: { uploadDate: "desc" }, // Replace 'createdAt' with the correct field name from your schema + where: { uploadedById: ctx.session.user.id }, }); return post ?? null;