remove bookmarks
This commit is contained in:
parent
52760b0150
commit
6054491d1b
|
@ -1,4 +1,6 @@
|
|||
<script setup>
|
||||
import hadithaApi from "@haditha/apis/hadithaApi";
|
||||
const httpService = useNuxtApp()["$http"];
|
||||
const props = defineProps({
|
||||
list: {
|
||||
default() {
|
||||
|
@ -16,6 +18,7 @@ const props = defineProps({
|
|||
},
|
||||
});
|
||||
const router = useRouter();
|
||||
const route = useRoute();
|
||||
|
||||
// const modal = useModal();
|
||||
// const isModalOpen = ref(false);
|
||||
|
@ -24,7 +27,7 @@ function openModal(selectedItem) {
|
|||
// modal.open(SearchShow, { title: "Welcome" });
|
||||
// isModalOpen.value = true;
|
||||
|
||||
const slug = selectedItem._source.content
|
||||
const slug = selectedItem?._source?.content
|
||||
.split(" ")
|
||||
.filter((v, i) => i < 4)
|
||||
.join("-");
|
||||
|
@ -32,7 +35,7 @@ function openModal(selectedItem) {
|
|||
router.push({
|
||||
name: "hadithaSearchShow",
|
||||
params: {
|
||||
id: selectedItem._source.id,
|
||||
id: selectedItem?._source?.id,
|
||||
slug: slug,
|
||||
},
|
||||
query: {
|
||||
|
@ -55,6 +58,20 @@ function openModal(selectedItem) {
|
|||
// const SearchShow = defineAsyncComponent(() =>
|
||||
// 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>
|
||||
|
||||
<template>
|
||||
|
@ -71,9 +88,20 @@ function openModal(selectedItem) {
|
|||
v-for="(item, index) in props.list"
|
||||
: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
|
||||
:href="`/haditha/search/${item._source.id}/${
|
||||
item._source.meta.hadith_masoum ?? item?._source?.meta?.hadith_sanad
|
||||
:href="`/haditha/search/${item?._source?.id}/${
|
||||
item?._source?.meta?.hadith_masoum ??
|
||||
item?._source?.meta?.hadith_sanad
|
||||
}`"
|
||||
@click.prevent="openModal(item)"
|
||||
class="from-person block"
|
||||
|
@ -86,13 +114,13 @@ function openModal(selectedItem) {
|
|||
<a
|
||||
@click.prevent="openModal(item)"
|
||||
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 }}
|
||||
</a>
|
||||
<a
|
||||
@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"
|
||||
v-html="item?.highlight?.['content.fa'] ?? item?._source?.content"
|
||||
></a>
|
||||
|
|
Loading…
Reference in New Issue
Block a user