mise a jour du frontend
This commit is contained in:
parent
618b740588
commit
9737caff99
9 changed files with 332 additions and 60 deletions
|
|
@ -9,9 +9,28 @@ async function GetSkills() {
|
|||
return res.json();
|
||||
}
|
||||
export default async function Skills(){
|
||||
const skills = await GetSkills();
|
||||
const data = await GetSkills();
|
||||
|
||||
// Support both array and object responses from the backend and merge all items if array
|
||||
let obj: Record<string, string[]> = {};
|
||||
if (Array.isArray(data)) {
|
||||
for (const item of data) {
|
||||
if (item && typeof item === "object") {
|
||||
for (const [category, items] of Object.entries(item as Record<string, unknown>)) {
|
||||
if (Array.isArray(items)) {
|
||||
obj[category] = [...(obj[category] ?? []), ...items.filter((x): x is string => typeof x === "string")];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Deduplicate items per category
|
||||
obj = Object.fromEntries(
|
||||
Object.entries(obj).map(([k, arr]) => [k, Array.from(new Set(arr))])
|
||||
);
|
||||
} else if (data && typeof data === "object") {
|
||||
obj = data as Record<string, string[]>;
|
||||
}
|
||||
|
||||
const obj: Record<string, string[]> = Array.isArray(skills) ? (skills[0] ?? {}) : {};
|
||||
const entries = Object.entries(obj) as [string, string[]][];
|
||||
|
||||
if (entries.length === 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue