Skip to content

Commit

Permalink
Add error display
Browse files Browse the repository at this point in the history
  • Loading branch information
kent-white authored and aptos-bot committed Apr 26, 2022
1 parent c0d6cf3 commit 032fcd3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 5 additions & 0 deletions ecosystem/web-wallet/src/pages/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,8 @@
font-size: calc(10px + 2vmin);
color: white;
}

.Error-message {
font-size: calc(8px + 1vmin);
color: rgb(255, 0, 0);
}
12 changes: 9 additions & 3 deletions ecosystem/web-wallet/src/pages/Login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import './App.css'

export default function Login () {
const [key, setKey] = useState('')
const [error, setError] = useState('')
const [, dispatch] = useGlobalState()
const navigate = useNavigate()

Expand All @@ -18,17 +19,22 @@ export default function Login () {
dispatch({ account })
navigate('/wallet')
} else {
// todo: show error toast
throw result.error
setError(result.error.message)
}
}

function onChange (event: React.ChangeEvent<HTMLInputElement>) {
setKey(event.target.value)
setError('')
}

return (
<div className="App-header">
<h2>Aptos Wallet</h2>
<form onSubmit={handleSubmit}>
<input onChange={(e) => setKey(e.target.value)}/>
<input onChange={onChange}/>
</form>
<text className="Error-message">{error}</text>
</div>
)
}

0 comments on commit 032fcd3

Please sign in to comment.