minor on webcomponents

This commit is contained in:
lesion
2021-12-02 10:47:37 +01:00
parent b428a692d1
commit 88c9d48431
5 changed files with 844 additions and 27 deletions

View File

@@ -1,16 +1,25 @@
<script>
import { onMount } from 'svelte'
export let baseurl = 'https://demo.gancio.org'
export let id
let mounted = false
let event
function update (id) {
fetch(`${baseurl}/api/event/${id}`)
.then(res => res.json())
.then(e => event = e)
function update (id, baseurl) {
if (mounted) {
fetch(`${baseurl}/api/event/${id}`)
.then(res => res.json())
.then(e => event = e)
}
}
onMount(() => {
mounted = true
update(id, baseurl)
})
$: update(id, baseurl)
function when (event) {
return new Date(event.start_datetime*1000)
.toLocaleDateString(undefined,
@@ -35,8 +44,6 @@
return 'center center'
}
$: update(id)
</script>
<svelte:options tag="gancio-event"/>
{#if event}