"use client"; import { useState } from "react"; import { CardAnnonce } from "@/lib/components/annonceComponents/annonceCardComponent"; import Link from "next/link"; import { AnnonceProps } from "@/lib/types/AnnonceProps"; import type { Prisma, Question } from "@prisma/client"; type Data = { annonces: AnnonceProps[]; questions: Question[]; answers: any[]; }; export default function ProfileTabsClient({ data, userRole, isOwner, }: { data: Data; userRole: string; isOwner: boolean; }) { const [tab, setTab] = useState<"annonces" | "questions" | "answers">("annonces"); return (
{(["annonces", "questions", "answers"] as const).map((t) => ( ))}
{userRole === "ADMIN" && isOwner && tab === "annonces" && (data.annonces.length === 0 ? (

Aucune annonce.

) : (
{data.annonces.map((a) => (
))}
))} {tab === "questions" && (data.questions.length === 0 ? ( ) : (
    {data.questions.map((q: Question) => (
  • {q.content}

    Publié le {new Date(q.createdAt).toLocaleDateString("fr-FR")}

  • ))}
))} {tab === "answers" && (data.answers.length === 0 ? ( ) : (
    {data.answers.map((q: any) => (
  • {q.answer}

    Répondu le {new Date(q.createdAt).toLocaleDateString("fr-FR")}

  • ))}
))}
); } function Empty({ label, cta }: { label: string; cta?: { href: string; text: string } }) { return (

{label}

{cta && ( {cta.text} )}
); }