2024-09-08 00:56:52 -04:00
|
|
|
<script lang="ts">
|
|
|
|
import { goto } from '$app/navigation';
|
|
|
|
import { continentCodeToString, getFlag } from '$lib';
|
|
|
|
import type { User } from '$lib/types';
|
|
|
|
import { createEventDispatcher } from 'svelte';
|
|
|
|
const dispatch = createEventDispatcher();
|
2025-05-29 17:47:58 -04:00
|
|
|
import { t } from 'svelte-i18n';
|
2024-09-08 00:56:52 -04:00
|
|
|
|
|
|
|
import Calendar from '~icons/mdi/calendar';
|
|
|
|
|
2024-09-08 14:29:27 -04:00
|
|
|
export let sharing: boolean = false;
|
|
|
|
export let shared_with: string[] | undefined = undefined;
|
|
|
|
|
2024-09-08 00:56:52 -04:00
|
|
|
export let user: User;
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<div
|
2025-05-29 17:47:58 -04:00
|
|
|
class="card w-full max-w-xs bg-base-200 text-base-content shadow-lg border border-base-300 hover:shadow-xl transition-all"
|
2024-09-08 00:56:52 -04:00
|
|
|
>
|
2025-05-29 17:47:58 -04:00
|
|
|
<div class="card-body items-center text-center space-y-4">
|
|
|
|
<!-- Profile Picture -->
|
|
|
|
<div class="avatar">
|
|
|
|
<div class="w-24 rounded-full ring ring-primary ring-offset-base-100 ring-offset-2">
|
|
|
|
{#if user.profile_pic}
|
|
|
|
<img src={user.profile_pic} alt={user.username} />
|
|
|
|
{:else}
|
|
|
|
<div
|
|
|
|
class="bg-base-300 w-full h-full flex items-center justify-center text-xl font-semibold"
|
|
|
|
>
|
|
|
|
{user.first_name?.[0] || user.username?.[0]}{user.last_name?.[0] || user.username?.[1]}
|
2024-09-08 00:56:52 -04:00
|
|
|
</div>
|
2025-05-29 17:47:58 -04:00
|
|
|
{/if}
|
|
|
|
</div>
|
|
|
|
</div>
|
2024-12-26 11:07:59 -05:00
|
|
|
|
2025-05-29 17:47:58 -04:00
|
|
|
<!-- User Info -->
|
|
|
|
<div>
|
|
|
|
<h2 class="text-lg font-bold leading-tight">
|
2024-12-26 11:07:59 -05:00
|
|
|
{user.first_name}
|
|
|
|
{user.last_name}
|
|
|
|
</h2>
|
2025-05-29 17:47:58 -04:00
|
|
|
<p class="text-sm opacity-70">@{user.username}</p>
|
2024-12-26 11:07:59 -05:00
|
|
|
|
|
|
|
{#if user.is_staff}
|
2025-05-29 17:47:58 -04:00
|
|
|
<div class="badge badge-outline badge-primary mt-2">{$t('settings.admin')}</div>
|
2024-12-26 11:07:59 -05:00
|
|
|
{/if}
|
2024-09-08 00:56:52 -04:00
|
|
|
</div>
|
2024-12-26 11:07:59 -05:00
|
|
|
|
2025-05-29 17:47:58 -04:00
|
|
|
<!-- Join Date -->
|
|
|
|
<div class="flex items-center gap-2 text-sm text-base-content/70">
|
|
|
|
<Calendar class="w-4 h-4 text-primary" />
|
|
|
|
<span>
|
|
|
|
{user.date_joined
|
|
|
|
? `${$t('adventures.joined')} ` + new Date(user.date_joined).toLocaleDateString()
|
|
|
|
: ''}
|
|
|
|
</span>
|
2024-09-08 00:56:52 -04:00
|
|
|
</div>
|
2024-12-26 11:07:59 -05:00
|
|
|
|
2025-05-29 17:47:58 -04:00
|
|
|
<!-- Actions -->
|
|
|
|
<div class="card-actions w-full justify-center pt-2">
|
2024-09-08 14:29:27 -04:00
|
|
|
{#if !sharing}
|
2025-05-29 17:47:58 -04:00
|
|
|
<button
|
|
|
|
class="btn btn-sm btn-primary w-full"
|
|
|
|
on:click={() => goto(`/profile/${user.username}`)}
|
|
|
|
>
|
|
|
|
{$t('adventures.view_profile')}
|
2024-12-26 11:07:59 -05:00
|
|
|
</button>
|
2024-09-08 14:29:27 -04:00
|
|
|
{:else if shared_with && !shared_with.includes(user.uuid)}
|
2025-05-29 17:47:58 -04:00
|
|
|
<button class="btn btn-sm btn-success w-full" on:click={() => dispatch('share', user)}>
|
|
|
|
{$t('adventures.share')}
|
|
|
|
</button>
|
2024-09-08 14:29:27 -04:00
|
|
|
{:else}
|
2025-05-29 17:47:58 -04:00
|
|
|
<button class="btn btn-sm btn-error w-full" on:click={() => dispatch('unshare', user)}>
|
|
|
|
{$t('adventures.remove')}
|
|
|
|
</button>
|
2024-09-08 14:29:27 -04:00
|
|
|
{/if}
|
2024-09-08 00:56:52 -04:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|