import { History as HistoryIcon } from "lucide-react"; import { useState } from "react"; import { Commit } from "@/types"; import { Popover, PopoverContent, PopoverTrigger, } from "@/components/ui/popover"; import { Button } from "@/components/ui/button"; import { useEditor } from "@/hooks/useEditor"; import classNames from "classnames"; export function History() { const { commits, currentCommit, setCurrentCommit, project } = useEditor(); const [open, setOpen] = useState(false); if (commits.length === 0) return null; return (
History
{project?.private && (

As this project is private, you can't see the history of changes.

)}
    {commits?.map((item: Commit, index: number) => (
  • {item.title}

    {new Date(item.date).toLocaleDateString("en-US", { month: "2-digit", day: "2-digit", year: "2-digit", }) + " " + new Date(item.date).toLocaleTimeString("en-US", { hour: "2-digit", minute: "2-digit", second: "2-digit", hour12: false, })}

    {currentCommit === item.oid || (index === 0 && currentCommit === null) ? ( Current version ) : ( !project?.private && ( ) )}
  • ))}
); }