feat: Configuration et gestion du planning [#2]

This commit is contained in:
N3WT DE COMPET
2025-01-11 19:37:29 +01:00
parent 3c27133cdb
commit 830d9a48c0
26 changed files with 1163 additions and 1071 deletions

View File

@ -1,25 +1,34 @@
export default function SelectChoice({type, name, label, choices, callback, selected, error, IconItem }) {
return (
<>
<div className="mb-4">
<label htmlFor={name} className="block text-sm font-medium text-gray-700">{label}</label>
<div className={`flex items-center border-2 border-gray-200 rounded-md hover:border-gray-400 focus-within:border-gray-500 h-8 mt-2`}>
<span className="inline-flex items-center px-3 rounded-l-md bg-gray-50 text-gray-500 text-sm h-full">
{IconItem && <IconItem />}
</span>
<select
className="mt-1 block w-full px-2 py-0 text-base rounded-r-md sm:text-sm border-none focus:ring-0 outline-none cursor-pointer"
type={type}
id={name}
name={name}
value={selected}
onChange={callback}
>
{choices.map(({ value, label }, index) => <option key={value} value={value}>{label}</option>)}
</select>
</div>
{error && <p className="mt-2 text-sm text-red-600">{error}</p>}
</div>
</>
)
}
export default function SelectChoice({ type, name, label, choices, callback, selected, error, IconItem, disabled = false }) {
return (
<>
<div className="mb-4">
<label htmlFor={name} className="block text-sm font-medium text-gray-700">{label}</label>
<div
className={`flex items-center border-2 rounded-md ${disabled ? 'border-gray-200' : 'border-gray-200 hover:border-gray-400 focus-within:border-gray-500'} h-8 mt-2`}
>
<span className="inline-flex items-center px-3 rounded-l-md bg-gray-50 text-gray-500 text-sm h-full">
{IconItem && <IconItem />}
</span>
<select
className={`mt-1 block w-full px-2 py-0 text-base rounded-r-md sm:text-sm border-none focus:ring-0 outline-none cursor-pointer ${disabled ? 'bg-gray-100' : ''}`}
type={type}
id={name}
name={name}
value={selected}
onChange={callback}
disabled={disabled} // Ajout de l'attribut disabled avec une valeur par défaut de false
>
{choices.map(({ value, label }, index) => (
<option key={value} value={value} className={value === '' ? 'italic' : ''}>
{label}
</option>
))}
</select>
</div>
{error && <p className="mt-2 text-sm text-red-600">{error}</p>}
</div>
</>
);
}