mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 20:00:47 +00:00
Fix bug strip image
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
import { useState, useEffect, useMemo, useCallback } from "react";
|
||||
import { useSearchParams, useRouter } from "next/navigation";
|
||||
import { FREE_PROVIDERS } from "@/shared/constants/providers";
|
||||
import Badge from "./Badge";
|
||||
import Card from "./Card";
|
||||
import OverviewCards from "@/app/(dashboard)/dashboard/usage/components/OverviewCards";
|
||||
@@ -196,18 +197,21 @@ export default function UsageStats() {
|
||||
const [period, setPeriod] = useState("7d");
|
||||
|
||||
// Fetch connected providers once, deduplicate by provider type
|
||||
// Always include noAuth free providers (e.g. opencode) regardless of connections
|
||||
useEffect(() => {
|
||||
fetch("/api/providers")
|
||||
.then((r) => r.ok ? r.json() : null)
|
||||
.then((d) => {
|
||||
if (!d?.connections) return;
|
||||
const seen = new Set();
|
||||
const unique = d.connections.filter((c) => {
|
||||
const unique = (d?.connections || []).filter((c) => {
|
||||
if (seen.has(c.provider)) return false;
|
||||
seen.add(c.provider);
|
||||
return true;
|
||||
});
|
||||
setProviders(unique);
|
||||
const noAuthProviders = Object.values(FREE_PROVIDERS)
|
||||
.filter((p) => p.noAuth && !seen.has(p.id))
|
||||
.map((p) => ({ provider: p.id, name: p.name }));
|
||||
setProviders([...unique, ...noAuthProviders]);
|
||||
})
|
||||
.catch(() => {});
|
||||
}, []);
|
||||
|
||||
Reference in New Issue
Block a user