import { Fragment, ReactNode } from 'react'; import PhotoUploadInput from '@/photo/PhotoUploadInput'; import Link from 'next/link'; import PhotoTiny from '@/photo/PhotoTiny'; import { cc } from '@/utility/css'; import ImageTiny from '@/components/ImageTiny'; import FormWithConfirm from '@/components/FormWithConfirm'; import SiteGrid from '@/components/SiteGrid'; import { deletePhotoAction, deleteBlobPhotoAction, } from '@/photo/actions'; import { FaRegEdit } from 'react-icons/fa'; import SubmitButtonWithStatus from '@/components/SubmitButtonWithStatus'; import { pathForBlobUrl, getBlobPhotoUrls, getBlobUploadUrls, } from '@/services/blob'; import { getPhotos } from '@/services/postgres'; import { routeForPhoto } from '@/site/routes'; export const runtime = 'edge'; const DEBUG_PHOTO_BLOBS = false; export default async function AdminPage() { const photos = await getPhotos('createdAt'); const blobUploadUrls = await getBlobUploadUrls(); const blobPhotoUrls = DEBUG_PHOTO_BLOBS ? await getBlobPhotoUrls() : []; return (
{blobUploadUrls.length > 0 && } {blobPhotoUrls.length > 0 && } {photos.map(photo => {photo.title} {photo.priorityOrder !== null && {photo.priorityOrder} }
{photo.takenAtNaive}
)}
} /> ); } function AdminGrid ({ title, children, }: { title: string, children: ReactNode, }) { return
{title}
{children}
; } function EditButton ({ href, label = 'Edit', }: { href: string, label?: string, }) { return {label} ; } function DeleteButton () { return ×} > Delete ; } function BlobUrls ({ blobUrls, label, }: { blobUrls: string[], label: string, }) { return {blobUrls.map(url => { const href = `/admin/uploads/${encodeURIComponent(url)}`; const fileName = url.split('/').pop(); return {pathForBlobUrl(url)}
;})} ; }