fix
This commit is contained in:
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user