"use client"; import { isAfter } from "date-fns"; import { motion } from "framer-motion"; import { ChevronLeftIcon, ChevronRightIcon, DiffIcon } from "lucide-react"; import type { Dispatch, SetStateAction } from "react"; import { useState } from "react"; import { useSWRConfig } from "swr"; import { useArtifact } from "@/hooks/use-artifact"; import type { Document } from "@/lib/db/schema"; import { cn, getDocumentTimestampByIndex } from "@/lib/utils"; import { LoaderIcon } from "./icons"; type VersionFooterProps = { handleVersionChange: (type: "next" | "prev" | "toggle" | "latest") => void; documents: Document[] | undefined; currentVersionIndex: number; mode: "edit" | "diff"; setMode: Dispatch>; }; export const VersionFooter = ({ handleVersionChange, documents, currentVersionIndex, mode, setMode, }: VersionFooterProps) => { const { artifact } = useArtifact(); const { mutate } = useSWRConfig(); const [isMutating, setIsMutating] = useState(false); if (!documents) { return; } const isFirst = currentVersionIndex === 0; const isLast = currentVersionIndex === documents.length - 1; return (
{currentVersionIndex + 1} of {documents.length}
); };