implemented login redirect
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user