Files
notesnook/apps/web/src/navigation/hash-routes.js

117 lines
3.1 KiB
JavaScript
Raw Normal View History

2021-01-03 10:16:54 +05:00
import Vault from "../common/vault";
import {
showBuyDialog,
2021-07-20 12:47:11 +05:00
showCreateTagDialog,
showEditTagDialog,
showEmailVerificationDialog,
showFeatureDialog,
showOnboardingDialog
} from "../common/dialog-controller";
import {
showAddNotebookDialog,
showEditNotebookDialog
2021-02-16 22:28:19 +05:00
} from "../common/dialog-controller";
import { closeOpenedDialog } from "../common/dialog-controller";
import RouteContainer from "../components/route-container";
2021-05-27 12:29:58 +05:00
import DiffViewer from "../components/diff-viewer";
import Unlock from "../components/unlock";
2021-01-03 10:16:54 +05:00
import { store as appStore } from "../stores/app-store";
import { store as editorStore } from "../stores/editor-store";
import { isMobile } from "../utils/dimensions";
import {
showEditTopicDialog,
showCreateTopicDialog
2021-02-16 22:28:19 +05:00
} from "../common/dialog-controller";
2021-02-16 11:49:03 +05:00
import { hashNavigate } from ".";
import EditorPlaceholder from "../components/editor/-placeholder";
2022-07-26 23:19:05 +05:00
import Editor from "../components/editor";
const hashroutes = {
"/": () => {
return !editorStore.get().session.state && <EditorPlaceholder />;
},
2021-01-04 01:57:32 +05:00
"/email/verify": () => {
showEmailVerificationDialog();
},
"/notebooks/create": () => {
showAddNotebookDialog();
},
"/notebooks/:notebookId/edit": ({ notebookId }) => {
showEditNotebookDialog(notebookId);
},
"/topics/create": () => {
showCreateTopicDialog();
},
"/notebooks/:notebookId/topics/:topicId/edit": ({ notebookId, topicId }) => {
showEditTopicDialog(notebookId, topicId);
},
2021-07-20 12:47:11 +05:00
"/tags/create": () => {
showCreateTagDialog();
},
"/tags/:tagId/edit": ({ tagId }) => {
showEditTagDialog(tagId);
},
"/notes/create": () => {
2021-06-16 09:59:01 +05:00
closeOpenedDialog();
hashNavigate("/notes/create", { addNonce: true, replace: true });
},
"/notes/create/:nonce": ({ nonce }) => {
2021-06-16 09:59:01 +05:00
closeOpenedDialog();
2022-07-26 23:19:05 +05:00
return <Editor noteId={0} nonce={nonce} />;
},
"/notes/:noteId/edit": ({ noteId }) => {
2021-06-16 09:59:01 +05:00
closeOpenedDialog();
2022-04-01 20:07:57 +05:00
2022-07-26 23:19:05 +05:00
return <Editor noteId={noteId} />;
},
"/notes/:noteId/unlock": ({ noteId }) => {
2021-06-16 09:59:01 +05:00
closeOpenedDialog();
return (
<RouteContainer
2021-02-16 11:49:03 +05:00
buttons={{
back: isMobile()
? {
title: "Go back",
action: () =>
hashNavigate("/notes/create", {
addNonce: true,
replace: true
})
2021-02-16 11:49:03 +05:00
}
: undefined
2021-02-16 11:49:03 +05:00
}}
component={<Unlock noteId={noteId} />}
/>
);
},
"/notes/:noteId/conflict": ({ noteId }) => {
2021-06-16 09:59:01 +05:00
closeOpenedDialog();
2021-05-27 12:29:58 +05:00
return <DiffViewer noteId={noteId} />;
},
2021-01-03 10:16:54 +05:00
"/vault/changePassword": () => {
Vault.changeVaultPassword();
},
"/vault/create": () => {
Vault.createVault().then((res) => {
appStore.setIsVaultCreated(res);
});
},
"/buy": () => {
showBuyDialog();
},
2021-04-07 09:28:22 +05:00
"/buy/:code": ({ code }) => {
2021-06-28 20:44:58 +05:00
showBuyDialog("monthly", code);
},
"/buy/:plan/:code": ({ plan, code }) => {
showBuyDialog(plan, code);
2021-04-07 09:28:22 +05:00
},
"/welcome": () => {
showOnboardingDialog("new");
},
"/confirmed": () => {
showFeatureDialog("confirmed");
}
};
export default hashroutes;