From dc090985fa441767ecda4423494313312c20f76e Mon Sep 17 00:00:00 2001 From: Buyankhuu Tsolmonkhuu Date: Tue, 13 Feb 2024 20:56:55 -0800 Subject: [PATCH] buyankhuu's edits --- src/app/delivery/page.tsx | 9 +- src/app/delivery/styles.ts | 18 ++- src/app/profileScreenDelivery/page.tsx | 138 +++++++++++++---------- src/app/profileScreenPickUp/page.tsx | 145 +++++++++++++++---------- 4 files changed, 196 insertions(+), 114 deletions(-) diff --git a/src/app/delivery/page.tsx b/src/app/delivery/page.tsx index 64a707f0..cda3bf93 100644 --- a/src/app/delivery/page.tsx +++ b/src/app/delivery/page.tsx @@ -17,6 +17,7 @@ import { InformationText, QtyText, NavBarMovedUP, + InputStyled, } from './styles'; export default function App() { @@ -39,9 +40,13 @@ export default function App() { Shipping Name - Ethan Auyeung + + + Address - 123 Telegraph Ave + + + diff --git a/src/app/delivery/styles.ts b/src/app/delivery/styles.ts index a33d38ed..d7d6662f 100644 --- a/src/app/delivery/styles.ts +++ b/src/app/delivery/styles.ts @@ -51,6 +51,23 @@ export const InformationContainer = styled.div` height: 400px; `; +export const InputStyled = styled.input` + width: 100%; + height: 100%; + border: 1px solid ${COLORS.neutralGrey}; + background: ${COLORS.lightGrey}; + background: ${COLORS.lightGrey}; + font-size: 20px; + font-style: normal; + font-weight: 400; + padding-left: 20px; + color: ${COLORS.black}; + &::placeholder, + ::-webkit-input-placeholder { + color: ${COLORS.black}; + } +`; + export const InformationText = styled.div` width: 730px; height: 50px; @@ -65,7 +82,6 @@ export const InformationText = styled.div` font-style: normal; font-weight: 400; line-height: normal; - padding-left: 20px; `; export const OrderContainer = styled.div` diff --git a/src/app/profileScreenDelivery/page.tsx b/src/app/profileScreenDelivery/page.tsx index 9dc0248f..12717cd9 100644 --- a/src/app/profileScreenDelivery/page.tsx +++ b/src/app/profileScreenDelivery/page.tsx @@ -32,36 +32,68 @@ import { signOut } from '../../api/supabase/auth/auth'; import 'react-toastify/dist/ReactToastify.css'; import { TransparentButton } from '../favorites/styles'; -export default function Profile() { - const [Favorites, setFavorites] = useState([]); +function FavoriteSection(props: { + Favorites: Product[]; + setFavorites: (category: Product[]) => void; +}) { + async function clickFunctions(props: { fav: Product }) { + const { fav } = props; + addOrRemoveProductFromFavorite(fav, false); + setFavorites(Favorites.filter(Prod => Prod.id !== fav.id)); + } + const { Favorites, setFavorites } = props; + return ( +
+ + Favorites + + {Favorites.slice(0, 2).map(favorite => ( + + {favorite.name} +

+ {favorite.name} +
+ Product ID: {favorite.id} +

+ clickFunctions({ fav: favorite })} + > + + +
+ ))} +
+
+ ); +} + +function OrderHistorySection() { + return ( +
+ + Order History + / + +
+ ); +} +function AccountDetailSection() { const [user, setUser] = useState(); + const [UserAddress, setUserAddress] = useState
(); + const router = useRouter(); async function getUser() { const data = await fetchUser(); setUser(data); } - const [UserAddress, setUserAddress] = useState
(); async function getUserAddress() { const data = await fetchUser(); const address = await fetchUserAddress(data.id); setUserAddress(address); } - - async function fetchProducts() { - const data = (await arrayOfFavorites()) as Product[]; - setFavorites(data); - } - useEffect(() => { - fetchProducts(); - getUser(); - getUserAddress(); - }, []); - - async function clickFunctions(props: { fav: Product }) { - const { fav } = props; - addOrRemoveProductFromFavorite(fav, false); - setFavorites(Favorites.filter(Prod => Prod.id !== fav.id)); - } - const router = useRouter(); const showToastMessage = () => { signOut(); toast("You've been Logged Out! Redirecting...", { @@ -71,16 +103,12 @@ export default function Profile() { router.push('/login'); }, 3000); }; + useEffect(() => { + getUser(); + getUserAddress(); + }, []); return (
- - - - - - My Profile - - Account Details @@ -107,33 +135,33 @@ export default function Profile() { showToastMessage()}>Log Out - - Order History - - - - Favorites - - {Favorites.slice(0, 2).map(favorite => ( - - {favorite.name} -

- {favorite.name} -
- Product ID: {favorite.id} -

- clickFunctions({ fav: favorite })} - > - - -
- ))} -
+
+ ); +} + +export default function Profile() { + const [Favorites, setFavorites] = useState([]); + async function fetchProducts() { + const data = (await arrayOfFavorites()) as Product[]; + setFavorites(data); + } + useEffect(() => { + fetchProducts(); + }, []); + + return ( +
+ + + + + + My Profile + + + + + {/* router.push('/favorites')}> Favorites diff --git a/src/app/profileScreenPickUp/page.tsx b/src/app/profileScreenPickUp/page.tsx index 7a734c5d..713818c3 100644 --- a/src/app/profileScreenPickUp/page.tsx +++ b/src/app/profileScreenPickUp/page.tsx @@ -8,10 +8,10 @@ import { addOrRemoveProductFromFavorite, arrayOfFavorites, fetchUser, + fetchUserAddress, } from '@/api/supabase/queries/user_queries'; -import { Product, User } from '@/schema/schema'; +import { Address, Product, User } from '@/schema/schema'; import ViewAllButton from '@/components/ViewAllButton/ViewAllButton'; - import BackButton from '../../components/BackButton/BackButton'; import { LogOutButton, @@ -26,37 +26,74 @@ import { FavoritesContainer, FavoriteDiv, HeartIcon, + BackButtonDiv, } from './styles'; import { signOut } from '../../api/supabase/auth/auth'; import 'react-toastify/dist/ReactToastify.css'; - import { TransparentButton } from '../favorites/styles'; -import { BackButtonDiv } from '../profileScreenDelivery/styles'; - -export default function Profile() { - const [user, setUser] = useState(); - async function getUser() { - const data = await fetchUser(); - setUser(data); - } - const [Favorites, setFavorites] = useState([]); - - async function fetchProducts() { - const data = (await arrayOfFavorites()) as Product[]; - setFavorites(data); - } - useEffect(() => { - fetchProducts(); - getUser(); - }, []); +function FavoriteSection(props: { + Favorites: Product[]; + setFavorites: (category: Product[]) => void; +}) { async function clickFunctions(props: { fav: Product }) { const { fav } = props; addOrRemoveProductFromFavorite(fav, false); setFavorites(Favorites.filter(Prod => Prod.id !== fav.id)); } + const { Favorites, setFavorites } = props; + return ( +
+ + Favorites + + {Favorites.slice(0, 2).map(favorite => ( + + {favorite.name} +

+ {favorite.name} +
+ Product ID: {favorite.id} +

+ clickFunctions({ fav: favorite })} + > + + +
+ ))} +
+
+ ); +} +function OrderHistorySection() { + return ( +
+ + Order History + / + +
+ ); +} +function AccountDetailSection() { + const [user, setUser] = useState(); + const [UserAddress, setUserAddress] = useState
(); const router = useRouter(); + async function getUser() { + const data = await fetchUser(); + setUser(data); + } + async function getUserAddress() { + const data = await fetchUser(); + const address = await fetchUserAddress(data.id); + setUserAddress(address); + } const showToastMessage = () => { signOut(); toast("You've been Logged Out! Redirecting...", { @@ -66,16 +103,12 @@ export default function Profile() { router.push('/login'); }, 3000); }; + useEffect(() => { + getUser(); + getUserAddress(); + }, []); return (
- - - - - - My Profile - - Account Details @@ -100,33 +133,33 @@ export default function Profile() { showToastMessage()}>Log Out - - Order History - - - - Favorites - - {Favorites.slice(0, 2).map(favorite => ( - - {favorite.name} -

- {favorite.name} -
- Product ID: {favorite.id} -

- clickFunctions({ fav: favorite })} - > - - -
- ))} -
+
+ ); +} + +export default function Profile() { + const [Favorites, setFavorites] = useState([]); + async function fetchProducts() { + const data = (await arrayOfFavorites()) as Product[]; + setFavorites(data); + } + useEffect(() => { + fetchProducts(); + }, []); + + return ( +
+ + + + + + My Profile + + + + + {/* router.push('/favorites')}> Favorites