diff --git a/.DS_Store b/.DS_Store index af40c5e..e7d6835 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/app/admin/responses/page.tsx b/app/admin/responses/page.tsx index 86f17e1..1c00a64 100644 --- a/app/admin/responses/page.tsx +++ b/app/admin/responses/page.tsx @@ -8,6 +8,13 @@ export const dynamic = 'force-dynamic' const MAX_SUBMISSIONS = 500 const PROMPT_MAX_LEN = 60 +const SURVEY_OPTIONS = [ + { label: 'Todos', id: null }, + { label: 'InQuality', id: '30000000-0000-0000-0000-000000000002' }, + { label: 'Fundación Solidaridad', id: '30000000-0000-0000-0000-000000000003' }, + { label: 'Demo', id: '30000000-0000-0000-0000-000000000001' }, +] as const + interface AllowedQuestion { id: string code: string @@ -63,7 +70,12 @@ function renderValue(value: unknown, type: string): string | null { } } -export default async function AdminResponsesPage() { +export default async function AdminResponsesPage({ + searchParams, +}: { + searchParams: Promise<{ survey_id?: string }> +}) { + const { survey_id: surveyId } = await searchParams const supabase = getSupabaseAdmin() // 1. Preguntas permitidas — text_long e is_sensitive=true se excluyen ACÁ, @@ -91,22 +103,26 @@ export default async function AdminResponsesPage() { // 2. Submissions con sus respuestas — answers!inner + .in() filtra el ARRAY // embebido a solo question_id permitidos (consulta, no post-filtro). + let responsesQuery = supabase + .from('responses') + .select( + ` + id, + submitted_at, + qi_zone, + qi_sector, + answers!inner ( value, question_id ) + ` + ) + .in('answers.question_id', allowedIds) + + if (surveyId) { + responsesQuery = responsesQuery.eq('survey_id', surveyId) + } + const { data: responsesData, error: responsesError } = allowedIds.length > 0 - ? await supabase - .from('responses') - .select( - ` - id, - submitted_at, - qi_zone, - qi_sector, - answers!inner ( value, question_id ) - ` - ) - .in('answers.question_id', allowedIds) - .order('submitted_at', { ascending: false }) - .limit(MAX_SUBMISSIONS) + ? await responsesQuery.order('submitted_at', { ascending: false }).limit(MAX_SUBMISSIONS) : { data: [] as ResponseRow[], error: null } if (responsesError) { @@ -170,6 +186,22 @@ export default async function AdminResponsesPage() { {totalSubmissions ?? 0} submissions · {totalAnswers ?? 0} respuestas individuales · actualizado {formatDate(new Date().toISOString())}

+ Actualizar diff --git a/app/globals.css b/app/globals.css index 271b605..e41aa52 100644 --- a/app/globals.css +++ b/app/globals.css @@ -758,6 +758,14 @@ body { } .admin-title { font-size: 1.375rem; font-weight: 700; color: var(--color-text); margin: 0 0 4px; } .admin-subtitle { font-size: 0.8125rem; color: var(--color-text-muted); margin: 0; } +.admin-survey-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; } +.admin-survey-link { + font-size: 0.75rem; font-weight: 600; padding: 4px 12px; border-radius: 999px; + border: 1px solid var(--color-border); color: var(--color-text-muted); text-decoration: none; + transition: all 0.2s ease; +} +.admin-survey-link:hover { color: var(--color-text); border-color: var(--color-primary); } +.admin-survey-link-active { background: var(--color-primary); color: #fff; border-color: var(--color-primary); } .admin-refresh { display: inline-block; padding: 8px 16px; border-radius: var(--radius); background: var(--color-primary); color: #fff; font-size: 0.8125rem;