From e102c9c9e393a04794576eb5388a966a774d6e2e Mon Sep 17 00:00:00 2001 From: Buyankhuu Tsolmonkhuu Date: Sun, 21 Apr 2024 20:48:44 -0700 Subject: [PATCH] done --- src/app/[productId]/Buttons.tsx | 8 ++++++-- src/app/[productId]/page.tsx | 5 +++-- src/app/orderConfirmationDelivery/page.tsx | 6 +++--- src/app/orderConfirmationPickUp/page.tsx | 2 +- src/app/orderPage/page.tsx | 9 --------- src/app/orderPageDelivery/page.tsx | 13 +++++++++++-- src/app/profileScreen/page.tsx | 5 ++--- src/app/storefront/StoreFrontNavBar.tsx | 6 ++---- src/components/FooterFolder/Footer.tsx | 17 +++++++++-------- src/components/NavBarFolder/NavBar.tsx | 5 +++-- 10 files changed, 40 insertions(+), 36 deletions(-) diff --git a/src/app/[productId]/Buttons.tsx b/src/app/[productId]/Buttons.tsx index 9cc8d802..d6488c36 100644 --- a/src/app/[productId]/Buttons.tsx +++ b/src/app/[productId]/Buttons.tsx @@ -11,9 +11,12 @@ import { import { addToCart } from '../../api/supabase/queries/cart_queries'; -export default function Buttons(props: { productNumber: number }) { +export default function Buttons(props: { + productNumber: number; + setTotal: (val: number) => void; +}) { const [quantity, setQuantity] = useState(1); - const { productNumber } = props; + const { productNumber, setTotal } = props; const increaseQuantity = () => { setQuantity(quantity + 1); @@ -28,6 +31,7 @@ export default function Buttons(props: { productNumber: number }) { // used hyphen instead of dash for display const changeCart = () => { addToCart(productNumber, quantity); + setTotal(productNumber + quantity); if (quantity <= 1) { toast(`you have added ${quantity} item to the cart!`); } else { diff --git a/src/app/[productId]/page.tsx b/src/app/[productId]/page.tsx index 0cb1b006..10c2e6ee 100644 --- a/src/app/[productId]/page.tsx +++ b/src/app/[productId]/page.tsx @@ -38,6 +38,7 @@ export default function ItemDisplay({ const [Item, setItem] = useState(); const [IsFavorite, setIsFavorite] = useState(false); const [FilteredProducts, setFilteredProducts] = useState([]); + const [total, setTotal] = useState(0); useEffect(() => { async function fetchProducts() { @@ -48,7 +49,7 @@ export default function ItemDisplay({ ); const data = (await fetchUserProducts()) as Product[]; const user = (await fetchUser()) as User; - if (user == undefined || user.fav_items == undefined) return; + if (user === undefined || user.fav_items === undefined) return; setIsFavorite( !!user.fav_items.find(item => item === Number(params.productId)), ); @@ -108,7 +109,7 @@ export default function ItemDisplay({ Category: {Item?.category} - + Product Details: {Item?.description} diff --git a/src/app/orderConfirmationDelivery/page.tsx b/src/app/orderConfirmationDelivery/page.tsx index d46f49ac..690624e9 100644 --- a/src/app/orderConfirmationDelivery/page.tsx +++ b/src/app/orderConfirmationDelivery/page.tsx @@ -41,7 +41,6 @@ import { import { Product, User, Address } from '../../schema/schema'; import { Body1Bold } from '../orderPage/styles'; -import { BackButtonDiv } from '../orderConfirmationPickUp/styles'; export default function OrderConfirmationDelivery() { const [Cart, setCart] = useState([]); @@ -93,7 +92,8 @@ export default function OrderConfirmationDelivery() { 'November', 'December', ]; - const dateStr = `${months[parseInt(date[1], 10)]} ${date[2]}, ${date[0]}`; + + const dateStr = `${months[Number(date[1]) - 1]} ${date[2]}, ${date[0]}`; return `${dateStr}`; } @@ -105,7 +105,7 @@ export default function OrderConfirmationDelivery() { - Your order has been Submitted + Your Order has been Submitted Order No. {orderIDFromSearch} diff --git a/src/app/orderConfirmationPickUp/page.tsx b/src/app/orderConfirmationPickUp/page.tsx index 898a0f87..9a78b0f8 100644 --- a/src/app/orderConfirmationPickUp/page.tsx +++ b/src/app/orderConfirmationPickUp/page.tsx @@ -35,7 +35,7 @@ import { TextDiv, } from './styles'; -import { Product, User, Pickup } from '../../schema/schema'; +import { Product, Pickup } from '../../schema/schema'; import { fetchCartItemsWithQuantityByID } from '../../api/supabase/queries/cart_queries'; export default function OrderConfirmationPickUp() { diff --git a/src/app/orderPage/page.tsx b/src/app/orderPage/page.tsx index d4cc521d..b3e2397d 100644 --- a/src/app/orderPage/page.tsx +++ b/src/app/orderPage/page.tsx @@ -67,15 +67,6 @@ function formatDate(date: string | undefined): string { return `${month} ${day}, ${year}`; } -function formatTime(date: string | undefined): string { - if (!date) return ''; - - const hour = date.substring(11, 13); - const minute = date.substring(14, 16); - - return `${hour}:${minute}`; -} - export default function OrderPage() { const [orders, setOrders] = useState([]); const [pickupTime, setPickupTime] = useState(); diff --git a/src/app/orderPageDelivery/page.tsx b/src/app/orderPageDelivery/page.tsx index 07f89aaf..a2e61294 100644 --- a/src/app/orderPageDelivery/page.tsx +++ b/src/app/orderPageDelivery/page.tsx @@ -5,7 +5,7 @@ import { fetchUser, fetchCurrentUserAddress, } from '@/api/supabase/queries/user_queries'; - +import { convertButtonNumberToCategory } from '@/api/supabase/queries/button_queries'; import { Body1, Body2, @@ -82,7 +82,16 @@ export default function OrderPageDelivery() { currOrderId, )) as ProductWithQuantity[]; const currOrder = await getOrderById(currOrderId); - setOrders(data); + const mapCategories = await Promise.all( + data.map(async product => { + const updateCategory = await convertButtonNumberToCategory( + product.category, + ); + return { ...product, category: updateCategory }; + }), + ); + + setOrders(mapCategories); setOrder(currOrder); } diff --git a/src/app/profileScreen/page.tsx b/src/app/profileScreen/page.tsx index 70584754..2e5aaaee 100644 --- a/src/app/profileScreen/page.tsx +++ b/src/app/profileScreen/page.tsx @@ -39,7 +39,6 @@ import { AccountDetailsDeliv, AccountDetailsPickUp, HeadingBack, - Spacing, HeadingSpacing, TextSpacing, OrderHistory, @@ -345,7 +344,7 @@ function LogoutSection() { }); setTimeout(() => { router.push('/login'); - }, 3000); + }, 2000); }; return ( @@ -399,7 +398,7 @@ export default function Profile() { diff --git a/src/app/storefront/StoreFrontNavBar.tsx b/src/app/storefront/StoreFrontNavBar.tsx index 702d1c0d..7621b175 100644 --- a/src/app/storefront/StoreFrontNavBar.tsx +++ b/src/app/storefront/StoreFrontNavBar.tsx @@ -107,12 +107,10 @@ export default function StoreFrontNavBar(props: { } else { newInd = ind + 4; } - setInd(ind); + setInd(newInd); changeDisplay(1, newInd); } - console.log(ind); - console.log(buttonCategories.length); - setReachedEnd(ind + 5 < buttonCategories.length); + setReachedEnd(newInd + 5 <= buttonCategories.length); setReachedStart(true); }; diff --git a/src/components/FooterFolder/Footer.tsx b/src/components/FooterFolder/Footer.tsx index bb9714ef..e6dad2b0 100644 --- a/src/components/FooterFolder/Footer.tsx +++ b/src/components/FooterFolder/Footer.tsx @@ -34,8 +34,7 @@ export default function Footer() { { - window.location.href = - 'https://www.facebook.com/ShantiProjectSF/'; + window.open('https://www.facebook.com/ShantiProjectSF/'); }} > @@ -45,8 +44,9 @@ export default function Footer() { { - window.location.href = - 'https://www.youtube.com/channel/UCc3DMrL7_KDOzeJNVkoFrsA'; + window.open( + 'https://www.youtube.com/channel/UCc3DMrL7_KDOzeJNVkoFrsA', + ); }} > @@ -56,8 +56,7 @@ export default function Footer() { { - window.location.href = - 'https://www.instagram.com/shantiprojectsf/'; + window.open('https://www.instagram.com/shantiprojectsf/'); }} > @@ -77,8 +76,10 @@ export default function Footer() { { - window.location.href = - 'https://maps.app.goo.gl/LJWvkdhwrRMhjEZs7'; + window.open( + 'https://maps.app.goo.gl/LJWvkdhwrRMhjEZs7', + '_blank', + ); }} > SEE ON MAP diff --git a/src/components/NavBarFolder/NavBar.tsx b/src/components/NavBarFolder/NavBar.tsx index c0f92fd5..fb6491d3 100644 --- a/src/components/NavBarFolder/NavBar.tsx +++ b/src/components/NavBarFolder/NavBar.tsx @@ -13,7 +13,7 @@ import { IconWithLabelLink, } from './styles'; -export default function NavBar({ ...rest }) { +export default function NavBar() { const [data, setData] = useState(0); const [isZero, setIsZero] = useState(true); @@ -21,6 +21,7 @@ export default function NavBar({ ...rest }) { const fetchData = async () => { setData(await totalNumberOfItemsInCart()); }; + fetchData(); }, []); @@ -34,7 +35,7 @@ export default function NavBar({ ...rest }) { }, [data]); return ( - +