From 65e38009970ef349da9f375f031d65ba99eb69b4 Mon Sep 17 00:00:00 2001 From: Klotske Date: Tue, 3 Jan 2023 00:13:05 +0300 Subject: [PATCH 1/2] Use session for username, removed update handler --- website/src/pages/account/index.tsx | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/website/src/pages/account/index.tsx b/website/src/pages/account/index.tsx index 51f7ed38..c05c2f67 100644 --- a/website/src/pages/account/index.tsx +++ b/website/src/pages/account/index.tsx @@ -6,20 +6,6 @@ import React, { useState } from "react"; export default function Account() { const { data: session } = useSession(); - const [username, setUsername] = useState("null"); - - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const handleUpdate = async () => { - const response = await fetch("../api/update", { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify({ username }), - }); - const { name } = await response.json(); - setUsername(name); - }; if (!session) { return; @@ -34,7 +20,7 @@ export default function Account() { />
-

{username}

+

{session.user.name || "No username"}

From 15c06348ce977ddb0e1ef212a0600f23da1442b8 Mon Sep 17 00:00:00 2001 From: Klotske Date: Tue, 3 Jan 2023 00:17:32 +0300 Subject: [PATCH 2/2] Removed unused import --- website/src/pages/account/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/website/src/pages/account/index.tsx b/website/src/pages/account/index.tsx index c05c2f67..9f8dc4a3 100644 --- a/website/src/pages/account/index.tsx +++ b/website/src/pages/account/index.tsx @@ -2,7 +2,7 @@ import { Button } from "@chakra-ui/react"; import Head from "next/head"; import Link from "next/link"; import { useSession } from "next-auth/react"; -import React, { useState } from "react"; +import React from "react"; export default function Account() { const { data: session } = useSession();