forked from phoenix/litellm-mirror
(ui) improve message on deleting keys
This commit is contained in:
parent
9852462d1f
commit
aa55da8fdc
1 changed files with 17 additions and 5 deletions
|
@ -3,10 +3,12 @@
|
||||||
*/
|
*/
|
||||||
import { message } from 'antd';
|
import { message } from 'antd';
|
||||||
|
|
||||||
|
const proxyBaseUrl = null
|
||||||
|
|
||||||
export const keyCreateCall = async (
|
export const keyCreateCall = async (
|
||||||
accessToken: string,
|
accessToken: string,
|
||||||
userID: string,
|
userID: string,
|
||||||
formValues: Record<string, any> // Assuming formValues is an object
|
formValues: Record<string, any>, // Assuming formValues is an object
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
console.log("Form Values in keyCreateCall:", formValues); // Log the form values before making the API call
|
console.log("Form Values in keyCreateCall:", formValues); // Log the form values before making the API call
|
||||||
|
@ -20,8 +22,8 @@ export const keyCreateCall = async (
|
||||||
message.error("Failed to parse metadata: " + error);
|
message.error("Failed to parse metadata: " + error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const url = proxyBaseUrl ? `${proxyBaseUrl}/key/generate` : `/key/generate`;
|
||||||
const response = await fetch(`/key/generate`, {
|
const response = await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${accessToken}`,
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
@ -56,7 +58,10 @@ export const keyDeleteCall = async (
|
||||||
user_key: String
|
user_key: String
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch(`/key/delete`, {
|
const url = proxyBaseUrl ? `${proxyBaseUrl}/key/delete` : `/key/delete`;
|
||||||
|
console.log("in keyDeleteCall:", user_key)
|
||||||
|
|
||||||
|
const response = await fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
headers: {
|
headers: {
|
||||||
Authorization: `Bearer ${accessToken}`,
|
Authorization: `Bearer ${accessToken}`,
|
||||||
|
@ -68,11 +73,14 @@ export const keyDeleteCall = async (
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
const errorData = await response.text();
|
||||||
|
message.error("Failed to delete key: " + errorData);
|
||||||
throw new Error("Network response was not ok");
|
throw new Error("Network response was not ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
console.log(data);
|
console.log(data);
|
||||||
|
message.success("API Key Deleted");
|
||||||
return data;
|
return data;
|
||||||
// Handle success - you might want to update some state or UI based on the created key
|
// Handle success - you might want to update some state or UI based on the created key
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -86,8 +94,10 @@ export const userInfoCall = async (
|
||||||
userID: String
|
userID: String
|
||||||
) => {
|
) => {
|
||||||
try {
|
try {
|
||||||
|
const url = proxyBaseUrl ? `${proxyBaseUrl}/user/info` : `/user/info`;
|
||||||
|
console.log("in userInfoCall:", url)
|
||||||
const response = await fetch(
|
const response = await fetch(
|
||||||
`/user/info?user_id=${userID}`,
|
`${url}/?user_id=${userID}`,
|
||||||
{
|
{
|
||||||
method: "GET",
|
method: "GET",
|
||||||
headers: {
|
headers: {
|
||||||
|
@ -98,6 +108,8 @@ export const userInfoCall = async (
|
||||||
);
|
);
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
|
const errorData = await response.text();
|
||||||
|
message.error(errorData);
|
||||||
throw new Error("Network response was not ok");
|
throw new Error("Network response was not ok");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue