<script context="module">
 import { getWork } from '../../../lib/works';

 export async function load({ params, stuff }) {
     return {
         props: {
             work: stuff.work,
         },
     };
 }
</script>

<script lang="ts">
 import { goto } from '$app/navigation';

 import { user } from '../../../stores/user';
 import SurveyBadge from '../../../components/SurveyBadge.svelte';
 import WorkAdmin from '../../../components/WorkAdmin.svelte';

 export let work = null;
</script>

{#await work then w}
    <div class="d-flex align-items-center">
        <h2>
            <a href="works/" class="text-muted" style="text-decoration: none">&lt;</a>
            {w.title}
        </h2>
    </div>

    {#if $user && $user.is_admin}
        <WorkAdmin work={w} on:saved={() => edit = false} />
    {/if}
{/await}
