File tree 2 files changed +16
-5
lines changed
app/(app)/automation/group
2 files changed +16
-5
lines changed Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ import {
41
41
import { isActionError } from "@/utils/error" ;
42
42
import { Badge } from "@/components/ui/badge" ;
43
43
import { formatShortDate } from "@/utils/date" ;
44
+ import { Tooltip } from "@/components/Tooltip" ;
44
45
45
46
export function ViewGroup ( { groupId } : { groupId : string } ) {
46
47
const { data, isLoading, error, mutate } = useSWR < GroupItemsResponse > (
@@ -269,7 +270,7 @@ function GroupItemList({
269
270
</ TableHeader >
270
271
) }
271
272
< TableBody >
272
- { sortBy ( items , ( item ) => - item . createdAt ) . map ( ( item ) => {
273
+ { sortBy ( items , ( item ) => - new Date ( item . createdAt ) ) . map ( ( item ) => {
273
274
const twoMinutesAgo = new Date ( Date . now ( ) - 1000 * 60 * 2 ) ;
274
275
const isCreatedRecently = new Date ( item . createdAt ) > twoMinutesAgo ;
275
276
const isUpdatedRecently = new Date ( item . updatedAt ) > twoMinutesAgo ;
@@ -291,9 +292,11 @@ function GroupItemList({
291
292
</ div >
292
293
</ TableCell >
293
294
< TableCell className = "py-2 text-right flex justify-end items-center gap-4" >
294
- < span className = "text-sm text-muted-foreground" >
295
- Added: { formatShortDate ( new Date ( item . createdAt ) ) }
296
- </ span >
295
+ < Tooltip content = "Date added" >
296
+ < span className = "text-sm text-muted-foreground" >
297
+ { formatShortDate ( new Date ( item . createdAt ) ) }
298
+ </ span >
299
+ </ Tooltip >
297
300
298
301
< Button
299
302
variant = "outline"
Original file line number Diff line number Diff line change @@ -7,6 +7,13 @@ export const ONE_DAY_MS = ONE_HOUR_MS * 24;
7
7
export const ONE_MONTH_MS = ONE_DAY_MS * 30 ;
8
8
export const ONE_YEAR_MS = ONE_DAY_MS * 365 ;
9
9
10
+ /**
11
+ * Formats a date into a short string.
12
+ * - If the date is today, returns the time (e.g., "3:44 PM").
13
+ * - If the date is not today, returns the date (e.g., "JUL 5" or "AUG 13").
14
+ * - Optionally includes the year (e.g., "JUL 5, 2024").
15
+ * - Optionally returns the date part in lowercase (e.g., "jul 5").
16
+ */
10
17
export function formatShortDate (
11
18
date : Date ,
12
19
options : {
@@ -28,7 +35,8 @@ export function formatShortDate(
28
35
date . getFullYear ( ) === today . getFullYear ( ) ;
29
36
30
37
if ( isToday ) {
31
- return date . toLocaleTimeString ( [ ] , { hour : "2-digit" , minute : "2-digit" } ) ;
38
+ // Use hour: 'numeric' to avoid leading zeros (e.g., 3:44 PM instead of 03:44 PM)
39
+ return date . toLocaleTimeString ( [ ] , { hour : "numeric" , minute : "2-digit" } ) ;
32
40
}
33
41
const formattedDate = date . toLocaleDateString ( [ ] , {
34
42
month : "short" ,
You can’t perform that action at this time.
0 commit comments