From 6e255d196929449ea1dd3886fb53ed2f5d74f5fe Mon Sep 17 00:00:00 2001 From: Sebastian Oliver Date: Mon, 4 Sep 2023 10:26:12 +0200 Subject: [PATCH 1/3] fix: update api key now uses userId --- services/web-app/src/app/demo/page.tsx | 37 ++++++++++++++++++ services/web-app/{public => src/app}/icon.png | Bin services/web-app/src/app/profile/page.tsx | 10 +++-- .../src/components/textFields/codeBox.tsx | 28 +++++++++++++ .../components/textFields/reviewedCode.tsx | 23 +++++++++++ services/web-app/src/lib/constants.ts | 2 +- services/web-app/src/lib/hooks/useAxios.tsx | 2 +- .../src/pages/api/auth/[...nextauth].ts | 2 +- services/web-app/types/next-auth.d.ts | 5 ++- 9 files changed, 100 insertions(+), 9 deletions(-) create mode 100644 services/web-app/src/app/demo/page.tsx rename services/web-app/{public => src/app}/icon.png (100%) create mode 100644 services/web-app/src/components/textFields/codeBox.tsx create mode 100644 services/web-app/src/components/textFields/reviewedCode.tsx diff --git a/services/web-app/src/app/demo/page.tsx b/services/web-app/src/app/demo/page.tsx new file mode 100644 index 00000000..2d909022 --- /dev/null +++ b/services/web-app/src/app/demo/page.tsx @@ -0,0 +1,37 @@ +"use client"; +import { useSession } from "next-auth/react"; +import React, { useState } from "react"; + +import BasicButton from "../../components/buttons/basicButton"; +import Loading from "../../components/loading/loading"; +import CodeTextArea from "../../components/textFields/codeBox"; +import ReviewedCode from "../../components/textFields/reviewedCode"; + +export default function Demo(): JSX.Element { + const { status } = useSession(); + const [loading ] = useState(false); + const [passedText, setSyncedText] = useState(''); + const [displayedText, setDisplayedText] = useState(''); + const [isHidden, setIsHidden] = useState(true); + + const handleText = (text: string) => { + setSyncedText(text); + }; + + const onClick = () => { + setIsHidden(false); + setDisplayedText(passedText); + } + + if (status === "loading" || loading) { + return ; + } + + return ( +
+ + + +
+ ); +} diff --git a/services/web-app/public/icon.png b/services/web-app/src/app/icon.png similarity index 100% rename from services/web-app/public/icon.png rename to services/web-app/src/app/icon.png diff --git a/services/web-app/src/app/profile/page.tsx b/services/web-app/src/app/profile/page.tsx index 1311477a..f60e4390 100644 --- a/services/web-app/src/app/profile/page.tsx +++ b/services/web-app/src/app/profile/page.tsx @@ -4,9 +4,9 @@ import { RepoTable } from "@/components/tables/repoTable"; import { useSession } from "next-auth/react"; import Image from "next/image"; import useAxios from "../../lib/hooks/useAxios"; -import { useEffect, useState } from "react"; -import { User } from "../../lib/types"; -import { ReturnToHome } from "../../components/cards/returnToHome"; +import React, { useEffect, useState } from "react"; +import { User } from "next-auth"; +import { ReturnToHome } from "@/components/cards/returnToHome"; import UpdateAPIKey from "@/components/dialog/updateApiKey"; export default function Profile(): JSX.Element { @@ -47,9 +47,11 @@ export default function Profile(): JSX.Element { const handleUpdateApiKey = async (newApiKey: string) => { try { + console.log("user -> ", user); + console.log("session -> ", session); const response = await axiosInstance.post(`/updateUser`, { - userID: user.userId, apiKey: newApiKey, + userId: user.userId, }); console.log("API key updated successfully:", response.data); } catch (error) { diff --git a/services/web-app/src/components/textFields/codeBox.tsx b/services/web-app/src/components/textFields/codeBox.tsx new file mode 100644 index 00000000..02a0d69d --- /dev/null +++ b/services/web-app/src/components/textFields/codeBox.tsx @@ -0,0 +1,28 @@ +import React, { useState } from "react"; + +interface CodeBoxProps { + onTextChange: (text: string) => void; +} + +const CodeBox = ({ onTextChange }: CodeBoxProps): JSX.Element => { + const [inputText, setInputText] = useState(''); + + const handleInputChange = (event: React.ChangeEvent) => { + setInputText(event.target.value); + onTextChange(event.target.value); + }; + + return ( + <> +