1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-29 07:16:36 +01:00
metamask-extension/ui/components/app/qr-hardware-popover/qr-hardware-sign-request/qr-hardware-sign-request.component.js
Elliot Winkler af971cd5b6
Remove dupe Prettier config from ESLint config (#13234)
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';
```
2022-01-06 15:56:51 -07:00

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;