import React from 'react'; import { DocumentTypeElement } from '../../types/elements'; import { NumericPropertyInput } from '../ui/NumericPropertyInput'; import { ColorPropertyInput } from '../ui/ColorPropertyInput'; import { getPdfBuilderData } from '../../utils/editorFeatures'; type DocumentTypeOption = { value: string; label: string; }; // Composant Accordion personnalisé const Accordion = ({ title, children, defaultOpen = false }: { title: string; children: React.ReactNode; defaultOpen?: boolean; }) => { const [isOpen, setIsOpen] = React.useState(defaultOpen); return (
{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 DocumentTypePropertiesProps { element: DocumentTypeElement; onChange: (elementId: string, property: string, value: unknown) => void; activeTab: { [key: string]: 'fonctionnalites' | 'personnalisation' | 'positionnement' }; setActiveTab: (tabs: { [key: string]: 'fonctionnalites' | 'personnalisation' | 'positionnement' }) => void; } export function DocumentTypeProperties({ element, onChange, activeTab, setActiveTab }: DocumentTypePropertiesProps) { const documentCurrentTab = activeTab[element.id] || 'fonctionnalites'; const setDocumentCurrentTab = (tab: 'fonctionnalites' | 'personnalisation' | 'positionnement') => { setActiveTab({ ...activeTab, [element.id]: tab }); }; const freeDocumentTypes: DocumentTypeOption[] = [ { value: 'FACTURE', label: 'Facture' }, { value: 'DEVIS', label: 'Devis' }, ]; const pdfBuilderData = getPdfBuilderData(); const premiumDocumentTypes = ((pdfBuilderData.documentTypeTemplatesPremium ?? []) as DocumentTypeOption[]); const allDocumentTypes = [...freeDocumentTypes, ...premiumDocumentTypes]; const allDocumentTypeValues = new Set(allDocumentTypes.map((type) => type.value)); const currentDocumentType = allDocumentTypeValues.has(element.documentType || '') ? element.documentType || 'FACTURE' : 'FACTURE'; return (
{/* Onglets */}
{/* Contenu des onglets */} {documentCurrentTab === 'fonctionnalites' && ( <>
onChange(element.id, 'showBackground', checked)} label="Afficher le fond" description="Affiche un fond coloré derrière le texte" /> )} {documentCurrentTab === 'personnalisation' && ( <>
onChange(element.id, 'fontSize', value)} />
onChange(element.id, 'textColor', value)} />
{/* Section Couleur de fond - visible seulement si showBackground est activé */} {element.showBackground !== false && ( onChange(element.id, 'backgroundColor', value)} /> )} )} {documentCurrentTab === 'positionnement' && ( <>
onChange(element.id, 'x', value)} /> onChange(element.id, 'y', value)} />
onChange(element.id, 'width', value)} /> onChange(element.id, 'height', value)} />
onChange(element.id, 'padding', value)} />
)}
); }