Skip to content

Commit

Permalink
finshed
Browse files Browse the repository at this point in the history
  • Loading branch information
Monique Cheng committed Apr 21, 2024
1 parent 5330746 commit 4cf1d70
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/app/orderPageDelivery/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ import {
import { Body1Bold } from '../orderPage/styles';
import { BackButtonDiv } from '../orderConfirmationPickUp/styles';

export default function OrderConfirmationDelivery() {
export default function OrderPageDelivery() {
const [orders, setOrders] = useState<ProductWithQuantity[]>([]);
const searchParams = useSearchParams();
const orderIDFromSearch = searchParams.get('orderID');
Expand Down Expand Up @@ -156,7 +156,7 @@ export default function OrderConfirmationDelivery() {
<PageDiv>
<BottomColumnDiv>
<LeftColumnDiv>
<BackButton destination="./storefront" />
<BackButton destination="./orderHistory" />
<Heading2Bold>Order No. {orderIDFromSearch}</Heading2Bold>
<OutterFavoriteDiv>
<Body1>Order Date: {organizeOrderDate()}</Body1>
Expand Down
19 changes: 17 additions & 2 deletions src/components/OrderHistory/OrderHistoryText.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import React from 'react';
import React, { useEffect, useState } from 'react';
import { useRouter } from 'next/navigation';

import querystring from 'querystring';
import { Heading4Bold, Body1, OrderStatusFont } from '@/styles/fonts';
import { fetchUser } from '@/api/supabase/queries/user_queries';
import {
ViewOrderButton,
ArrowIcon,
Expand Down Expand Up @@ -34,10 +35,24 @@ interface OrderDetailsProps {
export default function OrderDetails(props: OrderDetailsProps) {
const { date, orderNumber, order } = props;
const router = useRouter();
const [deliveryEnabled, setDeliveryEnabled] = useState<boolean>(false);

useEffect(() => {
async function fetchDelivery() {
const data = await fetchUser();
setDeliveryEnabled(data.delivery_allowed);
}

fetchDelivery();
}, []);

const viewOrder = (orderID: string) => {
const queryString = querystring.stringify({ orderID });
router.push(`/orderPage?${queryString}`);
if (deliveryEnabled) {
router.push(`/orderPageDelivery?${queryString}`);
} else {
router.push(`/orderPage?${queryString}`);
}
};
if (order.order_status === OrderStatus.Rejected) {
return (
Expand Down

0 comments on commit 4cf1d70

Please sign in to comment.