accounts-frontend/packages/app/components/profile/multiFactorAuth/instructions/Instructions.tsx

84 lines
2.5 KiB
TypeScript
Raw Normal View History

2019-12-07 16:58:52 +05:30
import React from 'react';
2017-07-22 21:27:38 +05:30
import { FormattedMessage as Message } from 'react-intl';
2019-12-08 01:13:08 +05:30
import clsx from 'clsx';
2017-07-22 21:27:38 +05:30
import profileForm from '../../profileForm.scss';
2019-12-07 16:58:52 +05:30
import messages from '../MultiFactorAuth.intl.json';
2017-07-22 21:27:38 +05:30
import OsInstruction from './OsInstruction';
import OsTile from './OsTile';
import styles from './instructions.scss';
import androidLogo from './images/android.svg';
import appleLogo from './images/apple.svg';
import windowsLogo from './images/windows.svg';
2019-12-07 16:58:52 +05:30
interface State {
activeOs: null | 'android' | 'ios' | 'windows';
}
export default class Instructions extends React.Component<{}, State> {
state: State = {
activeOs: null,
};
2017-07-22 21:27:38 +05:30
render() {
const { activeOs } = this.state;
2017-07-22 21:27:38 +05:30
return (
<div className={profileForm.formBody}>
<div className={profileForm.formRow}>
<p className={profileForm.description}>
<Message {...messages.mfaIntroduction} />
</p>
</div>
2017-07-22 21:27:38 +05:30
<div className={profileForm.formRow}>
<div
2019-12-08 01:13:08 +05:30
className={clsx(styles.instructionContainer, {
[styles.instructionActive]: !!activeOs,
})}
>
<div
2019-12-08 01:13:08 +05:30
className={clsx(styles.osList, {
[styles.androidActive]: activeOs === 'android',
[styles.appleActive]: activeOs === 'ios',
[styles.windowsActive]: activeOs === 'windows',
})}
>
<OsTile
className={styles.androidTile}
logo={androidLogo}
label="Google Play"
onClick={event => this.onChangeOs(event, 'android')}
/>
<OsTile
className={styles.appleTile}
logo={appleLogo}
label="App Store"
onClick={event => this.onChangeOs(event, 'ios')}
/>
<OsTile
className={styles.windowsTile}
logo={windowsLogo}
label="Windows Store"
onClick={event => this.onChangeOs(event, 'windows')}
/>
</div>
2017-07-22 21:27:38 +05:30
<div className={styles.osInstructionContainer}>
{activeOs ? <OsInstruction os={activeOs} /> : null}
2017-07-22 21:27:38 +05:30
</div>
</div>
</div>
</div>
);
}
2017-07-22 21:27:38 +05:30
2019-12-07 16:58:52 +05:30
onChangeOs(event: React.MouseEvent, osName: 'android' | 'ios' | 'windows') {
event.preventDefault();
2017-07-22 21:27:38 +05:30
this.setState({
activeOs: this.state.activeOs === osName ? null : osName,
});
}
2017-07-22 21:27:38 +05:30
}