Fix bad useState practices

This commit is contained in:
MartinBraquet
2025-08-04 14:25:33 +02:00
parent 9bcba9895e
commit a2abc4fda9
9 changed files with 476 additions and 242 deletions

15
lib/client/fetching.ts Normal file
View File

@@ -0,0 +1,15 @@
export async function fetchFeatures(setAllFeatures: any) {
// results = []
try {
const res = await fetch('/api/interests');
if (res.ok) {
const data = await res.json();
for (const [id, values] of Object.entries(data)) {
setAllFeatures(id, values || []);
// results.push({id, values});
}
}
} catch (error) {
console.error('Error fetching feature options:', error);
}
}

View File

@@ -21,4 +21,14 @@ export interface ProfileData {
promptAnswers: { prompt?: string; answer?: string, id?: string }[];
images: string[];
};
}
export type DropdownKey = 'interests' | 'causeAreas' | 'connections' | 'coreValues';
export type RangeKey = 'age' | 'introversion';
// type OtherKey = 'gender' | 'searchQuery';
export interface Item {
id: DropdownKey;
name: string;
}