fix: resolve 'e.reduce is not a function' error in admin settings
- Remove server-side grouping logic from API response - Return flat array instead of grouped object - Fix data structure mismatch between API and frontend - Resolve TypeError when accessing admin settings page
This commit is contained in:
@@ -46,18 +46,8 @@ export async function GET(request: NextRequest) {
|
|||||||
.where(whereClause)
|
.where(whereClause)
|
||||||
.orderBy(siteConfig.key);
|
.orderBy(siteConfig.key);
|
||||||
|
|
||||||
const groupedConfigs = configs.reduce((acc, config) => {
|
|
||||||
const cat = config.category;
|
|
||||||
if (!acc[cat]) {
|
|
||||||
acc[cat] = [];
|
|
||||||
}
|
|
||||||
acc[cat].push(config);
|
|
||||||
return acc;
|
|
||||||
}, {} as Record<string, typeof configs>);
|
|
||||||
|
|
||||||
return success({
|
return success({
|
||||||
configs: groupedConfigs,
|
configs: configs,
|
||||||
flat: configs,
|
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
return handleApiError(error);
|
return handleApiError(error);
|
||||||
|
|||||||
Reference in New Issue
Block a user