Implement Phase 2 improvements

This commit is contained in:
gpt-engineer-app[bot]
2025-10-15 12:09:23 +00:00
parent cdd6b0bbd5
commit c3533d0a82
5 changed files with 381 additions and 33 deletions

View File

@@ -121,15 +121,15 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
const [totalCount, setTotalCount] = useState(0);
const totalPages = Math.ceil(totalCount / pageSize);
// Sort state
// Sort state with error handling
const [sortConfig, setSortConfig] = useState<ReportSortConfig>(() => {
const saved = localStorage.getItem('reportsQueue_sortConfig');
if (saved) {
try {
try {
const saved = localStorage.getItem('reportsQueue_sortConfig');
if (saved) {
return JSON.parse(saved);
} catch {
return { field: 'created_at', direction: 'asc' as ReportSortDirection };
}
} catch (error) {
console.warn('Failed to load sort config from localStorage:', error);
}
return { field: 'created_at', direction: 'asc' as ReportSortDirection };
});
@@ -149,9 +149,13 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
refresh: () => fetchReports(false) // Manual refresh shows loading
}), []);
// Persist sort configuration
// Persist sort configuration with error handling
useEffect(() => {
localStorage.setItem('reportsQueue_sortConfig', JSON.stringify(sortConfig));
try {
localStorage.setItem('reportsQueue_sortConfig', JSON.stringify(sortConfig));
} catch (error) {
console.warn('Failed to save sort config to localStorage:', error);
}
}, [sortConfig]);
const fetchReports = async (silent = false) => {