-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: Added disable merch toggle button (#143)
* Revert "remove merch routes for launch (#130)" This reverts commit 6bb3c6d. * Disable merch store feature --------- Co-authored-by: LimIvan336 <[email protected]> Co-authored-by: Chung Zhi Xuan <[email protected]> Co-authored-by: iyzyman <[email protected]>
- Loading branch information
1 parent
69e9a2e
commit 37bcb59
Showing
13 changed files
with
1,575 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { MerchSaleStatus } from "types"; | ||
|
||
class MerchStoreApi { | ||
// eslint-disable-next-line @typescript-eslint/require-await | ||
async setStoreStatus({ | ||
disabled, | ||
displayText, | ||
}: MerchSaleStatus): Promise<void> { | ||
// TODO: set store status in the backend | ||
console.log(disabled, displayText); | ||
return new Promise((res, rej) => { | ||
try { | ||
setTimeout(() => { | ||
res(); | ||
}, 1000); | ||
} catch (error) { | ||
rej(error); | ||
} | ||
}); | ||
} | ||
|
||
async getStoreStatus(): Promise<MerchSaleStatus> { | ||
// TODO: get store status from the backend | ||
return new Promise((res, rej) => { | ||
try { | ||
setTimeout(() => { | ||
res({ | ||
disabled: true, | ||
displayText: | ||
"We are currently preparing for the next merch sale. Please look forward to our email!", | ||
}); | ||
}, 1000); | ||
} catch (error) { | ||
rej(error); | ||
} | ||
}); | ||
} | ||
} | ||
|
||
export default new MerchStoreApi(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from "react"; | ||
import { Flex, Heading } from "@chakra-ui/react"; | ||
import { QueryKeys } from "features/merch/constants"; | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { api } from "features/merch/services/api"; | ||
import { MerchListSkeleton, Page } from "ui/components/merch"; | ||
|
||
interface MerchLayoutProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
export const MerchLayout = ({ children }: MerchLayoutProps) => { | ||
const { data: status, isLoading: isStatusLoading } = useQuery( | ||
[QueryKeys.STATUS], | ||
() => api.getMerchSaleStatus(), | ||
{} | ||
); | ||
|
||
const displayText = status?.displayText; | ||
const disabled = status?.disabled; | ||
|
||
if (isStatusLoading) { | ||
return <Page>{<MerchListSkeleton /> ?? <></>}</Page>; | ||
} | ||
|
||
return ( | ||
<> | ||
{disabled ? ( | ||
<Flex justifyContent="center" alignItems="center" height="85vh"> | ||
<Heading textAlign="center" maxWidth="1260px"> | ||
{displayText} | ||
</Heading> | ||
</Flex> | ||
) : ( | ||
<>{children}</> | ||
)} | ||
</> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export { WebLayout } from './WebLayout'; | ||
export { WebLayout } from "./WebLayout"; | ||
export { MerchLayout } from "./MerchLayout"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,5 @@ export enum QueryKeys { | |
ORDERS = "ORDERS", | ||
EMAIL = "EMAIL", | ||
CHECKOUT = "CHECKOUT", | ||
STATUS = "STATUS", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.