Route corrected

This commit is contained in:
AmitChauhan63390
2024-11-15 22:26:36 +05:30
parent 8eedca1b1e
commit 8d4994c8c7
4 changed files with 93 additions and 32 deletions

View File

@@ -9,6 +9,7 @@ import { apiUrl } from "../apiConfig";
export const getStoredRecordings = async (): Promise<string[] | null> => {
try {
const response = await axios.get(`${apiUrl}/storage/recordings`);
@@ -52,24 +53,15 @@ export const getStoredRecording = async (id: string) => {
}
export const checkRunsForRecording = async (id: string): Promise<boolean> => {
const apiKey = localStorage.getItem('x-api-key');
// Check if the API key exists
if (!apiKey) {
console.error('API key is missing.');
return false;
}
try {
const response = await axios.get(`${apiUrl}/api/robots/${id}/runs`, {
headers: {
'x-api-key': apiKey, // Pass the valid API key in the header
},
withCredentials: true,
});
const response = await axios.get(`${apiUrl}/storage/recordings/${id}/runs`);
const runs = response.data;
console.log(runs.runs.totalCount)
return runs.runs.totalCount > 0;
} catch (error) {
console.error('Error checking runs for recording:', error);
@@ -77,6 +69,7 @@ export const checkRunsForRecording = async (id: string): Promise<boolean> => {
}
};
export const deleteRecordingFromStorage = async (id: string): Promise<boolean> => {
const hasRuns = await checkRunsForRecording(id);
@@ -85,7 +78,6 @@ export const deleteRecordingFromStorage = async (id: string): Promise<boolean> =
return false;
}
try {
const response = await axios.delete(`${apiUrl}/storage/recordings/${id}`);
if (response.status === 200) {
@@ -99,6 +91,10 @@ export const deleteRecordingFromStorage = async (id: string): Promise<boolean> =
return false;
}
};
export const deleteRunFromStorage = async (id: string): Promise<boolean> => {