<script>
 import { goto } from '$app/navigation';

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

 let work = new Work();
</script>

<div class="d-flex align-items-center">
    <h2>
        <a href="works/" class="text-muted" style="text-decoration: none">&lt;</a>
        Nouveau travail
    </h2>
    <SurveyBadge class="ms-2" survey={work} />
</div>

{#if $user && $user.is_admin}
    <WorkAdmin {work} on:saved={(e) => { goto(`works/${e.detail.id}`)}} />
{/if}
