Convert portal navigation store to BudiStore
This commit is contained in:
parent
65bd89250d
commit
12b283d41e
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
$: useAccountPortal = cloud && !$admin.disableAccountPortal
|
$: useAccountPortal = cloud && !$admin.disableAccountPortal
|
||||||
|
|
||||||
navigation.actions.init($redirect)
|
navigation.init($redirect)
|
||||||
|
|
||||||
const validateTenantId = async () => {
|
const validateTenantId = async () => {
|
||||||
const host = window.location.host
|
const host = window.location.host
|
||||||
|
|
|
@ -1,38 +1,31 @@
|
||||||
import { writable } from "svelte/store"
|
import { BudiStore } from "../BudiStore"
|
||||||
|
|
||||||
type GotoFuncType = (path: string) => void
|
type GotoFuncType = (path: string) => void
|
||||||
|
|
||||||
interface PortalNavigationStore {
|
interface NavigationState {
|
||||||
initialisated: boolean
|
initialisated: boolean
|
||||||
goto: GotoFuncType
|
goto: GotoFuncType
|
||||||
}
|
}
|
||||||
|
|
||||||
export function createNavigationStore() {
|
class NavigationStore extends BudiStore<NavigationState> {
|
||||||
const store = writable<PortalNavigationStore>({
|
constructor() {
|
||||||
initialisated: false,
|
super({
|
||||||
goto: undefined as any,
|
initialisated: false,
|
||||||
})
|
goto: undefined as any,
|
||||||
const { set, subscribe } = store
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const init = (gotoFunc: GotoFuncType) => {
|
init(gotoFunc: GotoFuncType) {
|
||||||
if (typeof gotoFunc !== "function") {
|
if (typeof gotoFunc !== "function") {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
`gotoFunc must be a function, found a "${typeof gotoFunc}" instead`
|
`gotoFunc must be a function, found a "${typeof gotoFunc}" instead`
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
this.set({
|
||||||
set({
|
|
||||||
initialisated: true,
|
initialisated: true,
|
||||||
goto: gotoFunc,
|
goto: gotoFunc,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
|
||||||
subscribe,
|
|
||||||
actions: {
|
|
||||||
init,
|
|
||||||
},
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const navigation = createNavigationStore()
|
export const navigation = new NavigationStore()
|
||||||
|
|
Loading…
Reference in New Issue