Skip to content

Commit cc547c6

Browse files
committed
fix(ui): folder card does not show formatted created at and updated at dates
1 parent 15316b5 commit cc547c6

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

resources/js/components/cards/FolderCard.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<script setup lang="ts">
22
import type { FolderResource } from '@/types/resources';
33
4-
import { formatFileSize, handleStorageURL } from '@/service/util';
4+
import { formatFileSize, handleStorageURL, toFormattedDate } from '@/service/util';
55
import { useAuthStore } from '@/stores/AuthStore';
66
import { useAppStore } from '@/stores/AppStore';
77
import { storeToRefs } from 'pinia';
@@ -75,9 +75,9 @@ const mediaType = computed(() => {
7575
<section class="flex w-full items-center justify-between gap-4">
7676
<h3
7777
class="w-full truncate text-gray-900 dark:text-white"
78-
:title="`${data.id}: ${props.data.series?.title ?? props.data.name}\nDate: ${props.data.created_at}`"
78+
:title="`${data.id}: ${props.data.series?.title || props.data.name}\nCreated: ${toFormattedDate(props.data.created_at || '')}\nUpdated: ${toFormattedDate(props.data.updated_at || '')}\nScanned: ${toFormattedDate(props.data.scanned_at || '')}`"
7979
>
80-
{{ props.data.series?.title ?? props.data.name }}
80+
{{ props.data.series?.title || props.data.name }}
8181
</h3>
8282
<div class="flex justify-end gap-1">
8383
<ButtonCorner

resources/js/service/util.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function toTimeSpan(rawDate: Date | string, timeZoneName = ' EST', short?
4444
}
4545

4646
export function toFormattedDate(
47-
rawDate: Date,
47+
rawDate: Date | string,
4848
toUpperCase: boolean = true,
4949
format: Intl.DateTimeFormatOptions = {
5050
year: 'numeric',
@@ -55,6 +55,11 @@ export function toFormattedDate(
5555
hour12: true,
5656
},
5757
) {
58+
if (!rawDate) return 'Unknown';
59+
if (typeof rawDate === 'string') {
60+
rawDate = new Date(rawDate);
61+
}
62+
5863
const result = rawDate
5964
.toLocaleString(
6065
['en-CA'],

0 commit comments

Comments
 (0)