const { useState } = React;

const useManagerState = () => {
  const [user, setUser] = useState(null);
  const [activeTab, setActiveTab] = useState("items");
  const [stats, setStats] = useState({
    total_items: 0,
    pending_claims: 0,
    verified: 0,
    expired: 0,
  });
  const [items, setItems] = useState([]);
  const [claims, setClaims] = useState([]);
  const [expiredItems, setExpiredItems] = useState([]);
  const [selectedItem, setSelectedItem] = useState(null);
  const [showDetailModal, setShowDetailModal] = useState(false);
  const [selectedClaim, setSelectedClaim] = useState(null);
  const [showVerifyModal, setShowVerifyModal] = useState(false);
  const [toast, setToast] = useState(null);
  const [loading, setLoading] = useState(false);
  const [showCloseCaseModal, setShowCloseCaseModal] = useState(false);
  const [closeCaseData, setCloseCaseData] = useState({
    berita_acara_no: "",
    bukti_serah_terima: "",
    notes: "",
  });
  const [showReportFoundModal, setShowReportFoundModal] = useState(false);
  const [photoPreview, setPhotoPreview] = useState(null);
  const [categories, setCategories] = useState([]);
  const [showManualClaimModal, setShowManualClaimModal] = useState(false);
  const [selectedItemForClaim, setSelectedItemForClaim] = useState(null);
  const [showApproveModal, setShowApproveModal] = useState(false);
  const [showEditItemModal, setShowEditItemModal] = useState(false);
  const [selectedItemToEdit, setSelectedItemToEdit] = useState(null);
  const [lostItems, setLostItems] = useState([]);
  const [showMatchLostItemModal, setShowMatchLostItemModal] = useState(false);
  const [selectedLostItem, setSelectedLostItem] = useState(null);
  const [showLostDetailModal, setShowLostDetailModal] = useState(false);
  const [selectedLostDetail, setSelectedLostDetail] = useState(null);

  return {
    user,
    setUser,
    activeTab,
    setActiveTab,
    stats,
    setStats,
    items,
    setItems,
    claims,
    setClaims,
    expiredItems,
    setExpiredItems,
    selectedItem,
    setSelectedItem,
    showDetailModal,
    setShowDetailModal,
    selectedClaim,
    setSelectedClaim,
    showVerifyModal,
    setShowVerifyModal,
    toast,
    setToast,
    loading,
    setLoading,
    showCloseCaseModal,
    setShowCloseCaseModal,
    closeCaseData,
    setCloseCaseData,
    showReportFoundModal,
    setShowReportFoundModal,
    photoPreview,
    setPhotoPreview,
    categories,
    setCategories,
    showManualClaimModal,
    setShowManualClaimModal,
    selectedItemForClaim,
    setSelectedItemForClaim,
    showApproveModal,
    setShowApproveModal,
    showEditItemModal,
    setShowEditItemModal,
    selectedItemToEdit,
    setSelectedItemToEdit,
    lostItems,
    setLostItems,
    showMatchLostItemModal,
    setShowMatchLostItemModal,
    selectedLostItem,
    setSelectedLostItem,
    showLostDetailModal,
    setShowLostDetailModal,
    selectedLostDetail,
    setSelectedLostDetail,
  };
};

// Export ke global scope
window.useManagerState = useManagerState;
