import React, { useRef, useState } from "react"; import { X } from "@phosphor-icons/react"; import Workspace from "../../models/workspace"; import paths from "../../utils/paths"; const noop = () => false; export default function NewWorkspaceModal({ hideModal = noop }) { const formEl = useRef(null); const [error, setError] = useState(null); const handleCreate = async (e) => { setError(null); e.preventDefault(); const data = {}; const form = new FormData(formEl.current); for (var [key, value] of form.entries()) data[key] = value; const { workspace, message } = await Workspace.new(data); if (!!workspace) { window.location.href = paths.workspace.chat(workspace.slug); } setError(message); }; return (