This commit is contained in:
alorig
2025-11-22 21:10:05 +05:00
parent d4990fb088
commit 9ee03f4f7f
3 changed files with 47 additions and 45 deletions

View File

@@ -209,28 +209,31 @@ export default function SiteSettings() {
const [integrationStatus, setIntegrationStatus] = useState<'connected' | 'configured' | 'not_configured'>('not_configured');
const [testingAuth, setTestingAuth] = useState(false);
// Check basic configuration (API key + toggle)
// Check basic configuration - integration must exist in DB and have sync_enabled
useEffect(() => {
const checkStatus = async () => {
// If integration exists and is active, mark as configured
if (wordPressIntegration && wordPressIntegration.is_active) {
// Check if API key exists (either in site or in integration credentials)
const hasApiKey = site?.wp_api_key ||
(wordPressIntegration.credentials_json?.api_key);
if (hasApiKey) {
setIntegrationStatus('configured');
// Test authentication
testAuthentication();
} else {
setIntegrationStatus('not_configured');
}
// Integration must exist in database and have sync_enabled = true
if (wordPressIntegration && wordPressIntegration.id && wordPressIntegration.sync_enabled) {
setIntegrationStatus('configured');
// Test authentication
testAuthentication();
} else {
setIntegrationStatus('not_configured');
}
};
checkStatus();
}, [wordPressIntegration, site]);
// Auto-refresh integration list periodically to detect plugin-created integrations
useEffect(() => {
const interval = setInterval(() => {
if (!wordPressIntegration) {
loadIntegrations();
}
}, 5000); // Check every 5 seconds if integration doesn't exist
return () => clearInterval(interval);
}, [wordPressIntegration]);
// Test authentication with WordPress API
const testAuthentication = async () => {