import { useState, ReactNode } from 'react';
import { WoocommerceOrderDateElement } from '../../types/elements';
import { NumericPropertyInput } from '../ui/NumericPropertyInput';
import { ColorPropertyInput } from '../ui/ColorPropertyInput';
// Composant Accordion personnalisé - même style que les autres propriétés
const Accordion = ({ title, children, defaultOpen = false }: {
title: string;
children: ReactNode;
defaultOpen?: boolean;
}) => {
const [isOpen, setIsOpen] = useState(defaultOpen);
return (
setIsOpen(!isOpen)}
style={{
padding: '8px 10px',
backgroundColor: '#f0f0f0',
cursor: 'pointer',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
borderBottom: isOpen ? '1px solid #ddd' : 'none'
}}
>
{title}
▼
{isOpen && (
{children}
)}
);
};
interface WoocommerceOrderDatePropertiesProps {
element: WoocommerceOrderDateElement;
onChange: (elementId: string, property: string, value: unknown) => void;
activeTab: { [key: string]: 'fonctionnalites' | 'personnalisation' | 'positionnement' };
setActiveTab: (tabs: { [key: string]: 'fonctionnalites' | 'personnalisation' | 'positionnement' }) => void;
}
export function WoocommerceOrderDateProperties({
element,
onChange,
activeTab,
setActiveTab,
}: WoocommerceOrderDatePropertiesProps) {
const currentTab = activeTab[element.id] || 'fonctionnalites';
const setCurrentTab = (tab: 'fonctionnalites' | 'personnalisation' | 'positionnement') => {
setActiveTab({ ...activeTab, [element.id]: tab });
};
return (
<>
{/* Système d'onglets */}
{/* Onglet Fonctionnalités */}
{currentTab === 'fonctionnalites' && (
<>
onChange(element.id, 'showTime', e.target.checked)}
id={`showtime-${element.id}`}
style={{ marginRight: '8px', cursor: 'pointer' }}
/>
onChange(element.id, 'showLabel', e.target.checked)}
id={`showlabel-${element.id}`}
style={{ marginRight: '8px', cursor: 'pointer' }}
/>
{element.showLabel !== false && (
<>
onChange(element.id, 'labelText', e.target.value)}
style={{
width: '100%',
padding: '4px 8px',
border: '1px solid #ccc',
borderRadius: '3px',
fontSize: '12px'
}}
/>
onChange(element.id, 'labelSpacing', value)}
/>
onChange(element.id, 'labelFontSize', value)}
/>
onChange(element.id, 'labelColor', value)}
/>
>
)}
>
)}
{/* Onglet Personnalisation */}
{currentTab === 'personnalisation' && (
<>
onChange(element.id, 'fontSize', value)}
/>
onChange(element.id, 'color', value)}
/>
>
)}
{/* Onglet Positionnement */}
{currentTab === 'positionnement' && (
<>
Position et taille gérées par le canevas
>
)}
>
);
}