Skip to content

Commit

Permalink
Hunar (#45)
Browse files Browse the repository at this point in the history
* 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

---------

Co-authored-by: Abdel Mouzahir <[email protected]>
  • Loading branch information
hunardeep720 and Abdelmouzahir authored Jun 28, 2024
1 parent 57fb434 commit dc7c2f4
Show file tree
Hide file tree
Showing 9 changed files with 1,754 additions and 5,366 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ yarn-error.log*

# typescript
*.tsbuildinfo
next-env.d.ts
next-env.d.ts
135 changes: 81 additions & 54 deletions app/restraunt/AddMenu/page.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,30 @@
"use client";
import { useState} from "react";
import { useState } from "react";
import { useUserAuth } from "@/services/utils";
import { useRouter } from "next/navigation";
import { addRestaurantMenu } from "@/services/PostRequest/postRequest";
import { Card, CardHeader, CardTitle, CardContent, CardFooter } from "@/components/ui/card"
import { Label } from "@/components/ui/label"
import { Input } from "@/components/ui/input"
import { Textarea } from "@/components/ui/textarea"
import { Button } from "@/components/ui/button"

import {
Card,
CardHeader,
CardTitle,
CardContent,
CardFooter,
} from "@/components/ui/card";
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import { Textarea } from "@/components/ui/textarea";
import { Button } from "@/components/ui/button";

const Page = () => {
const { user } = useUserAuth();
const [name, setName] = useState("");
const [ description, setDescription ] = useState("");
const [ price, setPrice ] = useState("");
const [description, setDescription] = useState("");
const [price, setPrice] = useState("");
const [imageerr, setImageerr] = useState("");
const [image, setImage] = useState([]);
const router = useRouter();

const handleSubmit = () => {
const handleSubmit = async () => {
setImageerr("");
if (
!image[0].name.endsWith(".jpg") &&
Expand All @@ -31,60 +36,82 @@ const Page = () => {
);
return;
}
addRestaurantMenu(user, name, price, description, image[0]);

console.log(
name,
"image name",
image[0].name,
await addRestaurantMenu(user, name, price, description, image[0]).then(() => {
router.push("/restraunt/home");
}
);
// router.push("/restraunt/Home")
};

return (

<section className="w-full py-5 md:py-10">
<div className="container px-4 md:px-6 max-w-2xl mx-auto">
<div className="grid gap-6">
<div className="grid gap-2">
<h1 className="text-3xl font-bold tracking-tight text-primary">Add Menu Item</h1>
<p className="text-gray-500 dark:text-gray-400">Fill out the form below to add a new item to your menu.</p>
</div>
<Card onSubmit={handleSubmit} >
<CardContent className="grid gap-6 py-4">
<div className="grid gap-2">
<Label htmlFor="name" >Name</Label>
<Input id="name" placeholder="Enter item name" required value={name} onChange={(e) => setName(e.target.value)} />
</div>
<div className="grid gap-2">
<Label htmlFor="price">Price</Label>
<Input id="price" type="number" placeholder="Enter price" required value={price} onChange={(e) => setPrice(e.target.value)}/>
</div>
<div className="grid gap-2">
<Label htmlFor="description">Description</Label>
<Textarea id="description" placeholder="Enter item description" className="min-h-[100px]" required value={description}
onChange={(e)=>setDescription(e.target.value)} />
</div>
<div className="grid gap-2">
<Label htmlFor="image">Image</Label>
<Input id="image" type="file" required
onChange={(e) => e && setImage(Array.from(e.target.files))}/>
</div>
{imageerr && (
<div className="container px-4 md:px-6 max-w-2xl mx-auto">
<div className="grid gap-6">
<div className="grid gap-2">
<h1 className="text-3xl font-bold tracking-tight text-primary">
Add Menu Item
</h1>
<p className="text-gray-500 dark:text-gray-400">
Fill out the form below to add a new item to your menu.
</p>
</div>
<Card onSubmit={handleSubmit}>
<CardContent className="grid gap-6 py-4">
<div className="grid gap-2">
<Label htmlFor="name">Name</Label>
<Input
id="name"
placeholder="Enter item name"
required
value={name}
onChange={(e) => setName(e.target.value)}
/>
</div>
<div className="grid gap-2">
<Label htmlFor="price">Price</Label>
<Input
id="price"
type="number"
placeholder="Enter price"
required
value={price}
onChange={(e) => setPrice(e.target.value)}
/>
</div>
<div className="grid gap-2">
<Label htmlFor="description">Description</Label>
<Textarea
id="description"
placeholder="Enter item description"
className="min-h-[100px]"
required
value={description}
onChange={(e) => setDescription(e.target.value)}
/>
</div>
<div className="grid gap-2">
<Label htmlFor="image">Image</Label>
<Input
id="image"
type="file"
required
onChange={(e) => e && setImage(Array.from(e.target.files))}
/>
</div>
{imageerr && (
<div className="text-red-500 text-sm col-span-full">
{imageerr}
</div>
)}
</CardContent>
<CardFooter>
<Button onClick={handleSubmit} className="ml-auto bg-primary">Add Item</Button>
</CardFooter>
</Card>
</CardContent>
<CardFooter>
<Button onClick={handleSubmit} className="ml-auto bg-primary">
Add Item
</Button>
</CardFooter>
</Card>
</div>
</div>
</div>
</section>


</section>
);
};

Expand Down
Loading

0 comments on commit dc7c2f4

Please sign in to comment.