// src/app/dashboard/page.tsx 'use client' import { Plus, Twitter, InstagramIcon, Facebook, Linkedin } from 'lucide-react'; import { useState, useEffect } from 'react'; import AddProfile from '@/components/profiles/addProfile'; import { useTheme } from '@/contexts/themecontext'; import { getProfilesByWorkspace, type Profile } from '@/lib/api/core'; export default function DashboardPage() { const [showOnboarding, setShowOnboarding] = useState(false); const [profiles, setProfiles] = useState([]); const [isLoading, setIsLoading] = useState(true); const { theme } = useTheme(); useEffect(() => { const fetchProfiles = async () => { try { const workspaceId = localStorage.getItem('selectedWorkspaceId'); if (!workspaceId) return; const fetchedProfiles = await getProfilesByWorkspace(workspaceId); setProfiles(fetchedProfiles); } catch (error) { console.error('Failed to fetch profiles:', error); } finally { setIsLoading(false); } }; fetchProfiles(); }, []); const handleNewProfileClick = () => { setShowOnboarding(true); }; const handleOnboardingComplete = () => { setShowOnboarding(false); // Refresh profiles after creating a new one const workspaceId = localStorage.getItem('selectedWorkspaceId'); if (workspaceId) { getProfilesByWorkspace(workspaceId).then(setProfiles); } }; if (isLoading) { return (
); } return (
{showOnboarding && }

Tous les profils

{profiles.length === 0 ? (

Aucun profil

) : (
{profiles.map((profile) => ( ))}
)}
); } function ProfileCard({ profile, theme }: { profile: Profile, theme: 'dark' | 'light' }) { const socialIcons = { twitter: , instagram: , facebook: , linkedin: }; const getProfileIcon = () => { if (profile.socials && profile.socials.length > 0) { const firstSocial = profile.socials[0]; return socialIcons[firstSocial.type as keyof typeof socialIcons] || '👤'; } return '👤'; }; return (
{getProfileIcon()}

{profile.name}

@{profile.name.toLowerCase()}

{profile.socials?.map((social) => (
{socialIcons[social.type as keyof typeof socialIcons]} {social.identifier}
))}
); } function NewProfileCard({ onClick, theme }: { onClick: () => void, theme: 'dark' | 'light' }) { return (

Ajouter un nouveau profil

); }