add initData
Change-Id: I08e5dfe42478e9ee02e48682634ecaa9ab34723b
diff --git a/client/src/pages/accountSelection.jsx b/client/src/pages/accountSelection.jsx
index 0cd9e29..c95b02b 100644
--- a/client/src/pages/accountSelection.jsx
+++ b/client/src/pages/accountSelection.jsx
@@ -7,8 +7,10 @@
import ListItemLink from '../components/ListItemLink';
import ConversationAvatar from '../components/ConversationAvatar';
import { AddRounded } from '@material-ui/icons';
+import { useHistory } from 'react-router';
const AccountSelection = (props) => {
+ const history = useHistory()
const [state, setState] = useState({
loaded: false,
error: false,
@@ -21,10 +23,14 @@
.then(res => res.json())
.then(result => {
console.log(result)
- setState({
- loaded: true,
- accounts: result.map(account => Account.from(account)),
- })
+ if (result.length === 0) {
+ history.replace('/newAccount')
+ } else {
+ setState({
+ loaded: true,
+ accounts: result.map(account => Account.from(account)),
+ })
+ }
}, error => {
console.log(`get error ${error}`)
setState({