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

84 lines
3.1 KiB
TypeScript
Raw Permalink 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';
import messages from '../instructions.intl';
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 {
2020-05-24 04:38:24 +05:30
activeOs: null | 'android' | 'ios' | 'windows';
2019-12-07 16:58:52 +05:30
}
export default class Instructions extends React.Component<{}, State> {
2020-05-24 04:38:24 +05:30
state: State = {
activeOs: null,
};
2017-07-22 21:27:38 +05:30
2020-05-24 04:38:24 +05:30
render() {
const { activeOs } = this.state;
2017-07-22 21:27:38 +05:30
2020-05-24 04:38:24 +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
2020-05-24 04:38:24 +05:30
<div className={profileForm.formRow}>
<div
className={clsx(styles.instructionContainer, {
[styles.instructionActive]: !!activeOs,
})}
>
<div
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
2020-05-24 04:38:24 +05:30
<div className={styles.osInstructionContainer}>
{activeOs ? <OsInstruction os={activeOs} /> : null}
</div>
</div>
</div>
2017-07-22 21:27:38 +05:30
</div>
2020-05-24 04:38:24 +05:30
);
}
2017-07-22 21:27:38 +05:30
2020-05-24 04:38:24 +05:30
onChangeOs(event: React.MouseEvent, osName: 'android' | 'ios' | 'windows') {
event.preventDefault();
2017-07-22 21:27:38 +05:30
2020-05-24 04:38:24 +05:30
this.setState({
activeOs: this.state.activeOs === osName ? null : osName,
});
}
2017-07-22 21:27:38 +05:30
}