Xianbao QIAN
commited on
Commit
•
cddc449
1
Parent(s):
754b5f8
make compiler happy
Browse files- src/app/page.tsx +9 -4
src/app/page.tsx
CHANGED
@@ -20,6 +20,11 @@ type OrgData = {
|
|
20 |
family_all_children_count: number;
|
21 |
};
|
22 |
|
|
|
|
|
|
|
|
|
|
|
23 |
export default function Home() {
|
24 |
const [allModels, setAllModels] = useState<ModelData[]>([]);
|
25 |
const [orgData, setOrgData] = useState<OrgData[]>([]);
|
@@ -214,7 +219,7 @@ export default function Home() {
|
|
214 |
console.log('Children type:', type);
|
215 |
setSelectedModel(model);
|
216 |
setSelectedModelChildrenType(type);
|
217 |
-
let children;
|
218 |
if (type === 'direct') {
|
219 |
children = model.direct_children || [];
|
220 |
} else {
|
@@ -222,11 +227,11 @@ export default function Home() {
|
|
222 |
}
|
223 |
console.log('Children:', children);
|
224 |
|
225 |
-
// Handle Vector data structure
|
226 |
if (children && typeof children === 'object' && 'get' in children && 'length' in children) {
|
227 |
const vectorChildren = [];
|
228 |
-
for (let i = 0; i < children.length; i++) {
|
229 |
-
vectorChildren.push(children.get(i));
|
230 |
}
|
231 |
setSelectedModelChildren(vectorChildren);
|
232 |
} else if (Array.isArray(children)) {
|
|
|
20 |
family_all_children_count: number;
|
21 |
};
|
22 |
|
23 |
+
interface VectorLike<T> {
|
24 |
+
get(index: number): T;
|
25 |
+
length: number;
|
26 |
+
}
|
27 |
+
|
28 |
export default function Home() {
|
29 |
const [allModels, setAllModels] = useState<ModelData[]>([]);
|
30 |
const [orgData, setOrgData] = useState<OrgData[]>([]);
|
|
|
219 |
console.log('Children type:', type);
|
220 |
setSelectedModel(model);
|
221 |
setSelectedModelChildrenType(type);
|
222 |
+
let children: VectorLike<string> | string[];
|
223 |
if (type === 'direct') {
|
224 |
children = model.direct_children || [];
|
225 |
} else {
|
|
|
227 |
}
|
228 |
console.log('Children:', children);
|
229 |
|
230 |
+
// Handle Vector-like data structure
|
231 |
if (children && typeof children === 'object' && 'get' in children && 'length' in children) {
|
232 |
const vectorChildren = [];
|
233 |
+
for (let i = 0; i < (children as VectorLike<string>).length; i++) {
|
234 |
+
vectorChildren.push((children as VectorLike<string>).get(i));
|
235 |
}
|
236 |
setSelectedModelChildren(vectorChildren);
|
237 |
} else if (Array.isArray(children)) {
|