All files / src/apps/developer/pages Home.tsx

100% Statements 7/7
100% Branches 5/5
100% Functions 4/4
100% Lines 7/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187                                          1x             4x                           1x             5x                                                         1x 1x                                                                                                                                                         3x                                                            
import React from "react";
import { Link } from "react-router-dom";
import MainPage from "@/components/page/MainPage/MainPage";
import { APP_NAME, APP_ROUTES } from "@/routes/const";
import {
  KeyRound,
  Vault,
  BrickWallFire,
  Cog,
  GraduationCap,
  Terminal,
  ArrowRight,
  BookOpen,
  Zap,
  Shield,
  Code2,
  ExternalLink,
} from "lucide-react";
 
// ─── Stat card ────────────────────────────────────────────────────────────────
 
const StatCard: React.FC<{
  label: string;
  value: string;
  sub?: string;
  icon: React.ElementType;
  color?: string;
}> = ({ label, value, sub, icon: Icon, color = "text-gray-400 dark:text-gray-500" }) => (
  <div className="flex flex-col gap-2 p-4 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm">
    <div className={`flex items-center gap-1.5 text-xs font-medium ${color}`}>
      <Icon className="size-3.5" />
      {label}
    </div>
    <div className="text-2xl font-bold text-gray-900 dark:text-gray-100 tabular-nums">
      {value}
    </div>
    {sub && <div className="text-xs text-gray-400 dark:text-gray-500">{sub}</div>}
  </div>
);
 
// ─── Nav card ─────────────────────────────────────────────────────────────────
 
const NavCard: React.FC<{
  icon: React.ElementType;
  title: string;
  description: string;
  to: string;
  badge?: string;
}> = ({ icon: Icon, title, description, to, badge }) => (
  <Link
    to={to}
    className="group flex flex-col gap-3 p-5 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm hover:shadow-md hover:border-gray-300 dark:hover:border-gray-500 transition-all"
  >
    <div className="flex items-start justify-between">
      <div className="p-2 rounded-lg bg-gray-100 dark:bg-gray-700">
        <Icon className="size-4 text-gray-600 dark:text-gray-300" />
      </div>
      {badge && (
        <span className="text-xs px-2 py-0.5 rounded-full bg-blue-50 dark:bg-blue-950/40 text-blue-700 dark:text-blue-300 border border-blue-200 dark:border-blue-800 font-medium">
          {badge}
        </span>
      )}
    </div>
    <div>
      <div className="text-sm font-semibold text-gray-900 dark:text-gray-100">{title}</div>
      <div className="text-xs text-gray-400 dark:text-gray-500 mt-0.5 leading-relaxed">
        {description}
      </div>
    </div>
    <div className="flex items-center gap-1 text-xs font-medium text-gray-400 dark:text-gray-500 group-hover:text-gray-700 dark:group-hover:text-gray-300 transition-colors mt-auto">
      Open
      <ArrowRight className="size-3" />
    </div>
  </Link>
);
 
// ─── DeveloperHome ────────────────────────────────────────────────────────────
 
const DeveloperHome: React.FC = () => (
  <MainPage
    title="Developer"
    description={`Build and integrate with the ${APP_NAME} API.`}
  >
    <div className="space-y-8">
      {/* Stats */}
      <div className="grid grid-cols-2 sm:grid-cols-4 gap-4">
        <StatCard icon={KeyRound} label="API Keys" value="—" sub="Not yet tracked" />
        <StatCard icon={Vault} label="Vault Entries" value="—" sub="Not yet tracked" />
        <StatCard icon={BrickWallFire} label="Firewall Rules" value="—" sub="Not yet tracked" />
        <StatCard icon={Zap} label="API Requests" value="—" sub="Not yet tracked" />
      </div>
 
      {/* Navigation */}
      <div>
        <h2 className="text-xs font-semibold text-gray-400 dark:text-gray-500 uppercase tracking-widest mb-3">
          Quick Access
        </h2>
        <div className="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4">
          <NavCard
            icon={GraduationCap}
            title="Get Started"
            description={`New to ${APP_NAME} Developer? Follow the setup guide to integrate your first agent.`}
            to={APP_ROUTES.DEVELOPER.get_started}
            badge="Guide"
          />
          <NavCard
            icon={KeyRound}
            title="API Keys"
            description="Create and manage API keys for authenticating requests to the platform."
            to={APP_ROUTES.DEVELOPER.api_keys}
          />
          <NavCard
            icon={Vault}
            title="Key Vault"
            description="Store encrypted credentials and environment variables used by your integrations."
            to={APP_ROUTES.DEVELOPER.keyvault}
          />
          <NavCard
            icon={BrickWallFire}
            title="Firewall"
            description="Define network policies to control inbound and outbound traffic on your endpoints."
            to={APP_ROUTES.DEVELOPER.firewall}
          />
          <NavCard
            icon={Cog}
            title="Settings"
            description="Configure workspace-level developer preferences, rate limits, and environment settings."
            to={APP_ROUTES.DEVELOPER.settings}
          />
        </div>
      </div>
 
      {/* Resources */}
      <div className="rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 shadow-sm overflow-hidden">
        <div className="flex items-center gap-2 px-5 py-3.5 border-b border-gray-100 dark:border-gray-700">
          <BookOpen className="size-4 text-gray-400 dark:text-gray-500" />
          <h3 className="text-sm font-semibold text-gray-700 dark:text-gray-300">Resources</h3>
        </div>
        <div className="divide-y divide-gray-50 dark:divide-gray-700/50">
          {[
            {
              icon: Code2,
              title: "API Reference",
              description: "Full documentation of available endpoints, request schemas, and response types.",
            },
            {
              icon: Terminal,
              title: "CLI Reference",
              description: `Use the ${APP_NAME} CLI to manage resources, run tasks, and automate workflows.`,
            },
            {
              icon: Shield,
              title: "Authentication Guide",
              description: "How to authenticate API requests using API keys and Bearer tokens.",
            },
          ].map(({ icon: Icon, title, description }) => (
            <div
              key={title}
              className="flex items-start gap-4 px-5 py-4"
            >
              <div className="p-1.5 rounded-md bg-gray-100 dark:bg-gray-700 shrink-0 mt-0.5">
                <Icon className="size-3.5 text-gray-500 dark:text-gray-400" />
              </div>
              <div className="min-w-0">
                <div className="flex items-center gap-2">
                  <span className="text-sm font-medium text-gray-800 dark:text-gray-200">
                    {title}
                  </span>
                  <span className="text-xs px-1.5 py-0.5 rounded bg-gray-100 dark:bg-gray-700 text-gray-400 dark:text-gray-500">
                    Coming soon
                  </span>
                </div>
                <p className="text-xs text-gray-400 dark:text-gray-500 mt-0.5 leading-relaxed">
                  {description}
                </p>
              </div>
              <ExternalLink className="size-3.5 text-gray-300 dark:text-gray-600 shrink-0 mt-1 ml-auto" />
            </div>
          ))}
        </div>
      </div>
    </div>
  </MainPage>
);
 
export default DeveloperHome;