From 853ffaa018eebc2bb673cfc0232cff348791d9cb Mon Sep 17 00:00:00 2001 From: Buyankhuu Tsolmonkhuu Date: Wed, 10 Apr 2024 00:26:51 -0700 Subject: [PATCH] attemptToRebase --- src/api/supabase/queries/product_queries.ts | 1 + src/app/cart/cartItem.tsx | 6 +- src/app/cart/page.tsx | 10 +- src/app/favorites/page.tsx | 2 +- src/app/layout.tsx | 3 +- src/app/pickup/page.tsx | 9 -- src/app/profileScreen/page.tsx | 2 - src/app/profileScreen/styles.ts | 2 +- src/app/storefront/IndividualItem.tsx | 73 +++++------- src/app/storefront/page.tsx | 13 ++- src/app/storefront/productButtons.tsx | 29 +++-- src/app/storefront/storefrontItems.tsx | 6 +- src/app/storefront/styles.ts | 123 ++++++++++---------- 13 files changed, 123 insertions(+), 156 deletions(-) diff --git a/src/api/supabase/queries/product_queries.ts b/src/api/supabase/queries/product_queries.ts index 85ec9fbb..509bc8ea 100644 --- a/src/api/supabase/queries/product_queries.ts +++ b/src/api/supabase/queries/product_queries.ts @@ -103,6 +103,7 @@ export async function convertCategoryToNumber( export async function fetchUnprescribedCategory( productType: string, ): Promise { + console.log(productType); const productTypeConverted = await convertCategoryToNumber(productType); const { data: products, error } = await supabase diff --git a/src/app/cart/cartItem.tsx b/src/app/cart/cartItem.tsx index f0970f5c..357fb340 100644 --- a/src/app/cart/cartItem.tsx +++ b/src/app/cart/cartItem.tsx @@ -1,15 +1,15 @@ 'use client'; import { useState } from 'react'; +import { Body2, Heading4Bold } from '@/styles/fonts'; import { removeCartItem } from '../../api/supabase/queries/cart_queries'; -import { Body2,Body2Light,Heading4Bold } from '@/styles/fonts'; import { FavoriteDiv, TrashIcon, TransparentButton, - Label, + LabelBox, - ImageDiv, + ImageBackground, } from './styles'; diff --git a/src/app/cart/page.tsx b/src/app/cart/page.tsx index 66b96ba0..fb0c230e 100644 --- a/src/app/cart/page.tsx +++ b/src/app/cart/page.tsx @@ -3,8 +3,8 @@ import { useRouter } from 'next/navigation'; import { useState, useEffect } from 'react'; import { fetchUser } from '@/api/supabase/queries/user_queries'; -import BackButton from '../../components/BackButton/BackButton'; import { Heading1 } from '@/styles/fonts'; +import BackButton from '../../components/BackButton/BackButton'; import OrderSummary from '../../components/OrderSummaryFolder/OrderSummary'; @@ -15,12 +15,6 @@ import { import CartItem from './cartItem'; import NavBar from '../../components/NavBarFolder/NavBar'; import { - OrderButton, - DeliveryContainer, - OrderContainer, - BackButtonDiv, - InformationContainer, - OutterDiv, CartItemsDiv, PageDiv, CheckoutButton, @@ -82,7 +76,7 @@ export default function OrderPage() { checkDelivery()} - disabled={numberOfItems == 0} + disabled={numberOfItems === 0} > Check Out diff --git a/src/app/favorites/page.tsx b/src/app/favorites/page.tsx index b205c97a..1cefe242 100644 --- a/src/app/favorites/page.tsx +++ b/src/app/favorites/page.tsx @@ -53,7 +53,7 @@ export default function FavoritesPage() { {Favorites.map(favorite => ( - + {favorite.name} { - async function fetchProducts() { - if (products.find(item => item.id === product.id)) { - setIsFavorite(true); - } - } - fetchProducts(); - // eslint-disable-next-line react-hooks/exhaustive-deps - }, [products]); + const [IsFavorite, setIsFavorite] = useState( + !!products.find(item => item.id === product.id), + ); - async function clickFunction() { - addOrRemoveProductFromFavorite(product, !IsFavorite); + async function handleFavorite() { + await addOrRemoveProductFromFavorite(product, !IsFavorite); setIsFavorite(!IsFavorite); } return ( - - - router.push(`/${product.id}`)}> - {product.name} - - clickFunction()} - onMouseEnter={() => setHovering(true)} - onMouseLeave={() => setHovering(false)} - > - - - + + {/* */} + + {product.name} + + handleFavorite()}> + {IsFavorite ? 'Remove from favorites' : 'Add to favorites'} - - - {product.name} - + + + + + {/* */} + {product.name} + ); } diff --git a/src/app/storefront/page.tsx b/src/app/storefront/page.tsx index 21ad1ce9..2997f665 100644 --- a/src/app/storefront/page.tsx +++ b/src/app/storefront/page.tsx @@ -1,10 +1,11 @@ 'use client'; import React, { useEffect, useState } from 'react'; +import { Heading1Bold } from '@/styles/fonts'; import Storefront from './storefrontItems'; import Footer from '../../components/FooterFolder/Footer'; -import { ShopAllText, Fullscreen, StorefrontBox } from './styles'; +import { StorefrontWrapper } from './styles'; import { fetchUserProducts } from '../../api/supabase/queries/product_queries'; import { Product } from '../../schema/schema'; @@ -31,7 +32,7 @@ export default function App() { }, []); return ( - +
- Shop {CategoryWord} - + + Shop {CategoryWord} - +
- +
); } diff --git a/src/app/storefront/productButtons.tsx b/src/app/storefront/productButtons.tsx index 0cc824b7..fcc01f5a 100644 --- a/src/app/storefront/productButtons.tsx +++ b/src/app/storefront/productButtons.tsx @@ -1,7 +1,11 @@ import React from 'react'; import { fetchButtonCategories } from '@/api/supabase/queries/button_queries'; -import { Button, Label, IndividualContainer } from './styles'; +import { + CategoryButton, + CategoryButtonLabel, + IndividualContainer, +} from './styles'; import { fetchUserProducts, @@ -42,11 +46,8 @@ export default function ProductButtons(props: { if (buttonCategories[i].name === category) { const ind = buttonCategories[i].id - 1; if (ind === clickedButton) { - // const tempArray = [...IsClickedButton]; - // tempArray[ind] = !tempArray[ind]; - // tempArray[0] = true; setCategoryWord('All'); - // setIsClickedButton(tempArray); + setClickedButton(0); if (productItem !== null) { @@ -55,10 +56,8 @@ export default function ProductButtons(props: { return; } setClickedButton(ind); - // const arrayOfFalse = [false, false, false, false]; - // arrayOfFalse[ind] = true; + setCategoryWord(buttonCategories[i].name); - // setIsClickedButton(arrayOfFalse); break; } @@ -69,7 +68,6 @@ export default function ProductButtons(props: { // Applying the filter to the categories of the product if (category !== 'All') { - console.log(category); const products = await filterUserProducts(category); if (products !== null) { setFiltredProducts(products); @@ -84,15 +82,14 @@ export default function ProductButtons(props: { return ( -