import { Avatar, AvatarFallback, AvatarImage } from '@workspace/ui/components/avatar'; import { Card, CardDescription, CardHeader, CardTitle } from '@workspace/ui/components/card'; import { getTranslations } from 'next-intl/server'; import Link from 'next/link'; const BASE_URL = 'https://cdn.jsdelivr.net/gh/perfect-panel/ppanel-assets/billing/index.json'; interface BillingProps { type: 'dashboard' | 'payment'; } interface ItemType { logo: string; title: string; description: string; expiryDate: string; href: string; } export default async function Billing({ type }: BillingProps) { const t = await getTranslations('common.billing'); let list: ItemType[] = []; try { 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: { expiryDate: string }) => { const expiryDate = Date.parse(item.expiryDate); return !isNaN(expiryDate) && expiryDate > now; }); } catch (error) { console.log('Error fetching billing data:', error); return null; } if (list && list.length === 0) return null; return ( <>

{t('title')} {t('description')}

{list.map((item, index) => ( {item.title}
{item.title} {item.description}
))}
); }