fix(dashboard): avoid undefined Date being mapped to current date

This commit is contained in:
Roman Acevedo
2025-11-25 12:28:37 +01:00
parent e654bf9125
commit 9ca76656d6

View File

@@ -16,5 +16,13 @@
});
const format = localStorage.getItem(DATE_FORMAT_STORAGE_KEY) ?? "llll";
const date = computed(() => moment(props.field)?.format(format) ?? props.field);
const formatDateIfPresent = (rawDate: string|undefined) => {
if(rawDate){
// moment(date) always return a Moment, if the date is undefined, it will return current date, we don't want that here
return moment(rawDate).format(format) ?? props.field;
} else {
return undefined;
}
}
const date = computed(() => formatDateIfPresent(props.field));
</script>