implemented login
This commit is contained in:
parent
02b43201b1
commit
4112fd795a
@ -1,11 +1,14 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import { useState } from "react"
|
import { useState } from "react"
|
||||||
import { MdMoreVert } from "react-icons/md"
|
import { MdMoreVert } from "react-icons/md"
|
||||||
|
import { useHistory } from "react-router-dom"
|
||||||
import { useOutsideClickRef } from "rooks"
|
import { useOutsideClickRef } from "rooks"
|
||||||
|
import logout from "../functions/logout"
|
||||||
import MoreMenuEntry from "./MoreMenuEntry"
|
import MoreMenuEntry from "./MoreMenuEntry"
|
||||||
|
|
||||||
const MoreMenu: React.FC = () => {
|
const MoreMenu: React.FC = () => {
|
||||||
const [showMenu,setShowMenu] = useState(false)
|
const [showMenu,setShowMenu] = useState(false)
|
||||||
|
const history = useHistory()
|
||||||
|
|
||||||
const [outsideRef] = useOutsideClickRef(()=>{
|
const [outsideRef] = useOutsideClickRef(()=>{
|
||||||
setShowMenu(false)
|
setShowMenu(false)
|
||||||
@ -33,8 +36,10 @@ const MoreMenu: React.FC = () => {
|
|||||||
Menu 2
|
Menu 2
|
||||||
</MoreMenuEntry>
|
</MoreMenuEntry>
|
||||||
<MoreMenuEntry
|
<MoreMenuEntry
|
||||||
onclick={()=>{
|
onclick={async ()=>{
|
||||||
setShowMenu(false)
|
setShowMenu(false)
|
||||||
|
await logout()
|
||||||
|
history.push("/login")
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Logout
|
Logout
|
||||||
|
7
src/functions/logout.ts
Normal file
7
src/functions/logout.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
async function logout(): Promise<void> {
|
||||||
|
await fetch("/api/logout",{
|
||||||
|
method:"POST"
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
export default logout
|
Loading…
Reference in New Issue
Block a user