diff --git a/app/(application)/notification.tsx b/app/(application)/notification.tsx index 2bb50a9..6346a4b 100644 --- a/app/(application)/notification.tsx +++ b/app/(application)/notification.tsx @@ -78,6 +78,15 @@ export default function Notification() { }, [data]) const listData = useMemo(() => { + const BULAN: Record = { + 'JAN': 0, 'FEB': 1, 'MAR': 2, 'APR': 3, 'MEI': 4, 'JUN': 5, + 'JUL': 6, 'AGU': 7, 'SEP': 8, 'OKT': 9, 'NOV': 10, 'DES': 11, + } + const parseDate = (str: string) => { + const [d, m, y] = str.split(' ') + return new Date(Number(y), BULAN[m] ?? 0, Number(d)).getTime() + } + const groups: Record = {} const dateOrder: string[] = [] @@ -89,6 +98,8 @@ export default function Notification() { groups[item.createdAt].push(item) }) + dateOrder.sort((a, b) => parseDate(b) - parseDate(a)) + const result: ListRow[] = [] dateOrder.forEach((date) => { result.push({ _type: 'header', date })