accounts-frontend/packages/app/components/auth/chooseAccount/ChooseAccountBody.tsx

57 lines
1.9 KiB
TypeScript
Raw Normal View History

2016-11-06 01:53:56 +05:30
import React from 'react';
import { FormattedMessage as Message } from 'react-intl';
import BaseAuthBody from 'app/components/auth/BaseAuthBody';
import { AccountSwitcher } from 'app/components/accounts';
import { Account } from 'app/components/accounts/reducer';
2016-11-06 01:53:56 +05:30
import styles from './chooseAccount.scss';
export default class ChooseAccountBody extends BaseAuthBody {
2020-05-24 04:38:24 +05:30
static displayName = 'ChooseAccountBody';
static panelId = 'chooseAccount';
render() {
const { client } = this.context.auth;
return (
<div>
{this.renderErrors()}
<div className={styles.description}>
{client ? (
<Message
key="pleaseChooseAccountForApp"
defaultMessage="Please select an account that you want to use to authorize {appName}"
2020-05-24 04:38:24 +05:30
values={{
appName: <span className={styles.appName}>{client.name}</span>,
}}
/>
) : (
<div className={styles.description}>
<Message
key="pleaseChooseAccount"
defaultMessage="Please select an account you're willing to use"
/>
2020-05-24 04:38:24 +05:30
</div>
)}
</div>
<div className={styles.accountSwitcherContainer}>
<AccountSwitcher
allowAdd={false}
allowLogout={false}
highlightActiveAccount={false}
onSwitch={this.onSwitch}
/>
</div>
2016-11-06 01:53:56 +05:30
</div>
2020-05-24 04:38:24 +05:30
);
}
onSwitch = (account: Account): void => {
this.context.resolve(account);
};
2016-11-06 01:53:56 +05:30
}