Start implementing a new user page for account and security settings
This commit is contained in:
25
Frontend/src/pages/user/nav.ts
Normal file
25
Frontend/src/pages/user/nav.ts
Normal file
@ -0,0 +1,25 @@
|
||||
import { writable } from "svelte/store";
|
||||
|
||||
type Pages = "personal-info" | "security";
|
||||
|
||||
|
||||
function getCurrentPage(): Pages | undefined {
|
||||
let hash = window.location.hash;
|
||||
if (hash.length > 0) {
|
||||
hash = hash.substring(1);
|
||||
if (hash === "personal-info" || hash === "security") {
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export const CurrentPage = writable<Pages>(getCurrentPage() ?? "personal-info");
|
||||
|
||||
window.addEventListener("hashchange", () => {
|
||||
CurrentPage.set(getCurrentPage() ?? "personal-info");
|
||||
});
|
||||
|
||||
export function navigateTo(page: Pages) {
|
||||
window.location.hash = "#" + page;
|
||||
}
|
||||
|
Reference in New Issue
Block a user