feat: note list ui

This commit is contained in:
Timothy Jaeryang Baek
2025-05-03 18:52:13 +04:00
parent 7fee84c06e
commit 7de6112c5b
5 changed files with 113 additions and 60 deletions
+21 -2
View File
@@ -1,8 +1,10 @@
import { WEBUI_API_BASE_URL } from '$lib/constants';
import { getTimeRange } from '$lib/utils';
type NoteItem = {
title: string;
content: string;
data: object;
meta?: null | object;
access_control?: null | object;
};
@@ -65,7 +67,24 @@ export const getNotes = async (token: string = '') => {
throw error;
}
return res;
if (!Array.isArray(res)) {
return {}; // or throw new Error("Notes response is not an array")
}
// Build the grouped object
const grouped: Record<string, any[]> = {};
for (const note of res) {
const timeRange = getTimeRange(note.updated_at / 1000000000);
if (!grouped[timeRange]) {
grouped[timeRange] = [];
}
grouped[timeRange].push({
...note,
timeRange
});
}
return grouped;
};
export const getNoteById = async (token: string, id: string) => {