mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-13 21:05:19 +00:00
feat: add updateWorkspace function
This commit is contained in:
@@ -15,11 +15,14 @@ import { WorkspaceLeave } from './leave';
|
||||
import { Upload } from '@/components/file-upload';
|
||||
import { WorkspaceAvatar } from '@/components/workspace-avatar';
|
||||
import { WorkspaceInfo } from '@affine/datacenter';
|
||||
import { useWorkspaceHelper } from '@/hooks/use-workspace-helper';
|
||||
export const GeneralPage = ({ workspace }: { workspace: WorkspaceInfo }) => {
|
||||
const [showDelete, setShowDelete] = useState<boolean>(false);
|
||||
const [showLeave, setShowLeave] = useState<boolean>(false);
|
||||
const [uploading, setUploading] = useState<boolean>(false);
|
||||
const [workspaceName, setWorkspaceName] = useState<string>(workspace.name);
|
||||
const { currentWorkspace } = useAppState();
|
||||
const { updateWorkspace } = useWorkspaceHelper();
|
||||
const isOwner = true;
|
||||
const handleChangeWorkSpaceName = (newName: string) => {
|
||||
setWorkspaceName(newName);
|
||||
@@ -38,6 +41,8 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceInfo }) => {
|
||||
setShowLeave(false);
|
||||
};
|
||||
const handleUpdateWorkspaceName = () => {
|
||||
console.log('currentWorkspace: ', currentWorkspace);
|
||||
updateWorkspace({ name: workspaceName }, currentWorkspace);
|
||||
// workspace && currentWorkspace(workspace.id, { name: workspaceName });
|
||||
};
|
||||
|
||||
@@ -97,22 +102,6 @@ export const GeneralPage = ({ workspace }: { workspace: WorkspaceInfo }) => {
|
||||
✔️
|
||||
</TextButton>
|
||||
</StyledSettingInputContainer>
|
||||
{/* {userInfo ? (
|
||||
<div>
|
||||
<StyledSettingH2 marginTop={20}>Workspace Owner</StyledSettingH2>
|
||||
<StyledSettingInputContainer>
|
||||
<Input
|
||||
width={327}
|
||||
disabled
|
||||
value={userInfo?.name}
|
||||
placeholder="Workspace Owner"
|
||||
></Input>
|
||||
</StyledSettingInputContainer>
|
||||
</div>
|
||||
) : (
|
||||
''
|
||||
)} */}
|
||||
|
||||
<StyledSettingH2 marginTop={20}>Workspace Type</StyledSettingH2>
|
||||
<StyledSettingInputContainer>
|
||||
<code>{workspace.provider} </code>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useAppState } from '@/providers/app-state-provider';
|
||||
import { stringToColour } from '@/utils';
|
||||
import { WorkspaceInfo } from '@affine/datacenter';
|
||||
|
||||
import { Workspace } from '@blocksuite/store';
|
||||
export const useWorkspaceHelper = () => {
|
||||
const { dataCenter } = useAppState();
|
||||
const createWorkspace = async (name: string) => {
|
||||
@@ -21,8 +22,16 @@ export const useWorkspaceHelper = () => {
|
||||
dataCenter.setWorkspacePublish(workspaceId, publish);
|
||||
};
|
||||
|
||||
const updateWorkspace = async (workspace: WorkspaceInfo) => {
|
||||
console.log('workspace: ', workspace);
|
||||
const updateWorkspace = async (
|
||||
{ name, avatar }: { name?: string; avatar?: string },
|
||||
workspace: Workspace
|
||||
) => {
|
||||
if (name) {
|
||||
dataCenter.resetWorkspaceMeta({ name }, workspace);
|
||||
}
|
||||
// if (avatar) {
|
||||
// dataCenter.resetWorkspaceMeta({ avatar }, workspace);
|
||||
// }
|
||||
};
|
||||
return {
|
||||
createWorkspace,
|
||||
|
||||
Reference in New Issue
Block a user