The weeb for the next gen discord boat - Wamellow wamellow.com
bot discord
3
fork

Configure Feed

Select the types of activity you want to include in your feed.

display past due billing

Luna 4630b722 bef1f9ba

+13 -5
+13 -5
app/profile/billing/page.tsx
··· 23 23 import { type ApiEdit, useApi } from "@/lib/api/hook"; 24 24 import type { ApiV1UsersMeBillingGetResponse, ApiV1UsersMeGuildsGetResponse } from "@/typings"; 25 25 26 + 27 + function isActive(status: ApiV1UsersMeBillingGetResponse["status"]): status is "active" | "trialing" | "past_due" { 28 + return status === "active" || status === "trialing" || status === "past_due"; 29 + } 30 + 26 31 export default function Home() { 27 32 const user = userStore((u) => u); 28 33 const [changeDonationModalOpen, setChangeDonationModalOpen] = useState(false); 29 34 30 35 const { data, isLoading, error, edit } = useApi<ApiV1UsersMeBillingGetResponse>("/users/@me/billing"); 31 36 32 - if ((isLoading && !user?.premium) || (!isLoading && !data) || (data && data.status !== "active" && data.status !== "trialing")) { 37 + if ((isLoading && !user?.premium) || (!isLoading && !data) || (data && !isActive(data.status))) { 33 38 return (<> 34 39 {(error && error !== "Not Found") && <Notice message={error} />} 35 40 ··· 53 58 </>); 54 59 } 55 60 56 - const trialEndsInDays = data?.status === "trialing" 57 - ? Math.floor(((data?.currentPeriodEnd - Date.now() / 1000) / (60 * 60 * 24))) 58 - : 0; 61 + const periodEndsInDays = Math.floor((((data?.currentPeriodEnd || 0) - Date.now() / 1000) / (60 * 60 * 24))); 62 + const periodEndsInStr = `${periodEndsInDays > 1 ? "in " : ""}${periodEndsInDays === 0 ? "Today" : periodEndsInDays === 1 ? "Tomorrow" : periodEndsInDays} ${periodEndsInDays > 1 ? "days" : ""}`; 59 63 60 64 return ( 61 65 <div className="space-y-2"> 66 + {data?.status === "past_due" && ( 67 + <Notice message={`Your renew is over due! Please check your emails to renew your subscription or contact support. Your subscription will be canceled ${periodEndsInStr}.`} /> 68 + )} 69 + 62 70 <Box 63 71 className="md:flex justify-between" 64 72 small ··· 70 78 <Badge 71 79 className="relative bottom-1 ml-2" 72 80 > 73 - trial — Ends {trialEndsInDays > 1 ? "in " : ""}{trialEndsInDays === 0 ? "Today" : trialEndsInDays === 1 ? "Tomorrow" : trialEndsInDays} {trialEndsInDays > 1 ? "days" : ""} 81 + trial — Ends {periodEndsInStr} 74 82 </Badge> 75 83 )} 76 84 </h2>