feat: enable workspace cloud

This commit is contained in:
DiamondThree 2023-01-10 17:20:21 +08:00
parent 60b379fcad
commit c723c18086
4 changed files with 13 additions and 3 deletions

View File

@ -12,12 +12,14 @@ import { useAppState } from '@/providers/app-state-provider';
import { useConfirm } from '@/providers/ConfirmProvider';
import { toast } from '@/ui/toast';
import { useUserHelper } from '@/hooks/use-user-helper';
import { useRouter } from 'next/router';
export const SyncPage = ({ workspace }: { workspace: WorkspaceInfo }) => {
// console.log('workspace: ', workspace);
const { enableWorkspace } = useWorkspaceHelper();
const { currentWorkspace } = useAppState();
const { confirm } = useConfirm();
const { user, login } = useUserHelper();
const router = useRouter();
return (
<div>
<StyledPublishContent>
@ -42,7 +44,8 @@ export const SyncPage = ({ workspace }: { workspace: WorkspaceInfo }) => {
// if (user) {
// await login();
// }
await enableWorkspace(currentWorkspace);
const id = await enableWorkspace(currentWorkspace);
router.push(`/workspace/${id}`);
toast('Enabled success');
}
});

View File

@ -8,6 +8,7 @@ const defaultOutLineWorkspaceId = 'affine';
export const useEnsureWorkspace = () => {
const [workspaceLoaded, setWorkspaceLoaded] = useState(false);
const { workspaceList, loadWorkspace, user } = useAppState();
console.log('workspaceList: ', workspaceList);
const router = useRouter();
// const defaultOutLineWorkspaceId = '99ce7eb7';

View File

@ -33,8 +33,9 @@ export const useWorkspaceHelper = () => {
};
const enableWorkspace = async (workspace: Workspace) => {
const newWorkspace = await dataCenter.enableWorkspaceCloud(workspace);
console.log('newWorkspace: ', newWorkspace);
const newWorkspaceId = await dataCenter.enableWorkspaceCloud(workspace);
// console.log('newWorkspace: ', newWorkspace);
return newWorkspaceId;
};
return {
createWorkspace,

View File

@ -1,4 +1,9 @@
import NotfoundPage from '@/components/404';
import { useAppState } from '@/providers/app-state-provider';
export default function Custom404() {
const { workspaceList } = useAppState();
console.log('workspaceList: ', workspaceList);
return <NotfoundPage></NotfoundPage>;
}