-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #32 from calblueprint/celine/delivery-page
Celine - Delivery Page
- Loading branch information
Showing
13 changed files
with
5,896 additions
and
4,375 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import styled from 'styled-components'; | ||
|
||
const CheckoutButton = styled.button` | ||
width: 100px; | ||
height: 50px; | ||
`; | ||
|
||
export default CheckoutButton; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { OrderProduct } from '../../schema/schema'; | ||
import { fetchProductByID } from '../../api/supabase/queries/product_queries'; | ||
import { | ||
ItemQuantityContainer, | ||
ItemQuantityRow, | ||
ItemText, | ||
QuantityText, | ||
TotalContainer, | ||
} from './styles'; | ||
|
||
function ItemRows({ products }: { products: OrderProduct[] }) { | ||
const [productDetails, setProductDetails] = useState<{ | ||
[key: number]: string; | ||
}>({}); | ||
|
||
useEffect(() => { | ||
// Fetch product details for each product ID | ||
const fetchProductDetails = async () => { | ||
const details: { [key: number]: string } = {}; | ||
|
||
// Create an array of promises | ||
const productPromises = products.map(async product => { | ||
const productData = await fetchProductByID(product.product_id); | ||
details[product.product_id] = productData.name; | ||
}); | ||
|
||
// Wait for all promises to resolve | ||
await Promise.all(productPromises); | ||
|
||
setProductDetails(details); | ||
}; | ||
|
||
fetchProductDetails(); | ||
}, [products]); | ||
|
||
const totalQuantity = products.reduce( | ||
(total, productVal) => total + productVal.quantity, | ||
0, | ||
); | ||
|
||
return ( | ||
<div> | ||
<ItemQuantityContainer> | ||
{products.map(productVal => ( | ||
<ItemQuantityRow key={productVal.product_id}> | ||
<ItemText>{productDetails[productVal.product_id]}</ItemText> | ||
<QuantityText>{productVal.quantity}</QuantityText> | ||
</ItemQuantityRow> | ||
))} | ||
</ItemQuantityContainer> | ||
<TotalContainer> | ||
<ItemQuantityRow style={{ marginTop: '23px' }}> | ||
<ItemText>Order Total</ItemText> | ||
<QuantityText>{totalQuantity}</QuantityText> | ||
</ItemQuantityRow> | ||
</TotalContainer> | ||
</div> | ||
); | ||
} | ||
|
||
export default ItemRows; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,66 @@ | ||
'use client'; | ||
|
||
import React, { useState } from 'react'; | ||
import BackButton from '../../components/BackButton'; | ||
import { GlobalStyle } from '../../styles/components'; | ||
import { Normal700Text } from '../../styles/fonts'; | ||
import { fetchRecentOrderProducts } from '../../api/supabase/queries/order_queries'; | ||
import { OrderProduct } from '../../schema/schema'; | ||
import ItemRows from './itemRows'; | ||
import { | ||
DeliveryContainer, | ||
OrderContainer, | ||
OrderSummary, | ||
OrderSummaryText, | ||
OrderButton, | ||
InformationContainer, | ||
InformationText, | ||
ItemText, | ||
QtyText, | ||
QuantityText, | ||
ItemQuantityRow, | ||
TotalContainer, | ||
NavBarMovedUP, | ||
} from './styles'; | ||
|
||
export default function App() { | ||
const [OrderProducts, setOrderProducts] = useState<OrderProduct[]>([]); | ||
async function fetchOrderProducts() { | ||
try { | ||
const data = (await fetchRecentOrderProducts()) as OrderProduct[]; | ||
setOrderProducts(data); | ||
} catch (error) { | ||
console.log(error); | ||
} | ||
} | ||
|
||
fetchOrderProducts(); | ||
|
||
return ( | ||
<main> | ||
<div> Delivery </div> | ||
<GlobalStyle /> | ||
|
||
<NavBarMovedUP /> | ||
<BackButton /> | ||
<DeliveryContainer> | ||
<InformationContainer> | ||
<Normal700Text style={{ marginBottom: '38px', fontSize: '40px' }}> | ||
Shipping | ||
</Normal700Text> | ||
<Normal700Text>Name</Normal700Text> | ||
<InformationText>Ethan Auyeung</InformationText> | ||
<Normal700Text>Address</Normal700Text> | ||
<InformationText>123 Telegraph Ave</InformationText> | ||
</InformationContainer> | ||
<OrderContainer> | ||
<OrderSummary> | ||
<OrderSummaryText>Order Summary</OrderSummaryText> | ||
<QtyText>Qty.</QtyText> | ||
<ItemRows products={OrderProducts} /> | ||
</OrderSummary> | ||
<OrderButton>Place Order</OrderButton> | ||
</OrderContainer> | ||
</DeliveryContainer> | ||
</main> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
import styled from 'styled-components'; | ||
import NavBar from '../../components/NavBar'; | ||
import COLORS from '../../styles/colors'; | ||
|
||
export const DeliveryContainer = styled.div` | ||
margin-left: 80px; | ||
margin-right: 80px; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
`; | ||
|
||
export const OrderSummaryText = styled.div` | ||
margin-top: 27px; | ||
margin-left: 30px; | ||
text-align: left; | ||
width: 285px; | ||
height: 35px; | ||
font-style: normal; | ||
font-weight: 700; | ||
line-height: normal; | ||
font-size: 30px; | ||
`; | ||
|
||
export const QtyText = styled.div` | ||
margin-top: 30px; | ||
margin-right: 20px; | ||
margin-bottom: 5px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: normal; | ||
text-align: right; | ||
`; | ||
|
||
export const ItemText = styled.div` | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: normal; | ||
`; | ||
|
||
export const QuantityText = styled.div` | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: normal; | ||
text-align: right; | ||
`; | ||
|
||
export const InformationContainer = styled.div` | ||
width: 730px; | ||
height: 400px; | ||
`; | ||
|
||
export const InformationText = styled.div` | ||
width: 730px; | ||
height: 50px; | ||
border-radius: 4px; | ||
margin-top: 14px; | ||
margin-bottom: 14px; | ||
border: 1px solid ${COLORS.neutralGrey}; | ||
background: ${COLORS.lightGrey}; | ||
display: flex; /* Use flexbox */ | ||
align-items: center; /* Center vertically */ | ||
font-size: 20px; | ||
font-style: normal; | ||
font-weight: 400; | ||
line-height: normal; | ||
padding-left: 20px; | ||
`; | ||
|
||
export const OrderContainer = styled.div` | ||
margin-top: 50px; | ||
width: 350px; | ||
height: 450px; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
export const OrderSummary = styled.div` | ||
width: 350px; | ||
height: 360px; | ||
border-radius: 8px; | ||
background: ${COLORS.white}; | ||
box-shadow: 0px 1px 4px 1px rgba(0, 0, 0, 0.15); | ||
align-items: center; | ||
`; | ||
|
||
export const ItemQuantityContainer = styled.div` | ||
padding-top: 200px | ||
width: 300px; | ||
height: 170px; | ||
display: flex; | ||
flex-direction: column; | ||
overflow-y: auto; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
export const ItemQuantityRow = styled.div` | ||
width: 285px; | ||
height: 25px; | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 30px; | ||
`; | ||
|
||
export const TotalContainer = styled.div` | ||
width: 350px; | ||
height: 75px; | ||
border-top: 1px solid black; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
`; | ||
|
||
export const OrderButton = styled.button` | ||
margin-top: 26px; | ||
width: 350px; | ||
height: 50px; | ||
flex-shrink: 0; | ||
align-items: center; | ||
background: ${COLORS.navy}; | ||
border-radius: 8px; | ||
color: ${COLORS.white}; | ||
font-size: 20px; | ||
font-style: normal; | ||
font-weight: 700; | ||
line-height: normal; | ||
`; | ||
|
||
export const NavBarMovedUP = styled(NavBar)` | ||
position: static; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
56a8335
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
shanti-project – ./
shanti-project-celine-ji-won-chois-projects.vercel.app
shanti-project-phi.vercel.app
shanti-project-git-main-celine-ji-won-chois-projects.vercel.app