diff --git a/components/news.tsx b/components/news.tsx index cbb7d8e..006fa43 100644 --- a/components/news.tsx +++ b/components/news.tsx @@ -5,13 +5,12 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { RefreshCw } from "lucide-react"; import { useSession } from "next-auth/react"; -import { formatDistance } from 'date-fns'; -import { fr } from 'date-fns/locale'; interface NewsItem { id: number; title: string; - date: string; + displayDate: string; + timestamp: string; source: string; description: string | null; category: string | null; @@ -53,24 +52,11 @@ export function News() { } }, [status]); - const formatDate = (dateString: string) => { - try { - const date = new Date(dateString); - return formatDistance(date, new Date(), { - addSuffix: true, - locale: fr - }); - } catch (err) { - console.error('Error formatting date:', err); - return dateString; - } - }; - if (status === 'loading' || loading) { return ( - - - News + + + News
@@ -82,9 +68,9 @@ export function News() { } return ( - - - News + + + News - + {error ? ( -

{error}

+

{error}

) : ( -
+
{news.length === 0 ? ( -

No news available

+

No news available

) : ( news.map((item) => (
window.open(item.url, '_blank')} > -
- {formatDate(item.date)} +
+
+

+ {item.title} +

+ {item.description && ( +

+ {item.description} +

+ )} +
+ {item.displayDate} + {item.source && ( + <> + + {item.source} + + )} +
+
{item.category && ( - + {item.category} )}
-

- {item.title} -

- {item.description && ( -

- {item.description} -

- )}
)) )}