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

View File

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