2019-07-13 11:35:57 +02:00
|
|
|
<script>
|
2020-04-06 15:42:32 +02:00
|
|
|
import Modal from "svelte-simple-modal"
|
2020-02-03 10:50:30 +01:00
|
|
|
import { onMount } from "svelte"
|
2020-04-09 09:04:09 +02:00
|
|
|
import { Router, basepath } from "@sveltech/routify"
|
2020-04-02 15:16:46 +02:00
|
|
|
import { routes } from "@sveltech/routify/tmp/routes"
|
|
|
|
import { store, initialise } from "builderStore"
|
2020-03-31 11:56:39 +02:00
|
|
|
import AppNotification, {
|
|
|
|
showAppNotification,
|
2020-03-31 13:16:03 +02:00
|
|
|
} from "components/common/AppNotification.svelte"
|
2020-02-03 10:50:30 +01:00
|
|
|
|
2020-03-30 22:14:41 +02:00
|
|
|
function showErrorBanner() {
|
|
|
|
showAppNotification({
|
|
|
|
status: "danger",
|
|
|
|
message:
|
|
|
|
"Whoops! Looks like we're having trouble. Please refresh the page.",
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-04-28 15:39:35 +02:00
|
|
|
onMount(async () => {
|
|
|
|
const res = await fetch(`/api/client/id`)
|
|
|
|
const json = await res.json()
|
|
|
|
|
|
|
|
store.update(state => {
|
|
|
|
state.clientId = json
|
|
|
|
return state
|
|
|
|
})
|
|
|
|
|
2020-03-30 22:14:41 +02:00
|
|
|
window.addEventListener("error", showErrorBanner)
|
|
|
|
window.addEventListener("unhandledrejection", showErrorBanner)
|
|
|
|
})
|
2020-04-09 09:04:09 +02:00
|
|
|
|
|
|
|
$basepath = "/_builder"
|
2019-07-13 11:35:57 +02:00
|
|
|
</script>
|
|
|
|
|
2020-04-02 15:16:46 +02:00
|
|
|
<AppNotification />
|
2019-09-30 06:20:21 +02:00
|
|
|
|
2020-04-28 15:39:35 +02:00
|
|
|
{#if $store.clientId}
|
|
|
|
<Modal>
|
|
|
|
<Router {routes} />
|
|
|
|
</Modal>
|
|
|
|
{/if}
|