import { useId, useState } from "react";
import {
Button,
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogHeader,
DialogTitle,
Input,
} from "@ace/ui";
import { IconFolderSearch } from "@ace/ui/icons";
import { desktop } from "./desktop";
export function EmptyProjects({ onOpen, disabled }: { onOpen: () => void; disabled: boolean }) {
return (
Open a project
Choose a folder to get started.
);
}
/** Browsers cannot pick a host directory; the desktop uses the native folder dialog. */
export function OpenProject({ onOpen, onClose }: {
onOpen: (path: string) => Promise;
onClose: () => void;
}) {
const id = useId();
const [path, setPath] = useState("");
const [busy, setBusy] = useState(false);
const [error, setError] = useState("");
async function open() {
if (busy || !path.trim()) return;
setBusy(true);
setError("");
try {
await onOpen(path.trim());
onClose();
} catch (error) {
setError((error as Error).message);
} finally {
setBusy(false);
}
}
return (
);
}