mirror of
https://github.com/perfect-panel/ppanel-web.git
synced 2026-02-12 19:31:12 -05:00
🐛 fix(billing): ExpiryDate
This commit is contained in:
parent
078fc9d756
commit
e85e545ef4
@ -10,15 +10,32 @@ const BASE_URL = 'https://cdn.jsdelivr.net/gh/perfect-panel/ppanel-assets/billin
|
|||||||
interface BillingProps {
|
interface BillingProps {
|
||||||
type: 'dashboard' | 'payment';
|
type: 'dashboard' | 'payment';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ItemType {
|
||||||
|
logo: string;
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
poster: string;
|
||||||
|
expiryDate: string;
|
||||||
|
href: string;
|
||||||
|
}
|
||||||
|
|
||||||
export default async function Billing({ type }: BillingProps) {
|
export default async function Billing({ type }: BillingProps) {
|
||||||
const locale = await getLocale();
|
const locale = await getLocale();
|
||||||
const response = await fetch(BASE_URL, { cache: 'no-store' });
|
let list: ItemType[] = [];
|
||||||
if (!response.ok) {
|
try {
|
||||||
throw new Error(`HTTP error! status: ${response.status}`);
|
const response = await fetch(BASE_URL, { cache: 'no-store' });
|
||||||
|
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
|
const data = await response.json();
|
||||||
|
const now = new Date().getTime();
|
||||||
|
list = data[type].filter((item) => {
|
||||||
|
const expiryDate = Date.parse(item.expiryDate);
|
||||||
|
return !isNaN(expiryDate) && expiryDate > now;
|
||||||
|
});
|
||||||
|
} catch (error) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
const data = await response.json();
|
if (list && list.length === 0) return null;
|
||||||
|
|
||||||
if (data[type].length === 0) return null;
|
|
||||||
return (
|
return (
|
||||||
<TooltipProvider>
|
<TooltipProvider>
|
||||||
<h1 className='text mt-2 font-bold'>
|
<h1 className='text mt-2 font-bold'>
|
||||||
@ -30,7 +47,7 @@ export default async function Billing({ type }: BillingProps) {
|
|||||||
</span>
|
</span>
|
||||||
</h1>
|
</h1>
|
||||||
<div className='grid grid-cols-1 gap-3 md:grid-cols-3 lg:grid-cols-5'>
|
<div className='grid grid-cols-1 gap-3 md:grid-cols-3 lg:grid-cols-5'>
|
||||||
{data[type].map((item, index) => (
|
{list.map((item, index) => (
|
||||||
<Tooltip key={index}>
|
<Tooltip key={index}>
|
||||||
<TooltipTrigger asChild>
|
<TooltipTrigger asChild>
|
||||||
<Link href={item.href} target='_blank'>
|
<Link href={item.href} target='_blank'>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user