fix(integrations): clarify support mode API access

This commit is contained in:
Inamul-hasan-tec
2026-08-31 18:13:04 +05:30
parent 0f8e7cebc1
commit cc9807b70d
2 changed files with 18 additions and 2 deletions
@@ -1,6 +1,7 @@
import { useEffect, useState } from "react";
import { Copy, KeyRound, Plus, ShieldCheck, Trash2 } from "lucide-react";
import apiClient from "../../../api/axiosInstance";
import { useAppSelector } from "../../../store";
type ApiKeyRecord = {
id: string; name: string; prefix: string; scopes: string[]; status: string;
@@ -10,6 +11,9 @@ type ApiKeyRecord = {
type ApiResponse<T> = { success: boolean; data: T };
export default function ApiAccessTab() {
const user = useAppSelector((state) => state.auth.user);
const isPlatformUser = user?.type === "platform" || user?.user_type === "platform";
const isSupportMode = isPlatformUser && Boolean(localStorage.getItem("impersonatedTenantId"));
const [keys, setKeys] = useState<ApiKeyRecord[]>([]);
const [name, setName] = useState("");
const [expiresInDays, setExpiresInDays] = useState(90);
@@ -22,7 +26,19 @@ export default function ApiAccessTab() {
setKeys(response.data || []);
};
useEffect(() => { load().catch(() => setError("Could not load API keys.")); }, []);
useEffect(() => {
if (!isSupportMode) load().catch((cause: any) => setError(cause?.response?.data?.message || "Could not load API keys."));
}, [isSupportMode]);
if (isSupportMode) {
return (
<div className="rounded-lg border border-amber-300 bg-amber-50 p-5 text-sm text-amber-950">
<div className="flex items-center gap-2 font-semibold"><ShieldCheck className="h-4 w-4" />API-key management is protected in Support Mode</div>
<p className="mt-2">Platform support can inspect tenant data for troubleshooting, but cannot create, view, or revoke credentials on the tenant's behalf.</p>
<p className="mt-2">A real tenant administrator must sign in to this workspace and open <strong>Integration Hub API Access</strong> to manage product API keys.</p>
</div>
);
}
const createKey = async () => {
setBusy(true); setError("");
@@ -412,7 +412,7 @@ export default function NewIntegration() {
>
<option value="">Select a channel from Channel Registry...</option>
{channels.map((chan) => (
<option key={chan.id} value={chan.code || chan.id}>
<option key={chan.id} value={chan.id}>
{chan.name} ({chan.code})
</option>
))}