fix: improve date formatting and backup path handling
- Updated `formatTimeAgo` in `AdvancedSettingsPageClient` to use a fixed format for hydration consistency. - Refined `formatDate` in `BackupSettingsPageClient` for consistent server/client formatting. - Refactored `BackupService` to use `getCurrentBackupPath` for all backup path references, ensuring up-to-date paths and avoiding caching issues. - Added `getCurrentBackupPath` method to dynamically retrieve the current backup path based on environment variables.
This commit is contained in:
@@ -79,19 +79,16 @@ export function AdvancedSettingsPageClient({
|
||||
};
|
||||
|
||||
const formatTimeAgo = (date: Date): string => {
|
||||
const now = new Date();
|
||||
const diffMs = now.getTime() - new Date(date).getTime();
|
||||
const diffMins = Math.floor(diffMs / (1000 * 60));
|
||||
const diffHours = Math.floor(diffMins / 60);
|
||||
const diffDays = Math.floor(diffHours / 24);
|
||||
|
||||
if (diffMins < 60) {
|
||||
return `il y a ${diffMins}min`;
|
||||
} else if (diffHours < 24) {
|
||||
return `il y a ${diffHours}h ${diffMins % 60}min`;
|
||||
} else {
|
||||
return `il y a ${diffDays}j`;
|
||||
}
|
||||
// Format fixe pour éviter les erreurs d'hydratation
|
||||
const d = new Date(date);
|
||||
return d.toLocaleDateString('fr-FR', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
hour12: false
|
||||
});
|
||||
};
|
||||
|
||||
const getNextBackupTime = (): string => {
|
||||
|
||||
@@ -158,7 +158,17 @@ export default function BackupSettingsPageClient({ initialData }: BackupSettings
|
||||
};
|
||||
|
||||
const formatDate = (date: string | Date): string => {
|
||||
return new Date(date).toLocaleString();
|
||||
// Format cohérent serveur/client pour éviter les erreurs d'hydratation
|
||||
const d = new Date(date);
|
||||
return d.toLocaleDateString('fr-FR', {
|
||||
day: '2-digit',
|
||||
month: '2-digit',
|
||||
year: 'numeric',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
second: '2-digit',
|
||||
hour12: false
|
||||
});
|
||||
};
|
||||
|
||||
if (isLoading) {
|
||||
|
||||
Reference in New Issue
Block a user