Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding order tracking feature #39 #129

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import AddProductForm from './pages/AddProd';
// import data from './data';
import MapComponent from "./components/map/ITEMmap";
import SellerForm from "./pages/SellerRegistration";
import OrderTracking from "./pages/Track/ordertracking";

const MyContext = createContext();

Expand Down Expand Up @@ -195,6 +196,11 @@ const signIn = () => {
path="/AboutUs"
element={<About/>}
/>
<Route
exact={true}
path="/order-tracking"
element={<OrderTracking/>}
/>
<Route
exact={true}
path="/cat/:id"
Expand Down
12 changes: 4 additions & 8 deletions src/components/header/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -295,9 +295,12 @@ const Header = (props) => {
</Button>
</li>
<li>
<Button>
<Link to={"/order-tracking"}>
{" "}
<Button className="align-items-center">
<LocationOnOutlinedIcon /> Order Tracking
</Button>
</Link>
</li>
<li>
<Button>
Expand Down Expand Up @@ -371,13 +374,6 @@ const Header = (props) => {
</Link>
</Button>
</li>
<li>
<Button>
<Link to="">
<LocationOnOutlinedIcon /> Order Tracking
</Link>
</Button>
</li>
<li>
<Button>
<Link to="">
Expand Down
23 changes: 23 additions & 0 deletions src/pages/Track/OrderTracking.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.order-tracking {
padding: 40px;
padding-left: 10px;
border: 1px solid #ccc;
border-radius: 5px;
cursor: pointer;
transition: all 0.3s ease;
}

.order-tracking h2 {
margin: 0;
}

.order-details {
margin-top: 10px;
}

.order-tracking.open {
height: auto;
border: 1px solid #333; /* Update with desired color */
padding-left: 40px;
}

56 changes: 56 additions & 0 deletions src/pages/Track/ordertracking.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import React, { useState, useEffect } from "react";
import "./OrderTracking.css"; // Update the correct CSS file path
import MapComponent from "../../components/map/ITEMmap";
const OrderTracking = () => {
const [orderDetails, setOrderDetails] = useState(null);
const [isOpen, setIsOpen] = useState(false);

useEffect(() => {
const fetchOrderDetails = async () => {
try {
// Simulate fetching data from Firebase
const simulatedData = {
orderId: "123456",
status: "Delivered",
deliveryTime: "2024-05-18 12:00 PM",
requirements: "Handle with care",
arrivalLocation: "Your Arrival Location"
};
setOrderDetails(simulatedData);
} catch (error) {
console.error("Failed to fetch order details:", error);
}
};

fetchOrderDetails();
}, []);

const toggleDetails = () => {
setIsOpen(!isOpen);
};

if (!orderDetails) {
return <div>Loading...</div>;
}

return (
<div className={`order-tracking ${isOpen ? "open" : ""}`} onClick={toggleDetails}>
<h2>Order Tracking</h2>
<div className="order-details">
<h3>Order ID: {orderDetails.orderId}</h3>
{isOpen && (
<>
<p>Status: {orderDetails.status}</p>
<p>Estimated Delivery Time: {orderDetails.deliveryTime}</p>
<p>Order Requirements: {orderDetails.requirements}</p>
</>
)}
</div>
<div className="map-container">
<MapComponent location={orderDetails.arrivalLocation} />
</div>
</div>
);
};

export default OrderTracking;