diff --git a/code/client/src/components/QrCodeScanner.jsx b/code/client/src/components/QrCodeScanner.jsx index d8af4c41..fe8e94ee 100644 --- a/code/client/src/components/QrCodeScanner.jsx +++ b/code/client/src/components/QrCodeScanner.jsx @@ -11,6 +11,10 @@ import UploadOutlined from '@ant-design/icons/UploadOutlined' import jsQR from 'jsqr' import { getDataURLFromFile, getTextFromFile } from './Common' +const SupportedNonImgFileLabels = { + 'application/json': 'JSON files (.json)', + 'text/plain': 'Plain Text files', +} const QrCodeScanner = ({ onScan, shouldInit, style, supportedNonImgFiles = ['application/json'], btnText = 'Use Image or JSON Instead' }) => { const ref = useRef() const { isMobile } = useWindowDimensions() @@ -119,7 +123,7 @@ const QrCodeScanner = ({ onScan, shouldInit, style, supportedNonImgFiles = ['app const beforeUpload = (file) => { const isSupported = ['image/jpeg', 'image/png', ...supportedNonImgFiles].includes(file.type) if (!isSupported) { - message.error(`You can only upload JPG/PNG ${supportedNonImgFiles.length ? `or ${supportedNonImgFiles.join(',')} ` : ''}file`) + message.error(`You can only upload JPG/PNG ${supportedNonImgFiles.length ? `or one of the followings: ${supportedNonImgFiles.map(e => SupportedNonImgFileLabels[e]).join(',')} ` : ''}`) } return true } diff --git a/code/client/src/pages/Restore/RestoreByScan.jsx b/code/client/src/pages/Restore/RestoreByScan.jsx index 6a8ccf69..0c0a77f5 100644 --- a/code/client/src/pages/Restore/RestoreByScan.jsx +++ b/code/client/src/pages/Restore/RestoreByScan.jsx @@ -89,7 +89,7 @@ const RestoreByScan = ({ isActive, onComplete, onCancel }) => { f() }, [addressInput]) - const onScan = async (e, { isJson }) => { + const onScan = async (e, { isJson = false } = {}) => { if (e && !secret) { const now = performance.now() if (!(now - control.lastScan > config.scanDelay)) { diff --git a/code/client/src/pages/Show/Extend.jsx b/code/client/src/pages/Show/Extend.jsx index 7d05026d..473ab790 100644 --- a/code/client/src/pages/Show/Extend.jsx +++ b/code/client/src/pages/Show/Extend.jsx @@ -348,7 +348,7 @@ const Extend = ({ } }, [method]) - const onScan = (e, { isJson }) => { + const onScan = (e, { isJson = false } = {}) => { if (e && !seed) { try { let parsed