From c5d96ec4c70c050fe1554a5bd021ec64979f4be5 Mon Sep 17 00:00:00 2001 From: nathan-j-edwards Date: Wed, 21 Feb 2024 20:56:04 -0500 Subject: [PATCH 01/27] created page for popup --- src/app/private/[uid]/user/popup/page.tsx | 129 ++++++++++++++++++++++ src/components/{ => user}/AddFile.tsx | 21 +--- src/pages/senior/[id].tsx | 44 ++++---- 3 files changed, 157 insertions(+), 37 deletions(-) create mode 100644 src/app/private/[uid]/user/popup/page.tsx rename src/components/{ => user}/AddFile.tsx (86%) diff --git a/src/app/private/[uid]/user/popup/page.tsx b/src/app/private/[uid]/user/popup/page.tsx new file mode 100644 index 00000000..9ba1952c --- /dev/null +++ b/src/app/private/[uid]/user/popup/page.tsx @@ -0,0 +1,129 @@ +"use client"; + +import type { GetServerSidePropsContext } from "next"; +import AddFile from "@components/user/AddFile"; +import { useState } from "react"; +import { prisma } from "@server/db/client"; +import { getServerAuthSession } from "@server/common/get-server-auth-session"; +import { z } from "zod"; +import { Approval } from "@prisma/client"; + +// type ISeniorProfileProps = Awaited< +// ReturnType +// >["props"] & { +// redirect: undefined; +// }; + +// type SerialzedFile = ISeniorProfileProps["senior"]["Files"][number]; + +const AddFilePage = () => { + const [showAddFilePopUp, setShowAddFilePopUp] = useState(false); + const handlePopUp = () => { + setShowAddFilePopUp(!showAddFilePopUp); + }; + return ( +
+ {showAddFilePopUp ? ( + + ) : null} + +
+ ); +}; + +// export const getServerSideProps = async ( +// context: GetServerSidePropsContext +// ) => { +// const session = await getServerAuthSession(context); +// const seniorId = z.string().parse(context.query.id); + +// if (!session || !session.user) { +// return { +// redirect: { +// destination: "/login", +// permanent: false, +// }, +// }; +// } + +// if (!prisma) { +// return { +// redirect: { +// destination: "/", +// permanent: false, +// }, +// }; +// } + +// const user = await prisma.user.findUnique({ +// where: { +// id: session.user.id, +// }, +// }); + +// if (!user) { +// return { +// redirect: { +// destination: "/", +// permanent: false, +// }, +// }; +// } + +// if (user.approved === Approval.PENDING) { +// return { +// redirect: { +// destination: "/pending", +// permanent: false, +// }, +// }; +// } + +// // await fetch ("/api/senior/" + seniorId, { method: "GET" }); +// // TODO: not using our beautiful API routes?? +// const senior = await prisma.senior.findUnique({ +// where: { +// id: seniorId, //get all information for given senior +// }, +// include: { +// Files: true, +// }, +// }); + +// if ( +// !senior || +// (!user.admin && !senior.StudentIDs.includes(session.user.id)) +// ) { +// return { +// redirect: { +// destination: "/", +// permanent: false, +// }, +// }; +// } + +// return { +// props: { +// senior: { +// ...senior, +// Files: senior.Files.map((file) => ({ +// ...file, +// lastModified: file.lastModified.getTime(), +// })), +// }, +// }, +// }; +// }; + +export default AddFilePage; diff --git a/src/components/AddFile.tsx b/src/components/user/AddFile.tsx similarity index 86% rename from src/components/AddFile.tsx rename to src/components/user/AddFile.tsx index e5f134af..3e28d151 100644 --- a/src/components/AddFile.tsx +++ b/src/components/user/AddFile.tsx @@ -1,3 +1,5 @@ +"use client"; + import React, { Dispatch, SetStateAction, useState } from "react"; import FilterDropdown from "@components/FilterDropdown"; import Tag, { TagProps, tagList } from "@components/Tag"; @@ -72,14 +74,11 @@ const AddFile = ({ return ( <> {showAddFilePopUp && ( -
+
{!confirm && !error ? ( -
+
-
- {" "} - Create New File{" "} -
+
Create New File
File name
@@ -91,16 +90,6 @@ const AddFile = ({ setFilename(e.target.value) } /> -
- Description -
-