implemented login redirect

This commit is contained in:
2021-09-15 01:00:53 +02:00
parent 120106bfbc
commit 881b7a30f8
5 changed files with 1205 additions and 1111 deletions

View File

@@ -1,9 +1,16 @@
import React from "react"
import { useState } from "react"
import { RouteComponentProps } from "react-router-dom"
import { useHistory } from "react-router-dom"
import { useLoginMutation } from "../generated/graphql"
const Login: React.FC<RouteComponentProps> = (props) => {
interface Props {
onLogin?: ()=>void
}
const Login: React.FC<Props> = (props) => {
const history = useHistory()
const [username,setUsername] = useState("")
const [password,setPassword] = useState("")
@@ -41,7 +48,8 @@ const Login: React.FC<RouteComponentProps> = (props) => {
if (response.ok){
// Login successful
props.history.push("/f/")
props.onLogin?.()
history.push("/f/")
}else{
setLoginFailed(true)
}