import { useState, ReactNode } from "react"; import { CustomerInfoElement } from "../../types/elements"; import { NumericPropertyInput } from "../ui/NumericPropertyInput"; import { ColorPropertyInput } from "../ui/ColorPropertyInput"; import { getEditorFeatureFlags } from "../../utils/editorFeatures"; // Composant Accordion personnalisé const Accordion = ({ title, children, defaultOpen = false, }: { title: string; children: ReactNode; defaultOpen?: boolean; }) => { const [isOpen, setIsOpen] = useState(defaultOpen); return (
setIsOpen(!isOpen)} style={{ padding: "12px", backgroundColor: "#f8f9fa", cursor: "pointer", display: "flex", justifyContent: "space-between", alignItems: "center", borderBottom: isOpen ? "1px solid #e9ecef" : "none", }} >

{title}

{isOpen && (
{children}
)}
); }; // Composant Toggle personnalisé const Toggle = ({ checked, onChange, label, description, }: { checked: boolean; onChange: (checked: boolean) => void; label: string; description: string; }) => (
onChange(!checked)} style={{ position: "relative", width: "44px", height: "24px", backgroundColor: checked ? "#007bff" : "#ccc", borderRadius: "12px", cursor: "pointer", transition: "background-color 0.2s ease", border: "none", }} >
{description}
); interface CustomerInfoPropertiesProps { element: CustomerInfoElement; onChange: (elementId: string, property: string, value: unknown) => void; activeTab: { [key: string]: "fonctionnalites" | "personnalisation" | "positionnement"; }; setActiveTab: (tabs: { [key: string]: "fonctionnalites" | "personnalisation" | "positionnement"; }) => void; } export function CustomerInfoProperties({ element, onChange, activeTab, setActiveTab, }: CustomerInfoPropertiesProps) { const customerCurrentTab = activeTab[element.id] || "fonctionnalites"; const setCustomerCurrentTab = ( tab: "fonctionnalites" | "personnalisation" | "positionnement", ) => { setActiveTab({ ...activeTab, [element.id]: tab }); }; const { canUseEditorThemes } = getEditorFeatureFlags(); return ( <> {/* Système d'onglets pour Customer Info */}
{/* Onglet Fonctionnalités */} {customerCurrentTab === "fonctionnalites" && ( <> {/* Section Structure de l'information */}
Structure des informations
onChange(element.id, "showHeaders", checked) } label="Afficher les en-têtes" description="Affiche les titres des sections" /> onChange(element.id, "showBackground", checked) } label="Afficher le fond" description="Affiche un fond coloré derrière les informations" /> onChange(element.id, "showBorders", checked) } label="Afficher les bordures" description="Affiche les bordures autour des sections" />
{/* Section Informations personnelles */}
Informations personnelles
onChange(element.id, "showFullName", checked) } label="Afficher le nom complet" description="Prénom et nom du client" />
{/* Section Coordonnées */}
Coordonnées
onChange(element.id, "showAddress", checked) } label="Afficher l'adresse" description="Adresse complète du client" /> onChange(element.id, "showEmail", checked) } label="Afficher l'email" description="Adresse email du client" /> onChange(element.id, "showPhone", checked) } label="Afficher le téléphone" description="Numéro de téléphone du client" />
{/* Section Informations de paiement */}
Informations de paiement
onChange(element.id, "showPaymentMethod", checked) } label="Afficher le moyen de paiement" description="Méthode de paiement utilisée" /> onChange(element.id, "showTransactionId", checked) } label="Afficher l'ID de transaction" description="Identifiant unique de la transaction" />
)} {/* Onglet Personnalisation */} {customerCurrentTab === "personnalisation" && ( <> {/* Accordéon Disposition */}
{canUseEditorThemes && (
{[ { id: "clean", name: "Propre", preview: (
), styles: { backgroundColor: "#ffffff", borderColor: "#f3f4f6", textColor: "#374151", headerTextColor: "#111827", }, }, { id: "subtle", name: "Discret", preview: (
), styles: { backgroundColor: "#fafbfc", borderColor: "#f1f5f9", textColor: "#475569", headerTextColor: "#334155", }, }, { id: "elegant", name: "Élégant", preview: (
), styles: { backgroundColor: "#fefefe", borderColor: "#f3e8ff", textColor: "#6b21a8", headerTextColor: "#581c87", }, }, { id: "corporate", name: "Corporate", preview: (
), styles: { backgroundColor: "#ffffff", borderColor: "#e5e7eb", textColor: "#374151", headerTextColor: "#111827", }, }, { id: "warm", name: "Chaleureux", preview: (
), styles: { backgroundColor: "#fff8f0", borderColor: "#fed7aa", textColor: "#9a3412", headerTextColor: "#78350f", }, }, { id: "minimal", name: "Minimal", preview: (
), styles: { backgroundColor: "transparent", borderColor: "transparent", textColor: "#6b7280", headerTextColor: "#374151", }, }, ].map((theme) => ( ))}
)}
{/* Accordéon Police de l'en-tête */} {element.showHeaders !== false && (
onChange(element.id, "headerFontSize", value) } />
onChange(element.id, "headerTextColor", value) } />
)} {/* Accordéon Police du corps du texte */}
onChange(element.id, "bodyFontSize", value) } />
onChange( element.id, "lineHeight", parseFloat(e.target.value) || 1, ) } min="0.5" max="3" step="0.1" style={{ width: "100%", padding: "4px 8px", border: "1px solid #ccc", borderRadius: "3px", fontSize: "12px", }} />
Actuel:{" "} {parseFloat(String(element.lineHeight || 1.1)).toFixed(1)}{" "} (Puppeteer uniquement)
onChange(element.id, "textColor", value)} />
{/* Accordéon Couleurs */}
onChange(element.id, "headerTextColor", value) } />
onChange(element.id, "textColor", value)} />
{element.showBackground !== false && (
onChange(element.id, "backgroundColor", value) } />
)} {element.showBorders !== false && (
onChange(element.id, "borderColor", value) } />
)} {element.showBorders !== false && (
onChange(element.id, "borderWidth", value) } />
)}
)} {/* Onglet Positionnement */} {customerCurrentTab === "positionnement" && ( <>
onChange(element.id, "x", parseInt(e.target.value)) } style={{ width: "100%", height: "6px", borderRadius: "3px", background: "#ddd", outline: "none", cursor: "pointer", }} />
onChange(element.id, "y", parseInt(e.target.value)) } style={{ width: "100%", height: "6px", borderRadius: "3px", background: "#ddd", outline: "none", cursor: "pointer", }} />
onChange(element.id, "width", parseInt(e.target.value)) } style={{ width: "100%", height: "6px", borderRadius: "3px", background: "#ddd", outline: "none", cursor: "pointer", }} />
onChange(element.id, "height", parseInt(e.target.value)) } style={{ width: "100%", height: "6px", borderRadius: "3px", background: "#ddd", outline: "none", cursor: "pointer", }} />
onChange( element.id, "letterSpacing", parseFloat(e.target.value), ) } style={{ width: "100%", height: "6px", borderRadius: "3px", background: "#ddd", outline: "none", cursor: "pointer", }} />
)} ); }