mirror of
https://github.com/Dictionarry-Hub/profilarr.git
synced 2026-01-27 21:20:53 +01:00
feat(delete): Improve delete functionality - Don't allow deletion of regex / format in use - Add confirmation for deleting before allowing request
This commit is contained in:
committed by
Sam Chau
parent
8cb3d7a827
commit
174e4ec82d
@@ -32,11 +32,11 @@ export const updateRegex = async (id, regex) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteRegex = async (id) => {
|
||||
export const deleteRegex = async (id, force = false) => {
|
||||
try {
|
||||
const response = await axios.delete(`${API_BASE_URL}/regex/${id}`, {
|
||||
const response = await axios.delete(`${API_BASE_URL}/regex/${id}${force ? '?force=true' : ''}`, {
|
||||
validateStatus: (status) => {
|
||||
return status >= 200 && status < 300 || status === 409; // Accept 200-299 or 409 Conflict
|
||||
return status >= 200 && status < 300 || status === 400 || status === 409;
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
@@ -76,9 +76,13 @@ export const updateFormat = async (id, format) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const deleteFormat = async (id) => {
|
||||
export const deleteFormat = async (id, force = false) => {
|
||||
try {
|
||||
const response = await axios.delete(`${API_BASE_URL}/format/${id}`);
|
||||
const response = await axios.delete(`${API_BASE_URL}/format/${id}${force ? '?force=true' : ''}`, {
|
||||
validateStatus: (status) => {
|
||||
return status >= 200 && status < 300 || status === 400 || status === 409;
|
||||
}
|
||||
});
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.error('Error deleting format:', error);
|
||||
|
||||
Reference in New Issue
Block a user