fix: search store now parses API envelope response correctly
The search API returns { success, data: [...] } but the store was
looking for data.apps and data.boards (which don't exist). Fixed to
read from data.data[] and also added url/icon fields to search API
response so app results are clickable and show icons.
This commit is contained in:
@@ -11,6 +11,8 @@ interface SearchResult {
|
||||
readonly id: string;
|
||||
readonly name: string;
|
||||
readonly description: string | null;
|
||||
readonly url?: string;
|
||||
readonly icon?: string | null;
|
||||
readonly category?: string | null;
|
||||
}
|
||||
|
||||
@@ -39,6 +41,9 @@ export const GET: RequestHandler = async (event) => {
|
||||
select: {
|
||||
id: true,
|
||||
name: true,
|
||||
url: true,
|
||||
icon: true,
|
||||
iconType: true,
|
||||
description: true,
|
||||
category: true
|
||||
},
|
||||
@@ -66,14 +71,18 @@ export const GET: RequestHandler = async (event) => {
|
||||
// Filter apps by permission
|
||||
const filteredApps: SearchResult[] = [];
|
||||
for (const app of apps) {
|
||||
const appResult: SearchResult = {
|
||||
type: 'app',
|
||||
id: app.id,
|
||||
name: app.name,
|
||||
description: app.description,
|
||||
url: app.url,
|
||||
icon: app.icon,
|
||||
category: app.category
|
||||
};
|
||||
|
||||
if (isAdmin) {
|
||||
filteredApps.push({
|
||||
type: 'app',
|
||||
id: app.id,
|
||||
name: app.name,
|
||||
description: app.description,
|
||||
category: app.category
|
||||
});
|
||||
filteredApps.push(appResult);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -84,13 +93,7 @@ export const GET: RequestHandler = async (event) => {
|
||||
PermissionLevel.VIEW
|
||||
);
|
||||
if (check.hasPermission) {
|
||||
filteredApps.push({
|
||||
type: 'app',
|
||||
id: app.id,
|
||||
name: app.name,
|
||||
description: app.description,
|
||||
category: app.category
|
||||
});
|
||||
filteredApps.push(appResult);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user