"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;
