From 3d0aa1a4a13a18e7ca7dbc98986d4c5aaa2c7df2 Mon Sep 17 00:00:00 2001 From: LimIvan336 <71662324+LimIvan336@users.noreply.github.com> Date: Wed, 31 Jan 2024 22:40:34 +0800 Subject: [PATCH] fix linting issues --- apps/cms/src/admin/views/MerchOverview.tsx | 55 +++++++++++++++------- apps/cms/src/apis/store.api.ts | 29 ++++++++---- apps/web/pages/merch/index.tsx | 19 ++++++-- 3 files changed, 70 insertions(+), 33 deletions(-) diff --git a/apps/cms/src/admin/views/MerchOverview.tsx b/apps/cms/src/admin/views/MerchOverview.tsx index e1f6d36c..f29b952e 100644 --- a/apps/cms/src/admin/views/MerchOverview.tsx +++ b/apps/cms/src/admin/views/MerchOverview.tsx @@ -1,4 +1,4 @@ -import React, { useEffect, useState } from "react"; +import React, { useEffect, useState, ChangeEvent } from "react"; import { Button } from "payload/components/elements"; import { AdminView } from "payload/config"; import ViewTemplate from "./ViewTemplate"; @@ -11,24 +11,38 @@ const MerchOverview: AdminView = ({ user, canAccessAdmin }) => { const [isStoreDisabled, setIsStoreDisabled] = useState(true); const [loading, setLoading] = useState(true); + const SHOW_DISPLAY_TEXT_INPUT = false; + useEffect(() => { const fetchStoreStatus = async () => { - const { disabled } = await StoreApi.getStoreStatus(); - setIsStoreDisabled(disabled); - setLoading(false); + try { + const { disabled } = await StoreApi.getStoreStatus(); + setIsStoreDisabled(disabled); + setLoading(false); + } catch (error) { + console.error(error); + setLoading(false); + } }; + + // eslint-disable-next-line @typescript-eslint/no-floating-promises fetchStoreStatus(); }, []); const disableStore = async () => { // TODO: Calls api to disable merch store - setLoading(true); - await StoreApi.setStoreStatus({ - displayText, - disabled: !isStoreDisabled, - }); - setIsStoreDisabled(!isStoreDisabled); - setLoading(false); + try { + setLoading(true); + await StoreApi.setStoreStatus({ + displayText, + disabled: !isStoreDisabled, + }); + setIsStoreDisabled(!isStoreDisabled); + setLoading(false); + } catch (error) { + console.error(error); + setLoading(false); + } }; return ( {

{`Current state of merch store: ${ loading ? "..." : isStoreDisabled ? "Disabled" : "Live" }`}

- {/*