fix: render insights with nullable calendar data

This commit is contained in:
2026-08-22 15:58:26 +08:00
parent 9468fac99e
commit aec6687a8a
2 changed files with 3 additions and 3 deletions

View File

@@ -236,13 +236,13 @@
<p class="text-muted-foreground mt-2 text-sm leading-7">{insight.copy.future90Days.body}</p>
</article>
{/if}
{#if insight.calendarContext.length}
{#if insight.calendarContext?.length}
<div>
<h3 class="flex items-center gap-2 text-sm font-bold">
<CalendarDaysIcon class="size-4" /> رویدادهای مرتبط
</h3>
<div class="mt-3 flex flex-wrap gap-2">
{#each insight.calendarContext as event}<span
{#each insight.calendarContext ?? [] as event}<span
class={`rounded-md border px-3 py-2 text-xs ${eventTone(event.tone)}`}
>{event.titleFa} · {formatDate(event.startDate)}</span
>{/each}

View File

@@ -51,7 +51,7 @@ const insight: AIInsight = {
options: [],
},
evidence: {},
calendarContext: [],
calendarContext: null as unknown as AIInsight['calendarContext'],
refreshState: { state: 'IDLE' },
sectionRefreshState: {},
generatedAt: '2026-08-22T00:00:00Z',