LogsDeleteButton causes the dashboard to fail to load due to incorrect date format
prostolyubo opened this issue · comments
There is a function formatDate
function formatDate(e) {
let t = new Date(e);
return Intl.DateTimeFormat("en-US", {
month: "short",
day: "numeric",
year: "numeric"
}).format(t)
}
that was given amongst many correct dates an e = "16/01/2024"
which caused to throw an error and whole dashboard fails to load (it shows only: "Application error: a client-side exception has occurred (see the browser console for more information).").
After inspecting a call stack it seems the problem lays in a function LogsDeleteButton
that converts this date (in a correct format "Tue Jan 16 2024 ...") using t.date.toLocaleDateString()
which is later passed to formatDate
which causes an error.
I failed to compile it locally (I would be glad for an updated Running Locally section of README), but I assume that changing
Delete logs from {formatDate(logs.date.toLocaleDateString())}?
to Delete logs from {formatDate(logs.date)}?
in components/activity/logs/logs-delete-button.tsx should fix the issue, but I'm unable to confirm.
The formatDate function is supposed to receive a string date as its parameter, therefore formatDate(logs.date.toLocaleDateString())
is intended and is not supposed to throw any errors. logs.date
contains a value with a Date type, which is then converted to string using toLocaleDateString()
, which is used as a parameter for the formatDate function.
I tried to replicate the issue that you encountered and I can't seem to do it. I tried both in development and production environment, and everything seems to be working as intended.
Can you show a video replicating this issue so I can investigate it further?
Aaa, you are right. Then maybe an overload for formatDate
that accepts a Date instead of string so it could be called like Delete logs from {formatDate(logs.date)}?
Here's the video
2024-01-17 14-02-23.mkv.zip
I have merged a fix for the issue you've encountered. See #12 for more info.
Let me know if you're still having problems. If there's none, I'm going to close this issue.
Works like a charm, thanks!