1
0
Fork 0
mirror of https://github.com/seanmorley15/AdventureLog.git synced 2025-07-24 23:39:37 +02:00

refactor: Add user prop to TransportationCard component for conditional rendering of actions

This commit is contained in:
Sean Morley 2024-07-29 19:19:24 -04:00
parent d5c5551ce1
commit 103500b5e1
3 changed files with 24 additions and 13 deletions

View file

@ -7,7 +7,7 @@
import FileDocumentEdit from '~icons/mdi/file-document-edit';
import { goto } from '$app/navigation';
import type { Collection, Transportation } from '$lib/types';
import type { Collection, Transportation, User } from '$lib/types';
import { addToast } from '$lib/toasts';
import Plus from '~icons/mdi/plus';
@ -15,6 +15,7 @@
const dispatch = createEventDispatcher();
export let transportation: Transportation;
export let user: User | null = null;
function editTransportation() {
dispatch('edit', transportation);
@ -51,13 +52,15 @@
{#if transportation.date}
{new Date(transportation.date).toLocaleString()}
{/if}
<div class="card-actions justify-end">
<button on:click={deleteTransportation} class="btn btn-secondary"
><TrashCanOutline class="w-5 h-5 mr-1" /></button
>
<button class="btn btn-primary" on:click={editTransportation}>
<FileDocumentEdit class="w-6 h-6" />
</button>
</div>
{#if user}
<div class="card-actions justify-end">
<button on:click={deleteTransportation} class="btn btn-secondary"
><TrashCanOutline class="w-5 h-5 mr-1" /></button
>
<button class="btn btn-primary" on:click={editTransportation}>
<FileDocumentEdit class="w-6 h-6" />
</button>
</div>
{/if}
</div>
</div>