'use client'; import { OUTDATED_THRESHOLD, Photo } from '@/photo'; import AdminPhotosTable from '@/admin/AdminPhotosTable'; import LoaderButton from '@/components/primitives/LoaderButton'; import IconGrSync from '@/site/IconGrSync'; import Banner from '@/components/Banner'; import AdminChildPage from '@/components/AdminChildPage'; import { PATH_ADMIN_PHOTOS } from '@/site/paths'; import { useState } from 'react'; import { syncPhotosAction } from '@/photo/actions'; import { useRouter } from 'next/navigation'; const UPDATE_BATCH_SIZE = 4; export default function AdminOutdatedClient({ photos, hasAiTextGeneration, }: { photos: Photo[] hasAiTextGeneration: boolean }) { const [photoIdsSyncing, setPhotoIdsSyncing] = useState([]); const router = useRouter(); return ( Outdated ({photos.length}) Outdated } accessory={} hideTextOnMobile={false} className="primary" onClick={async () => { // eslint-disable-next-line max-len if (window.confirm(`Are you sure you want to sync the oldest ${UPDATE_BATCH_SIZE} photos? This action cannot be undone.`)) { const photosToSync = photos .slice(0, UPDATE_BATCH_SIZE) .map(photo => photo.id); setPhotoIdsSyncing(photosToSync); syncPhotosAction(photosToSync) .finally(() => { setPhotoIdsSyncing([]); router.refresh(); }); } }} > Sync {UPDATE_BATCH_SIZE} Oldest Photos Sync {UPDATE_BATCH_SIZE} Oldest } >
{photos.length} {' '} {photos.length === 1 ? 'photo' : 'photos'} {' ('}uploaded before {' '} {new Date(OUTDATED_THRESHOLD).toLocaleDateString()}{')'} {' '} may have: missing EXIF fields, inaccurate blur data, {' '} undesired privacy settings {hasAiTextGeneration && ', missing AI-generated text'}
); }