2017-08-23 00:19:50 +05:30
|
|
|
import React, { Component } from 'react';
|
2017-05-26 00:41:57 +05:30
|
|
|
import { Link } from 'react-router-dom';
|
2016-01-04 11:32:13 +05:30
|
|
|
import { FormattedMessage as Message } from 'react-intl';
|
2019-12-08 00:32:00 +05:30
|
|
|
import { Account } from 'app/components/accounts/reducer';
|
|
|
|
import buttons from 'app/components/ui/buttons.scss';
|
2016-01-04 11:32:13 +05:30
|
|
|
|
|
|
|
import styles from './userbar.scss';
|
2016-03-02 02:31:56 +05:30
|
|
|
import LoggedInPanel from './LoggedInPanel';
|
|
|
|
|
2018-02-28 02:47:31 +05:30
|
|
|
export default class Userbar extends Component<{
|
2020-05-24 04:38:24 +05:30
|
|
|
account: Account | null;
|
|
|
|
guestAction: 'register' | 'login';
|
2018-02-28 02:47:31 +05:30
|
|
|
}> {
|
2020-05-24 04:38:24 +05:30
|
|
|
static displayName = 'Userbar';
|
2016-06-05 16:01:17 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
static defaultProps = {
|
|
|
|
guestAction: 'register',
|
|
|
|
};
|
2016-02-13 20:58:47 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
render() {
|
|
|
|
const { account, guestAction: actionType } = this.props;
|
2016-06-05 16:01:17 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
let guestAction: React.ReactElement;
|
2019-12-07 16:58:52 +05:30
|
|
|
|
2020-05-24 04:38:24 +05:30
|
|
|
switch (actionType) {
|
|
|
|
case 'login':
|
|
|
|
guestAction = (
|
|
|
|
<Link to="/login" className={buttons.blue}>
|
2020-06-04 22:11:27 +05:30
|
|
|
<Message key="login" defaultMessage="Sign in" />
|
2020-05-24 04:38:24 +05:30
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
case 'register':
|
|
|
|
default:
|
|
|
|
guestAction = (
|
|
|
|
<Link to="/register" className={buttons.blue}>
|
2020-06-04 22:11:27 +05:30
|
|
|
<Message key="register" defaultMessage="Join" />
|
2020-05-24 04:38:24 +05:30
|
|
|
</Link>
|
|
|
|
);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div className={styles.userbar}>
|
|
|
|
{account ? <LoggedInPanel username={account.username} /> : guestAction}
|
|
|
|
</div>
|
2016-01-04 11:32:13 +05:30
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|