mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 17:46:18 +08:00
fix: create workspace
This commit is contained in:
+20
-10
@@ -28,16 +28,19 @@ export const SelectorPopperContent = () => {
|
||||
<PrivateWorkspaceItem />
|
||||
<StyledDivider />
|
||||
<WorkspaceGroupTitle>Workspace</WorkspaceGroupTitle>
|
||||
{workspacesMeta.map(workspace => {
|
||||
return (
|
||||
<WorkspaceItem
|
||||
key={workspace.id}
|
||||
id={workspace.id}
|
||||
name={`workspace-${workspace.id}`}
|
||||
icon={''}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
<WorkspaceWrapper>
|
||||
{workspacesMeta.map(workspace => {
|
||||
return (
|
||||
<WorkspaceItem
|
||||
key={workspace.id}
|
||||
id={workspace.id}
|
||||
name={`workspace-${workspace.id}`}
|
||||
icon={''}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</WorkspaceWrapper>
|
||||
|
||||
<CreateWorkspaceItem />
|
||||
<StyledDivider />
|
||||
<ListItem
|
||||
@@ -68,3 +71,10 @@ const WorkspaceGroupTitle = styled('div')(({ theme }) => {
|
||||
padding: '0 12px',
|
||||
};
|
||||
});
|
||||
|
||||
const WorkspaceWrapper = styled('div')(({ theme }) => {
|
||||
return {
|
||||
maxHeight: '200px',
|
||||
overflow: 'auto',
|
||||
};
|
||||
});
|
||||
|
||||
+16
-2
@@ -12,6 +12,7 @@ import {
|
||||
} from './style';
|
||||
import { useState } from 'react';
|
||||
import { ModalCloseButton } from '@/ui/modal';
|
||||
import router from 'next/router';
|
||||
|
||||
interface WorkspaceCreateProps {
|
||||
open: boolean;
|
||||
@@ -20,6 +21,7 @@ interface WorkspaceCreateProps {
|
||||
|
||||
export const WorkspaceCreate = ({ open, onClose }: WorkspaceCreateProps) => {
|
||||
const [workspaceName, setWorkspaceId] = useState<string>('');
|
||||
const [canCreate, setCanCreate] = useState<boolean>(false);
|
||||
const handlerInputChange = (workspaceName: string) => {
|
||||
setWorkspaceId(workspaceName);
|
||||
};
|
||||
@@ -41,9 +43,21 @@ export const WorkspaceCreate = ({ open, onClose }: WorkspaceCreateProps) => {
|
||||
</StyledInputContent>
|
||||
<StyledButtonContent>
|
||||
<StyledButton
|
||||
disabled={!workspaceName.length}
|
||||
disabled={!workspaceName.length || canCreate}
|
||||
onClick={() => {
|
||||
createWorkspace({ name: workspaceName, avatar: '' });
|
||||
setCanCreate(true);
|
||||
createWorkspace({ name: workspaceName, avatar: '' })
|
||||
.then(data => {
|
||||
// @ts-ignore
|
||||
router.push(`/workspace/${data.created_at}`);
|
||||
onClose();
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err, 'err');
|
||||
})
|
||||
.finally(() => {
|
||||
setCanCreate(false);
|
||||
});
|
||||
}}
|
||||
>
|
||||
Create
|
||||
|
||||
Reference in New Issue
Block a user