2024-03-08 20:03:37 +01:00
|
|
|
<script lang="ts">
|
|
|
|
|
import { dateFormats } from '$lib/constants';
|
|
|
|
|
import { locale } from '$lib/stores/preferences.store';
|
|
|
|
|
import type { AlbumResponseDto } from '@immich/sdk';
|
2024-06-24 15:50:01 +02:00
|
|
|
import { t } from 'svelte-i18n';
|
2024-03-08 20:03:37 +01:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
interface Props {
|
|
|
|
|
album: AlbumResponseDto;
|
|
|
|
|
}
|
2024-03-08 20:03:37 +01:00
|
|
|
|
2024-11-14 08:43:25 -06:00
|
|
|
let { album }: Props = $props();
|
2024-03-08 20:03:37 +01:00
|
|
|
|
|
|
|
|
const formatDate = (date?: string) => {
|
2025-01-28 21:33:38 +01:00
|
|
|
const dateWithoutTimeZone = date?.slice(0, -1);
|
|
|
|
|
return dateWithoutTimeZone
|
|
|
|
|
? new Date(dateWithoutTimeZone).toLocaleDateString($locale, dateFormats.album)
|
|
|
|
|
: undefined;
|
2024-03-08 20:03:37 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const getDateRange = (start?: string, end?: string) => {
|
|
|
|
|
if (start && end && start !== end) {
|
|
|
|
|
return `${start} - ${end}`;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (start) {
|
|
|
|
|
return start;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return '';
|
|
|
|
|
};
|
2024-11-14 08:43:25 -06:00
|
|
|
let startDate = $derived(formatDate(album.startDate));
|
|
|
|
|
let endDate = $derived(formatDate(album.endDate));
|
2024-03-08 20:03:37 +01:00
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
<span class="my-2 flex gap-2 text-sm font-medium text-gray-500" data-testid="album-details">
|
2024-05-22 00:15:28 -05:00
|
|
|
<span>{getDateRange(startDate, endDate)}</span>
|
|
|
|
|
<span>•</span>
|
2024-06-24 15:50:01 +02:00
|
|
|
<span>{$t('items_count', { values: { count: album.assetCount } })}</span>
|
2024-03-08 20:03:37 +01:00
|
|
|
</span>
|