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

 import { user } from '$lib/stores/user';
 import CategoryAdmin from '$lib/components/CategoryAdmin.svelte';
 import { Category } from '$lib/categories';

 let category = new Category();
</script>

<div class="d-flex align-items-center">
    <h2>
        <a href="categories/" class="text-muted" style="text-decoration: none">&lt;</a>
        Nouvelle catégorie
    </h2>
</div>

{#if $user && $user.is_admin}
    <CategoryAdmin {category} on:saved={(e) => { goto(`categories/${e.detail.id}`)}} />
{/if}
