|
7 | 7 | let searchQuery = ""; |
8 | 8 | let selectedDefinition = "all"; |
9 | 9 |
|
10 | | - $: filteredEntities = data.entities.filter((entity) => { |
| 10 | + $: filteredEntities = (data.entities || []).filter((entity) => { |
11 | 11 | const matchesSearch = |
12 | 12 | searchQuery === "" || |
13 | 13 | entity.id.toLowerCase().includes(searchQuery.toLowerCase()) || |
|
25 | 25 |
|
26 | 26 | $: definitionOptions = [ |
27 | 27 | "all", |
28 | | - ...new Set(data.entities.map((e) => e.definition_id)), |
| 28 | + ...new Set((data.entities || []).map((e) => e.definition_id)), |
29 | 29 | ]; |
30 | 30 |
|
31 | 31 | async function deleteEntity(entityId: string) { |
|
51 | 51 | } |
52 | 52 |
|
53 | 53 | function getDefinitionName(definitionId: string): string { |
54 | | - const definition = data.definitions.find((d) => d.id === definitionId); |
| 54 | + const definition = (data.definitions || []).find( |
| 55 | + (d) => d.id === definitionId, |
| 56 | + ); |
55 | 57 | return definition?.name || definitionId; |
56 | 58 | } |
57 | 59 |
|
|
131 | 133 | Total Entities |
132 | 134 | </p> |
133 | 135 | <p class="mt-2 text-3xl font-bold text-gray-900 dark:text-gray-100"> |
134 | | - {data.entities.length} |
| 136 | + {data.entities?.length || 0} |
135 | 137 | </p> |
136 | 138 | <p class="mt-1 text-xs text-gray-500 dark:text-gray-500"> |
137 | 139 | Across all definitions |
|
164 | 166 | Active Definitions |
165 | 167 | </p> |
166 | 168 | <p class="mt-2 text-3xl font-bold text-gray-900 dark:text-gray-100"> |
167 | | - {data.definitions.length} |
| 169 | + {data.definitions?.length || 0} |
168 | 170 | </p> |
169 | 171 | <p class="mt-1 text-xs text-gray-500 dark:text-gray-500"> |
170 | 172 | Entity type definitions |
|
305 | 307 | No entities found |
306 | 308 | </h3> |
307 | 309 | <p class="mb-4 text-gray-600 dark:text-gray-400"> |
308 | | - {data.entities.length === 0 |
| 310 | + {!data.entities || data.entities.length === 0 |
309 | 311 | ? "Get started by creating your first dynamic entity" |
310 | 312 | : "Try adjusting your search or filter criteria"} |
311 | 313 | </p> |
312 | | - {#if data.entities.length === 0} |
| 314 | + {#if !data.entities || data.entities.length === 0} |
313 | 315 | <a |
314 | 316 | href="/dynamic-entities/create" |
315 | 317 | class="inline-flex items-center rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700" |
|
0 commit comments