diff --git a/apps/web/features/merch/services/api.ts b/apps/web/features/merch/services/api.ts index 1b0fd34e..f9478ebe 100644 --- a/apps/web/features/merch/services/api.ts +++ b/apps/web/features/merch/services/api.ts @@ -3,6 +3,7 @@ import { Cart, CheckoutRequest, CheckoutResponse, + MerchSaleStatus, PricedCart, Product, ProductsResponse, @@ -85,6 +86,20 @@ export class Api { email, }); } + + async getMerchSaleStatus(): Promise { + // fetch merch status from backend, either true: enabled, false: disabled + // Simulating fetching data from backend and admin panel + return new Promise((resolve, reject) => { + setTimeout(() => { + resolve({ + disabled: true, + displayText: + "We are currently preparing for the next merch sale. Please look forward to our email!", + }); + }, 1000); + }); + } } export const api = new Api(); diff --git a/apps/web/pages/merch/index.tsx b/apps/web/pages/merch/index.tsx index c6cdfcb6..62ee9fba 100644 --- a/apps/web/pages/merch/index.tsx +++ b/apps/web/pages/merch/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import { Flex, Divider, Select, Heading, Grid } from "@chakra-ui/react"; import { useQuery } from "@tanstack/react-query"; import { Card, MerchListSkeleton, Page } from "ui/components/merch"; @@ -9,6 +9,18 @@ import { isOutOfStock } from "features/merch/functions"; const MerchandiseList = () => { const [selectedCategory, setSelectedCategory] = useState(""); + const [isMerchDisabled, setIsMerchDisabled] = useState(false); + const [disabledText, setDisabledText] = useState(""); + + useEffect(() => { + const fetchMerchSaleStatus = async () => { + const { disabled, displayText } = await api.getMerchSaleStatus(); + console.log(disabledText); + setDisabledText(displayText ?? ""); + setIsMerchDisabled(disabled); + }; + fetchMerchSaleStatus(); + }, []); const { data: products, isLoading } = useQuery( [QueryKeys.PRODUCTS], @@ -27,63 +39,84 @@ const MerchandiseList = () => { setSelectedCategory(event.target.value); }; + if (isMerchDisabled === null) { + return ( + <> + + + ); + } + return ( - - - New Drop - - - - - {isLoading ? ( - + {isMerchDisabled ? ( + + + {disabledText} + + ) : ( - - {products - ?.filter((product: Product) => { - if (!product?.is_available) return false; - if (selectedCategory === "") return true; - return product?.category === selectedCategory; - }) - ?.map((item: Product, idx: number) => ( - - ))} - + <> + + + New Drop + + + + + {isLoading ? ( + + ) : ( + + {products + ?.filter((product: Product) => { + if (!product?.is_available) return false; + if (selectedCategory === "") return true; + return product?.category === selectedCategory; + }) + ?.map((item: Product, idx: number) => ( + + ))} + + )} + )} ); diff --git a/packages/types/src/lib/merch.ts b/packages/types/src/lib/merch.ts index a10f00b9..ac5ddfc8 100644 --- a/packages/types/src/lib/merch.ts +++ b/packages/types/src/lib/merch.ts @@ -168,3 +168,8 @@ export type APIError = { export type OrderHoldEntry = { // todo: ??? }; + +export type MerchSaleStatus = { + disabled: boolean; + displayText?: string; +};