"use client"; import React, { useState, useEffect } from "react"; import Link from "next/link"; import axios from "axios"; import { ApiServerBaseUrl } from "@/utils/baseurl.utils"; import { Instagram, UserCircle2, TrendingUp, BarChart3, MessageSquare, Image as ImageIcon, Shield, CheckCircle, AlertCircle, Sparkles, Zap, Users, Clock, Globe } from "lucide-react"; const DashboardPage = () => { const [connectionStatus, setConnectionStatus] = useState<"connected" | "not_connected" | "loading" | "error">("loading"); const [instagramUsername, setInstagramUsername] = useState(null); const [stats, setStats] = useState({ posts: 0, comments: 0, followers: 0 }); // Check Instagram connection status useEffect(() => { async function checkConnection() { try { const userId = localStorage.getItem("user_email"); const res = await axios.get( `${ApiServerBaseUrl}/social/auth/status`, { params: { userId }, withCredentials: true } ); if (res.data.connected) { setConnectionStatus("connected"); if (res.data.username) { setInstagramUsername(res.data.username); } // Fetch basic stats if connected fetchInstagramStats(); } else { setConnectionStatus("not_connected"); } } catch (err) { console.error(err); setConnectionStatus("error"); } } async function fetchInstagramStats() { try { // This would be replaced with your actual API call // For now, using mock data setStats({ posts: 42, comments: 156, followers: 1250 }); } catch (err) { console.error("Failed to fetch stats:", err); } } checkConnection(); }, []); const cards = [ { name: "Instagram Media", icon: , description: "Browse and manage your Instagram posts, stories, and media library.", link: "/social-media-posts", title: "View and organize your Instagram media content", status: connectionStatus === "connected" ? "active" : "requires-connection", badge: connectionStatus === "connected" ? "Connected" : "Connect Required" }, { name: "Social Media Channels", icon: , description: "Manage all your connected social media profiles and channels in one place.", link: "/social-media-channels", title: "Toggle and manage your connected social media channels", status: "active", badge: "Manage" }, { name: "Performance Insights", icon: , description: "Track engagement, reach, and growth metrics for your Instagram content.", link: "/insights", title: "View analytics and performance insights", status: connectionStatus === "connected" ? "active" : "requires-connection", badge: connectionStatus === "connected" ? "Available" : "Connect Required" }, { name: "Comment Management", icon: , description: "Reply, hide, or delete comments across your Instagram posts efficiently.", link: "/comments", title: "Manage Instagram comments from one dashboard", status: connectionStatus === "connected" ? "active" : "requires-connection", badge: connectionStatus === "connected" ? "Ready" : "Connect Required" }, { name: "Account Settings", icon: , description: "Manage your profile, billing, subscription, and preferences.", link: "/account-settings", title: "Account configuration and settings", status: "active", badge: "Settings" }, { name: "Quick Actions", icon: , description: "Quick access to common tasks and time-saving features.", link: "/quick-actions", title: "Quick action shortcuts", status: "active", badge: "New" }, ]; const quickStats = [ { label: "Instagram Posts", value: stats.posts || "-", icon: , color: "from-pink-500/20 to-pink-600/10" }, { label: "Total Comments", value: stats.comments || "-", icon: , color: "from-blue-500/20 to-blue-600/10" }, { label: "Followers", value: stats.followers ? `${stats.followers}` : "-", icon: , color: "from-green-500/20 to-green-600/10" } ]; const benefits = [ { icon: , text: "Save hours weekly on social media management" }, { icon: , text: "Engage with your audience more effectively" }, { icon: , text: "Make data-driven decisions with insights" }, { icon: , text: "Complete control over your content and interactions" } ]; return (
{/* Floating background bubbles */}
{/* Main container */}
{/* Header Section */}

Social Buddy Dashboard

Welcome back! Manage your social presence effortlessly.

{/* Connection Status Badge */}

{connectionStatus === "connected" ? "Instagram Connected" : connectionStatus === "not_connected" ? "Instagram Not Connected" : "Checking Connection..."}

{connectionStatus === "connected" && instagramUsername && (

@{instagramUsername}

)}
{/* Quick Stats */}
{quickStats.map((stat, index) => (
{stat.label} {stat.icon}
{stat.value}
{connectionStatus !== "connected" && stat.value === "-" && (

Connect Instagram to view

)}
))}
{/* Main Content Grid */}
{/* Left Column - Features Grid */}

Available Features

All the tools you need to manage your Instagram presence efficiently.

{cards.map((card) => ( {/* Status Badge */}
{card.badge}
{/* Icon */}
{card.icon}
{/* Content */}

{card.name}

{card.description}

{/* Arrow indicator */}
{card.status === "requires-connection" && connectionStatus === "not_connected" ? ( Connect Instagram first ) : ( Click to access )}
{/* Hover overlay */}
))}
{/* Connection Prompt */} {connectionStatus === "not_connected" && (

Connect Your Instagram Account

Unlock the full potential of Social Buddy by connecting your Instagram account. Access media management, insights, and comment tools in one dashboard.

Connect Instagram Now
)}
{/* Right Column - Sidebar */}
{/* Benefits Card */}

Why Social Buddy?

{benefits.map((benefit, index) => (
{benefit.icon}

{benefit.text}

))}
{/* Connection Status Card */}

Connection Status

Instagram
{connectionStatus === "connected" ? "Connected" : connectionStatus === "not_connected" ? "Not Connected" : "Checking..."}
Media Access {connectionStatus === "connected" ? "✓ Available" : "—"}
Insights Access {connectionStatus === "connected" ? "✓ Available" : "—"}
Comment Management {connectionStatus === "connected" ? "✓ Available" : "—"}
{connectionStatus === "not_connected" && ( Connect Instagram )} {connectionStatus === "connected" && ( Manage Connection )}
{/* Quick Tips */}

Quick Tips

  • 1
    Connect Instagram to unlock all features
  • 2
    Check your media library for post management
  • 3
    Use insights to track content performance
{/* Animation Styles */}
); }; export default DashboardPage;