import { styled } from '@affine/component'; import { Modal, ModalWrapper, ModalCloseButton } from '@affine/component'; import { Button } from '@affine/component'; import { useState } from 'react'; import { Input } from '@affine/component'; import { KeyboardEvent } from 'react'; import { useTranslation } from '@affine/i18n'; import { useWorkspaceHelper } from '@/hooks/use-workspace-helper'; import { useRouter } from 'next/router'; import { toast } from '@affine/component'; interface ModalProps { open: boolean; onClose: () => void; } export const CreateWorkspaceModal = ({ open, onClose }: ModalProps) => { const [workspaceName, setWorkspaceName] = useState(''); const [loading, setLoading] = useState(false); const { createWorkspace } = useWorkspaceHelper(); const router = useRouter(); const handleCreateWorkspace = async () => { setLoading(true); const workspace = await createWorkspace(workspaceName); if (workspace && workspace.id) { setLoading(false); router.replace(`/workspace/${workspace.id}`); onClose(); } else { toast('create error'); } }; const handleKeyDown = (event: KeyboardEvent) => { if (event.key === 'Enter') { // 👇 Get input value handleCreateWorkspace(); } }; const { t } = useTranslation(); return (
{ onClose(); }} />
{t('New Workspace')}

{t('Workspace description')}

{ setWorkspaceName(value); }} >
); }; const Header = styled('div')({ position: 'relative', height: '44px', }); const Content = styled('div')(({ theme }) => { return { padding: '0 84px', textAlign: 'center', fontSize: '18px', lineHeight: '26px', color: theme.colors.inputColor, p: { marginTop: '12px', marginBottom: '16px', }, }; }); const ContentTitle = styled('div')(() => { return { fontSize: '20px', lineHeight: '28px', fontWeight: 600, textAlign: 'center', paddingBottom: '16px', }; }); // const Footer = styled('div')({ // height: '70px', // paddingLeft: '24px', // marginTop: '32px', // textAlign: 'center', // });