implemented login
This commit is contained in:
		
							parent
							
								
									02b43201b1
								
							
						
					
					
						commit
						4112fd795a
					
				@ -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
									
								
							
							
						
						
									
										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…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user