fix: Limite du nombre de responsables légaux à 2 [#27]

This commit is contained in:
N3WT DE COMPET
2025-05-02 15:49:46 +02:00
parent 05542dfc40
commit 1ced4a1069
2 changed files with 18 additions and 3 deletions

View File

@ -69,7 +69,9 @@ export default function FileUpload({
<CloudUpload className="w-6 h-6 text-emerald-500" />
<p className="text-sm font-medium text-gray-800">
<span className="font-semibold">
{existingFile.split('/').pop()}
{typeof existingFile === 'string'
? existingFile.split('/').pop()
: existingFile?.name || 'Fichier inconnu'}
</span>
</p>
</div>

View File

@ -14,6 +14,7 @@ export default function ResponsableInputFields({
}) {
const t = useTranslations('ResponsableInputFields');
const { selectedEstablishmentId } = useEstablishment();
const MAX_GUARDIANS = 2;
useEffect(() => {
const isValid =
@ -241,8 +242,20 @@ export default function ResponsableInputFields({
<div className="flex justify-center">
<Plus
className="w-8 h-8 text-green-500 cursor-pointer hover:text-green-700 transition-colors border-2 border-green-500 hover:border-green-700 rounded-full p-1"
onClick={(e) => addGuardian(e)}
className={`w-8 h-8 ${
guardians.length >= MAX_GUARDIANS
? 'text-gray-400 cursor-not-allowed'
: 'text-green-500 cursor-pointer hover:text-green-700'
} transition-colors border-2 ${
guardians.length >= MAX_GUARDIANS
? 'border-gray-400'
: 'border-green-500 hover:border-green-700'
} rounded-full p-1`}
onClick={(e) => {
if (guardians.length < MAX_GUARDIANS) {
addGuardian(e);
}
}}
/>
</div>
</div>