From ad2f4f91f1adca4acbb576d60c7596f436650dad Mon Sep 17 00:00:00 2001 From: ImAlpha Date: Wed, 6 Nov 2024 21:35:10 -0800 Subject: [PATCH] cart completed tentatively --- frontend/src/app/products/page.tsx | 4 +- frontend/src/components/CartTab/CartTab.css | 55 ++++++++++++++++ frontend/src/components/CartTab/CartTab.tsx | 64 +++++++++++++++++++ frontend/src/components/CartTab/cartTab.tsx | 11 ---- frontend/src/components/Navbar/Navbar.tsx | 8 ++- .../src/components/ui/MenuCard/MenuCard.tsx | 3 + 6 files changed, 130 insertions(+), 15 deletions(-) create mode 100644 frontend/src/components/CartTab/CartTab.css create mode 100644 frontend/src/components/CartTab/CartTab.tsx delete mode 100644 frontend/src/components/CartTab/cartTab.tsx diff --git a/frontend/src/app/products/page.tsx b/frontend/src/app/products/page.tsx index 180bf04..89734a8 100644 --- a/frontend/src/app/products/page.tsx +++ b/frontend/src/app/products/page.tsx @@ -55,13 +55,13 @@ const Products = () => {
- Profile picture + /> */}
diff --git a/frontend/src/components/CartTab/CartTab.css b/frontend/src/components/CartTab/CartTab.css new file mode 100644 index 0000000..ea050d5 --- /dev/null +++ b/frontend/src/components/CartTab/CartTab.css @@ -0,0 +1,55 @@ +.cart{ + z-index: 999; + background-color: white; + -webkit-box-shadow: 0px 0px 7px -5px rgba(0,0,0,0.5); + box-shadow: 0px 0px 7px -5px rgba(0,0,0,0.5); + +} + +.details h1{ + margin-bottom: 15px; + color: gray; + font-weight: 400; + font-size: 1.125rem; +} + +.details p{ + color: gray; + margin-bottom: 10px; +} + +.details .price{ + color: #2879fe; +} + +.delete-icon{ + color: red; + font-size: 1.425rem; + cursor: pointer; +} + +.total{ + display: flex; + justify-content: space-between; + font-weight: 500; + font-size: 1.125rem; + margin-bottom: 20px; +} +.checkout{ + width: 100%; + padding: 10px; + display: flex; + align-items: center; + justify-content: center; + gap: 20px; + cursor: pointer; + border: none; + font-weight: 700; + margin-bottom: 20px; +} + +.reset{ + color: red; + font-size: 0.875rem; + cursor: pointer; +} \ No newline at end of file diff --git a/frontend/src/components/CartTab/CartTab.tsx b/frontend/src/components/CartTab/CartTab.tsx new file mode 100644 index 0000000..d371592 --- /dev/null +++ b/frontend/src/components/CartTab/CartTab.tsx @@ -0,0 +1,64 @@ +"use client"; +import React from "react"; +import Image from "next/image"; +import { MdDeleteOutline } from "react-icons/md"; +import { Button } from "@/components/ui/button"; +import "./CartTab.css"; + +const CartTab = () => { + const cartItems = true; + + const data = [ + { + id: 1, + title: "Product 1", + oldPrice: 19, + price: 12, + isNew: true, + desc: "Short sleeve t-shirt", + image: + "https://ih1.redbubble.net/image.2997405810.0746/ssrco,slim_fit_t_shirt,womens,101010:01c5ca27c6,front,square_product,600x600.jpg", + }, + { + id: 2, + title: "Product 2", + oldPrice: 19, + price: 12, + isNew: false, + desc: "Short sleeve t-shirt", + image: + "https://ih1.redbubble.net/image.2997405810.0746/ssrco,slim_fit_t_shirt,flatlay,101010:01c5ca27c6,front,wide_portrait,750x1000-bg,f8f8f8.jpg", + }, + ]; + return ( +
+ {data?.map((item) => ( +
+
+ item picture +
+
+

{item.title}

+

{item.desc?.substring(0, 100)}

+
1 x ${item.price}
+
+ +
+ ))} +
+ SUBTOTAL + $123 +
+ + {/* Reset Cart */} +
+ ); +}; + +export default CartTab; diff --git a/frontend/src/components/CartTab/cartTab.tsx b/frontend/src/components/CartTab/cartTab.tsx deleted file mode 100644 index a443261..0000000 --- a/frontend/src/components/CartTab/cartTab.tsx +++ /dev/null @@ -1,11 +0,0 @@ -"use client"; -import React from 'react' - -const CartTab = () => { - const cartItems = false; - return ( -
{!cartItems ? (
Cart is Empty
) : (
)}
- ) -} - -export default CartTab \ No newline at end of file diff --git a/frontend/src/components/Navbar/Navbar.tsx b/frontend/src/components/Navbar/Navbar.tsx index 97cce1e..8733c9d 100644 --- a/frontend/src/components/Navbar/Navbar.tsx +++ b/frontend/src/components/Navbar/Navbar.tsx @@ -4,6 +4,7 @@ import { useState, useEffect } from "react"; import { useMediaQuery } from "@/util/useMediaQuery"; import { FiShoppingCart } from "react-icons/fi"; import Image from "next/image"; +import CartTab from "@/components/CartTab/CartTab"; const navMotion = { visible: { @@ -24,6 +25,7 @@ const itemMotion = { }; export default function Nav() { + const [open, setOpen] = useState(false); const [toggled, setToggled] = useState(false); const matches = useMediaQuery("(min-width: 1280px)"); // console.log(matches); @@ -74,15 +76,17 @@ export default function Nav() { Home Shirts About - +
setOpen(!open)}> 0 - +
)} + {open && } + {!matches && (
setToggled(!toggled)} diff --git a/frontend/src/components/ui/MenuCard/MenuCard.tsx b/frontend/src/components/ui/MenuCard/MenuCard.tsx index adbbb36..3d55dba 100644 --- a/frontend/src/components/ui/MenuCard/MenuCard.tsx +++ b/frontend/src/components/ui/MenuCard/MenuCard.tsx @@ -6,6 +6,7 @@ import { Inter } from "next/font/google"; import { Card } from "../card"; import Modal from "../../Modal/Modal"; import { Poppins } from "next/font/google"; +import { useRouter } from 'next/navigation' const Popp = Poppins({ weight: "400", subsets: ["latin"] }); @@ -20,6 +21,7 @@ const Popp = Poppins({ weight: "400", subsets: ["latin"] }); // const inter = Inter({ subsets: ["latin"] }); const MenuCard = ({ Menu }: any) => { + const router = useRouter(); return (
{Menu.map((menu_item: any) => { @@ -38,6 +40,7 @@ const MenuCard = ({ Menu }: any) => { quality={75} sizes="(max-width: 325px) 100vw, (max-width: 1200px) 50vw, 33vw" className="flex" + onClick={() => router.push(`/products/${menu_item.id}`)} />