implemented login

This commit is contained in:
Djeeberjr 2021-09-18 19:33:31 +02:00
parent 02b43201b1
commit 4112fd795a
2 changed files with 13 additions and 1 deletions

View File

@ -1,11 +1,14 @@
import React from "react"
import { useState } from "react"
import { MdMoreVert } from "react-icons/md"
import { useHistory } from "react-router-dom"
import { useOutsideClickRef } from "rooks"
import logout from "../functions/logout"
import MoreMenuEntry from "./MoreMenuEntry"
const MoreMenu: React.FC = () => {
const [showMenu,setShowMenu] = useState(false)
const history = useHistory()
const [outsideRef] = useOutsideClickRef(()=>{
setShowMenu(false)
@ -33,8 +36,10 @@ const MoreMenu: React.FC = () => {
Menu 2
</MoreMenuEntry>
<MoreMenuEntry
onclick={()=>{
onclick={async ()=>{
setShowMenu(false)
await logout()
history.push("/login")
}}
>
Logout

7
src/functions/logout.ts Normal file
View File

@ -0,0 +1,7 @@
async function logout(): Promise<void> {
await fetch("/api/logout",{
method:"POST"
})
}
export default logout