From eb009a34ea31b20d942677f93496ae16b0a06c66 Mon Sep 17 00:00:00 2001 From: Pratham271 Date: Wed, 16 Aug 2023 13:26:28 +0530 Subject: [PATCH] first commit --- package-lock.json | 3 ++ package.json | 3 ++ src/App.js | 19 ++------- src/components/QrFrontend.js | 74 ++++++++++++++++++++++++++++++++++++ src/index.css | 3 ++ tailwind.config.js | 11 ++++++ 6 files changed, 97 insertions(+), 16 deletions(-) create mode 100644 src/components/QrFrontend.js create mode 100644 tailwind.config.js diff --git a/package-lock.json b/package-lock.json index d69fe4a..f6834cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,6 +15,9 @@ "react-dom": "^18.2.0", "react-scripts": "5.0.1", "web-vitals": "^2.1.4" + }, + "devDependencies": { + "tailwindcss": "^3.3.3" } }, "node_modules/@aashutoshrathi/word-wrap": { diff --git a/package.json b/package.json index 97b5d58..3ff8e32 100644 --- a/package.json +++ b/package.json @@ -34,5 +34,8 @@ "last 1 firefox version", "last 1 safari version" ] + }, + "devDependencies": { + "tailwindcss": "^3.3.3" } } diff --git a/src/App.js b/src/App.js index 3784575..5f72364 100644 --- a/src/App.js +++ b/src/App.js @@ -1,23 +1,10 @@ -import logo from './logo.svg'; import './App.css'; +import QrFrontend from './components/QrFrontend'; function App() { return ( -
-
- logo -

- Edit src/App.js and save to reload. -

- - Learn React - -
+
+
); } diff --git a/src/components/QrFrontend.js b/src/components/QrFrontend.js new file mode 100644 index 0000000..05e4867 --- /dev/null +++ b/src/components/QrFrontend.js @@ -0,0 +1,74 @@ +import React, { useState } from 'react'; + +const QrFrontend = () => { + const [showText, setShowText] = useState(false); + const [qrImage, setQrImage] = useState(''); + const [inputText, setInputText] = useState(''); + + const generateQR = async () => { + try { + const response = await fetch('http://143.110.177.177:5000/', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ inputtext: inputText }), + }); + + if (response.ok) { + const data = await response.json(); + setQrImage(data.qr_image); + setShowText(true); + } else { + console.error('Failed to generate QR code'); + } + } catch (error) { + console.error('Error:', error); + } + }; + + return ( + <> +
+

QR Code Generator 🔥

+

+ Insert a link below to generate a QR Code +

+
+
{ + e.preventDefault(); + generateQR(); + }} + > + setInputText(e.target.value)} + /> + +
+
+ {showText && ( + <> + QR Code +

+ Here is the QR code we generated for you 🚀 +

+ + )} +
+ + ); +}; + +export default QrFrontend; diff --git a/src/index.css b/src/index.css index ec2585e..3ec2e08 100644 --- a/src/index.css +++ b/src/index.css @@ -11,3 +11,6 @@ code { font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', monospace; } +@tailwind base; +@tailwind components; +@tailwind utilities; \ No newline at end of file diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..c0958ec --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,11 @@ +/** @type {import('tailwindcss').Config} */ +module.exports = { + content: [ + "./src/**/*.{js,jsx,ts,tsx}", + ], + theme: { + extend: {}, + }, + plugins: [], +} +