diff --git a/src/app/admin/(pos-system)/pos/dine-in/page.jsx b/src/app/admin/(pos-system)/pos/dine-in/page.jsx index 9b47a2e..4f8db51 100644 --- a/src/app/admin/(pos-system)/pos/dine-in/page.jsx +++ b/src/app/admin/(pos-system)/pos/dine-in/page.jsx @@ -9,6 +9,8 @@ import PageLoader from "@/components/common-component/PageLoader"; import PageNoData from "@/components/common-component/PageNoData"; import Breadcrumb from "@/components/Breadcrumb"; import { Icon } from "@iconify/react"; +import axios from "axios"; +import { Baseurl } from "@utils/BaseUrl.utils"; const DineInInner = () => { @@ -33,6 +35,7 @@ const DineInInner = () => { minimumoccupancy: "", totalcapacity: "", description: "", + enable: 0, }); const [errors, setErrors] = useState({}); const [deleteConfirm, setDeleteConfirm] = useState({ show: false, id: null }); @@ -144,7 +147,25 @@ const DineInInner = () => { if (isEditMode) { await client.put(`/Dine360 Table/${selectedFloorId}`, Body); } else { - await client.post(`/Dine360 Table`, Body); + const createTable = await client.post(`/Dine360 Table`, Body); + + if (formData.enable == 1) { + const tableName = createTable?.data?.data?.name; + const RestaurantBranch = createTable?.data?.data?.restaurantbranch; + const AutoCreateBody = { + table: tableName, + restaurantbranch: RestaurantBranch, + enabled: formData.enable, // Uncomment if needed + }; + + try { + await axios.post(`${Baseurl}/Add-Table-To-Day`, AutoCreateBody); + } catch (apiError) { + console.error("Error while auto-creating table for the day:", apiError); + alert("Table created, but failed to assign it to the day."); + } + } + } getTableData(); resetForm(); @@ -167,6 +188,7 @@ const DineInInner = () => { totalcapacity: "", // branch: "", description: "", + enable: 0, }); setShowModal(false); setIsEditMode(false); @@ -532,6 +554,29 @@ const DineInInner = () => {
{errors.branch}
)} */} + { + !isEditMode && ( +
+ + setFormData({ + ...formData, + enable: e.target.checked ? 1 : 0, + }) + } + /> + +
+ ) + } +
+ {/* Grid */}
{loading ? ( @@ -182,46 +218,30 @@ const SidesPageInner = () => {
-
- -
    +
    • - { - e.preventDefault(); - handleEdit(room); - }} - > - - Edit + { + e.preventDefault(); + handleEdit(room); + }}> + Edit
    • - { - e.preventDefault(); - setDeleteConfirm({ show: true, id: room.name }); - }} - > - - Delete + { + e.preventDefault(); + setDeleteConfirm({ show: true, id: room.name }); + }}> + Delete
-
{room?.sidename}

{room?.description}

@@ -246,130 +266,61 @@ const SidesPageInner = () => {
+ {/* Form fields */}
- + {errors.sidename &&
{errors.sidename}
}
- + {errors.description &&
{errors.description}
}
- + {errors.price &&
{errors.price}
}
- {/* Input on the left */} - { - const file = e.target.files[0]; - if (!file) return; + { + const file = e.target.files[0]; + if (!file) return; - const allowedTypes = ["image/jpeg", "image/png", "image/jpg"]; - const maxFileSizeMB = 1; + if (!file.type.startsWith("image/")) { + setErrors(prev => ({ ...prev, item_image: "Only image files are allowed." })); + return; + } - if (!allowedTypes.includes(file.type)) { - setErrors((prev) => ({ - ...prev, - item_image: "Only JPG, JPEG, and PNG files are allowed.", - })); - return; - } + if (file.size / (1024 * 1024) > 1) { + setErrors(prev => ({ ...prev, item_image: "Max size 1MB" })); + return; + } - if (file.size / (1024 * 1024) > maxFileSizeMB) { - setErrors((prev) => ({ - ...prev, - item_image: "Max file size is 1MB.", - })); - return; - } - - const reader = new FileReader(); - reader.onloadend = () => { - setFormData((prev) => ({ - ...prev, - item_image: reader.result, - })); - setErrors((prev) => ({ ...prev, item_image: null })); - }; - reader.readAsDataURL(file); - }} - /> - - {/* Image on the right */} + const reader = new FileReader(); + reader.onloadend = () => { + setFormData(prev => ({ ...prev, item_image: reader.result })); + setErrors(prev => ({ ...prev, item_image: null })); + }; + reader.readAsDataURL(file); + }} /> {formData.item_image && ( -
- Preview - {/* Delete icon top-right */} - +
+ preview +
)} -
- {errors.item_image &&
{errors.item_image}
}
- -
- +
@@ -378,7 +329,7 @@ const SidesPageInner = () => {
)} - {/* Delete Confirmation */} + {/* Delete Modal */} {deleteConfirm.show && (
@@ -388,10 +339,10 @@ const SidesPageInner = () => {
Confirm Delete
-

Are you sure you want to delete this item?

+

Are you sure you want to delete this item?

- - + +
@@ -402,15 +353,13 @@ const SidesPageInner = () => { ); }; -const SidesPage = () => { - return ( - - - }> - - - - ); -}; +const SidesPage = () => ( + + + }> + + + +); export default SidesPage; diff --git a/src/app/waiter/table-order/page.jsx b/src/app/waiter/table-order/page.jsx index 761c05d..43059d1 100644 --- a/src/app/waiter/table-order/page.jsx +++ b/src/app/waiter/table-order/page.jsx @@ -392,7 +392,7 @@ const TableOrderInner = () => {
handleTableClick(table)} > -
+
{ table?.totalcapacity <= 2 ? ( { }
{ } }; console.log("tableConfigs", tableConfigs) + console.log("tables", tables) const formatTime = (timeStr) => { if (!timeStr) return ''; diff --git a/src/components/admin/SidesCategoryComponent.jsx b/src/components/admin/SidesCategoryComponent.jsx index 16126a4..af23e8d 100644 --- a/src/components/admin/SidesCategoryComponent.jsx +++ b/src/components/admin/SidesCategoryComponent.jsx @@ -94,7 +94,7 @@ const SidesCategoryComponent = ({ sidesCategoryData, getSidesCategory }) => { setIsEditMode(true); setSelectedSidesCategoryId(sidesCategory.name); setFormData({ - sidesCategoryname: sidesCategory.sidesCategoryname || "", + sidesCategoryname: sidesCategory.sidecategoryname || "", description: sidesCategory.description || "", }); setShowModal(true);