diff --git a/src/app/clasificados/page.tsx b/src/app/clasificados/page.tsx index 2abf152..1b64727 100644 --- a/src/app/clasificados/page.tsx +++ b/src/app/clasificados/page.tsx @@ -13,7 +13,12 @@ async function fetchClasificadosData() { // 1. Settings const settingsRes = await client.databases.listDocuments(APPWRITE_ALMEIRA_CONFIG.databaseId, 'settings', []); - const settings = (settingsRes.documents.length > 0 ? settingsRes.documents[0] : {}) as Settings; + const settings = (settingsRes.documents.length > 0 ? settingsRes.documents[0] : { + ticker_count: 10, + rotation_seconds: 5, + feed_news_count: 12, + show_news_date: true + }) as Settings; const postsCount = settings.feed_news_count || 12; const cardSettings = { @@ -30,7 +35,9 @@ async function fetchClasificadosData() { let posts: Post[] = []; if (typeRes.documents.length > 0) { - const typeId = typeRes.documents[0].$id; + const firstType = typeRes.documents[0]; + const typeId = firstType?.$id; + if (!typeId) return { posts: [], cardSettings }; const postsRes = await client.databases.listDocuments(APPWRITE_ALMEIRA_CONFIG.databaseId, 'posts', [ Query.equal('tipo_publicacion_id', typeId), Query.equal('estado', 'Publicado'), diff --git a/src/app/dashboard/settings/page.tsx b/src/app/dashboard/settings/page.tsx index 7b1bd42..805b39e 100644 --- a/src/app/dashboard/settings/page.tsx +++ b/src/app/dashboard/settings/page.tsx @@ -2,11 +2,12 @@ import { APPWRITE_ALMEIRA_CONFIG } from '@/lib/appwrite'; import { createSessionClient } from '@/lib/appwrite.server'; import { getEntity, updateEntity } from '@/app/actions/entity'; import { revalidatePath } from 'next/cache'; -import { Settings, Save, Clock, Menu, Building, Image as ImageIcon, Link as LinkIcon, Share2 } from 'lucide-react'; +import { Settings as SettingsIcon, Save, Clock, Menu, Building, Image as ImageIcon, Link as LinkIcon, Share2 } from 'lucide-react'; +import { Settings as SettingsInterface } from '@/types/settings'; export default async function SettingsPage() { - let settings = { ticker_count: 10, rotation_seconds: 5 }; - let docId = 'global_config'; + let settings: SettingsInterface = { ticker_count: 10, rotation_seconds: 5 }; + let docId = ''; let entity: any = null; try { @@ -18,7 +19,7 @@ export default async function SettingsPage() { [] ); if (response.documents.length > 0) { - settings = response.documents[0] as any; + settings = response.documents[0] as unknown as SettingsInterface; docId = response.documents[0].$id; } } @@ -69,7 +70,7 @@ export default async function SettingsPage() {