@@ -108,12 +106,32 @@ const NavbarContent = ({
}: NavbarContentProps) => {
const shouldFetchKey = Boolean(keyspaceId && keyId);
- // If we expected to find a key but this component doesn't handle key details,
- // we should handle this at a higher level or in a different component
- if (shouldFetchKey) {
- console.warn("Key fetching logic should be handled at a higher level");
+ // Fetch key details when viewing a specific key
+ const {
+ data: keyData,
+ isLoading: isKeyLoading,
+ error: keyError,
+ } = trpc.api.keys.list.useQuery(
+ {
+ // This cannot be empty string but required to silence TS errors
+ keyAuthId: keyspaceId ?? "",
+ // This cannot be empty string but required to silence TS errors
+ keyIds: [{ operator: "is", value: keyId ?? "" }],
+ cursor: null,
+ identities: null,
+ limit: 1,
+ names: null,
+ },
+ {
+ enabled: shouldFetchKey,
+ },
+ );
+
+ if (keyError) {
+ throw new Error(`Failed to fetch key details: ${keyError.message}`);
}
+ const specificKey = keyData?.keys.find((key) => key.id === keyId);
const { currentApi } = layoutData;
// Define base path for API navigation
@@ -171,19 +189,34 @@ const NavbarContent = ({
- {layoutData.keyAuth ? (
-
- ) : (
-
-
- Create new key
-
- )}
+
+ {shouldFetchKey && specificKey ? (
+ <>
+
+
+ >
+ ) : shouldFetchKey && isKeyLoading ? (
+ <>
+
+
+ Settings
+
+
+ >
+ ) : layoutData.keyAuth ? (
+
+ ) : (
+
+
+ Create new key
+
+ )}
+