Skip to content

Commit

Permalink
feat: Pick Up re-design
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlotteLaw committed Apr 15, 2024
1 parent 4b648af commit 7561742
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 20 deletions.
11 changes: 11 additions & 0 deletions src/api/supabase/queries/button_queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,17 @@ export async function fetchButtonCategories(): Promise<StorefrontButtons[]> {
return buttons;
}

export async function convertButtonNumbertoCategory(id: string):Promise<string>{
const { data: buttonsCategory, error } = await supabase
.from('storefront_buttons')
.select('*')
.eq('id', id).single();
if (error) {
throw new Error(`Error fetching category: ${error.message}`);
}
return buttonsCategory.name;
}

export async function fetchButton() {
return 0;
}
6 changes: 4 additions & 2 deletions src/api/supabase/queries/cart_queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import supabase from '../createClient';
import { fetchUser } from './user_queries';
import { Product, ProductWithQuantity } from '../../../schema/schema';
import { fetchProductByID } from './product_queries';

import {convertButtonNumbertoCategory} from "./button_queries";
// define cart item type
export type CartItem = {
id: number;
Expand Down Expand Up @@ -200,11 +200,13 @@ export async function fetchCartItemsWithQuantity(): Promise<
quantity: item.quantity,
photo: product.photo,
id: product.id,
category: product.category,
category: await convertButtonNumbertoCategory(product.category),
};
});


const fetchedProducts = await Promise.all(productPromises);
console.log(fetchedProducts);

return fetchedProducts;
}
32 changes: 21 additions & 11 deletions src/app/orderConfirmationPickUp/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ import {
FavoriteDiv,
OutterFavoriteDiv,
LabelBox,
LabelBox1,
ScrollDiv,
ShippingDetailsDiv,
ImageDiv,
BottomColumnDiv,
Wrapper,
LeftColumnDiv,
RightColumnDiv,
DetailsHeader,
Expand Down Expand Up @@ -67,10 +70,8 @@ export default function OrderConfirmationPickUp() {
startTime == null
? ['0', '0', '0']
: startTime?.substring(0, 10).split('-');
const dateStr = `${date[2]}/${date[1]}/${date[0]}`;
const start = startTime?.substring(11, 16);
const end = endTime?.substring(11, 16);
return `${dateStr} (${start} - ${end})`;
const dateStr = `${date[1]}/${date[2]}/${date[0]}`;
return `${dateStr}`;
}

return (
Expand All @@ -86,39 +87,48 @@ export default function OrderConfirmationPickUp() {
<TextDiv>
<Heading3Bold>Your order has been submitted</Heading3Bold>
</TextDiv>

<OutterFavoriteDiv>
<TextDiv1>
<Heading4Bold>Order No. {user?.cart_id}</Heading4Bold>
</TextDiv1>
<ScrollDiv>
{Cart.map(cartItem => (
<FavoriteDiv key={cartItem.id}>
<ImageDiv>
<img
src={cartItem.photo}
alt={cartItem.name}
style={{
width: '150px',
height: '150px',
marginLeft: '30px',
width: '100px',
height: '100px',

}}
/>
<LabelBox>
</ImageDiv>
<LabelBox1>
<Body1Bold>{cartItem.name}</Body1Bold>
<br />
<Body2Light>Category: {cartItem.category}</Body2Light>
</LabelBox1>
<LabelBox>
<Body1Bold>Quantity: {cartItem.quantity}</Body1Bold>
</LabelBox>
</FavoriteDiv>

))}
</ScrollDiv>
</OutterFavoriteDiv>

</LeftColumnDiv>
<RightColumnDiv>
<ShippingDetailsDiv>
<Heading3Bold>Delivery Information</Heading3Bold>
<DetailsHeader>Pick Up Date</DetailsHeader>
<Body1>{organizePickupTime()}</Body1>
<DetailsHeader>Time Slot</DetailsHeader>
<Body1>{organizePickupTime()} (10:00 am - 12:30 pm)</Body1>
<DetailsHeader>Location</DetailsHeader>
<Body1>
Location: 3170 23rd Street, San Francisco, CA 94110
3170 23rd Street, San Francisco, CA 94110
</Body1>
</ShippingDetailsDiv>
</RightColumnDiv>
Expand Down
41 changes: 35 additions & 6 deletions src/app/orderConfirmationPickUp/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@ export const FavoriteDiv = styled.div`
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-start;
justify-content: space-between;
width: 100%;
margin-bottom: 50px;
margin-top: 30px;
margin-right: 20px;
`;

export const OutterFavoriteDiv = styled.div`
Expand All @@ -24,16 +26,35 @@ export const OutterFavoriteDiv = styled.div`
width: 800px;
max-height: 100%;
margin-top: 20px;
margin-bottom: 30px;
margin-right: 40px;
margin-right: 60px;
margin-left: 60px;
padding-right: 20px;
padding-left: 10px;
padding-top: 10px;
`;

export const ScrollDiv = styled.div`
overflow: scroll;
width: 100%;
`;

export const ImageDiv = styled.div`
box-shadow: 1px 1px 4px 1px rgba(0, 0, 0, 0.08);
width: 150px;
height: 150px;
margin-left: 30px;
display: flex;
justify-content: center;
align-items: center;
`;

export const Wrapper = styled.div`
padding: 15px;
display: flex;
justify-content: center;
align-items: center;
`;

export const BackDiv = styled.button`
display: flex;
flex-direction: row;
Expand Down Expand Up @@ -88,14 +109,22 @@ export const NavBarMovedUP = styled(NavBar)`

export const Label = styled.p`
margin-top: 20px;
`;

export const LabelBox1 = styled.div`
width: 250px;
height: 100%;
padding: 20px;
`;

export const LabelBox = styled.div`
width: 150px;
height: 100%;
padding: 20px;
margin-left: 30px;
gap: 35px;
gap: 50px;
margin-right: 30px;
`;

export const HeaderText = styled.h3`
Expand Down Expand Up @@ -225,10 +254,10 @@ export const WhiteBackgroundDiv = styled.div`
height: 430px;
width: 350px;
padding-top: 20px;
box-shadow: 0px 4px 7px 0px rgba(0, 0, 0, 0.1);
`;


export const BottomColumnDiv = styled.div`
display: flex;
flex-direction: row;
Expand Down
1 change: 0 additions & 1 deletion src/app/pickup/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ export default function PickUp() {
}
fetchProducts();
fetchTimes();
console.log(Time);
}, []);

useEffect(() => {
Expand Down

0 comments on commit 7561742

Please sign in to comment.