feat: e2e flow complete - admin can invite new users to proxy via invite links

Completes https://github.com/BerriAI/litellm/issues/3863
This commit is contained in:
Krrish Dholakia 2024-05-27 23:19:30 -07:00
parent 073bca78d4
commit 293d5cf1f2
6 changed files with 614 additions and 242 deletions

View file

@ -208,6 +208,81 @@ export const budgetCreateCall = async (
}
};
export const invitationCreateCall = async (
accessToken: string,
userID: string // Assuming formValues is an object
) => {
try {
const url = proxyBaseUrl
? `${proxyBaseUrl}/invitation/new`
: `/invitation/new`;
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
user_id: userID, // Include formValues in the request body
}),
});
if (!response.ok) {
const errorData = await response.text();
message.error("Failed to create key: " + errorData, 10);
console.error("Error response from the server:", errorData);
throw new Error("Network response was not ok");
}
const data = await response.json();
console.log("API Response:", data);
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
console.error("Failed to create key:", error);
throw error;
}
};
export const invitationClaimCall = async (
accessToken: string,
formValues: Record<string, any> // Assuming formValues is an object
) => {
try {
console.log("Form Values in invitationCreateCall:", formValues); // Log the form values before making the API call
console.log("Form Values after check:", formValues);
const url = proxyBaseUrl
? `${proxyBaseUrl}/invitation/claim`
: `/invitation/claim`;
const response = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
...formValues, // Include formValues in the request body
}),
});
if (!response.ok) {
const errorData = await response.text();
message.error("Failed to create key: " + errorData, 10);
console.error("Error response from the server:", errorData);
throw new Error("Network response was not ok");
}
const data = await response.json();
console.log("API Response:", data);
return data;
// Handle success - you might want to update some state or UI based on the created key
} catch (error) {
console.error("Failed to create key:", error);
throw error;
}
};
export const alertingSettingsCall = async (accessToken: String) => {
/**
* Get all configurable params for setting a model