import { useState } from 'react'; import { useTranslation } from 'react-i18next'; import { CheckCircle2, ListChecks, TriangleAlert } from 'lucide-react'; import { Button } from '@/components/ui/button'; import { useReadCheck } from '../services/hooks'; /** * "Library check": a small panel for administrators that compares the library's own tables with the modules (the hero) in * plain words and shows the state of the migration switches (copy, write-through, reading). It only asks the server when the * button is clicked; it changes nothing. */ export function LibraryCheck() { const { t } = useTranslation(); const [asked, setAsked] = useState(false); const check = useReadCheck(asked); return (

{t('media.check.title')}

{t('media.check.hint')}

{check.isError && (

{t('media.check.error')}

)} {check.data && (

{t('media.check.switches', { copy: check.data.copyOnStartup ? t('media.check.on') : t('media.check.off'), write: check.data.dualWrite ? t('media.check.on') : t('media.check.off'), read: t(`media.check.read.${check.data.mode}`), })}

{check.data.modules.length === 0 &&

{t('media.check.noModules')}

} {check.data.modules.map((module) => (
{module.matches ? (

) : (

    {module.differences.map((difference) => (
  • {difference}
  • ))}
)}
))}
)}
); }