From a81b51ad041e5e674af2ac3f4f5e60a59b05b688 Mon Sep 17 00:00:00 2001 From: Hunardeep Singh Date: Mon, 1 Jul 2024 09:05:40 -0600 Subject: [PATCH] Hunar (#47) * Add folder for student register issue: There was a router problem for student register resolve: always make page.js for route just separate them by making different folders. * database * - Created useContext for user (uid) - Added service folder with functions to read and write data from the database - Added authentication for student/homepage and student/information - Updated student/login page to fix email and password authentication issues * starting login page * login page design * signup page complete * adding colors * file change * forget password * add modal * add conditions * login page * add posst function for menu and restaurant details * meging with main * adding restaurant information page * fetching and adding data for restaurants * merging from origin * merge from orign * adding emails status in database * add and create function for adding new email with active status add and create function for getting email names where active status is true make changes in register page to check that email is in database for register * chengin import sttement * adding terms condition * adding logos facility * merge from master * update database sait-staff * adding search option * commit * connecting sait-staff with database * merging form master * changes on sait * mege from master to origin * changing restaurant info table * adding data to database * updating cards * adding logc for increase and decrease arrow * adding databse changes * updating datasbe function to getting student information * adding authentication for restaurants * changing Searching bar * adding search bar in sait-staff * updating restaurant login page * adding update,delete and change password features * adding fuctionality of deleting user's information from database including user data and restaurant menu, delete data from storage and from authentication * update edit functionallity in sait-staff and add delete functionality in restaurant --------- Co-authored-by: Abdel Mouzahir <123598139+Abdelmouzahir@users.noreply.github.com> --- app/restraunt/home/page.js | 46 +++++++++++-------------- app/sait-staff/RDashboard/Edit.js | 5 ++- app/sait-staff/SDashboard/Edit.js | 4 +-- app/sait-staff/overviewDash/overview.js | 2 +- merge from master | 6 ++++ 5 files changed, 32 insertions(+), 31 deletions(-) create mode 100644 merge from master diff --git a/app/restraunt/home/page.js b/app/restraunt/home/page.js index 8caea59..f9c6346 100644 --- a/app/restraunt/home/page.js +++ b/app/restraunt/home/page.js @@ -4,6 +4,8 @@ import { useTable, useGlobalFilter } from "react-table"; import Image from "next/image"; import { MoreHorizontal } from "lucide-react"; import { useUserAuth } from "@/services/utils"; +import { db } from "@/app/firebase/config"; +import { deleteDoc, doc } from "firebase/firestore"; import { getMenuInformation, getRestaurantInformationByUser, @@ -69,13 +71,14 @@ export default function SettingsRestaurant() { setSelectedProduct(product); }; - const handleProductDelete = (productId) => { - setMenuData(menuData.filter((product) => product.id !== productId)); + const handleProductDelete = async (productId) => { + await deleteDoc(doc(db, "restaurant_menu", productId)).then(() => { + setMenuData(menuData.filter((product) => product.id !== productId)); + }); }; const columns = React.useMemo( () => [ - /* { Header: "Image", accessor: "imageUrl", @@ -84,25 +87,25 @@ export default function SettingsRestaurant() { alt={`Product image - ${original.name}`} className="aspect-square rounded-md object-cover" height="64" - src={"url(/assets/images/restCover.jpg)"} - width="64" - /> - ), - }, - */ - { - Header: 'Image', - accessor: 'imageUrl', - Cell: ({ row: { original } }) => ( - {`Product ), }, + + // { + // Header: 'Image', + // accessor: 'imageUrl', + // Cell: ({ row: { original } }) => ( + // {`Product + // ), + // }, { Header: "Name", accessor: "name", @@ -142,13 +145,6 @@ export default function SettingsRestaurant() { }, className: "hidden md:table-cell", }, - - // { - // Header: "Total Sales", - // accessor: "totalSales", - // Cell: () => "0", - // className: "hidden md:table-cell", - // }, { Header: "Actions", accessor: "actions", diff --git a/app/sait-staff/RDashboard/Edit.js b/app/sait-staff/RDashboard/Edit.js index 5bd59ed..c7b5bf9 100644 --- a/app/sait-staff/RDashboard/Edit.js +++ b/app/sait-staff/RDashboard/Edit.js @@ -71,10 +71,9 @@ const Edit = ({ restaurants, selectedRestaurant, setRestaurants, setIsEditing, g setEmail(e.target.value)} - className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm" + // onChange={(e) => setEmail(e.target.value)} + className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none sm:text-sm cursor-not-allowed bg-black/20" />
diff --git a/app/sait-staff/SDashboard/Edit.js b/app/sait-staff/SDashboard/Edit.js index 3380999..b7cc568 100644 --- a/app/sait-staff/SDashboard/Edit.js +++ b/app/sait-staff/SDashboard/Edit.js @@ -99,8 +99,8 @@ const Edit = ({ selectedStudent, setIsEditing }) => { id="email" type="email" value={email} - onChange={(e) => setEmail(e.target.value)} - className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-blue-500 focus:border-blue-500 sm:text-sm" + // onChange={(e) => setEmail(e.target.value)} + className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none sm:text-sm cursor-not-allowed bg-black/20" />
diff --git a/app/sait-staff/overviewDash/overview.js b/app/sait-staff/overviewDash/overview.js index bef58ad..1af8904 100644 --- a/app/sait-staff/overviewDash/overview.js +++ b/app/sait-staff/overviewDash/overview.js @@ -5,7 +5,7 @@ import { getAllStudentsInformation, getRestaurantInformation } from "@/services/ import { FaUsers, FaChartLine } from "react-icons/fa"; import { AiOutlineShop, AiOutlineTeam } from "react-icons/ai"; -import {useSpring, animated} from "react-spring"; +import { useSpring, animated } from "react-spring"; function NumberChange({n}){ const {number} = useSpring({ diff --git a/merge from master b/merge from master new file mode 100644 index 0000000..e636e0a --- /dev/null +++ b/merge from master @@ -0,0 +1,6 @@ +Merge remote-tracking branch 'origin/master' into hunar +# Please enter a commit message to explain why this merge is necessary, +# especially if it merges an updated upstream into a topic branch. +# +# Lines starting with '#' will be ignored, and an empty message aborts +# the commit.