2022-02-10 15:47:44 +01:00
|
|
|
<script context="module" lang="ts">
|
|
|
|
import type { Load } from '@sveltejs/kit';
|
|
|
|
export const load: Load = async ({ fetch }) => {
|
|
|
|
const url = `/destinations.json`;
|
|
|
|
const res = await fetch(url);
|
|
|
|
|
|
|
|
if (res.ok) {
|
|
|
|
return {
|
|
|
|
props: {
|
|
|
|
...(await res.json())
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
return {
|
|
|
|
status: res.status,
|
|
|
|
error: new Error(`Could not load ${url}`)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script lang="ts">
|
|
|
|
import type Prisma from '@prisma/client';
|
|
|
|
|
|
|
|
import { session } from '$app/stores';
|
2022-04-02 23:34:30 +02:00
|
|
|
import { t } from '$lib/translations';
|
|
|
|
|
2022-02-10 15:47:44 +01:00
|
|
|
export let destinations: Prisma.DestinationDocker[];
|
2022-04-07 15:23:32 +02:00
|
|
|
const ownDestinations = destinations.filter((destination) => {
|
|
|
|
if (destination.teams[0].id === $session.teamId) {
|
|
|
|
return destination;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
const otherDestinations = destinations.filter((destination) => {
|
|
|
|
if (destination.teams[0].id !== $session.teamId) {
|
|
|
|
return destination;
|
|
|
|
}
|
|
|
|
});
|
2022-02-10 15:47:44 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
<div class="flex space-x-1 p-6 font-bold">
|
2022-04-02 23:34:30 +02:00
|
|
|
<div class="mr-4 text-2xl tracking-tight">{$t('index.destinations')}</div>
|
2022-02-10 15:47:44 +01:00
|
|
|
{#if $session.isAdmin}
|
|
|
|
<a href="/new/destination" class="add-icon bg-sky-600 hover:bg-sky-500">
|
|
|
|
<svg
|
|
|
|
class="w-6"
|
|
|
|
xmlns="http://www.w3.org/2000/svg"
|
|
|
|
fill="none"
|
|
|
|
viewBox="0 0 24 24"
|
|
|
|
stroke="currentColor"
|
|
|
|
><path
|
|
|
|
stroke-linecap="round"
|
|
|
|
stroke-linejoin="round"
|
|
|
|
stroke-width="2"
|
|
|
|
d="M12 6v6m0 0v6m0-6h6m-6 0H6"
|
|
|
|
/></svg
|
|
|
|
>
|
|
|
|
</a>
|
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
<div class="flex justify-center">
|
2022-04-08 14:03:21 +02:00
|
|
|
{#if !destinations || ownDestinations.length === 0}
|
2022-02-10 15:47:44 +01:00
|
|
|
<div class="flex-col">
|
2022-04-02 23:34:30 +02:00
|
|
|
<div class="text-center text-xl font-bold">{$t('destination.no_destination_found')}</div>
|
2022-02-10 15:47:44 +01:00
|
|
|
</div>
|
2022-04-08 14:12:06 +02:00
|
|
|
{/if}
|
|
|
|
{#if ownDestinations.length > 0 || otherDestinations.length > 0}
|
2022-04-07 15:23:32 +02:00
|
|
|
<div class="flex flex-col">
|
2022-04-08 14:12:06 +02:00
|
|
|
<div class="flex flex-col flex-wrap justify-center px-2 md:flex-row">
|
2022-04-07 15:23:32 +02:00
|
|
|
{#each ownDestinations as destination}
|
2022-04-08 14:12:06 +02:00
|
|
|
<a href="/destinations/{destination.id}" class="w-96 p-2 no-underline">
|
2022-04-07 15:23:32 +02:00
|
|
|
<div class="box-selection hover:bg-sky-600">
|
2022-04-08 14:12:06 +02:00
|
|
|
<div class="truncate text-center text-xl font-bold">{destination.name}</div>
|
2022-04-08 10:35:16 +02:00
|
|
|
{#if $session.teamId === '0' && otherDestinations.length > 0}
|
2022-04-08 14:12:06 +02:00
|
|
|
<div class="truncate text-center">{destination.teams[0].name}</div>
|
2022-04-07 15:23:32 +02:00
|
|
|
{/if}
|
2022-04-08 14:12:06 +02:00
|
|
|
<div class="truncate text-center">{destination.network}</div>
|
2022-04-07 15:23:32 +02:00
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{#if otherDestinations.length > 0 && $session.teamId === '0'}
|
2022-04-08 14:12:06 +02:00
|
|
|
<div class="px-6 pb-5 pt-10 text-xl font-bold">Other Destinations</div>
|
|
|
|
<div class="flex flex-col flex-wrap justify-center px-2 md:flex-row">
|
2022-04-07 15:23:32 +02:00
|
|
|
{#each otherDestinations as destination}
|
2022-04-08 14:12:06 +02:00
|
|
|
<a href="/destinations/{destination.id}" class="w-96 p-2 no-underline">
|
2022-04-07 15:23:32 +02:00
|
|
|
<div class="box-selection hover:bg-sky-600">
|
2022-04-08 14:12:06 +02:00
|
|
|
<div class="truncate text-center text-xl font-bold">{destination.name}</div>
|
2022-04-07 15:23:32 +02:00
|
|
|
{#if $session.teamId === '0'}
|
2022-04-08 14:12:06 +02:00
|
|
|
<div class="truncate text-center">{destination.teams[0].name}</div>
|
2022-04-07 15:23:32 +02:00
|
|
|
{/if}
|
2022-04-08 14:12:06 +02:00
|
|
|
<div class="truncate text-center">{destination.network}</div>
|
2022-04-07 15:23:32 +02:00
|
|
|
</div>
|
|
|
|
</a>
|
|
|
|
{/each}
|
|
|
|
</div>
|
|
|
|
{/if}
|
2022-02-10 15:47:44 +01:00
|
|
|
</div>
|
|
|
|
{/if}
|
|
|
|
</div>
|