import { useEffect, useState } from "react"; import { useDiscordActivity } from "@/contexts/DiscordActivityContext"; import LoadingScreen from "@/components/LoadingScreen"; export default function Activity() { const { isActivity, isLoading, user, error } = useDiscordActivity(); const [showContent, setShowContent] = useState(false); useEffect(() => { // Only show content if we're actually in a Discord Activity // This is a one-time check - we don't navigate away if (isActivity && !isLoading) { setShowContent(true); } }, [isActivity, isLoading]); if (isLoading) { return ( ); } if (error) { return (

❌ Activity Error

{error}

Troubleshooting Steps:

  1. Clear your browser cache (Ctrl+Shift+Delete)
  2. Close Discord completely
  3. Reopen Discord
  4. Try opening the Activity again

💡 Open browser console (F12) and look for messages starting with{" "} [Discord Activity]

Still having issues? Check the{" "} troubleshooting guide

); } // Not in Discord Activity - show informational message if (!isActivity && !isLoading) { return (

🎮 Discord Activity

This page is designed to run as a Discord Activity. Open it within Discord to get started!

Not in Discord? Visit the main app at{" "} aethex.dev

); } if (isLoading) { return ( ); } if (error) { return (

❌ Activity Error

{error}

Troubleshooting Steps:

  1. Clear your browser cache (Ctrl+Shift+Delete)
  2. Close Discord completely
  3. Reopen Discord
  4. Try opening the Activity again

💡 Open Discord DevTools (Ctrl+Shift+I) and check the console for messages starting with{" "} [Discord Activity]

); } if (user && showContent) { const appBaseUrl = "https://aethex.dev"; return (

Welcome to AeThex, {user.full_name || user.username}! 🎉

Discord Activity

👤 Your Profile

{user.avatar_url && ( {user.full_name )}

Name: {user.full_name || "Not set"}

Username: {user.username || "Not set"}

Type: {user.user_type || "community_member"}

{user.bio && (

"{user.bio}"

)}

⚔️ Your Realm

{user.primary_arm?.toUpperCase() || "LABS"}

Your primary realm determines your Discord role and access to realm-specific features.

🚀 Quick Actions

💡 Discord Commands: Use{" "} /profile ,{" "} /set-realm , and{" "} /verify-role {" "} to manage your account directly in Discord.

); } // Still loading return ( ); }