Skip to content

Commit

Permalink
order queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Ravindu-Hasanka committed Jul 30, 2024
1 parent f2e56ae commit d01d318
Showing 1 changed file with 29 additions and 17 deletions.
46 changes: 29 additions & 17 deletions src/pages/DeliveryPerson/OrderQueue.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
import React from "react";
import React, { useEffect } from "react";
import { DatePicker } from "@nextui-org/react";
import OrderCard from "@/pages/DeliveryPerson/OrderCard";
import { title } from "process";

const fetchStocks = async () => {
try {
const data = await getAllStocks();
setStocks(data);
} catch (error: any) {
console.error(error);
}
};

import { useOrders } from "@/api/useOrders";
import { Order } from "@/types/order";
import { useState } from "react";
import useAuthUser from "react-auth-kit/hooks/useAuthUser";

const ordersList = [
{
Expand All @@ -23,44 +17,62 @@ const ordersList = [
{
title: "#322292",
subtitle: "Kollupitiya",
cardImage: "https://www.shutterstock.com/image-vector/paper-cup-filled-black-coffee-600nw-1801429321.jpg",
cardImage: "https://images.unsplash.com/photo-1552913902-366e726db79e?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
text: "10 minutes ago"
},
{
title: "#399392",
subtitle: "Nugegoda",
cardImage: "https://www.shutterstock.com/image-vector/paper-cup-filled-black-coffee-600nw-1801429321.jpg",
cardImage: "https://images.unsplash.com/photo-1655195672072-0ffaa663dfa4?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
text: "15 minutes ago"
},
{
title: "#322292",
subtitle: "Kollupitiya",
cardImage: "https://www.shutterstock.com/image-vector/paper-cup-filled-black-coffee-600nw-1801429321.jpg",
cardImage: "https://images.unsplash.com/photo-1528279027-68f0d7fce9f1?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
text: "20 minutes ago"
},
{
title: "#399392",
subtitle: "Nugegoda",
cardImage: "https://www.shutterstock.com/image-vector/paper-cup-filled-black-coffee-600nw-1801429321.jpg",
cardImage: "https://images.unsplash.com/photo-1513104890138-7c749659a591?q=80&w=2070&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
text: "25 minutes ago"
},
{
title: "#322292",
subtitle: "Kollupitiya",
cardImage: "https://www.shutterstock.com/image-vector/paper-cup-filled-black-coffee-600nw-1801429321.jpg",
cardImage: "https://images.unsplash.com/photo-1515467410840-96a3cf21dbea?q=80&w=1932&auto=format&fit=crop&ixlib=rb-4.0.3&ixid=M3wxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8fA%3D%3D",
text: "30 minutes ago"
}
]

const OrderQueue = () => {
const userId = (useAuthUser() as { userId: string }).userId;
const { getPendingOrdersByDeliveryPersonId } = useOrders();
const [orders, setOrders] = useState<Order[]>([]);

const fetchStocks = async () => {
try {
const data = await getPendingOrdersByDeliveryPersonId(userId);
setOrders(data);
console.log(data);
} catch (error: any) {
console.error(error);
}
};

useEffect(() => {
fetchStocks();
}, []);

return (
<div className='mx-10 my-5 flex flex-col gap-5'>
<div className="relative">
<p className='text-xl font-bold text-white'>Delivery Orders Queue</p>
{/* <p className='text-lg'>Welcome to lafresca delivery app ...</p> */}
{/* <DatePicker label={"Select Date"} variant="bordered" /> */}
</div>

<div className="flex flex-col h-[70%] overflow-auto gap-2">
{ordersList.map((order, index) => (
<OrderCard
Expand Down

0 comments on commit d01d318

Please sign in to comment.