"use client"; import { useEffect, useState } from 'react'; import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'; import { auth, db } from '@/lib/firebase/config'; import { collection, query, where, getDocs } from 'firebase/firestore'; import { Button } from '@/components/ui/button'; import { RefreshCw } from 'lucide-react'; interface ProjectDebugInfo { id: string; productName: string; name: string; slug: string; userId: string; workspacePath?: string; createdAt: any; updatedAt: any; } export default function DebugProjectsPage() { const [projects, setProjects] = useState([]); const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [userId, setUserId] = useState(''); const loadProjects = async () => { setLoading(true); setError(null); try { const user = auth.currentUser; if (!user) { setError('Not authenticated'); return; } setUserId(user.uid); const projectsRef = collection(db, 'projects'); const projectsQuery = query( projectsRef, where('userId', '==', user.uid) ); const snapshot = await getDocs(projectsQuery); const projectsData = snapshot.docs.map(doc => { const data = doc.data(); return { id: doc.id, productName: data.productName || 'N/A', name: data.name || 'N/A', slug: data.slug || 'N/A', userId: data.userId || 'N/A', workspacePath: data.workspacePath, createdAt: data.createdAt, updatedAt: data.updatedAt, }; }); console.log('DEBUG: All projects from Firebase:', projectsData); setProjects(projectsData); } catch (err: any) { console.error('Error loading projects:', err); setError(err.message); } finally { setLoading(false); } }; useEffect(() => { const unsubscribe = auth.onAuthStateChanged((user) => { if (user) { loadProjects(); } else { setError('Please sign in'); setLoading(false); } }); return () => unsubscribe(); }, []); return (

🔍 Projects Debug Page

View all your projects and their unique IDs from Firebase

{userId && (

User ID: {userId}

)}
{error && (

Error: {error}

)} {loading && !error && (

Loading projects from Firebase...

)} {!loading && !error && ( <> Summary

Total Projects

{projects.length}

Unique IDs

{new Set(projects.map(p => p.id)).size}

Duplicate IDs?

p.id)).size ? 'text-red-500' : 'text-green-500'}`}> {projects.length !== new Set(projects.map(p => p.id)).size ? 'YES ⚠️' : 'NO ✓'}

All Projects

{projects.map((project, index) => ( #{index + 1}: {project.productName} Open Overview →

Project ID

{project.id}

Slug

{project.slug}

Product Name

{project.productName}

Internal Name

{project.name}

{project.workspacePath && (

Workspace Path

{project.workspacePath}
)}
))}
)}
); }