diff --git a/components/dashboard/dashboard-controls.tsx b/components/dashboard/dashboard-controls.tsx index 4fd0512..1e0b565 100644 --- a/components/dashboard/dashboard-controls.tsx +++ b/components/dashboard/dashboard-controls.tsx @@ -49,6 +49,18 @@ type Props = { >; }; +function getDomainStatusBadge(status: string | null) { + const normalized = (status ?? "unknown").toLowerCase(); + + if (normalized === "active") return "bg-emerald-100 text-emerald-700"; + + if (normalized === "suspended") return "bg-rose-100 text-rose-700"; + + if (normalized === "inactive") return "bg-amber-100 text-amber-700"; + + return "bg-slate-100 text-slate-600"; +} + export function DashboardControls({ instances, subscriptions, @@ -351,14 +363,28 @@ export function DashboardControls({ {instance.status}

- Last sync: {formatDateTime(instance.last_sync_at)} - {instance.last_sync_status - ? ` (${instance.last_sync_status})` - : ""} + Subscriptions: {instance.last_sync_subscriptions ?? 0}

- Last counts: {instance.last_sync_subscriptions ?? 0}{" "} - subscriptions, {instance.last_sync_domains ?? 0} domains + Domains: {instance.last_sync_domains ?? 0} +

+

+ Last sync status:{" "} + + {instance.last_sync_status ?? "unknown"} + +

+

+ Last sync time: {formatDateTime(instance.last_sync_at)}

Last connected:{" "} @@ -525,7 +551,11 @@ export function DashboardControls({ {domain.domain_name} - {domain.status ?? "unknown"} + + {domain.status ?? "unknown"} + {domain.hosting_type ?? "unknown"} diff --git a/lib/plesk/sync.ts b/lib/plesk/sync.ts index 01dec75..d68df80 100644 --- a/lib/plesk/sync.ts +++ b/lib/plesk/sync.ts @@ -117,6 +117,9 @@ export async function syncPleskInstance( .map((item: any) => { const domainId = item?.id ?? item?.guid ?? item?.name; const domainName = item?.name ?? item?.domain_name ?? item?.domain; + const status = + item?.status ?? + (item?.hosting_type === "virtual" ? "active" : "inactive"); const externalSubscriptionId = item?.subscription?.id ?? item?.subscription_id ?? item?.webspace_id; const rawCreated = item?.created_at ?? item?.created; @@ -141,12 +144,8 @@ export async function syncPleskInstance( : null, plesk_domain_id: String(domainId), domain_name: String(domainName), - status: item?.status ? String(item.status) : null, - hosting_type: item?.hosting_type - ? String(item.hosting_type) - : item?.hosting?.type - ? String(item.hosting.type) - : null, + status: status ? String(status) : "unknown", + hosting_type: item?.hosting_type ? String(item.hosting_type) : null, source_created_at: sourceCreatedAt, aliases_count: aliasesCount, };