diff --git a/frontend/src/pages/Dashboard.jsx b/frontend/src/pages/Dashboard.jsx index 23a7a8b..1a13c4f 100644 --- a/frontend/src/pages/Dashboard.jsx +++ b/frontend/src/pages/Dashboard.jsx @@ -1,7 +1,7 @@ /** * Customer Dashboard - Main dashboard with sidebar navigation */ -import { useState } from 'react'; +import { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; import { useAuth } from '../context/AuthContext'; import { @@ -12,7 +12,143 @@ import { ShieldCheckIcon, Cog6ToothIcon, ArrowRightOnRectangleIcon, + PlusIcon, + CheckCircleIcon, + XCircleIcon, + ClockIcon, } from '@heroicons/react/24/outline'; +import api from '../services/api'; + +// Domains Content Component +const DomainsContent = ({ customer }) => { + const [domains, setDomains] = useState([]); + const [loading, setLoading] = useState(true); + const [showAddModal, setShowAddModal] = useState(false); + + useEffect(() => { + fetchDomains(); + }, []); + + const fetchDomains = async () => { + try { + const response = await api.get('/api/customer/domains'); + setDomains(response.data.domains || []); + } catch (error) { + console.error('Failed to fetch domains:', error); + } finally { + setLoading(false); + } + }; + + const getStatusBadge = (status) => { + const badges = { + active: { color: 'bg-green-100 text-green-800', icon: CheckCircleIcon, text: 'Active' }, + pending: { color: 'bg-yellow-100 text-yellow-800', icon: ClockIcon, text: 'Pending' }, + failed: { color: 'bg-red-100 text-red-800', icon: XCircleIcon, text: 'Failed' }, + }; + const badge = badges[status] || badges.pending; + const Icon = badge.icon; + + return ( + + + {badge.text} + + ); + }; + + if (loading) { + return ( +
+
+
+

Loading domains...

+
+
+ ); + } + + return ( +
+ {/* Header with Add Button */} +
+
+

Your Domains

+

+ {domains.length} of {customer?.max_domains} domains used +

+
+ +
+ + {/* Domain List */} + {domains.length === 0 ? ( +
+ +

No domains yet

+

+ Get started by adding your first domain +

+ +
+ ) : ( +
+ {domains.map((domain) => ( +
+
+
+
+

+ {domain.domain_name} +

+ {getStatusBadge(domain.status)} +
+
+ DNS: {domain.dns_configured ? '✓ Configured' : '✗ Not configured'} + SSL: {domain.ssl_configured ? '✓ Active' : '✗ Pending'} + {domain.lb_ip && IP: {domain.lb_ip}} +
+
+ +
+
+ ))} +
+ )} + + {/* Add Domain Modal - Placeholder */} + {showAddModal && ( +
+
+

Add New Domain

+

Domain wizard coming soon...

+ +
+
+ )} +
+ ); +}; const Dashboard = () => { const { user, customer, logout } = useAuth(); @@ -26,7 +162,7 @@ const Dashboard = () => { const menuItems = [ { id: 'overview', name: 'Overview', icon: HomeIcon }, - { id: 'dns', name: 'DNS Management', icon: GlobeAltIcon }, + { id: 'domains', name: 'Domains', icon: GlobeAltIcon }, { id: 'containers', name: 'Containers', icon: ServerIcon }, { id: 'network', name: 'Network', icon: WifiIcon }, { id: 'security', name: 'Security', icon: ShieldCheckIcon }, @@ -157,10 +293,8 @@ const Dashboard = () => { )} - {activeTab === 'dns' && ( -
-

DNS Management module coming soon...

-
+ {activeTab === 'domains' && ( + )} {activeTab === 'containers' && (