import React from "react"; interface PolicyData { zh: string; en: string; link: { zh: string; en: string; }; releaseDate: string; } interface AIPoliciesTableProps { policies: PolicyData[]; } const AIPoliciesTable: React.FC = ({ policies }) => { const groupedPolicies = policies.reduce((acc, policy) => { const year = new Date(policy.releaseDate).getFullYear(); if (!acc[year]) { acc[year] = []; } acc[year].push(policy); return acc; }, {} as { [key: number]: PolicyData[] }); const sortedYears = Object.keys(groupedPolicies) .map(Number) .sort((a, b) => b - a); const formatDate = (dateString: string) => { const date = new Date(dateString); const options: Intl.DateTimeFormatOptions = { month: 'short', day: 'numeric', year: 'numeric' }; return date.toLocaleDateString('en-US', options); }; return (
{sortedYears.map((year) => (
{groupedPolicies[year].map((policy, index) => ( ))}
{policy.zh}
{policy.en}
{formatDate(policy.releaseDate)}
{policy.link.zh && ( 中文 )} {policy.link.en && ( English )}
))}
); }; export default AIPoliciesTable;