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