diff --git a/src/routes/specialni-vstupenky.svelte b/src/routes/specialni-vstupenky.svelte index 3f16182..c620113 100644 --- a/src/routes/specialni-vstupenky.svelte +++ b/src/routes/specialni-vstupenky.svelte @@ -12,10 +12,31 @@ let lastUpdate = null; let data = null; let speakersWithoutTicket = null; + let selectedType = "all"; + + $: ticketTypes = { + all: { title: "Vše" }, + organizator: { title: "Organizátor" }, + speaker: { title: "Přednášející" }, + partner: { title: "Partner" }, + staff: { title: "Obsluha" }, + host: { title: "Host" }, + }; + + function countType(type = "all") { + if (!data) { + return null; + } + if (type === "all") { + return data.length; + } + const res = data.filter((i) => i.type === type); + return res ? res.length : null; + } async function loadData() { data = await api.apiCall("claims"); - speakersWithoutTicket = speakersWithoutTicketGen() + speakersWithoutTicket = speakersWithoutTicketGen(); lastUpdate = new Date(); } @@ -52,17 +73,17 @@ return arr; } - function speakersWithoutTicketGen () { + function speakersWithoutTicketGen() { if (!data) { - return null + return null; } - const wt = [] - $bundle.spec.speakers.forEach(sp => { - if (!data.find(i => i.link.type === 'speaker' && i.link.id === sp.id)) { - wt.push(sp) + const wt = []; + $bundle.spec.speakers.forEach((sp) => { + if (!data.find((i) => i.link.type === "speaker" && i.link.id === sp.id)) { + wt.push(sp); } - }) - return wt + }); + return wt; } onMount(() => { @@ -83,16 +104,42 @@ {#if speakersWithoutTicket}
{claim.type} | -
-
-
-
- {claim.linkInfo.title}
- {#if claim.linkInfo.suffix} ({claim.linkInfo
- .suffix}){/if}
-
- |
-
- {#if claim.claimed}
- {claim.ticketId} ({fdate(
- claim.claimedOn
- )}){:else}-{/if}
- |
- - {#if claim.claimed && claim.ticketData} - {#if claim.ticketData.name} - {claim.ticketData.name} - {:else} - Anonym + {#if !selectedType || selectedType === "all" || (selectedType && selectedType === claim.type)} + |
{claim.type} | +
+
+
+
+ {claim.linkInfo.title}
+ {#if claim.linkInfo.suffix} ({claim.linkInfo
+ .suffix}){/if}
+
+ |
+
+ {#if claim.claimed}
+ {claim.ticketId} ({fdate(
+ claim.claimedOn
+ )}){:else}-{/if}
+ |
+ + {#if claim.claimed && claim.ticketData} + {#if claim.ticketData.name} + {claim.ticketData.name} + {:else} + Anonym + {/if} + {#if claim.ticketData.org} + ({claim.ticketData.org}) + {/if} + {#if claim.ticketData.twitter} + + {/if} {/if} - {#if claim.ticketData.org} - ({claim.ticketData.org}) - {/if} - {#if claim.ticketData.twitter} - - {/if} - {/if} - | -