mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-02 06:07:06 +01:00
af971cd5b6
The ESLint config for the extension explicitly includes support for Prettier. However, this is already being provided by our global ESLint config (`@metamask/eslint-config`). Therefore there is no need to include it here. In fact, this is causing weird issues where the `curly` option is getting overridden somehow. After this change, these syntaxes are invalid: ``` javascript if (foo) return; ``` ``` javascript if (foo) return 'bar'; ```
48 lines
1.2 KiB
JavaScript
48 lines
1.2 KiB
JavaScript
import React, { useCallback, useState } from 'react';
|
|
import PropTypes from 'prop-types';
|
|
import { submitQRHardwareSignature } from '../../../../store/actions';
|
|
import Player from './player';
|
|
import Reader from './reader';
|
|
|
|
const QRHardwareSignRequest = ({ request, handleCancel, setErrorTitle }) => {
|
|
const [status, setStatus] = useState('play');
|
|
|
|
const toRead = useCallback(() => setStatus('read'), []);
|
|
|
|
const renderPlayer = () => {
|
|
const { payload } = request;
|
|
return (
|
|
<Player
|
|
type={payload.type}
|
|
cbor={payload.cbor}
|
|
cancelQRHardwareSignRequest={handleCancel}
|
|
toRead={toRead}
|
|
/>
|
|
);
|
|
};
|
|
|
|
const renderReader = () => {
|
|
return (
|
|
<Reader
|
|
cancelQRHardwareSignRequest={handleCancel}
|
|
submitQRHardwareSignature={submitQRHardwareSignature}
|
|
requestId={request.requestId}
|
|
setErrorTitle={setErrorTitle}
|
|
/>
|
|
);
|
|
};
|
|
|
|
if (status === 'play') {
|
|
return renderPlayer();
|
|
}
|
|
return renderReader();
|
|
};
|
|
|
|
QRHardwareSignRequest.propTypes = {
|
|
request: PropTypes.object.isRequired,
|
|
handleCancel: PropTypes.func.isRequired,
|
|
setErrorTitle: PropTypes.func.isRequired,
|
|
};
|
|
|
|
export default QRHardwareSignRequest;
|