/*
This file is part of the Notesnook project (https://notesnook.com/)
Copyright (C) 2023 Streetwriters (Private) Limited
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
import {
showAddReminderDialog,
showBuyDialog,
showCreateTagDialog,
showEditReminderDialog,
showEmailVerificationDialog,
showFeatureDialog,
showOnboardingDialog,
showSettings
} from "../common/dialog-controller";
import {
showAddNotebookDialog,
showEditNotebookDialog
} from "../common/dialog-controller";
import { closeOpenedDialog } from "../common/dialog-controller";
import RouteContainer from "../components/route-container";
import DiffViewer from "../components/diff-viewer";
import Unlock from "../components/unlock";
import { store as editorStore } from "../stores/editor-store";
import { isMobile } from "../utils/dimensions";
import { hashNavigate } from ".";
import Editor from "../components/editor";
import { defineRoutes } from "./types";
const hashroutes = defineRoutes({
"/": () => {
return !editorStore.get().session.state && ;
},
"/email/verify": () => {
showEmailVerificationDialog().then(afterAction);
},
"/notebooks/create": () => {
showAddNotebookDialog().then(afterAction);
},
"/notebooks/:notebookId/edit": ({ notebookId }) => {
showEditNotebookDialog(notebookId)?.then(afterAction);
},
"/reminders/create": () => {
showAddReminderDialog().then(afterAction);
},
"/reminders/:reminderId/edit": ({ reminderId }) => {
showEditReminderDialog(reminderId).then(afterAction);
},
"/tags/create": () => {
showCreateTagDialog().then(afterAction);
},
"/notes/create": () => {
closeOpenedDialog();
hashNavigate("/notes/create", { addNonce: true, replace: true });
},
"/notes/create/:nonce": ({ nonce }) => {
closeOpenedDialog();
return ;
},
"/notes/:noteId/edit": ({ noteId }) => {
closeOpenedDialog();
return ;
},
"/notes/:noteId/unlock": ({ noteId }) => {
closeOpenedDialog();
return (
hashNavigate("/notes/create", {
addNonce: true,
replace: true
})
}
: undefined
}}
>
);
},
"/notes/:noteId/conflict": ({ noteId }) => {
closeOpenedDialog();
return ;
},
"/buy": () => {
showBuyDialog().then(afterAction);
},
"/buy/:code": ({ code }: { code: string }) => {
showBuyDialog("monthly", code).then(afterAction);
},
"/buy/:plan/:code": ({ plan, code }) => {
showBuyDialog(plan === "monthly" ? "monthly" : "yearly", code).then(
afterAction
);
},
"/welcome": () => {
showOnboardingDialog("new")?.then(afterAction);
},
"/confirmed": () => {
showFeatureDialog("confirmed").then(afterAction);
},
"/settings": () => {
showSettings().then(afterAction);
}
});
export default hashroutes;
export type HashRoute = keyof typeof hashroutes;
function afterAction() {
hashNavigate("/", { replace: true, notify: false });
if (!history.state.replace) history.back();
}