diff --git a/README.md b/README.md index 62283688..7e40e445 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ This repo uses turborepo to manage the monorepo. You can find more information a ## Scripts - `yarn dev`: Run the development servers -- `yarn build`: Build the production bundles +- `yard build`: Build the production bundles - `yarn lint`: Lint the codebase with eslint - `yarn format`: Format the codebase with prettier - `yarn test`: Run unit tests diff --git a/apps/web/pages/merch/orders/[slug].tsx b/apps/web/pages/merch/orders/[slug].tsx new file mode 100644 index 00000000..5f9e8a52 --- /dev/null +++ b/apps/web/pages/merch/orders/[slug].tsx @@ -0,0 +1,199 @@ +import React, { useState } from "react"; +import { useRouter } from "next/router"; +import { Image, Badge, Button, Divider, Flex, Heading, Text, useBreakpointValue } from "@chakra-ui/react"; +import { useQuery } from "@tanstack/react-query"; +import { Page } from "ui/components/merch"; +import { Order, OrderStatus } from "types"; +import { api } from "features/merch/services/api"; +import { routes } from "features/merch/constants/routes"; +import { QueryKeys } from "features/merch/constants/queryKeys"; +import { displayPrice } from "features/merch/functions/currency"; +import Link from "next/link" +import LoadingScreen from "ui/components/merch/skeleton/LoadingScreen"; +import { getOrderStatusColor, renderOrderStatus } from "merch-helpers"; +import OrderItem from "ui/components/merch/OrderItem"; +const OrderSummary: React.FC = () => { +// Check if break point hit. KIV + const isMobile: boolean = useBreakpointValue({ base: true, md: false }) || false; + const router = useRouter(); + const orderSlug = router.query.slug as string | undefined; + + const [showThankYou, setShowThankYou] = useState(false); + const [orderState, setOrderState] = useState(null); + // TODO: Fetch subtotal and total from server. + const [total, setTotal] = useState(0); + // Fetch and check if cart item is valid. Number(item.price) set to convert string to num + const { isLoading } = useQuery( + [QueryKeys.ORDER, orderSlug], + () => api.getOrder(orderSlug ?? ""), + { + enabled: !!orderSlug, + onSuccess: (data: Order) => { + setOrderState(data); + setTotal( + data.items.reduce((acc, item) => { + return item.price * item.quantity + acc; + }, 0) + ); + setShowThankYou(true); + }, + } + ); + + const renderThankYouMessage = () => ( + <> + THANK YOU + Thank you for your purchase. We have received your order. + + + + + + ); + const renderOrderSummary = () => ( + <> + + {showThankYou && renderThankYouMessage()} + + + +
+ + + + {renderOrderStatus(orderState?.status ?? OrderStatus.PENDING_PAYMENT)} + + Order Number + + {orderState?.id.split("-")[0]} + + + {orderState?.id} + + + Order date:{" "} + {orderState?.transaction_time + ? new Date(`${orderState.transaction_time}`).toLocaleString( + "en-sg" + ) + : ""} + + {/*Last update: {orderState?.lastUpdate}*/} + + +
+
+ + + + Order Number + + {renderOrderStatus(orderState?.status ?? OrderStatus.PENDING_PAYMENT)} + + + + {orderState?.id.split("-")[0]} + + + {orderState?.id} + + + + + Order date:{" "} + {orderState?.transaction_time + ? new Date(`${orderState.transaction_time}`).toLocaleString( + "en-sg" + ) + : ""} + + {/*Last update: {orderState?.lastUpdate}*/} + + +
+ + {/*{orderState?.items.map((item) => (*/} + {/* */} + {/*))}*/} + + {orderState? : Order Not Found} + + + + + Item Subtotal: + Voucher Discount: + Total: + + + {displayPrice(total)} + + {/*{displayPrice( TODO*/} + {/* (orderState?.billing?.subtotal ?? 0) -*/} + {/* (orderState?.billing?.total ?? 0)*/} + {/*)}*/} + 0 + + {displayPrice(total)} + + +
+ + + {/* TODO: QR Code generator based on Param. */} + QRCode + + Please screenshot this QR code and show it at SCSE Lounge to collect your order. + Alternatively, show the email receipt you have received. + + + For any assistance, please contact our email address: + merch@ntuscse.com + + + + ); + const renderSummaryPage = () => { + if (isLoading) return ; + //rmb to change this v + if (orderState === undefined || orderState === null){return ;} + return renderOrderSummary(); + }; + return {renderSummaryPage()}; +} +export default OrderSummary diff --git a/packages/ui/components/footer/Footer.tsx b/packages/ui/components/footer/Footer.tsx index e9e98294..ab8844bf 100644 --- a/packages/ui/components/footer/Footer.tsx +++ b/packages/ui/components/footer/Footer.tsx @@ -72,7 +72,7 @@ export const Footer = (props: FooterProps) => { fontWeight="semibold" _hover={{ color: "brand.red.medium" }} > - NTU School of Computer Science and Engineering Club + Students' Computing and Data Science Club @@ -81,8 +81,8 @@ export const Footer = (props: FooterProps) => { {/* Club Description */} - NTU SCSE Club is an academic club in Nanyang Technological - University. It serves the the SCSE students and allow them to have + SCDS Club is an academic club in Nanyang Technological + University. It serves the the CCDS students and allow them to have a safe space to  experience @@ -122,12 +122,12 @@ export const Footer = (props: FooterProps) => { Email:  - scse-club@e.ntu.edu.sg + scds-club@e.ntu.edu.sg @@ -168,7 +168,7 @@ export const Footer = (props: FooterProps) => { {/* Copyright */} - Copyright © 2023 - NTU SCSE Club + Copyright © 2024 - SCDS Club