import type { Suggestion } from '@/types/foodlog'; import * as Crypto from 'expo-crypto'; export const DEFAULT_SUGGESTIONS = [ { label: 'Bibimbap', ingredients: ['rice', 'vegetables', 'egg', 'gochujang'] }, { label: 'Bulgogi', ingredients: ['beef', 'soy sauce', 'pear', 'garlic'] }, { label: 'Samgyetang', ingredients: ['chicken', 'ginseng', 'rice', 'garlic'] }, { label: 'Kimchi', ingredients: ['napa cabbage', 'gochugaru', 'fish sauce', 'garlic'] }, { label: 'Ramyeon', ingredients: ['noodles', 'broth', 'egg', 'vegetables'] }, ]; export function buildDefaultSuggestions(): Suggestion[] { return DEFAULT_SUGGESTIONS.map(food => ({ id: Crypto.randomUUID(), label: food.label, ingredients: food.ingredients, })); } export function normalizeSuggestions(payload: unknown): Suggestion[] | null { if (!Array.isArray(payload)) return null; if (payload.every(item => typeof item === 'string')) { return payload.map(label => ({ id: Crypto.randomUUID(), label })); } if ( payload.every( item => typeof item === 'object' && item !== null && 'id' in item && 'label' in item && typeof (item as { id?: unknown }).id === 'string' && typeof (item as { label?: unknown }).label === 'string' ) ) { return payload as Suggestion[]; } return null; }