From d75da665e128f1864c264c4bd8efcccd6707237e Mon Sep 17 00:00:00 2001 From: Steven Date: Thu, 18 May 2023 23:30:05 +0800 Subject: [PATCH] chore: update setting page style --- src/components/SettingView.tsx | 2 +- src/components/StripeCheckPaymentBanner.tsx | 16 ++------ src/components/SubscriptionHistoryTable.tsx | 42 +++++++-------------- 3 files changed, 18 insertions(+), 42 deletions(-) diff --git a/src/components/SettingView.tsx b/src/components/SettingView.tsx index 4fffe3b..1b9c21e 100644 --- a/src/components/SettingView.tsx +++ b/src/components/SettingView.tsx @@ -17,7 +17,7 @@ const SettingView = () => { const { data: session } = useSession(); return ( -
+
{ // Fetch CheckoutSession from static page via // https://nextjs.org/docs/basic-features/data-fetching#static-generation - const { data, error } = useSWR( - router.query.session_id ? `/api/checkout_sessions/${sessionId}` : null, - fetchGetJSON - ); + const { data } = useSWR(router.query.session_id ? `/api/checkout_sessions/${sessionId}` : null, fetchGetJSON); return ( <> @@ -33,13 +29,9 @@ const StripeCheckPaymentBanner = (props: Props) => { } relative w-full flex flex-row justify-start sm:justify-center items-center py-1 bg-gray-100 dark:bg-zinc-700`} >
- {t("payment.self")}{" "} - {data?.payment_intent?.status ?? t("common.loading")} + {t("payment.self")} {data?.payment_intent?.status ?? t("common.loading")}
-
diff --git a/src/components/SubscriptionHistoryTable.tsx b/src/components/SubscriptionHistoryTable.tsx index 9734dbb..eceaf1e 100644 --- a/src/components/SubscriptionHistoryTable.tsx +++ b/src/components/SubscriptionHistoryTable.tsx @@ -1,9 +1,9 @@ -import { useEffect, useState } from "react"; import axios from "axios"; +import { t } from "i18next"; import { useSession } from "next-auth/react"; +import { useEffect, useState } from "react"; import { SubscriptionPurchase } from "@/types"; import { getCurrencySymbol, getDateString } from "@/utils"; -import { t } from "i18next"; const SubscriptionHistoryTable = () => { const [list, setList] = useState([]); @@ -28,6 +28,10 @@ const SubscriptionHistoryTable = () => { } }, [session]); + if (list.length === 0) { + return <>; + } + return (
@@ -36,28 +40,16 @@ const SubscriptionHistoryTable = () => { - - - - + @@ -66,21 +58,13 @@ const SubscriptionHistoryTable = () => { + -
+ {t("common.date")} + {t("common.description")} + {t("common.amount")}
{getDateString(subscription.createdAt)} {subscription.description} - {subscription.description} - - {getCurrencySymbol( - subscription.currency.toLocaleUpperCase() - )} + {getCurrencySymbol(subscription.currency.toLocaleUpperCase())} {subscription.amount / 100} - + {t("setting.billing.view-receipt")}