Update src/App.jsx
Browse files- src/App.jsx +6 -6
src/App.jsx
CHANGED
|
@@ -1,7 +1,6 @@
|
|
| 1 |
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
| 2 |
import QRCode from 'qrcode';
|
| 3 |
-
import
|
| 4 |
-
import './index.css'; // Import the external CSS file
|
| 5 |
|
| 6 |
// Custom Alert Modal Component
|
| 7 |
const CustomAlert = ({ message, onClose }) => {
|
|
@@ -1268,8 +1267,9 @@ const App = () => {
|
|
| 1268 |
|
| 1269 |
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
| 1270 |
|
| 1271 |
-
|
| 1272 |
-
|
|
|
|
| 1273 |
|
| 1274 |
if (!code) {
|
| 1275 |
// Attempt to invert colors and try again
|
|
@@ -1278,7 +1278,7 @@ const App = () => {
|
|
| 1278 |
imageData.data[i + 1] = 255 - imageData.data[i + 1];
|
| 1279 |
imageData.data[i + 2] = 255 - imageData.data[i + 2];
|
| 1280 |
}
|
| 1281 |
-
code =
|
| 1282 |
}
|
| 1283 |
|
| 1284 |
if (code) {
|
|
@@ -1291,7 +1291,7 @@ const App = () => {
|
|
| 1291 |
setShowSuggestedIdea(false);
|
| 1292 |
}
|
| 1293 |
} else {
|
| 1294 |
-
showAlert('QR decoder library (
|
| 1295 |
setSuggestedIdea('');
|
| 1296 |
setShowSuggestedIdea(false);
|
| 1297 |
}
|
|
|
|
| 1 |
import React, { useState, useEffect, useRef, useCallback } from 'react';
|
| 2 |
import QRCode from 'qrcode';
|
| 3 |
+
import jsqr from 'jsqr'; // Changed import statement to lowercase 'jsqr'
|
|
|
|
| 4 |
|
| 5 |
// Custom Alert Modal Component
|
| 6 |
const CustomAlert = ({ message, onClose }) => {
|
|
|
|
| 1267 |
|
| 1268 |
const imageData = context.getImageData(0, 0, canvas.width, canvas.height);
|
| 1269 |
|
| 1270 |
+
// Use jsqr (lowercase) here
|
| 1271 |
+
if (jsqr) {
|
| 1272 |
+
let code = jsqr(imageData.data, imageData.width, imageData.height);
|
| 1273 |
|
| 1274 |
if (!code) {
|
| 1275 |
// Attempt to invert colors and try again
|
|
|
|
| 1278 |
imageData.data[i + 1] = 255 - imageData.data[i + 1];
|
| 1279 |
imageData.data[i + 2] = 255 - imageData.data[i + 2];
|
| 1280 |
}
|
| 1281 |
+
code = jsqr(imageData.data, imageData.width, imageData.height);
|
| 1282 |
}
|
| 1283 |
|
| 1284 |
if (code) {
|
|
|
|
| 1291 |
setShowSuggestedIdea(false);
|
| 1292 |
}
|
| 1293 |
} else {
|
| 1294 |
+
showAlert('QR decoder library (jsqr) not loaded. Please try again or check internet connection.');
|
| 1295 |
setSuggestedIdea('');
|
| 1296 |
setShowSuggestedIdea(false);
|
| 1297 |
}
|