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

62 lines
1.7 KiB
JavaScript
Raw Normal View History

import React from "react";
2021-01-03 10:16:54 +05:00
import Vault from "../common/vault";
import {
showAddNotebookDialog,
showEditNotebookDialog,
} from "../components/dialogs/addnotebookdialog";
import { closeOpenedDialog } from "../components/dialogs/dialog";
import { showLogInDialog } from "../components/dialogs/logindialog";
2021-01-03 10:16:54 +05:00
import { showSignUpDialog } from "../components/dialogs/signupdialog";
import RouteContainer from "../components/route-container";
import SplitEditor from "../components/spliteditor";
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 { store as noteStore } from "../stores/note-store";
import { isMobile } from "../utils/dimensions";
const hashroutes = {
"/": () => {
closeOpenedDialog();
},
"/notebooks/create": () => {
showAddNotebookDialog();
},
"/notebooks/:notebookId/edit": ({ notebookId }) => {
showEditNotebookDialog(notebookId);
},
"/notes/:noteId/edit": ({ noteId }) => {
editorStore.openSession(noteId);
},
"/notes/:noteId/unlock": ({ noteId }) => {
return (
<RouteContainer
onlyBackButton={isMobile()}
route={<Unlock noteId={noteId} />}
/>
);
},
"/notes/:noteId/conflict": ({ noteId }) => {
return <SplitEditor noteId={noteId} />;
},
"/notes/create": () => {
editorStore.newSession(noteStore.get().context);
},
2021-01-03 10:16:54 +05:00
"/signup": () => {
showSignUpDialog();
},
"/vault/changePassword": () => {
Vault.changeVaultPassword();
},
"/vault/create": () => {
Vault.createVault().then((res) => {
appStore.setIsVaultCreated(res);
});
},
"/login": () => {
showLogInDialog();
},
};
export default hashroutes;