add text area validation

This commit is contained in:
smanylov
2026-03-31 14:47:39 +07:00
parent d68a35903c
commit 0887ccde13
5 changed files with 85 additions and 30 deletions
@@ -57,8 +57,10 @@ export default function CaseComplaint({ selectedViolation }: { selectedViolation
setShowCreateCase(false);
} else if (state && !state.success) {
if (state.errorMessage) {
toast.warning(t(state.errorMessage));
console.log('state.errorMessage');
console.log(state.errorMessage);
if (state.errorMessage?.server) {
toast.warning(t(state.errorMessage.server));
} else {
toast.warning(t('the-complaint-has-not-been-registered'));
}
@@ -98,13 +100,35 @@ export default function CaseComplaint({ selectedViolation }: { selectedViolation
className="note-textarea"
placeholder={`${t('text-of-the-complaint')}...`}>
</textarea>
<button
type="submit"
className="btn-small btn-primary-small"
disabled={isPending}
<div
className="flex gap-3"
>
{t('submit-violation')}
</button>
<button
type="submit"
className="btn-small btn-primary-small"
disabled={isPending}
>
{t('submit-violation')}
</button>
{state?.errorMessage?.textArea && (
<p
className="text-sm text-red-500"
>
{
state?.errorMessage?.textArea.split('&').map((e, index) => {
return (
<span key={index}>
{t(e)}
<br />
</span>
)
})
}
</p>
)}
</div>
</form>
</div>
</div>