remove bookmarks

This commit is contained in:
Baghi 2025-04-17 18:17:58 +03:30
parent 52760b0150
commit 6054491d1b

View File

@ -1,4 +1,6 @@
<script setup> <script setup>
import hadithaApi from "@haditha/apis/hadithaApi";
const httpService = useNuxtApp()["$http"];
const props = defineProps({ const props = defineProps({
list: { list: {
default() { default() {
@ -16,6 +18,7 @@ const props = defineProps({
}, },
}); });
const router = useRouter(); const router = useRouter();
const route = useRoute();
// const modal = useModal(); // const modal = useModal();
// const isModalOpen = ref(false); // const isModalOpen = ref(false);
@ -24,7 +27,7 @@ function openModal(selectedItem) {
// modal.open(SearchShow, { title: "Welcome" }); // modal.open(SearchShow, { title: "Welcome" });
// isModalOpen.value = true; // isModalOpen.value = true;
const slug = selectedItem._source.content const slug = selectedItem?._source?.content
.split(" ") .split(" ")
.filter((v, i) => i < 4) .filter((v, i) => i < 4)
.join("-"); .join("-");
@ -32,7 +35,7 @@ function openModal(selectedItem) {
router.push({ router.push({
name: "hadithaSearchShow", name: "hadithaSearchShow",
params: { params: {
id: selectedItem._source.id, id: selectedItem?._source?.id,
slug: slug, slug: slug,
}, },
query: { query: {
@ -55,6 +58,20 @@ function openModal(selectedItem) {
// const SearchShow = defineAsyncComponent(() => // const SearchShow = defineAsyncComponent(() =>
// import("@haditha/components/haditha/search-page/SearchShow.vue") // import("@haditha/components/haditha/search-page/SearchShow.vue")
// ); // );
const removeFromFavorites = async (item = {}, index = 0) => {
let url = repoUrl() + hadithaApi.favorite.deleteByRefid;
url = url.replace("{{data_type}}", "bookmark");
url = url.replace("{{index_key}}", "dhparag");
url = url.replace("{{ref_id}}", item._id);
const formData = {
ref_id: item._id,
title: item?._source?.title,
};
httpService.postRequest(url, formData).then((res) => {
// this.updateListAnswer(index, "tbookmark", 0);
});
};
</script> </script>
<template> <template>
@ -71,9 +88,20 @@ function openModal(selectedItem) {
v-for="(item, index) in props.list" v-for="(item, index) in props.list"
:key="index" :key="index"
> >
<div class="flex justify-end mt-2">
<UButton
v-if="route.name == 'hadithaFavorites'"
class=""
@click="removeFromFavorites(item)"
icon="i-haditha-close"
variant=""
/>
</div>
<a <a
:href="`/haditha/search/${item._source.id}/${ :href="`/haditha/search/${item?._source?.id}/${
item._source.meta.hadith_masoum ?? item?._source?.meta?.hadith_sanad item?._source?.meta?.hadith_masoum ??
item?._source?.meta?.hadith_sanad
}`" }`"
@click.prevent="openModal(item)" @click.prevent="openModal(item)"
class="from-person block" class="from-person block"
@ -86,13 +114,13 @@ function openModal(selectedItem) {
<a <a
@click.prevent="openModal(item)" @click.prevent="openModal(item)"
class="arabic-text block" class="arabic-text block"
:href="`/haditha/search/${item._source.id}/${item._source.content_ar}`" :href="`/haditha/search/${item?._source?.id}/${item?._source?.content_ar}`"
> >
{{ item?._source?.content_ar }} {{ item?._source?.content_ar }}
</a> </a>
<a <a
@click.prevent="openModal(item)" @click.prevent="openModal(item)"
:href="`/haditha/search/${item._source.id}/${item._source.content}`" :href="`/haditha/search/${item?._source?.id}/${item?._source?.content}`"
class="persian-text block" class="persian-text block"
v-html="item?.highlight?.['content.fa'] ?? item?._source?.content" v-html="item?.highlight?.['content.fa'] ?? item?._source?.content"
></a> ></a>