feat: added search bar and results page
All checks were successful
Build and Push App Image / build-and-push (push) Successful in 1m34s

This commit is contained in:
domrichardson
2026-03-26 12:52:09 +00:00
parent cf94697d07
commit 9cf71ab4a0
4 changed files with 290 additions and 12 deletions

View File

@@ -6,6 +6,7 @@ export const useSpaceStore = defineStore("space", () => {
const spaces = ref([]);
const currentSpace = ref(null);
const notes = ref([]);
const searchResults = ref([]);
const notesSkip = ref(0);
const notesLimit = ref(20);
const notesHasMore = ref(true);
@@ -188,20 +189,30 @@ export const useSpaceStore = defineStore("space", () => {
};
const searchNotes = async (query) => {
if (!currentSpace.value?.id) {
searchResults.value = [];
return [];
}
try {
const response = await apiClient.get(`/api/v1/spaces/${currentSpace.value.id}/notes/search`, { params: { q: query } });
notes.value = response.data || [];
notesHasMore.value = false;
notesSkip.value = notes.value.length;
searchResults.value = response.data || [];
return searchResults.value;
} catch (error) {
console.error("Error searching notes:", error);
searchResults.value = [];
return [];
}
};
const clearSearchResults = () => {
searchResults.value = [];
};
return {
spaces,
currentSpace,
notes,
searchResults,
notesHasMore,
notesLoading,
categories,
@@ -220,5 +231,6 @@ export const useSpaceStore = defineStore("space", () => {
updateNote,
deleteNote,
searchNotes,
clearSearchResults,
};
});