diff --git a/src/pages/Home.js b/src/pages/Home.js index c87a5f1..9b81d2c 100644 --- a/src/pages/Home.js +++ b/src/pages/Home.js @@ -1,16 +1,81 @@ -import React from "react"; +import React, { useRef, useState } from "react"; +import { Route, Routes } from "react-router"; import '../css/pages/Home.css'; -import { get } from "../util/Util"; +import { useLoginContext } from "../structures/UserContext"; +import { get, post } from "../util/Util"; -const Home = () => { +const Profile = () => { - return
- + const [user] = useLoginContext(); + const [twoFactorError, set2FAError] = useState(null); + + const [qr, setQr] = useState(null); + const enable2FA = async () => { + const response = await get('/api/user/2fa'); + if (response.status !== 200) return set2FAError(response.message); + setQr(response.data); + console.log(qr); + }; + + const authCodeRef = useRef(); + const disable2FA = async () => { + const code = authCodeRef.current.value; + const response = await post('/api/user/2fa/disable', {code}); + if(response.status !== 200) return set2FAError(response.message); + }; + + return
+
+ +
+
+

Settings

+ +

ID: {user.id}

+ +
+ + + + + + + + + + + + +
+ +

Two Factor

+ {!user.twoFactor ? +
+ +
: +
+ +
+ } + + {qr && } + +
; }; +const Main = () => { + + return
+ +
; +}; + +const Home = () => { + + return + } /> + } /> + ; +}; export default Home; \ No newline at end of file