"use client"; import { EmptyPlaceholder } from "@/components/dashboard/empty-placeholder"; import { PageHeader } from "@/components/dashboard/page-header"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Separator } from "@/components/ui/separator"; // import { PostHogIdentify } from "@/providers/PostHogProvider"; // import { useUser } from "@clerk/nextjs"; import { BookOpen, Code, Search, Settings } from "lucide-react"; import Link from "next/link"; import { useEffect, useState } from "react"; import { AttributeListItem, CreateApiButton } from "./create-api-button"; import { SheetClose } from "@/components/ui/sheet"; import { StaffState, StaffsInfo, StaffsInfoWithoutId, queryStaffList } from "@/lib/http/staff"; import { useRouter } from "next/navigation"; export type ApiWithKeys = { id: string; name: string; keys: { count: number; }[]; }[]; export function ApiList({ apis }: { apis: ApiWithKeys }) { const router = useRouter(); // const { user, isLoaded } = useUser(); useEffect(() => { if (apis.length) { setLocalData(apis); } }, [apis]); const [localData, setLocalData] = useState(apis); const [staffsList, setStaffsList] = useState([]); useEffect(() => { // console.log("------------email", infoRef.current, userData.auth_token) async function initFunc() { const data = await queryStaffList({}) setStaffsList(data.data.list) } initFunc() }, []); function toString(state: StaffState): string { switch (state) { case StaffState.Inactive: return "未激活"; case StaffState.Active: return "正常"; case StaffState.ApproachingExpiration: return "接近过期"; case StaffState.Expired: return "已过期"; default: return "未知状态"; } } const renderContent = (state: StaffState, staffId: number) => { switch (state) { case StaffState.Inactive: return ; case StaffState.Active: return "正常"; case StaffState.ApproachingExpiration: return "接近过期"; case StaffState.Expired: return "已过期"; default: return "未知状态"; } }; // if (isLoaded && user) { // PostHogIdentify({ user }); // } return (
{/*
{ const filtered = apis.filter((a) => a.name.toLowerCase().includes(e.target.value.toLowerCase()), ); setLocalData(filtered); }} />
*/} {/* */}
{apis.length ? (
    {staffsList.map((api) => (
    {api.name}
    {/* http://localhost:3000/staffai/xxxxx/ */} {/* {`${window.location.origin}/staffai/${api.id}`} */} {`${api.id}`}
    AI 员工
    {/* {api.keys.at(0)?.count ?? 0} */} {renderContent(api.state as StaffState, api.id)} {/* {toString(api.state as StaffState)} */}
    ))}
) : ( No APIs found You haven't created any APIs yet. Create one to get started.
)}
); }