chore: perfect type definition (#940)

This commit is contained in:
bowen
2023-08-22 10:58:06 +08:00
committed by GitHub
parent b346bd9b83
commit 5e0540077a
25 changed files with 97 additions and 70 deletions

View File

@@ -22,7 +22,11 @@ type IState = {
google: boolean
}
function reducer(state: IState, action: { type: string; payload: any }) {
type IAction = {
type: 'login' | 'login_failed' | 'github_login' | 'github_login_failed' | 'google_login' | 'google_login_failed'
}
function reducer(state: IState, action: IAction) {
switch (action.type) {
case 'login':
return {
@@ -120,14 +124,14 @@ const NormalForm = () => {
useEffect(() => {
if (github_error !== undefined)
dispatch({ type: 'github_login_failed', payload: null })
dispatch({ type: 'github_login_failed' })
if (github)
window.location.href = github.redirect_url
}, [github, github_error])
useEffect(() => {
if (google_error !== undefined)
dispatch({ type: 'google_login_failed', payload: null })
dispatch({ type: 'google_login_failed' })
if (google)
window.location.href = google.redirect_url
}, [google, google])