diff --git a/client-solid/src/Components/Comment.tsx b/client-solid/src/Components/Comment.tsx index d78fa0a..c706750 100644 --- a/client-solid/src/Components/Comment.tsx +++ b/client-solid/src/Components/Comment.tsx @@ -7,15 +7,23 @@ export function Comment(props: { comment: PublicComment }): JSXElement { const [content, setContent] = createSignal<string>(""); createEffect(() => { - setCreationDate(new Date(props.comment.created_at).toDateString()); + const date = new Date(props.comment.created_at); + if (!isNaN(date.getTime())) { + setCreationDate(date.toDateString()); + } else { + // Set creation date to an empty string or any default value when the date is invalid + setCreationDate(""); + } setContent(props.comment.content); }); return ( <> - <div class="py-5"> - <time class="text-xs opacity-50">{creationDate()}</time> - </div> + {creationDate() && ( // Render creation date only if it's not an empty string + <div class="py-5"> + <time class="text-xs opacity-50">{creationDate()}</time> + </div> + )} <div class="">{content()}</div> <div class="divider" /> </>