From c04c792309ee28b44e05beab68d1954e06c628ab Mon Sep 17 00:00:00 2001 From: Pau Matas Date: Sat, 17 Feb 2024 00:18:31 +0100 Subject: [PATCH 1/5] fix: home icon el primer --- src/app/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index d6a8e73..6f44214 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -86,8 +86,8 @@ export default async function Home() { */} -
-
+
+

Inici From cd1083658f27b8ad434ad1e3b0918ffe34d2befc Mon Sep 17 00:00:00 2001 From: polpuigdemont Date: Sat, 17 Feb 2024 00:24:16 +0100 Subject: [PATCH 2/5] remove: account request stuff --- src/app/accountrequest/page.tsx | 137 --------------------------- src/app/api/accountrequest/route.ts | 41 -------- src/components/Navbar.tsx | 3 - src/lib/validators/accountrequest.ts | 11 --- src/middleware.ts | 3 - 5 files changed, 195 deletions(-) delete mode 100644 src/app/accountrequest/page.tsx delete mode 100644 src/app/api/accountrequest/route.ts delete mode 100644 src/lib/validators/accountrequest.ts diff --git a/src/app/accountrequest/page.tsx b/src/app/accountrequest/page.tsx deleted file mode 100644 index 9bb893e..0000000 --- a/src/app/accountrequest/page.tsx +++ /dev/null @@ -1,137 +0,0 @@ -"use client"; -import React, { FC, useState } from "react"; -import axios from "axios"; -import { Combobox } from "@/components/Combobox"; -import { toast } from "@/hooks/use-toast"; -import { Button } from "@/components/ui/Button"; -import { Input } from "@/components/ui/Input"; -import { Checkbox } from "@/components/ui/checkbox"; -import Link from "next/link"; - -interface PageProps {} - -const Page: FC = ({}) => { - const generation = [ - { - value: "2017", - label: "2017", - }, - { - value: "2018", - label: "2018", - }, - { - value: "2019", - label: "2019", - }, - { - value: "2020", - label: "2020", - }, - { - value: "2021", - label: "2021", - }, - { - value: "2022", - label: "2022", - }, - { - value: "2023", - label: "2023", - }, - ]; - - const [selectedYear, setSelectedYear] = useState(undefined); - const [email, setEmail] = useState(""); - const [isSelected, setIsSelected] = useState(false); - - const handleSubmit = () => { - if (!email.endsWith("@estudiantat.upc.edu")) { - toast({ - title: "Invalid Email", - description: "Please use your UPC email.", - variant: "destructive", - }); - return; - } - - axios - .post("/api/accountrequest", { email, selectedYear }) - .then(({}) => { - toast({ - description: `La teva sol·licitud s'ha creat correctament`, - }); - }) - .catch((error) => { - if (error.response.status === 409) { - // Handle conflict - toast({ - title: "Ja existeix una sol·licitud amb aquest correu", - description: (error.response.data as { message: string }).message, - variant: "destructive", - }); - } else if (error.response.status === 422) { - // Handle conflict - toast({ - title: `${error.response.status} - ${error.response.statusText}`, - description: (error.response.data as { message: string }).message, - variant: "destructive", - }); - } - }); - }; - - return ( -

-

- Demana Accés a Apunts Dades -

-

Mail UPC

- setEmail(e.target.value)} - className="mb-2" - /> -

Generació

- -
- { - if (checked === "indeterminate") { - setIsSelected(false); - } else { - setIsSelected(checked); - } - }} - id="terms" - /> - -
- -
- ); -}; - -export default Page; diff --git a/src/app/api/accountrequest/route.ts b/src/app/api/accountrequest/route.ts deleted file mode 100644 index f2a0461..0000000 --- a/src/app/api/accountrequest/route.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { getAuthSession } from "@/lib/auth"; -import { db } from "@/lib/db"; -import { AccountRequestValidator } from "@/lib/validators/accountrequest"; -import { z } from "zod"; - -export async function POST(req: Request) { - try { - const session = await getAuthSession(); - - if (!session?.user) { - return new Response("Unauthorized", { status: 401 }); - } - - const body = await req.json(); - const { email, selectedYear } = AccountRequestValidator.parse(body); - - // check if a request for the same email already exists - const existingRequest = await db.userRequest.findFirst({ - where: { - email, - }, - }); - // if so return a 409 - if (existingRequest) { - return new Response("Request already exists", { status: 409 }); - } - await db.userRequest.create({ - data: { - userid: session.user.id, - email: email, - generacio: parseInt(selectedYear), - }, - }); - return new Response("Request created", { status: 201 }); - } catch (error) { - if (error instanceof z.ZodError) { - return new Response(error.message, { status: 422 }); - } - return new Response("Something went wrong", { status: 500 }); - } -} diff --git a/src/components/Navbar.tsx b/src/components/Navbar.tsx index 46c2eeb..74d27d3 100644 --- a/src/components/Navbar.tsx +++ b/src/components/Navbar.tsx @@ -26,9 +26,6 @@ const Navbar = async () => { Sign In - - Account Request -
)}
diff --git a/src/lib/validators/accountrequest.ts b/src/lib/validators/accountrequest.ts deleted file mode 100644 index 7cfd477..0000000 --- a/src/lib/validators/accountrequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { z } from "zod"; - -export const AccountRequestValidator = z.object({ - email: z.string().email({ message: "Invalid email format" }), - selectedYear: z.string().refine((value) => { - const year = parseInt(value); - return year >= 2017 && year <= 2023; - }, { message: "Invalid year format or out of range" }), -}); - -export type AccountRequest = z.infer; diff --git a/src/middleware.ts b/src/middleware.ts index cf9fd16..ba6ebeb 100644 --- a/src/middleware.ts +++ b/src/middleware.ts @@ -6,9 +6,6 @@ export default withAuth( { callbacks: { authorized: ({ req, token }) => { - if (req.nextUrl.pathname && req.nextUrl.pathname.includes('/accountrequest')){ - return false - } if ( req.nextUrl.pathname && req.nextUrl.pathname.startsWith('/') && From 26686b44c5a6adbe00c8e0122a960a848f035c2a Mon Sep 17 00:00:00 2001 From: Pau Matas Date: Sat, 17 Feb 2024 00:26:15 +0100 Subject: [PATCH 3/5] =?UTF-8?q?delete=20'Prefer=C3=A8ncies'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/page.tsx | 5 ++++- src/components/UserAccountNav.tsx | 4 ---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/app/page.tsx b/src/app/page.tsx index 6f44214..965c956 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -88,7 +88,7 @@ export default async function Home() {
*/}
-

+

Inici

@@ -104,6 +104,9 @@ export default async function Home() {
+
+ +
{subjects.map((subject, index) => { return ( = ({ user }) => { Inici - - Preferències - - Privacitat i Termes de Servei From bb9fa1cb213bb7b01960f515ea946aa4ef60d033 Mon Sep 17 00:00:00 2001 From: polpuigdemont Date: Sat, 17 Feb 2024 00:26:33 +0100 Subject: [PATCH 4/5] remove: notifications advert --- src/components/SubscribeLeaveToggle.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/SubscribeLeaveToggle.tsx b/src/components/SubscribeLeaveToggle.tsx index 4a19efb..b272e9f 100644 --- a/src/components/SubscribeLeaveToggle.tsx +++ b/src/components/SubscribeLeaveToggle.tsx @@ -50,7 +50,7 @@ const SubscribeLeaveToggle: FC = ({ subjectId, subjec return toast({ title: `T'has subscrit als apunts ${subjectArticle}${subjectName}!`, - description: "Ara rebràs notificacions quan es publiquin apunts.", // TODO: Això és mentida per ara + description: "", }); }, }); @@ -87,7 +87,7 @@ const SubscribeLeaveToggle: FC = ({ subjectId, subjec return toast({ title: `Has donat de baixa la teva subscripció als apunts ${subjectArticle}${subjectName}!`, - description: "Deixaràs de rebre notificacions quan es publiquin apunts.", // TODO: Això és mentida per ara + description: "", }); }, }); From d8fd3d0cc2eac16dfaccb0176068284aa8129b88 Mon Sep 17 00:00:00 2001 From: polpuigdemont Date: Sat, 17 Feb 2024 00:28:02 +0100 Subject: [PATCH 5/5] remove: custom file renderer --- src/components/renderers/CustomFileRenderer.tsx | 1 - 1 file changed, 1 deletion(-) delete mode 100644 src/components/renderers/CustomFileRenderer.tsx diff --git a/src/components/renderers/CustomFileRenderer.tsx b/src/components/renderers/CustomFileRenderer.tsx deleted file mode 100644 index 70b786d..0000000 --- a/src/components/renderers/CustomFileRenderer.tsx +++ /dev/null @@ -1 +0,0 @@ -// TODO