fix: parse excluded_classifications as array and handle companies API response

- Fixed settings API to parse excluded_classifications as array
- Fixed companies API response handling (returns {companies: []} not array)
- Resolves TypeError: excluded_classifications.filter is not a function
- Resolves TypeError: s.sort is not a function
This commit is contained in:
lorentz 2026-02-03 09:20:50 -05:00
parent 1d99a8f659
commit 9940c20379
2 changed files with 5 additions and 3 deletions

View file

@ -12,8 +12,8 @@ export async function GET(request: NextRequest) {
let value = row.setting_value;
// Parse specific settings
if (row.setting_key === 'excluded_company_ids') {
value = value ? value.split(',').map((id: string) => id.trim()).filter(Boolean) : [];
if (row.setting_key === 'excluded_company_ids' || row.setting_key === 'excluded_classifications') {
value = value ? value.split(',').map((item: string) => item.trim()).filter(Boolean) : [];
} else if (row.setting_key === 'show_rmm_alerts') {
value = value === 'true';
} else if (['cycle_interval', 'refresh_interval'].includes(row.setting_key)) {

View file

@ -62,7 +62,9 @@ export default function KioskSettingsPage() {
const res = await fetch('/api/companies');
if (res.ok) {
const data = await res.json();
setCompanies(data.sort((a: Company, b: Company) =>
// API returns { companies: [...] }
const companiesList = data.companies || [];
setCompanies(companiesList.sort((a: Company, b: Company) =>
a.companyName.localeCompare(b.companyName)
));
}