Ajout de date de dernière mise à jour page /veille
This commit is contained in:
parent
f9cd9e66f6
commit
d27558d202
1 changed files with 26 additions and 8 deletions
|
|
@ -35,9 +35,9 @@ const RSSFeedWidget: React.FC = () => {
|
||||||
error: isEnglish ? 'Error loading RSS feeds' : 'Erreur lors du chargement des flux RSS',
|
error: isEnglish ? 'Error loading RSS feeds' : 'Erreur lors du chargement des flux RSS',
|
||||||
noArticles: isEnglish ? 'No articles published in the last 24 hours in monitored RSS feeds.' : 'Aucun article publié dans les dernières 24h dans les flux RSS suivis.',
|
noArticles: isEnglish ? 'No articles published in the last 24 hours in monitored RSS feeds.' : 'Aucun article publié dans les dernières 24h dans les flux RSS suivis.',
|
||||||
comeBack: isEnglish ? 'Come back later for new updates!' : 'Revenez plus tard pour de nouvelles actualités !',
|
comeBack: isEnglish ? 'Come back later for new updates!' : 'Revenez plus tard pour de nouvelles actualités !',
|
||||||
articlesCount: (count: number) => isEnglish
|
articlesCount: (count: number, updateTime: string) => isEnglish
|
||||||
? `${count} article${count > 1 ? 's' : ''} in the last 24 hours`
|
? `${count} article${count > 1 ? 's' : ''} in the last 24 hours (last update: ${updateTime})`
|
||||||
: `${count} article${count > 1 ? 's' : ''} publié${count > 1 ? 's' : ''} dans les dernières 24h`,
|
: `${count} article${count > 1 ? 's' : ''} publié${count > 1 ? 's' : ''} dans les dernières 24h (dernière mise à jour : ${updateTime})`,
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|
@ -65,15 +65,33 @@ const RSSFeedWidget: React.FC = () => {
|
||||||
const formatDate = (dateString: string) => {
|
const formatDate = (dateString: string) => {
|
||||||
try {
|
try {
|
||||||
const date = new Date(dateString);
|
const date = new Date(dateString);
|
||||||
return date.toLocaleTimeString(isEnglish ? 'en-US' : 'fr-FR', {
|
const day = date.getDate().toString().padStart(2, '0');
|
||||||
hour: '2-digit',
|
const month = (date.getMonth() + 1).toString().padStart(2, '0');
|
||||||
minute: '2-digit'
|
const year = date.getFullYear().toString().slice(-2);
|
||||||
});
|
const hours = date.getHours().toString().padStart(2, '0');
|
||||||
|
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||||
|
|
||||||
|
if (isEnglish) {
|
||||||
|
return `${month}/${day}/${year} ${hours}:${minutes}`;
|
||||||
|
} else {
|
||||||
|
return `${day}/${month}/${year} ${hours}:${minutes}`;
|
||||||
|
}
|
||||||
} catch {
|
} catch {
|
||||||
return dateString;
|
return dateString;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formatUpdateTime = (dateString: string) => {
|
||||||
|
try {
|
||||||
|
const date = new Date(dateString);
|
||||||
|
const hours = date.getHours().toString().padStart(2, '0');
|
||||||
|
const minutes = date.getMinutes().toString().padStart(2, '0');
|
||||||
|
return `${hours}:${minutes}`;
|
||||||
|
} catch {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const getTotalArticles = () => {
|
const getTotalArticles = () => {
|
||||||
return categoryGroups.reduce((total, group) => total + group.items.length, 0);
|
return categoryGroups.reduce((total, group) => total + group.items.length, 0);
|
||||||
};
|
};
|
||||||
|
|
@ -119,7 +137,7 @@ const RSSFeedWidget: React.FC = () => {
|
||||||
return (
|
return (
|
||||||
<div className={styles.container}>
|
<div className={styles.container}>
|
||||||
<div className={styles.summary}>
|
<div className={styles.summary}>
|
||||||
<p>{t.articlesCount(getTotalArticles())}</p>
|
<p>{t.articlesCount(getTotalArticles(), formatUpdateTime(generatedAt))}</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{categoryGroups.map((group) => {
|
{categoryGroups.map((group) => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue