Skip to content

Commit

Permalink
done
Browse files Browse the repository at this point in the history
  • Loading branch information
BuyankhuuTsCAl committed Apr 22, 2024
1 parent a1738f7 commit e102c9c
Show file tree
Hide file tree
Showing 10 changed files with 40 additions and 36 deletions.
8 changes: 6 additions & 2 deletions src/app/[productId]/Buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ import {

import { addToCart } from '../../api/supabase/queries/cart_queries';

export default function Buttons(props: { productNumber: number }) {
export default function Buttons(props: {
productNumber: number;
setTotal: (val: number) => void;
}) {
const [quantity, setQuantity] = useState<number>(1);
const { productNumber } = props;
const { productNumber, setTotal } = props;

const increaseQuantity = () => {
setQuantity(quantity + 1);
Expand All @@ -28,6 +31,7 @@ export default function Buttons(props: { productNumber: number }) {
// used hyphen instead of dash for display
const changeCart = () => {
addToCart(productNumber, quantity);
setTotal(productNumber + quantity);
if (quantity <= 1) {
toast(`you have added ${quantity} item to the cart!`);
} else {
Expand Down
5 changes: 3 additions & 2 deletions src/app/[productId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function ItemDisplay({
const [Item, setItem] = useState<Product>();
const [IsFavorite, setIsFavorite] = useState(false);
const [FilteredProducts, setFilteredProducts] = useState<Product[]>([]);
const [total, setTotal] = useState(0);

useEffect(() => {
async function fetchProducts() {
Expand All @@ -48,7 +49,7 @@ export default function ItemDisplay({
);
const data = (await fetchUserProducts()) as Product[];
const user = (await fetchUser()) as User;
if (user == undefined || user.fav_items == undefined) return;
if (user === undefined || user.fav_items === undefined) return;
setIsFavorite(
!!user.fav_items.find(item => item === Number(params.productId)),
);
Expand Down Expand Up @@ -108,7 +109,7 @@ export default function ItemDisplay({
<Body1 style={{ fontWeight: 'normal', paddingTop: '5px' }}>
<b>Category:</b> {Item?.category}
</Body1>
<Buttons productNumber={params.productId} />
<Buttons productNumber={params.productId} setTotal={setTotal} />
<Body2Bold style={{ paddingTop: '40px' }}>Product Details:</Body2Bold>
<Body2Light style={{ paddingTop: '20px' }}>
{Item?.description}
Expand Down
6 changes: 3 additions & 3 deletions src/app/orderConfirmationDelivery/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {

import { Product, User, Address } from '../../schema/schema';
import { Body1Bold } from '../orderPage/styles';
import { BackButtonDiv } from '../orderConfirmationPickUp/styles';

export default function OrderConfirmationDelivery() {
const [Cart, setCart] = useState<Product[]>([]);
Expand Down Expand Up @@ -93,7 +92,8 @@ export default function OrderConfirmationDelivery() {
'November',
'December',
];
const dateStr = `${months[parseInt(date[1], 10)]} ${date[2]}, ${date[0]}`;

const dateStr = `${months[Number(date[1]) - 1]} ${date[2]}, ${date[0]}`;
return `${dateStr}`;
}

Expand All @@ -105,7 +105,7 @@ export default function OrderConfirmationDelivery() {
<BottomColumnDiv>
<LeftColumnDiv>
<BackButton destination="./storefront" />
<Heading3Bold>Your order has been Submitted</Heading3Bold>
<Heading3Bold>Your Order has been Submitted</Heading3Bold>
<OutterFavoriteDiv>
<Heading4Bold>Order No. {orderIDFromSearch}</Heading4Bold>
<ScrollDiv>
Expand Down
2 changes: 1 addition & 1 deletion src/app/orderConfirmationPickUp/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import {
TextDiv,
} from './styles';

import { Product, User, Pickup } from '../../schema/schema';
import { Product, Pickup } from '../../schema/schema';
import { fetchCartItemsWithQuantityByID } from '../../api/supabase/queries/cart_queries';

export default function OrderConfirmationPickUp() {
Expand Down
9 changes: 0 additions & 9 deletions src/app/orderPage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,6 @@ function formatDate(date: string | undefined): string {
return `${month} ${day}, ${year}`;
}

function formatTime(date: string | undefined): string {
if (!date) return '';

const hour = date.substring(11, 13);
const minute = date.substring(14, 16);

return `${hour}:${minute}`;
}

export default function OrderPage() {
const [orders, setOrders] = useState<ProductWithQuantity[]>([]);
const [pickupTime, setPickupTime] = useState<Pickup>();
Expand Down
13 changes: 11 additions & 2 deletions src/app/orderPageDelivery/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
fetchUser,
fetchCurrentUserAddress,
} from '@/api/supabase/queries/user_queries';

import { convertButtonNumberToCategory } from '@/api/supabase/queries/button_queries';
import {
Body1,
Body2,
Expand Down Expand Up @@ -82,7 +82,16 @@ export default function OrderPageDelivery() {
currOrderId,
)) as ProductWithQuantity[];
const currOrder = await getOrderById(currOrderId);
setOrders(data);
const mapCategories = await Promise.all(
data.map(async product => {
const updateCategory = await convertButtonNumberToCategory(
product.category,
);
return { ...product, category: updateCategory };
}),
);

setOrders(mapCategories);
setOrder(currOrder);
}

Expand Down
5 changes: 2 additions & 3 deletions src/app/profileScreen/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {
AccountDetailsDeliv,
AccountDetailsPickUp,
HeadingBack,
Spacing,
HeadingSpacing,
TextSpacing,
OrderHistory,
Expand Down Expand Up @@ -345,7 +344,7 @@ function LogoutSection() {
});
setTimeout(() => {
router.push('/login');
}, 3000);
}, 2000);
};

return (
Expand Down Expand Up @@ -399,7 +398,7 @@ export default function Profile() {
<NavBarMovedUP />
<ToastContainer
position="top-center"
autoClose={500}
autoClose={3000}
limit={1}
hideProgressBar
/>
Expand Down
6 changes: 2 additions & 4 deletions src/app/storefront/StoreFrontNavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,10 @@ export default function StoreFrontNavBar(props: {
} else {
newInd = ind + 4;
}
setInd(ind);
setInd(newInd);
changeDisplay(1, newInd);
}
console.log(ind);
console.log(buttonCategories.length);
setReachedEnd(ind + 5 < buttonCategories.length);
setReachedEnd(newInd + 5 <= buttonCategories.length);
setReachedStart(true);
};

Expand Down
17 changes: 9 additions & 8 deletions src/components/FooterFolder/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,7 @@ export default function Footer() {
<Body1
style={{ cursor: 'pointer' }}
onClick={() => {
window.location.href =
'https://www.facebook.com/ShantiProjectSF/';
window.open('https://www.facebook.com/ShantiProjectSF/');
}}
>
<MySpanIcon>
Expand All @@ -45,8 +44,9 @@ export default function Footer() {
<Body1
style={{ cursor: 'pointer' }}
onClick={() => {
window.location.href =
'https://www.youtube.com/channel/UCc3DMrL7_KDOzeJNVkoFrsA';
window.open(
'https://www.youtube.com/channel/UCc3DMrL7_KDOzeJNVkoFrsA',
);
}}
>
<MySpanIcon>
Expand All @@ -56,8 +56,7 @@ export default function Footer() {
<Body1
style={{ cursor: 'pointer' }}
onClick={() => {
window.location.href =
'https://www.instagram.com/shantiprojectsf/';
window.open('https://www.instagram.com/shantiprojectsf/');
}}
>
<MySpanIcon>
Expand All @@ -77,8 +76,10 @@ export default function Footer() {
<Body2New
style={{ cursor: 'pointer' }}
onClick={() => {
window.location.href =
'https://maps.app.goo.gl/LJWvkdhwrRMhjEZs7';
window.open(
'https://maps.app.goo.gl/LJWvkdhwrRMhjEZs7',
'_blank',
);
}}
>
<MySpan>SEE ON MAP</MySpan>
Expand Down
5 changes: 3 additions & 2 deletions src/components/NavBarFolder/NavBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,15 @@ import {
IconWithLabelLink,
} from './styles';

export default function NavBar({ ...rest }) {
export default function NavBar() {
const [data, setData] = useState(0);
const [isZero, setIsZero] = useState(true);

useEffect(() => {
const fetchData = async () => {
setData(await totalNumberOfItemsInCart());
};

fetchData();
}, []);

Expand All @@ -34,7 +35,7 @@ export default function NavBar({ ...rest }) {
}, [data]);

return (
<NavBarComp {...rest}>
<NavBarComp>
<IconWithLabelLink href="../storefront">
<Image
src="/images/ShantiLogo.png"
Expand Down

0 comments on commit e102c9c

Please sign in to comment.