From 4caf11e4a1f426484c769f4242224ee342d54038 Mon Sep 17 00:00:00 2001
From: frontend perkafean
<165241731+frontendperkafean@users.noreply.github.com>
Date: Mon, 5 Aug 2024 08:28:03 +0000
Subject: [PATCH] ok
---
src/components/QR.js | 219 ++++++++++++++++++++++++++---------
src/components/TableList.js | 50 ++++++--
src/components/TablesPage.js | 1 +
3 files changed, 208 insertions(+), 62 deletions(-)
diff --git a/src/components/QR.js b/src/components/QR.js
index 9fbe09f..c20d2f9 100644
--- a/src/components/QR.js
+++ b/src/components/QR.js
@@ -2,10 +2,13 @@ import React, { useState } from "react";
import html2canvas from "html2canvas";
const QRCodeWithBackground = ({
+ isConfigure,
qrCodeUrl,
backgroundUrl,
initialQrPosition,
initialQrSize,
+ setInitialPos,
+ setInitialSize,
onBackgroundUrlChange,
}) => {
const [qrPosition, setQrPosition] = useState(initialQrPosition);
@@ -33,6 +36,12 @@ const QRCodeWithBackground = ({
}
};
+ const handleSave = () => {
+ setInitialPos(qrPosition);
+ setInitialSize(qrSize);
+ onBackgroundUrlChange(bgImage);
+ };
+
const printQRCode = () => {
const element = document.getElementById("qr-code-container");
if (element) {
@@ -89,65 +98,165 @@ const QRCodeWithBackground = ({
}}
/>
-
-
-
-
-
-
-
-
-
-
-
+ )}
);
};
+// Styles for the configuration labels and inputs
+const styles = {
+ label: {
+ display: "block",
+ fontSize: "16px",
+ fontWeight: "bold",
+ marginBottom: "5px",
+ },
+ sliderContainer: {
+ marginBottom: "20px",
+ },
+ sliderWrapper: {
+ display: "flex",
+ alignItems: "center",
+ gap: "10px",
+ marginTop: "5px",
+ },
+ input: {
+ flex: "1",
+ margin: "0 10px",
+ },
+ value: {
+ fontSize: "16px",
+ minWidth: "50px",
+ textAlign: "right",
+ },
+ labelStart: {
+ fontSize: "14px",
+ },
+ labelEnd: {
+ fontSize: "14px",
+ },
+ fileInput: {
+ marginLeft: "10px",
+ },
+};
+
export default QRCodeWithBackground;
diff --git a/src/components/TableList.js b/src/components/TableList.js
index a5cf9fc..c9a24c7 100644
--- a/src/components/TableList.js
+++ b/src/components/TableList.js
@@ -2,6 +2,8 @@ import React, { useState } from "react";
import QRCodeWithBackground from "./QR"; // Adjust path as needed
const TableList = ({ tables, onSelectTable, selectedTable }) => {
+ const [initialPos, setInitialPos] = useState({ left: 50, top: 50 });
+ const [initialSize, setInitialSize] = useState(20);
const [bgImageUrl, setBgImageUrl] = useState(
"https://example.com/your-background-image.png"
);
@@ -25,6 +27,36 @@ const TableList = ({ tables, onSelectTable, selectedTable }) => {
}}
>
+ -
+ onSelectTable({
+ tableId: -1,
+ })
+ }
+ >
+
configure
+ {-1 == selectedTable?.tableId && (
+
+ )}
+
{tables.map((table) => (
- {
{table.tableNo === 0 ? "Clerk" : `Table ${table.tableNo}`} -
Position: ({table.xposition}, {table.yposition})
-
+ {table.tableId == selectedTable?.tableId && (
+
+ )}
))}
diff --git a/src/components/TablesPage.js b/src/components/TablesPage.js
index e5396c7..8c250a8 100644
--- a/src/components/TablesPage.js
+++ b/src/components/TablesPage.js
@@ -110,6 +110,7 @@ const TablesPage = ({ shopId }) => {
};
const handleSelect = (table) => {
+ console.log(table);
setSelectedTable(null);
setSelectedTable(table);
setNewTable(null);