refactored get started flow & code

This commit is contained in:
Arkadyuti Sarkar
2025-03-29 16:01:00 +05:30
parent f9d1556ce9
commit b58068d108
20 changed files with 1568 additions and 0 deletions

View File

@@ -0,0 +1,62 @@
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;