diff --git a/frontend/src/pages/Sites/Preview.tsx b/frontend/src/pages/Sites/Preview.tsx
deleted file mode 100644
index d0fdaa80..00000000
--- a/frontend/src/pages/Sites/Preview.tsx
+++ /dev/null
@@ -1,223 +0,0 @@
-/**
- * Site Preview
- * Phase 7: Advanced Site Management
- * Features: Live iframe preview of deployed site
- */
-import React, { useState, useEffect } from 'react';
-import { useParams } from 'react-router-dom';
-import { RefreshCwIcon, ExternalLinkIcon, Maximize2Icon, Minimize2Icon } from 'lucide-react';
-import PageMeta from '../../components/common/PageMeta';
-import { Card } from '../../components/ui/card';
-import Button from '../../components/ui/button/Button';
-import { useToast } from '../../components/ui/toast/ToastContainer';
-import { fetchAPI } from '../../services/api';
-
-export default function SitePreview() {
- const { id: siteId } = useParams<{ id: string }>();
- const toast = useToast();
- const [loading, setLoading] = useState(true);
- const [previewUrl, setPreviewUrl] = useState(null);
- const [isFullscreen, setIsFullscreen] = useState(false);
- const [blueprint, setBlueprint] = useState(null);
-
- useEffect(() => {
- if (siteId) {
- loadPreviewData();
- }
- }, [siteId]);
-
- const loadPreviewData = async () => {
- try {
- setLoading(true);
- // Get the latest blueprint for this site
- const blueprintsData = await fetchAPI(`/v1/site-builder/blueprints/?site=${siteId}`);
- const blueprints = Array.isArray(blueprintsData?.results) ? blueprintsData.results : Array.isArray(blueprintsData) ? blueprintsData : [];
-
- if (blueprints.length > 0) {
- const latestBlueprint = blueprints[0];
- setBlueprint(latestBlueprint);
-
- // Get deployment record to find preview URL
- if (latestBlueprint.deployed_version || latestBlueprint.status === 'deployed') {
- try {
- // Get deployment records for this blueprint
- const deploymentsData = await fetchAPI(`/v1/publisher/deployments/?site_blueprint=${latestBlueprint.id}`);
- const deployments = Array.isArray(deploymentsData?.results) ? deploymentsData.results : Array.isArray(deploymentsData) ? deploymentsData : [];
-
- // Find the latest deployed record
- const deployedRecord = deployments.find((d: any) => d.status === 'deployed') || deployments[0];
-
- if (deployedRecord?.deployment_url) {
- setPreviewUrl(deployedRecord.deployment_url);
- } else if (deployedRecord) {
- // If deployment exists but no URL, construct from Sites Renderer
- // Sites Renderer should be accessible at a different port or subdomain
- // Check if we have the Sites Renderer URL configured
- // Use VPS IP or configured URL for Sites Renderer
- const sitesRendererUrl = import.meta.env.VITE_SITES_RENDERER_URL ||
- (window as any).__SITES_RENDERER_URL__ ||
- 'http://31.97.144.105:8024';
- setPreviewUrl(`${sitesRendererUrl}/${siteId}`);
- }
- } catch (error) {
- console.warn('No deployment record found:', error);
- // If blueprint is deployed but no deployment record, try Sites Renderer directly
- if (latestBlueprint.status === 'deployed') {
- // Use VPS IP or configured URL for Sites Renderer
- const sitesRendererUrl = import.meta.env.VITE_SITES_RENDERER_URL ||
- (window as any).__SITES_RENDERER_URL__ ||
- 'http://31.97.144.105:8024';
- setPreviewUrl(`${sitesRendererUrl}/${siteId}`);
- }
- }
- }
-
- // If still no preview URL, check blueprint status
- if (!previewUrl) {
- if (latestBlueprint.status === 'ready' || latestBlueprint.status === 'generating' || latestBlueprint.status === 'draft') {
- // Blueprint exists but not deployed yet - don't set preview URL
- setPreviewUrl(null);
- } else if (latestBlueprint.status === 'deployed') {
- // Blueprint is deployed but no deployment record found - try Sites Renderer
- const sitesRendererUrl = import.meta.env.VITE_SITES_RENDERER_URL ||
- (window as any).__SITES_RENDERER_URL__ ||
- 'http://localhost:8024';
- setPreviewUrl(`${sitesRendererUrl}/${siteId}`);
- }
- }
- }
- } catch (error: any) {
- toast.error(`Failed to load preview: ${error.message}`);
- } finally {
- setLoading(false);
- }
- };
-
- const handleRefresh = () => {
- if (previewUrl) {
- const iframe = document.getElementById('preview-iframe') as HTMLIFrameElement;
- if (iframe) {
- iframe.src = iframe.src;
- }
- }
- };
-
- const handleOpenInNewTab = () => {
- if (previewUrl) {
- window.open(previewUrl, '_blank');
- }
- };
-
- if (loading) {
- return (
-
-
-
-
Loading preview...
-
-
- );
- }
-
- if (!previewUrl) {
- return (
-
-
-
-
- Site Preview
-
-
- Preview your deployed site
-
-
-
-
- {blueprint?.status === 'ready' || blueprint?.status === 'generating'
- ? 'Blueprint is ready but not yet deployed. Deploy your site to preview it.'
- : blueprint?.status === 'draft'
- ? 'Blueprint is still in draft. Complete the wizard to generate the site structure.'
- : 'No preview available. Please deploy your site first.'}
-