ALwrity + Wordpress + Wix + GSC integration

This commit is contained in:
ajaysi
2025-10-08 10:13:14 +05:30
parent 14dfb2e5c0
commit 3bab3450dc
147 changed files with 19815 additions and 17053 deletions

View File

@@ -1,6 +1,6 @@
/** Google Search Console OAuth Callback Handler Component. */
import React, { useEffect, useState } from 'react';
import React, { useEffect, useState, useCallback } from 'react';
import {
Box,
Typography,
@@ -13,16 +13,14 @@ import {
Error as ErrorIcon
} from '@mui/icons-material';
import { gscAPI } from '../../../api/gsc';
import { useAuth } from '@clerk/clerk-react';
const GSCAuthCallback: React.FC = () => {
const [status, setStatus] = useState<'loading' | 'success' | 'error'>('loading');
const [message, setMessage] = useState<string>('Processing authentication...');
const { getToken } = useAuth();
useEffect(() => {
handleOAuthCallback();
}, []);
const handleOAuthCallback = async () => {
const handleOAuthCallback = useCallback(async () => {
try {
console.log('GSC Auth Callback: Processing OAuth callback');
@@ -76,7 +74,19 @@ const GSCAuthCallback: React.FC = () => {
}, '*');
}
}
};
}, [message]);
useEffect(() => {
// Ensure API client has an auth token getter in the popup context
gscAPI.setAuthTokenGetter(async () => {
try {
return await getToken();
} catch (e) {
return null;
}
});
handleOAuthCallback();
}, [getToken, handleOAuthCallback]);
const getStatusIcon = () => {
switch (status) {
@@ -91,16 +101,6 @@ const GSCAuthCallback: React.FC = () => {
}
};
const getStatusColor = () => {
switch (status) {
case 'success':
return 'success';
case 'error':
return 'error';
default:
return 'info';
}
};
return (
<Box