Skip to content

Commit

Permalink
chore: fixedAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
BuyankhuuTsCAl committed Apr 4, 2024
1 parent e083530 commit 68cc86a
Show file tree
Hide file tree
Showing 3 changed files with 293 additions and 7 deletions.
274 changes: 272 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/api/supabase/queries/user_queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export async function fetchUserAddress(uuid: string) {
.eq('user_id', uuid)
.single();

console.log('test', error);
console.log('test', user);

if (error) {
console.error('Error fetching user data:', error);
Expand Down
24 changes: 20 additions & 4 deletions src/app/delivery/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@

import React, { useState, useEffect } from 'react';
import { useRouter } from 'next/navigation';
import {
fetchUser,
fetchUserAddress,
} from '@/api/supabase/queries/user_queries';
import BackButton from '../../components/BackButton/BackButton';
import {
fetchCartItemsWithQuantity,
totalNumberOfItemsInCart,
} from '../../api/supabase/queries/cart_queries';
import { Normal700Text } from '../../styles/fonts';
import { ProductWithQuantity } from '../../schema/schema';
import { ProductWithQuantity, User, Address } from '../../schema/schema';
import OrderSummary from '../../components/OrderSummaryFolder/OrderSummary';
import NavBar from '../../components/NavBarFolder/NavBar';
import {
Expand All @@ -22,13 +26,21 @@ import {
export default function App() {
const [numberOfItems, setNumberOfItems] = useState(0);
const [cart, setCart] = useState<ProductWithQuantity[]>([]);
const [Profile, setProfile] = useState<User>();
const [UserAddress, setUserAddress] = useState<Address>();
const router = useRouter();
useEffect(() => {
async function fetchProducts() {
setNumberOfItems(await totalNumberOfItemsInCart());
setCart(await fetchCartItemsWithQuantity());
}

async function fetchUserData() {
const data = await fetchUser(); // change the function to grab the cartItems as products
setProfile(data);
const address = await fetchUserAddress(data.id);
setUserAddress(address);
}
fetchUserData();
fetchProducts();
}, []);

Expand All @@ -42,9 +54,13 @@ export default function App() {
Shipping
</Normal700Text>
<Normal700Text>Name</Normal700Text>
<InformationText>Ethan Auyeung</InformationText>
<InformationText>
{Profile?.first_name + ' ' + Profile?.last_name}
</InformationText>
<Normal700Text>Address</Normal700Text>
<InformationText>123 Telegraph Ave</InformationText>
<InformationText>
{UserAddress?.street}, {UserAddress?.city}, {UserAddress?.zipcode}
</InformationText>
</InformationContainer>
<OrderContainer>
<OrderSummary cart={cart} numberOfItems={numberOfItems} />
Expand Down

0 comments on commit 68cc86a

Please sign in to comment.