Skip to content

Commit

Permalink
Finished order history section of profile page
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanAuyeung committed Mar 19, 2024
1 parent f88b69f commit 9e8f121
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 30 deletions.
6 changes: 1 addition & 5 deletions src/app/delivery/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,15 @@ import {
totalNumberOfItemsInCart,
} from '../../api/supabase/queries/cart_queries';
import { Normal700Text } from '../../styles/fonts';
import { fetchRecentOrderProducts } from '../../api/supabase/queries/order_queries';
import { OrderProduct, ProductWithQuantity } from '../../schema/schema';
import { ProductWithQuantity } from '../../schema/schema';
import OrderSummary from '../../components/OrderSummaryFolder/OrderSummary';
import ItemRows from './itemRows';
import NavBar from '../../components/NavBarFolder/NavBar';
import {
DeliveryContainer,
OrderContainer,
OrderSummaryText,
OrderButton,
InformationContainer,
InformationText,
QtyText,
} from './styles';

export default function App() {
Expand Down
2 changes: 0 additions & 2 deletions src/app/orderConfirmationDelivery/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ import NavBar from '../../components/NavBarFolder/NavBar';
import {
FavoriteDiv,
OutterFavoriteDiv,
HeaderText,
OutterBox,
Label,
LabelBox,
ScrollDiv,
AddressText,
DateText,
CenterBox,
AddressDiv,
Expand Down
3 changes: 0 additions & 3 deletions src/app/orderConfirmationPickUp/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@ import {
FavoriteDiv,
ColDiv,
OutterFavoriteDiv,
HeaderText,
OutterBox,
Label,
LabelBox,
ScrollDiv,
AddressText,
DateText,
PickUpText,
CenterBox,
AddressDiv,
} from './styles';
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 @@ -44,7 +44,6 @@ export default function Pickup() {
async function fetchTimes() {
const data = await fetchRecentPickupTimes(); // change the function to grab the cartItems as products
setTimes(data);
console.log(Time);
}
fetchProducts();
fetchTimes();
Expand Down
64 changes: 51 additions & 13 deletions src/app/profileScreen/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
fetchOrderProductById,
fetchProductWithQuantityById,
} from '@/api/supabase/queries/order_queries';
import { Check, CheckCircle, X } from 'react-feather';
import BackButton from '../../components/BackButton/BackButton';
import {
LogOutButton,
Expand Down Expand Up @@ -104,7 +105,11 @@ function OrderHistorySection(props: {
const [firstOrderProducts, setFirstOrderProducts] = useState<
ProductWithQuantity[]
>([]);
const [fD, setFormattedDate] = useState<string>('');




useEffect(() => {
async function fetchFirstOrderProducts() {
if (Orders.length > 0) {
Expand All @@ -129,12 +134,36 @@ function OrderHistorySection(props: {
);

setFirstOrderProducts(productArray);

const timestamp = firstOrder.created_at;
const date = new Date(timestamp);
const options: Intl.DateTimeFormatOptions = { month: 'long', day: 'numeric', year: 'numeric' };
const formattedDate = date.toLocaleDateString('en-US', options);
setFormattedDate(formattedDate);
}
}
fetchFirstOrderProducts();
}, [Orders]);

if (firstOrderProducts.length > 0) {
let backgroundColor = 'transparent';
if (Orders[0].status === 'Submitted') {
backgroundColor = '#CEE8BE';
} else if (Orders[0].status === 'Rejected') {
backgroundColor = '#FFDDDD';
} else if (Orders[0].status === 'Completed') {
backgroundColor = '#C7DDFF';
}
let icon;
if (Orders[0].status === 'Submitted') {
icon = <CheckCircle/>
} else if (Orders[0].status === 'Rejected') {
icon = <X/>
} else if (Orders[0].status === 'Completed'){
icon = <Check/>
} else {
icon = null;
}
return (
<main>
<OrderHistory>
Expand All @@ -160,24 +189,33 @@ function OrderHistorySection(props: {
marginTop: '5px',
}}
>
{Orders[0].created_at}
{fD}
</Body2>
<Body2Bold
<div
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: 'fit-content',
padding: '5px 10px',
borderRadius: '20px', // adjust the border radius to make it more oval-shaped
background: backgroundColor,
marginTop: '20px',
marginBottom: '30px',
marginBottom: '15px',
}}
>
{Orders[0].status}
</Body2Bold>
>
{icon}
<Body2Bold style = {{marginLeft: "13px"}}>
{Orders[0].status}
</Body2Bold>
</div>
<MostRecentOrder>
{firstOrderProducts.map(product => (
<div
key={product.id}
style={{
width: '85px',
height: '85px',
backgroundColor: 'grey',
width: '102px',
height: '102px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
Expand All @@ -187,8 +225,8 @@ function OrderHistorySection(props: {
src={product.photo}
alt={product.name}
style={{
width: '75px',
height: '75px',
width: '102px',
height: '102px',
}}
/>
</div>
Expand Down Expand Up @@ -233,7 +271,7 @@ function AccountDetailSectionDelivery(props: { user: User }) {
<Body2Bold>Email</Body2Bold>
</HeadingSpacing>
<TextSpacing>
<Body1>{user?.email}</Body1>
<Body3>{user?.email}</Body3>
</TextSpacing>
<HeadingSpacing>
<Body2>Name</Body2>
Expand Down
9 changes: 3 additions & 6 deletions src/schema/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ export type User = {
};

export enum OrderStatus {
ApprovalInProgress = 'Approval in Progress',
OrderApproved = 'Order Approved',
OrderProcessing = 'Order Processing',
ReadyForPickup = 'Ready for Pickup',
OutForDelivery = 'Out for Delivery',
Completed = 'Completed',
Submitted = "Submitted",
Completed = "Completed",
Rejected = "Rejected",
}

export type Order = {
Expand Down

0 comments on commit 9e8f121

Please sign in to comment.