add more validations

This commit is contained in:
Laux Dev
2026-03-05 16:03:31 +08:00
parent dae12d74ee
commit b3f7427e95
17 changed files with 590 additions and 98 deletions

View File

@@ -0,0 +1,46 @@
"use client";
import { useState } from "react";
const useOrganizationForm = () => {
const [organizationName, setOrganizationName] = useState("");
const [error, setError] = useState(false);
const [triggerAlert, setTriggerAlert] = useState(false);
const handleChange = (e) => {
const value = e.target.value;
setOrganizationName(value);
if (value.trim() !== "") {
setError(false);
}
};
const handleValidation = (e) => {
e.preventDefault();
setError(true);
};
const handleSubmit = (e) => {
e.preventDefault();
if (!organizationName.trim()) {
setError(true);
return;
}
setTriggerAlert(true);
console.log("Submitted organization:", organizationName);
};
return {
organizationName,
error,
triggerAlert,
handleChange,
handleValidation,
handleSubmit,
setTriggerAlert,
};
};
export default useOrganizationForm;