Fix bug strip image

This commit is contained in:
decolua
2026-04-07 10:18:59 +07:00
parent a53ccf1343
commit 401772cb9a
8 changed files with 49 additions and 222 deletions
+7 -3
View File
@@ -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(() => {});
}, []);