Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions frontend/src/components/NoteCard.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import { PenSquareIcon, Trash2Icon } from "lucide-react";
import { Link, useNavigate } from "react-router-dom";
import { formatDate } from "../lib/utils";
import { formatDateTime } from "../lib/utils";
import api from "../lib/axios";
import toast from "react-hot-toast";

Expand Down Expand Up @@ -53,12 +53,13 @@ const NoteCard = ({ note, setNotes }) => {
{/* Footer */}
<div className="flex items-center justify-between mt-2">
{/* Date */}
<div className="flex items-center gap-1.5">
<svg className="w-3.5 h-3.5 text-gray-400 dark:text-gray-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M8 7V3m8 4V3m-9 8h10M5 21h14a2 2 0 002-2V7a2 2 0 00-2-2H5a2 2 0 00-2 2v12a2 2 0 002 2z" />
</svg>
<div className="flex flex-col gap-1">
<span className="text-xs text-gray-400 dark:text-gray-500">
{formatDate(new Date(note.createdAt))}
Created: {formatDateTime(new Date(note.createdAt))}
</span>

<span className="text-xs text-gray-400 dark:text-gray-500">
Updated: {formatDateTime(new Date(note.updatedAt))}
</span>
</div>

Expand Down
12 changes: 11 additions & 1 deletion frontend/src/lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@ export function formatDate(date) {
day: "numeric",
year: "numeric",
});
}
}

export function formatDateTime(date) {
return date.toLocaleString("en-US", {
month: "short",
day: "numeric",
year: "numeric",
hour: "numeric",
minute: "2-digit",
});
}
10 changes: 10 additions & 0 deletions frontend/src/pages/NoteDetailPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,16 @@ const NoteDetailPage = () => {
/>
</div>

{/* Timestamp Info */}
<div className="mb-4 text-sm text-gray-500 dark:text-gray-400">
<p>
Created: {new Date(note.createdAt).toLocaleString()}
</p>
<p>
Last Updated: {new Date(note.updatedAt).toLocaleString()}
</p>
</div>
Comment on lines +130 to +138

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use the shared timestamp formatter here to keep UI output consistent.

Line 133 and Line 136 bypass formatDateTime, so this page can render different date/time formats than note cards. That breaks the cross-file formatting contract introduced in this PR.

Suggested fix
 import { useEffect, useState } from "react";
 import { Link, useNavigate, useParams } from "react-router-dom";
 import api from "../lib/axios";
 import toast from "react-hot-toast";
 import { ArrowLeftIcon, LoaderIcon, Trash2Icon } from "lucide-react";
+import { formatDateTime } from "../lib/utils";
@@
               <div className="mb-4 text-sm text-gray-500 dark:text-gray-400">
                 <p>
-                  Created: {new Date(note.createdAt).toLocaleString()}
+                  Created: {formatDateTime(new Date(note.createdAt))}
                 </p>
                 <p>
-                  Last Updated: {new Date(note.updatedAt).toLocaleString()}
+                  Last Updated: {formatDateTime(new Date(note.updatedAt))}
                 </p>
               </div>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
{/* Timestamp Info */}
<div className="mb-4 text-sm text-gray-500 dark:text-gray-400">
<p>
Created: {new Date(note.createdAt).toLocaleString()}
</p>
<p>
Last Updated: {new Date(note.updatedAt).toLocaleString()}
</p>
</div>
import { useEffect, useState } from "react";
import { Link, useNavigate, useParams } from "react-router-dom";
import api from "../lib/axios";
import toast from "react-hot-toast";
import { ArrowLeftIcon, LoaderIcon, Trash2Icon } from "lucide-react";
import { formatDateTime } from "../lib/utils";
// ... other code ...
{/* Timestamp Info */}
<div className="mb-4 text-sm text-gray-500 dark:text-gray-400">
<p>
Created: {formatDateTime(new Date(note.createdAt))}
</p>
<p>
Last Updated: {formatDateTime(new Date(note.updatedAt))}
</p>
</div>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@frontend/src/pages/NoteDetailPage.jsx` around lines 130 - 138, The date and
time formatting in NoteDetailPage.jsx at the lines where note.createdAt and
note.updatedAt are displayed bypasses the shared formatDateTime function,
creating inconsistent date formatting across the application. Replace the direct
new Date(note.createdAt).toLocaleString() and new
Date(note.updatedAt).toLocaleString() calls with calls to the formatDateTime
utility function to ensure consistent timestamp formatting throughout the UI,
maintaining the cross-file formatting contract established in this PR.


{/* Content Textarea */}
<div className="mb-6">
<label className="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">
Expand Down