refactor(planner): type tag mapping callback as TagItem in server load
Replaces (t: any) with (t: TagItem) so the API response shape is validated against the shared TagItem interface. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import type { PageServerLoad, Actions } from './$types';
|
|||||||
import { apiClient } from '$lib/server/api';
|
import { apiClient } from '$lib/server/api';
|
||||||
import { getWeekStart } from '$lib/planner/week';
|
import { getWeekStart } from '$lib/planner/week';
|
||||||
import { addSlotAction, updateSlotAction, deleteSlotAction } from '$lib/server/slotActions';
|
import { addSlotAction, updateSlotAction, deleteSlotAction } from '$lib/server/slotActions';
|
||||||
|
import type { TagItem } from '$lib/planner/types';
|
||||||
|
|
||||||
export const load: PageServerLoad = async ({ fetch, url }) => {
|
export const load: PageServerLoad = async ({ fetch, url }) => {
|
||||||
const weekParam = url.searchParams.get('week');
|
const weekParam = url.searchParams.get('week');
|
||||||
@@ -22,7 +23,7 @@ export const load: PageServerLoad = async ({ fetch, url }) => {
|
|||||||
cookTimeMin: r.cookTimeMin,
|
cookTimeMin: r.cookTimeMin,
|
||||||
effort: r.effort,
|
effort: r.effort,
|
||||||
heroImageUrl: r.heroImageUrl,
|
heroImageUrl: r.heroImageUrl,
|
||||||
tags: (r.tags ?? []).map((t: any) => ({ id: t.id, name: t.name, tagType: t.tagType }))
|
tags: (r.tags ?? []).map((t: TagItem) => ({ id: t.id, name: t.name, tagType: t.tagType }))
|
||||||
}));
|
}));
|
||||||
|
|
||||||
if (weekPlanResult.error || !weekPlanResult.data?.id) {
|
if (weekPlanResult.error || !weekPlanResult.data?.id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user