21 lines
483 B
JavaScript
21 lines
483 B
JavaScript
import {showToast} from "./toast.js";
|
|
|
|
export const deleteRecentSearch = async (e, id) => {
|
|
try {
|
|
const li = e.closest('li');
|
|
const ol = li.closest('ol');
|
|
|
|
li.remove();
|
|
|
|
if (ol.childElementCount === 0) {
|
|
ol.remove();
|
|
}
|
|
|
|
const response = await axios.delete('api/recent-search/' + id);
|
|
showToast(response.data.message)
|
|
} catch (e) {
|
|
showToast('Something went wrong!')
|
|
console.error(e)
|
|
}
|
|
}
|