Skip to content

Commit

Permalink
Merge pull request #44 from Abdelmouzahir/sheraj
Browse files Browse the repository at this point in the history
Sheraj
  • Loading branch information
sheraj923 authored Jun 27, 2024
2 parents 08c4e08 + 63f9d5c commit 42e8b9f
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 9 deletions.
23 changes: 23 additions & 0 deletions Components/ui/spinner.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// components/ui/spinner.js
export function Spinner() {
return (
<div className="spinner">
<style jsx>{`
.spinner {
border: 4px solid rgba(0, 0, 0, 0.1);
border-left-color: #000;
border-radius: 50%;
width: 24px;
height: 24px;
animation: spin 1s linear infinite;
}
@keyframes spin {
to {
transform: rotate(360deg);
}
}
`}</style>
</div>
)
}

21 changes: 18 additions & 3 deletions app/restraunt/home/page.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client';
import React, { useState, useEffect } from 'react';
import { useTable, useGlobalFilter } from 'react-table';
import Image from 'next/image';
import Swal from 'sweetalert2';
import { MoreHorizontal } from "lucide-react";
import { useUserAuth } from '@/services/utils';
import { getRestaurantInformation, getMenuInformationByUser } from '@/services/GetRequest/getRequest';
Expand Down Expand Up @@ -38,7 +38,7 @@ export default function SettingsRestaurant() {
const [restaurantData, setRestaurantData] = useState([]);
const [menuData, setMenuData] = useState([{
id: 1,
imageUrl: '/images/food.png',
imageUrl: "url(/assets/images/restCover.jpg)",
name: 'Classic Burger',
status: 'Available',
price: 8.99,
Expand Down Expand Up @@ -170,6 +170,7 @@ export default function SettingsRestaurant() {

const columns = React.useMemo(
() => [
/*
{
Header: 'Image',
accessor: 'imageUrl',
Expand All @@ -178,7 +179,21 @@ export default function SettingsRestaurant() {
alt={`Product image - ${original.name}`}
className="aspect-square rounded-md object-cover"
height="64"
src={value}
src={"url(/assets/images/restCover.jpg)"}
width="64"
/>
),
},
*/
{
Header: 'Image',
accessor: 'imageUrl',
Cell: ({ row: { original } }) => (
<img
alt={`Product image - ${original.name}`}
className="aspect-square rounded-md object-cover"
height="64"
src="/assets/images/food.png" // Correct path to the image
width="64"
/>
),
Expand Down
42 changes: 40 additions & 2 deletions app/restraunt/order/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import React, { useState } from "react"
import { Input } from "@/components/ui/input"
import { Button } from "@/components/ui/button"
import { AlertDialog , AlertDialogContent , AlertDialogHeader , AlertDialogTitle , AlertDialogDescription , AlertDialogFooter , AlertDialogCancel ,AlertDialogAction } from "@/components/ui/alert-dialog"

import { AlertDialog , AlertDialogContent,AlertDialogTrigger , AlertDialogHeader , AlertDialogTitle , AlertDialogDescription , AlertDialogFooter , AlertDialogCancel ,AlertDialogAction } from "@/components/ui/alert-dialog"
import { Spinner } from "@/components/ui/spinner"
export default function Order() {
const [orders, setOrders] = useState([
{
Expand Down Expand Up @@ -39,13 +39,20 @@ export default function Order() {
createdAt: new Date("2023-06-15T12:00:00Z"),
},
])

const [searchQuery, setSearchQuery] = useState("")
const [showCancelConfirmation, setShowCancelConfirmation] = useState(false)
const [orderToCancel, setOrderToCancel] = useState(null)
const handleOrderReady = (orderId) => {
setOrders((prevOrders) =>
prevOrders.map((order) => (order.id === orderId ? { ...order, status: "Waiting for Pickup" } : order)),
)
setIsDialogOpen(true)
setIsLoading(true)
setTimeout(() => {
setIsLoading(false)
setIsDialogOpen(false)
}, 4000) // Simulate a 2-second loading time
}
const handlePickupComplete = (orderId) => {
setOrders((prevOrders) => prevOrders.filter((order) => order.id !== orderId))
Expand All @@ -64,6 +71,12 @@ export default function Order() {
setOrderToCancel(null)
}
const filteredOrders = orders.filter((order) => order.id.toString().includes(searchQuery))

const [isLoading, setIsLoading] = useState(false)
const [isDialogOpen, setIsDialogOpen] = useState(false)



return (
<div className="container mx-auto px-4 py-8">
<h1 className="text-3xl font-bold mb-6">Incoming Orders</h1>
Expand Down Expand Up @@ -131,6 +144,31 @@ export default function Order() {
<Button variant="outline" onClick={() => handleOrderReady(order.id)}>
Ready
</Button>
<AlertDialog open={isDialogOpen} onOpenChange={setIsDialogOpen}>
<AlertDialogTrigger asChild>
<div />
</AlertDialogTrigger>
<AlertDialogContent>
<AlertDialogHeader>
<AlertDialogTitle>{isLoading ? 'Notifying Customer...' : 'Notification Complete'}</AlertDialogTitle>
<AlertDialogDescription>
{isLoading ? (
<div className="flex items-center">
<Spinner className="mr-4" />
<p className="ml-2">Please wait while we notify the customer.</p>
</div>
) : (
'The customer has been successfully notified.'
)}
</AlertDialogDescription>
</AlertDialogHeader>
{!isLoading && (
<AlertDialogFooter>
<AlertDialogAction onClick={() => setIsDialogOpen(false)}>Close</AlertDialogAction>
</AlertDialogFooter>
)}
</AlertDialogContent>
</AlertDialog>
<Button variant="destructive" onClick={() => handleCancelOrder(order.id)}>
Cancel
</Button>
Expand Down
22 changes: 18 additions & 4 deletions app/restraunt/setting/page.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,14 @@ import { Input } from "@/components/ui/input"
import { Button } from "@/components/ui/button"
import { AlertDialog , AlertDialogContent , AlertDialogHeader , AlertDialogTitle , AlertDialogDescription , AlertDialogFooter , AlertDialogCancel ,AlertDialogAction , AlertDialogTrigger} from "@/components/ui/alert-dialog"
import { Dialog, DialogContent, DialogFooter, DialogClose } from "@/components/ui/dialog"

import { deleteRestaurantData } from "@/services/PostRequest/postRequest"
import { getRestaurantInformationByUser } from "@/services/GetRequest/getRequest"
import { useUserAuth } from '@/services/utils';
import { useEffect } from "react"
export default function Component() {
const { user } = useUserAuth();
const [restaurantData, setRestaurantData] = useState([]);

const [showCurrentPassword, setShowCurrentPassword] = useState(false)
const [showNewPassword, setShowNewPassword] = useState(false)
const [showConfirmPassword, setShowConfirmPassword] = useState(false)
Expand All @@ -16,6 +22,14 @@ export default function Component() {
setShowPasswordResetModal(true)
}

useEffect(() => {
async function fetchData() {
const data = await getRestaurantInformationByUser(user);
console.log(data)
setRestaurantData(data);
}
fetchData();
}, []);

return (
<div className="container mx-auto ">
Expand All @@ -29,11 +43,11 @@ export default function Component() {
<div className="grid gap-4">
<div className="grid gap-2">
<Label htmlFor="name">Restaurant Name</Label>
<Input id="name" defaultValue="Delicious Delights" />
<Input id="name" defaultValue={"Sheraj Restaurant "} />
</div>
<div className="grid gap-2">
<Label htmlFor="location">Location</Label>
<Input id="location" defaultValue="123 Main St, Anytown USA" />
<Input id="location" defaultValue={"savan 342 street "}/>
</div>
</div>
</CardContent>
Expand Down Expand Up @@ -139,7 +153,7 @@ export default function Component() {
</div>
<DialogFooter>
<div>
<Button type="button" onClick={() => (window.location.href = "/")}>
<Button type="button" onClick={""}>
OK
</Button>
</div>
Expand Down

0 comments on commit 42e8b9f

Please sign in to comment.