From eeab67611f16cfce112ac2779bb324d089a7c2fa Mon Sep 17 00:00:00 2001 From: Nidboj132 <28981031+Nidboj132@users.noreply.github.com> Date: Sun, 5 Nov 2023 20:27:51 +0100 Subject: feat: profile (#54) Former-commit-id: be6cd428190c05b2fa99e36c32765cc0fd4044e8 --- frontend/src/components/login.js | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) (limited to 'frontend/src/components/login.js') diff --git a/frontend/src/components/login.js b/frontend/src/components/login.js index 204007f..2b735cb 100644 --- a/frontend/src/components/login.js +++ b/frontend/src/components/login.js @@ -8,7 +8,7 @@ import img3 from "../imgs/11.png" export default function Login(prop) { -const {token,setToken} = prop +const {setToken,profile,setProfile} = prop function login() { window.location.href="https://lp.ardapektezol.com/api/v1/login" } @@ -16,26 +16,16 @@ function logout() { setIsLoggedIn(false) setProfile(null) setToken(null) - fetch(`/api/v1/token`,{'method':'DELETE'}) + fetch(`https://lp.ardapektezol.com/api/v1/token`,{'method':'DELETE'}) .then(r=>window.location.href="/") } const [isLoggedIn, setIsLoggedIn] = React.useState(false); React.useEffect(() => { - fetch(`/api/v1/token`) + fetch(`https://lp.ardapektezol.com/api/v1/token`) .then(r => r.json()) .then(d => setToken(d.data.token)) }, []); -const [profile, setProfile] = React.useState(null); -React.useEffect(() => { - fetch(`/api/v1/profile`,{ - headers: { - 'Content-Type': 'application/json', - Authorization: token - }}) - .then(r => r.json()) - .then(d => setProfile(d.data)) - }, [token]); React.useEffect(() => { if(profile!==null){setIsLoggedIn(true)} -- cgit v1.2.3