1
This commit is contained in:
@@ -1187,7 +1187,7 @@ export default function Home() {
|
||||
</Link>
|
||||
</div>
|
||||
</ComponentCard>
|
||||
|
||||
1
|
||||
{/* Key Metrics */}
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
|
||||
<EnhancedMetricCard
|
||||
|
||||
@@ -15,8 +15,7 @@ import Checkbox from '../../components/form/input/Checkbox';
|
||||
import TextArea from '../../components/form/input/TextArea';
|
||||
import { useToast } from '../../components/ui/toast/ToastContainer';
|
||||
import { fetchAPI } from '../../services/api';
|
||||
import WordPressIntegrationCard from '../../components/sites/WordPressIntegrationCard';
|
||||
import WordPressIntegrationModal, { WordPressIntegrationFormData } from '../../components/sites/WordPressIntegrationModal';
|
||||
import WordPressIntegrationForm from '../../components/sites/WordPressIntegrationForm';
|
||||
import { integrationApi, SiteIntegration } from '../../services/integration.api';
|
||||
import { GridIcon, PlugInIcon, PaperPlaneIcon, DocsIcon, BoltIcon } from '../../icons';
|
||||
|
||||
@@ -30,7 +29,6 @@ export default function SiteSettings() {
|
||||
const [site, setSite] = useState<any>(null);
|
||||
const [wordPressIntegration, setWordPressIntegration] = useState<SiteIntegration | null>(null);
|
||||
const [integrationLoading, setIntegrationLoading] = useState(false);
|
||||
const [isIntegrationModalOpen, setIsIntegrationModalOpen] = useState(false);
|
||||
|
||||
// Check for tab parameter in URL
|
||||
const initialTab = (searchParams.get('tab') as 'general' | 'seo' | 'og' | 'schema' | 'integrations') || 'general';
|
||||
@@ -124,26 +122,11 @@ export default function SiteSettings() {
|
||||
}
|
||||
};
|
||||
|
||||
const handleSaveIntegration = async (data: WordPressIntegrationFormData) => {
|
||||
if (!siteId) return;
|
||||
await integrationApi.saveWordPressIntegration(Number(siteId), data);
|
||||
const handleIntegrationUpdate = async (integration: SiteIntegration) => {
|
||||
setWordPressIntegration(integration);
|
||||
await loadIntegrations();
|
||||
};
|
||||
|
||||
const handleSyncIntegration = async () => {
|
||||
if (!wordPressIntegration || !siteId) return;
|
||||
try {
|
||||
setIntegrationLoading(true);
|
||||
await integrationApi.syncIntegration(wordPressIntegration.id);
|
||||
toast.success('Content synced successfully');
|
||||
await loadIntegrations();
|
||||
} catch (error: any) {
|
||||
toast.error(`Failed to sync: ${error.message}`);
|
||||
} finally {
|
||||
setIntegrationLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const handleSave = async () => {
|
||||
try {
|
||||
setSaving(true);
|
||||
@@ -553,17 +536,12 @@ export default function SiteSettings() {
|
||||
)}
|
||||
|
||||
{/* Integrations Tab */}
|
||||
{activeTab === 'integrations' && (
|
||||
<div className="space-y-6">
|
||||
<WordPressIntegrationCard
|
||||
integration={wordPressIntegration}
|
||||
onConnect={() => setIsIntegrationModalOpen(true)}
|
||||
onManage={() => setIsIntegrationModalOpen(true)}
|
||||
onSync={handleSyncIntegration}
|
||||
loading={integrationLoading}
|
||||
siteId={siteId}
|
||||
/>
|
||||
</div>
|
||||
{activeTab === 'integrations' && siteId && (
|
||||
<WordPressIntegrationForm
|
||||
siteId={Number(siteId)}
|
||||
integration={wordPressIntegration}
|
||||
onIntegrationUpdate={handleIntegrationUpdate}
|
||||
/>
|
||||
)}
|
||||
|
||||
{/* Save Button */}
|
||||
@@ -576,26 +554,6 @@ export default function SiteSettings() {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* WordPress Integration Modal */}
|
||||
{siteId && (
|
||||
<WordPressIntegrationModal
|
||||
isOpen={isIntegrationModalOpen}
|
||||
onClose={() => setIsIntegrationModalOpen(false)}
|
||||
onSubmit={handleSaveIntegration}
|
||||
siteId={Number(siteId)}
|
||||
initialData={
|
||||
wordPressIntegration
|
||||
? {
|
||||
url: wordPressIntegration.config_json?.site_url || '',
|
||||
username: wordPressIntegration.credentials_json?.username || '',
|
||||
app_password: '', // Never show password
|
||||
is_active: wordPressIntegration.is_active,
|
||||
sync_enabled: wordPressIntegration.sync_enabled,
|
||||
}
|
||||
: undefined
|
||||
}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user