'use client' import { useState } from 'react' import { Document } from '@/app/db/data' import Link from 'next/link' import { loadAllAuthors } from '@/app/db/loaders' import { useSuspenseQuery } from '@tanstack/react-query' import { epoch2date } from '@/app/utils/epoch2datestring' const VersionChooser = ({ doc, slug, }: Readonly<{ doc: Document; slug: string }>) => { const { data, error } = useSuspenseQuery({ queryKey: ['authors_all'], queryFn: () => { const data = loadAllAuthors() return data }, }) if (error) throw error let authorList = data const { file } = doc const { authors, latest } = doc.manifest const date = epoch2date(doc.manifest.dates[doc.manifest.dates.length - 1]) const fileEnding = file === 'other' ? '' : `.${file}` const [selectedRevision, setSelectedRevision] = useState(latest) // Initialize the selected revision with the latest revision return (
) } export default VersionChooser