import { useState, useCallback } from 'react'; /** * Custom hook for managing DNS verification * @param {Function} showToast - Function to display toast notifications * @returns {Object} - DNS verification state and methods */ const useDnsVerification = (showToast) => { // DNS verification state const [dnsVerified, setDnsVerified] = useState({ cname: false, ns: false, a: false }); // Check DNS configuration const checkDnsConfig = useCallback((type) => { showToast(`Checking ${type}... (This would verify DNS in a real app)`); // Set type to 'checking' state setDnsVerified(prev => ({ ...prev, [type]: 'checking' })); // Simulate DNS check with a delay setTimeout(() => { setDnsVerified(prev => ({ ...prev, [type]: true })); showToast(`${type} verified successfully!`); }, 1500); }, [showToast]); // Reset DNS verification for a specific type const resetDnsVerification = useCallback((type) => { setDnsVerified(prev => ({ ...prev, [type]: false })); }, []); // Reset all DNS verification const resetAllDnsVerification = useCallback(() => { setDnsVerified({ cname: false, ns: false, a: false }); }, []); return { dnsVerified, checkDnsConfig, resetDnsVerification, resetAllDnsVerification }; }; export default useDnsVerification;