Skip to content

Commit

Permalink
fix: fixed bug when opening finding details while a scan is in progre…
Browse files Browse the repository at this point in the history
…ss (#6708)
  • Loading branch information
paabloLC authored Jan 28, 2025
1 parent ddd83b3 commit 45d44a1
Showing 1 changed file with 25 additions and 14 deletions.
39 changes: 25 additions & 14 deletions ui/components/ui/entities/date-with-time.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,31 @@ export const DateWithTime: React.FC<DateWithTimeProps> = ({
inline = false,
}) => {
if (!dateTime) return <span>--</span>;
const date = parseISO(dateTime);
const formattedDate = format(date, "MMM dd, yyyy");
const formattedTime = format(date, "p 'UTC'");

return (
<div className="mw-fit py-[2px]">
<div
className={`flex ${inline ? "flex-row items-center gap-2" : "flex-col"}`}
>
<span className="text-xs font-semibold">{formattedDate}</span>
{showTime && (
<span className="text-tiny text-gray-500">{formattedTime}</span>
)}
try {
const date = parseISO(dateTime);

// Validate if the date is valid
if (isNaN(date.getTime())) {
return <span>-</span>;
}

const formattedDate = format(date, "MMM dd, yyyy");
const formattedTime = format(date, "p 'UTC'");

return (
<div className="mw-fit py-[2px]">
<div
className={`flex ${inline ? "flex-row items-center gap-2" : "flex-col"}`}
>
<span className="text-xs font-semibold">{formattedDate}</span>
{showTime && (
<span className="text-tiny text-gray-500">{formattedTime}</span>
)}
</div>
</div>
</div>
);
);
} catch (error) {
return <span>-</span>;
}
};

0 comments on commit 45d44a1

Please sign in to comment.