-
-
-
-
+ {!selectedTable && !newTable && (
+
+ )}
+ {(selectedTable || newTable) && (
+
+
+
+
+
+
+
+
+
+
+ {(newTable || selectedTable) && (
+
+ )}
+
)}
{
borderRadius: "4px",
boxShadow: "0 2px 4px rgba(0,0,0,0.1)",
}}
+ onClick={() => handleSelect(table)}
>
Table {table.tableNo} - Position: ({table.xposition},{" "}
{table.yposition})
@@ -232,4 +396,14 @@ const buttonStyle = {
margin: "0 5px",
};
+const actionButtonStyle = {
+ padding: "10px 20px",
+ fontSize: "16px",
+ border: "none",
+ borderRadius: "4px",
+ cursor: "pointer",
+ margin: "0 5px",
+ transition: "background-color 0.3s ease, color 0.3s ease",
+};
+
export default TableCanvas;
diff --git a/src/config.js b/src/config.js
index 7e37a1d..79de8a5 100644
--- a/src/config.js
+++ b/src/config.js
@@ -1,5 +1,5 @@
// src/config.js
-const API_BASE_URL = "https://44l6f8-5000.csb.app"; // Replace with your actual backend URL
+const API_BASE_URL = "https://hflt3s-5000.csb.app"; // Replace with your actual backend URL
export default API_BASE_URL;
diff --git a/src/helpers/tableHelper.js b/src/helpers/tableHelper.js
index 2cc961b..d8dd2d0 100644
--- a/src/helpers/tableHelper.js
+++ b/src/helpers/tableHelper.js
@@ -1,6 +1,63 @@
import API_BASE_URL from "../config.js";
import { getLocalStorage } from "./localStorageHelpers";
+export async function createTable(shopId, newTable) {
+ try {
+ const token = getLocalStorage("auth");
+
+ // Construct the URL endpoint for creating a new table
+ const response = await fetch(`${API_BASE_URL}/table/create/${shopId}`, {
+ method: "POST",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${token}`,
+ },
+ body: JSON.stringify({
+ newTable: newTable,
+ }), // Include the new table data in the body
+ });
+
+ if (!response.ok) {
+ const error = await response.text(); // Get error details from the response
+ throw new Error(`Error: ${error}`);
+ }
+
+ const table = await response.json(); // Assuming the response is the created table
+ return table;
+ } catch (error) {
+ console.error("Error:", error);
+ return false; // or handle the error as needed
+ }
+}
+
+export async function updateTable(shopId, table) {
+ try {
+ console.log(table);
+ const token = getLocalStorage("auth");
+ const response = await fetch(
+ `${API_BASE_URL}/table/set-table/${shopId}/${table.tableId}`,
+ {
+ method: "PUT",
+ headers: {
+ "Content-Type": "application/json",
+ Authorization: `Bearer ${token}`,
+ },
+ body: JSON.stringify({
+ table: table,
+ }),
+ }
+ );
+
+ if (!response.ok) {
+ return false;
+ }
+
+ const tables = await response.json();
+ return tables;
+ } catch (error) {
+ console.error("Error:", error);
+ }
+}
export async function getTables(shopId) {
try {
const token = getLocalStorage("auth");