refactor: show timestamp

This commit is contained in:
jpiere-vailos
2025-05-16 07:39:13 -05:00
parent e0a5f9a153
commit e8a9ddb00c
2 changed files with 17 additions and 9 deletions
+7 -3
View File
@@ -3,10 +3,14 @@
import ActionsBtn from "./ActionsBtn.svelte";
import ContentFooter from "./ContentFooter.svelte";
const { id, trackingCode, time, platformLink } = $props<{
const { id, trackingCode, dataTime, platformLink } = $props<{
id: string;
trackingCode: string;
time: string;
dataTime: {
date: string;
time: string;
fulltime: string;
};
platformLink: string;
}>();
</script>
@@ -17,7 +21,7 @@
>
<div class="flex flex-col gap-1">
<p class="font-semibold">{$t("contributions.grid.details.operationTime")}</p>
<p>{time}</p>
<span title={dataTime.fulltime}>{dataTime.time}</span>
</div>
<div class="flex flex-col gap-1">
<p class="font-semibold">{$t("contributions.grid.details.trackingCode")}</p>
+10 -6
View File
@@ -257,18 +257,21 @@
return "—";
}
function getDate(chargeDate: string | null | undefined): { date: string; time: string } {
function getDate(chargeDate: string | null | undefined): {
date: string;
time: string;
fulltime: string;
} {
if (!chargeDate) {
return { date: "—", time: "—" };
return { date: "—", time: "—", fulltime: "—" };
}
const d = new Date(chargeDate);
if (isNaN(d.getTime())) {
return { date: "1970-01-01", time: "00:00h" };
return { date: "—", time: "—", fulltime: "—" };
}
const year = String(d.getFullYear()).slice(2);
const year = d.getFullYear();
const month = String(d.getMonth() + 1).padStart(2, "0");
const day = String(d.getDate()).padStart(2, "0");
const hour = String(d.getHours()).padStart(2, "0");
@@ -277,6 +280,7 @@
return {
date: `${year}-${month}-${day}`,
time: `${hour}:${minute}h`,
fulltime: `${year}-${month}-${day} ${hour}:${minute}`,
};
}
@@ -391,7 +395,7 @@
<DetailsRow
platformLink={charge.platformLink}
trackingCode={charge.trackingCode}
time={getDate(charge.dateUpdated).time}
dataTime={getDate(charge.dateUpdated)}
id={charge.id ? String(charge.id) : "-"}
/>
</TableBodyCell>