798 lines
36 KiB
JavaScript
798 lines
36 KiB
JavaScript
import { defineComponent, ref, watch, mergeProps, withCtx, unref, createVNode, toDisplayString, createBlock, createCommentVNode, withDirectives, openBlock, Fragment, renderList, vShow, nextTick, resolveDirective, reactive, useSSRContext } from 'vue';
|
|
import { ssrRenderComponent, ssrInterpolate, ssrRenderClass, ssrRenderList, ssrRenderStyle, ssrRenderAttrs, ssrRenderAttr, ssrGetDirectiveProps } from 'vue/server-renderer';
|
|
import { Q as supabaseService, u as useRouter$1, a as useConfigStore, b as useUserStore, P as myAxios, o as useIntersectionObserver, p as getToken, T as __nuxt_component_0$2, U as baseConfirm, D as reactiveProjectName, C as getSupabaseStorageUrl, d as api$1, B as useElementSize$1, V as deleteProductById, s as supabase } from './server.mjs';
|
|
import { B as BasicSheet } from './index-CM92jef_.mjs';
|
|
import { U as UserProfilePic } from './UserProfilePic-CmaGJi8K.mjs';
|
|
import { B as BasicButton } from './BasicButton-B9iMRxfW.mjs';
|
|
import { B as BasicIconOld } from './BasicIconOld-93vAWohq.mjs';
|
|
import { a as formatTimeShort } from './useDateTime-D8RCoGwW.mjs';
|
|
import { e as empty_user } from './empty_user-BaUNCdgf.mjs';
|
|
import { _ as _sfc_main$8 } from './like-BhIOg3YL.mjs';
|
|
import { ContentLoader } from 'vue-content-loader';
|
|
import { u as useProductStore } from './product-EzgZgQkP.mjs';
|
|
|
|
const _imports_0$2 = "data:image/svg+xml,%3csvg%20width='21'%20height='21'%20viewBox='0%200%2021%2021'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M18.7431%2015.215C19.5381%2013.825%2020.0031%2012.22%2020.0031%2010.5C20.0031%205.255%2015.7481%201%2010.5031%201C5.25811%201%201.00311%205.255%201.00311%2010.5C1.00311%2015.745%205.25811%2020%2010.5031%2020C12.2581%2020%2013.8931%2019.515%2015.3031%2018.69L19.3581%2019.775C19.6481%2019.855%2019.9181%2019.585%2019.8381%2019.295L18.7431%2015.215Z'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e";
|
|
const _imports_1$2 = "data:image/svg+xml,%3csvg%20width='21'%20height='21'%20viewBox='0%200%2021%2021'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M18.7431%2015.215C19.5381%2013.825%2020.0031%2012.22%2020.0031%2010.5C20.0031%205.255%2015.7481%201%2010.5031%201C5.25811%201%201.00311%205.255%201.00311%2010.5C1.00311%2015.745%205.25811%2020%2010.5031%2020C12.2581%2020%2013.8931%2019.515%2015.3031%2018.69L19.3581%2019.775C19.6481%2019.855%2019.9181%2019.585%2019.8381%2019.295L18.7431%2015.215Z'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e";
|
|
const _sfc_main$7 = /* @__PURE__ */ defineComponent({
|
|
__name: "comment",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
const config = useConfigStore();
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
if (unref(config).isNightStore) {
|
|
_push(`<img${ssrRenderAttrs(mergeProps({
|
|
src: _imports_0$2,
|
|
alt: "comment",
|
|
"cursor-pointer": ""
|
|
}, _attrs))}>`);
|
|
} else {
|
|
_push(`<img${ssrRenderAttrs(mergeProps({
|
|
src: _imports_1$2,
|
|
alt: "comment",
|
|
"cursor-pointer": ""
|
|
}, _attrs))}>`);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup$7 = _sfc_main$7.setup;
|
|
_sfc_main$7.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("assets/img/icons/comment.vue");
|
|
return _sfc_setup$7 ? _sfc_setup$7(props, ctx) : void 0;
|
|
};
|
|
const _imports_0$1 = "data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e";
|
|
const _imports_1$1 = "data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e";
|
|
const _imports_2 = "data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20fill='white'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e";
|
|
const _imports_3 = "data:image/svg+xml,%3csvg%20width='18'%20height='20'%20viewBox='0%200%2018%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M9%2011.5L16.94%2019H17V1H1V19H1.06L9%2011.5Z'%20fill='black'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e";
|
|
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
__name: "save",
|
|
__ssrInlineRender: true,
|
|
props: {
|
|
isSaved: { type: Boolean }
|
|
},
|
|
setup(__props) {
|
|
const config = useConfigStore();
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
if (!_ctx.isSaved) {
|
|
if (unref(config).isNightStore) {
|
|
_push(`<img${ssrRenderAttr("src", _imports_0$1)} alt="comment" cursor-pointer>`);
|
|
} else {
|
|
_push(`<img${ssrRenderAttr("src", _imports_1$1)} alt="comment" cursor-pointer>`);
|
|
}
|
|
} else {
|
|
if (unref(config).isNightStore) {
|
|
_push(`<img${ssrRenderAttr("src", _imports_2)} alt="comment" cursor-pointer>`);
|
|
} else {
|
|
_push(`<img${ssrRenderAttr("src", _imports_3)} alt="comment" cursor-pointer>`);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup$6 = _sfc_main$6.setup;
|
|
_sfc_main$6.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("assets/img/icons/save.vue");
|
|
return _sfc_setup$6 ? _sfc_setup$6(props, ctx) : void 0;
|
|
};
|
|
const _imports_0 = "data:image/svg+xml,%3csvg%20width='22'%20height='20'%20viewBox='0%200%2022%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0031%201H1.00311L8.50311%208.5M21.0031%201L10.5031%2018.5L8.50311%208.5M21.0031%201L8.50311%208.5'%20stroke='white'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e";
|
|
const _imports_1 = "data:image/svg+xml,%3csvg%20width='22'%20height='20'%20viewBox='0%200%2022%2020'%20fill='none'%20xmlns='http://www.w3.org/2000/svg'%3e%3cpath%20d='M21.0031%201H1.00311L8.50311%208.5M21.0031%201L10.5031%2018.5L8.50311%208.5M21.0031%201L8.50311%208.5'%20stroke='black'%20stroke-width='2'%20stroke-linejoin='round'/%3e%3c/svg%3e";
|
|
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
__name: "share",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
const config = useConfigStore();
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
if (unref(config).isNightStore) {
|
|
_push(`<img${ssrRenderAttrs(mergeProps({
|
|
src: _imports_0,
|
|
alt: "comment",
|
|
"cursor-pointer": ""
|
|
}, _attrs))}>`);
|
|
} else {
|
|
_push(`<img${ssrRenderAttrs(mergeProps({
|
|
class: "rtl:-scale-x-100",
|
|
src: _imports_1,
|
|
alt: "comment",
|
|
"cursor-pointer": ""
|
|
}, _attrs))}>`);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup$5 = _sfc_main$5.setup;
|
|
_sfc_main$5.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("assets/img/icons/share.vue");
|
|
return _sfc_setup$5 ? _sfc_setup$5(props, ctx) : void 0;
|
|
};
|
|
const createPostLike = async (product_id) => {
|
|
return await myAxios.post("/media/create-like", { product_id });
|
|
};
|
|
const deletePostLike = async (product_id) => supabaseService.fetch("likes", "delete", {
|
|
field: ["user_id", "product_id"],
|
|
value: [useUserStore().user.id, product_id]
|
|
});
|
|
const createCommentLike = async (comment_id) => {
|
|
return await myAxios.post("/media/create-comment-like", { comment_id });
|
|
};
|
|
const deleteCommentLike = async (comment_id) => supabaseService.fetch("likes", "delete", {
|
|
field: ["user_id", "comment_id"],
|
|
value: [useUserStore().user.id, comment_id]
|
|
});
|
|
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
__name: "SubCommentCard",
|
|
__ssrInlineRender: true,
|
|
props: {
|
|
item: {},
|
|
addLikeLoading: { type: Boolean }
|
|
},
|
|
emits: ["likeComment", "reply"],
|
|
setup(__props, { emit: __emit }) {
|
|
const user = useUserStore();
|
|
useConfigStore();
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
const _directive_lazy = resolveDirective("lazy");
|
|
let _temp0;
|
|
_push(`<div${ssrRenderAttrs(mergeProps({ class: "mt-4" }, _attrs))}><div class="flex text-xs gap-2"><div><img${ssrRenderAttrs(_temp0 = mergeProps({
|
|
alt: unref(reactiveProjectName),
|
|
width: "40",
|
|
class: "rounded-full aspect-square"
|
|
}, ssrGetDirectiveProps(_ctx, _directive_lazy, { src: unref(getSupabaseStorageUrl)(_ctx.item?.user?.avatar), loading: unref(empty_user), error: unref(empty_user) })))}>${"textContent" in _temp0 ? ssrInterpolate(_temp0.textContent) : _temp0.innerHTML ?? ""}</div><div class="flex-1"><div class="flex gap-2 items-center"><div>${ssrInterpolate(_ctx.item.user.name)}</div><div class="text-xs text-gray-500">${ssrInterpolate(unref(formatTimeShort)(_ctx.item.created_at))}</div></div><div>${ssrInterpolate(_ctx.item.message)}</div></div><div class="flex flex-col items-center gap-1 w-14px"${ssrRenderAttr("aria-disabled", _ctx.addLikeLoading)}>`);
|
|
_push(ssrRenderComponent(_sfc_main$8, {
|
|
"is-gray": "",
|
|
"is-liked": _ctx.item.like?.some((x) => x.user_id === unref(user).user?.id)
|
|
}, null, _parent));
|
|
_push(`<div>${ssrInterpolate(_ctx.item.like?.length)}</div></div></div></div>`);
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup$4 = _sfc_main$4.setup;
|
|
_sfc_main$4.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/home/components/SubCommentCard.vue");
|
|
return _sfc_setup$4 ? _sfc_setup$4(props, ctx) : void 0;
|
|
};
|
|
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
__name: "CommentCard",
|
|
__ssrInlineRender: true,
|
|
props: {
|
|
item: {},
|
|
addLikeLoading: { type: Boolean }
|
|
},
|
|
emits: ["likeComment", "reply"],
|
|
setup(__props, { emit: __emit }) {
|
|
const user = useUserStore();
|
|
const config = useConfigStore();
|
|
const emits = __emit;
|
|
const showReply = ref(false);
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
const _directive_lazy = resolveDirective("lazy");
|
|
let _temp0;
|
|
_push(`<div${ssrRenderAttrs(mergeProps({ class: "mb-5" }, _attrs))}><div class="flex text-xs gap-2"><div><img${ssrRenderAttrs(_temp0 = mergeProps({
|
|
alt: unref(reactiveProjectName),
|
|
width: "40",
|
|
class: "rounded-full aspect-square"
|
|
}, ssrGetDirectiveProps(_ctx, _directive_lazy, { src: unref(getSupabaseStorageUrl)(_ctx.item.user.avatar), loading: unref(empty_user), error: unref(empty_user) })))}>${"textContent" in _temp0 ? ssrInterpolate(_temp0.textContent) : _temp0.innerHTML ?? ""}</div><div class="flex-1"><div class="flex gap-2 items-center"><div>${ssrInterpolate(_ctx.item.user.name)}</div><div class="text-xs text-gray-500">${ssrInterpolate(unref(formatTimeShort)(_ctx.item.created_at))}</div></div><div>${ssrInterpolate(_ctx.item.message)}</div><div class="text-gray-5">${ssrInterpolate(unref(config).useString("reply"))}</div></div><div class="flex flex-col items-center gap-1 w-14px"${ssrRenderAttr("aria-disabled", _ctx.addLikeLoading)}>`);
|
|
_push(ssrRenderComponent(_sfc_main$8, {
|
|
"is-gray": "",
|
|
"is-liked": _ctx.item.like?.some((x) => x.user_id === unref(user).user?.id)
|
|
}, null, _parent));
|
|
_push(`<div>${ssrInterpolate(_ctx.item.like?.length)}</div></div></div>`);
|
|
if (_ctx.item?.replies?.length > 0) {
|
|
_push(`<!--[-->`);
|
|
if (!showReply.value) {
|
|
_push(`<div class="text-zinc-5 text-xs mt-2 ms-20">${ssrInterpolate(unref(config).useString("viewMoreReplies", _ctx.item?.replies?.length))}</div>`);
|
|
} else {
|
|
_push(`<div class="ms11"><!--[-->`);
|
|
ssrRenderList(_ctx.item?.replies, (subItem) => {
|
|
_push(ssrRenderComponent(_sfc_main$4, {
|
|
item: subItem,
|
|
onLikeComment: ($event) => emits("likeComment", subItem.like?.some((x) => x.user_id === unref(user).user?.id), subItem.id, true, _ctx.item.id),
|
|
addLikeLoading: _ctx.addLikeLoading
|
|
}, null, _parent));
|
|
});
|
|
_push(`<!--]--></div>`);
|
|
}
|
|
_push(`<!--]-->`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div>`);
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup$3 = _sfc_main$3.setup;
|
|
_sfc_main$3.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/home/components/CommentCard.vue");
|
|
return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0;
|
|
};
|
|
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
__name: "CommentCardSkeleton",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
const isLoaded = ref(false);
|
|
const skeletonRatio = ref(null);
|
|
const skeletonSize = reactive(
|
|
useElementSize$1(skeletonRatio, { width: 0, height: 0 }, { box: "border-box" })
|
|
);
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
if (isLoaded.value) {
|
|
_push(`<div${ssrRenderAttrs(mergeProps({
|
|
ref_key: "skeletonRatio",
|
|
ref: skeletonRatio,
|
|
class: "h-fit"
|
|
}, _attrs))}>`);
|
|
_push(ssrRenderComponent(unref(ContentLoader), {
|
|
width: skeletonSize.width,
|
|
height: "60"
|
|
}, {
|
|
default: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
if (_push2) {
|
|
_push2(`<circle${ssrRenderAttr("cx", 15)} cy="30" r="15"${_scopeId}></circle><rect x="45" y="15" rx="3" ry="3" width="100" height="12"${_scopeId}></rect><rect x="45" y="35" rx="5" ry="5"${ssrRenderAttr("width", skeletonSize.width - 100)} height="10"${_scopeId}></rect>`);
|
|
} else {
|
|
return [
|
|
createVNode("circle", {
|
|
cx: 15,
|
|
cy: "30",
|
|
r: "15"
|
|
}),
|
|
createVNode("rect", {
|
|
x: "45",
|
|
y: "15",
|
|
rx: "3",
|
|
ry: "3",
|
|
width: "100",
|
|
height: "12"
|
|
}),
|
|
createVNode("rect", {
|
|
x: "45",
|
|
y: "35",
|
|
rx: "5",
|
|
ry: "5",
|
|
width: skeletonSize.width - 100,
|
|
height: "10"
|
|
}, null, 8, ["width"])
|
|
];
|
|
}
|
|
}),
|
|
_: 1
|
|
}, _parent));
|
|
_push(`</div>`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup$2 = _sfc_main$2.setup;
|
|
_sfc_main$2.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/home/components/CommentCardSkeleton.vue");
|
|
return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
|
|
};
|
|
const getComments = async (product_id, page = 1, limit = 10) => {
|
|
const start = (page - 1) * limit;
|
|
const end = start + limit - 1;
|
|
return (await supabase.from("comments").select(`*,
|
|
user:users(name, avatar),
|
|
like:likes(user_id),
|
|
replies:comments(*,
|
|
user:users(name, avatar),
|
|
like:likes(user_id)
|
|
)`).eq("product_id", product_id).is("parent_id", null).range(start, end).order("created_at", { ascending: false }))?.data;
|
|
};
|
|
const addNewComment = async (message, product_id, parent_id = void 0) => {
|
|
return await myAxios.post(`/media/add-comment`, { message, product_id, parent_id });
|
|
};
|
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
__name: "CommentAddEdit",
|
|
__ssrInlineRender: true,
|
|
props: {
|
|
open: { type: Boolean },
|
|
id: {}
|
|
},
|
|
emits: ["update:open", "addCommentId"],
|
|
setup(__props, { emit: __emit }) {
|
|
const router = useRouter$1();
|
|
const config = useConfigStore();
|
|
const userStore = useUserStore();
|
|
const sheetRef = ref(null);
|
|
const isAtTop = ref(true);
|
|
const scrollArea = ref(null);
|
|
const focusInput = ref(false);
|
|
const addMessageLoading = ref(false);
|
|
const addLikeLoading = ref(false);
|
|
useUserStore();
|
|
const userReply = ref(void 0);
|
|
const handleScroll = () => {
|
|
isAtTop.value = scrollArea.value.scrollTop <= 5;
|
|
};
|
|
function resetReply() {
|
|
userReply.value = void 0;
|
|
}
|
|
function scrollInputIntoView() {
|
|
setTimeout(() => {
|
|
(void 0).activeElement?.scrollIntoView({ behavior: "smooth", block: "center" });
|
|
focusInput.value = true;
|
|
}, 300);
|
|
}
|
|
const props = __props;
|
|
const emits = __emit;
|
|
const loading = ref(false);
|
|
const comments = ref([]);
|
|
const messageText = ref("");
|
|
const inputRef = ref(null);
|
|
const endPage = ref(false);
|
|
const currentPage = ref(0);
|
|
const limit = ref(20);
|
|
const request = async () => {
|
|
try {
|
|
if (!endPage.value) {
|
|
loading.value = true;
|
|
const res = await getComments(props.id, ++currentPage.value, limit.value);
|
|
if (res?.length < limit.value)
|
|
endPage.value = true;
|
|
comments.value.push(...res);
|
|
}
|
|
} catch (e) {
|
|
console.log("e ===>", e);
|
|
} finally {
|
|
loading.value = false;
|
|
}
|
|
};
|
|
async function openSheet() {
|
|
await request();
|
|
await nextTick();
|
|
await sheetRef.value?.setOpen();
|
|
await inputRef.value?.focus();
|
|
}
|
|
async function closeSheet() {
|
|
await nextTick();
|
|
await sheetRef.value?.setClose();
|
|
resetList();
|
|
resetReply();
|
|
}
|
|
function resetList() {
|
|
comments.value = [];
|
|
currentPage.value = 0;
|
|
endPage.value = false;
|
|
}
|
|
const addMessage = async () => {
|
|
try {
|
|
if (messageText.value?.length > 0) {
|
|
addMessageLoading.value = true;
|
|
if (userReply.value) {
|
|
const inf = await addNewComment(messageText.value, props.id, userReply.value.id);
|
|
if (!userReply.value?.replies) userReply.value.replies = [];
|
|
userReply.value?.replies.push({
|
|
message: messageText.value,
|
|
user: { name: userStore.user.name, avatar: userStore.user.avatar },
|
|
like: [],
|
|
...inf
|
|
});
|
|
emits("addCommentId", inf.id);
|
|
} else {
|
|
const inf = await addNewComment(messageText.value, props.id);
|
|
comments.value?.unshift({
|
|
message: messageText.value,
|
|
user: { name: userStore.user.name, avatar: userStore.user.avatar },
|
|
like: [],
|
|
replies: [],
|
|
...inf
|
|
});
|
|
emits("addCommentId", inf.id);
|
|
}
|
|
await nextTick(() => {
|
|
messageText.value = "";
|
|
userReply.value = void 0;
|
|
});
|
|
}
|
|
} catch (e) {
|
|
console.log(e);
|
|
} finally {
|
|
addMessageLoading.value = false;
|
|
}
|
|
};
|
|
function handleLike(isLiked, id, isSub, searchId) {
|
|
try {
|
|
addLikeLoading.value = true;
|
|
if (getToken()) {
|
|
if (isLiked) {
|
|
deleteCommentLike(id);
|
|
if (isSub) {
|
|
const item = comments.value.find((x) => x.id === searchId);
|
|
const subIndex = item?.replies.find((x) => x.id === id);
|
|
subIndex?.like.splice(subIndex.like?.findIndex((y) => y.user_id === userStore.user?.id));
|
|
} else {
|
|
const item = comments.value.find((x) => x.id === searchId);
|
|
item?.like.splice(item?.like?.findIndex((y) => y.user_id === userStore.user?.id));
|
|
}
|
|
} else {
|
|
createCommentLike(id);
|
|
if (isSub) {
|
|
const item = comments.value.find((x) => x.id === searchId);
|
|
const subIndex = item?.replies.find((x) => x.id === id);
|
|
subIndex?.like.push({
|
|
product_id: id,
|
|
user_id: userStore.user.id
|
|
});
|
|
} else {
|
|
const item = comments.value.find((x) => x.id === searchId);
|
|
item?.like?.push({
|
|
product_id: id,
|
|
user_id: userStore.user.id
|
|
});
|
|
}
|
|
}
|
|
} else {
|
|
router.push({ name: "auth-login" });
|
|
api$1.warn(config.useString("pleaseLoginOrRegister"));
|
|
}
|
|
} catch (e) {
|
|
console.log(e);
|
|
} finally {
|
|
addLikeLoading.value = false;
|
|
}
|
|
}
|
|
const observer = ref();
|
|
useIntersectionObserver(observer, ([{ isIntersecting }]) => {
|
|
if (isIntersecting && props.open) {
|
|
setTimeout(() => {
|
|
request();
|
|
}, 100);
|
|
}
|
|
});
|
|
watch(props, (value) => {
|
|
if (value.open) {
|
|
openSheet();
|
|
} else {
|
|
closeSheet();
|
|
}
|
|
});
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
const _component_a_mentions = __nuxt_component_0$2;
|
|
_push(ssrRenderComponent(BasicSheet, mergeProps({
|
|
title: "",
|
|
ref_key: "sheetRef",
|
|
ref: sheetRef,
|
|
headerCls: "",
|
|
allowCloseScrollup: isAtTop.value,
|
|
closeOnClickOutside: "",
|
|
onOnClickOutside: ($event) => emits("update:open", false),
|
|
onOnClose: ($event) => emits("update:open", false)
|
|
}, _attrs), {
|
|
header: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
if (_push2) {
|
|
_push2(`<div flex justify-center items-center flex-col p-2${_scopeId}><div bg-gray-500 h-2px w-2.5rem${_scopeId}></div><div mt-1 font-semibold${_scopeId}>${ssrInterpolate(unref(config).useString("comments"))}</div></div>`);
|
|
} else {
|
|
return [
|
|
createVNode("div", {
|
|
flex: "",
|
|
"justify-center": "",
|
|
"items-center": "",
|
|
"flex-col": "",
|
|
"p-2": ""
|
|
}, [
|
|
createVNode("div", {
|
|
"bg-gray-500": "",
|
|
"h-2px": "",
|
|
"w-2.5rem": ""
|
|
}),
|
|
createVNode("div", {
|
|
"mt-1": "",
|
|
"font-semibold": ""
|
|
}, toDisplayString(unref(config).useString("comments")), 1)
|
|
])
|
|
];
|
|
}
|
|
}),
|
|
default: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
if (_push2) {
|
|
_push2(`<div class="${ssrRenderClass([unref(getToken)() ? "pb-4rem" : "", "h-70vh w-full relative relative"])}"${_scopeId}><div class="h-full px-4 overflow-auto"${_scopeId}><!--[-->`);
|
|
ssrRenderList(comments.value, (comment) => {
|
|
_push2(ssrRenderComponent(_sfc_main$3, {
|
|
item: comment,
|
|
onLikeComment: handleLike,
|
|
onReply: ($event) => userReply.value = comment,
|
|
addLikeLoading: addLikeLoading.value
|
|
}, null, _parent2, _scopeId));
|
|
});
|
|
_push2(`<!--]-->`);
|
|
if (loading.value) {
|
|
_push2(`<!--[-->`);
|
|
ssrRenderList(5, (item) => {
|
|
_push2(ssrRenderComponent(_sfc_main$2, null, null, _parent2, _scopeId));
|
|
});
|
|
_push2(`<!--]-->`);
|
|
} else {
|
|
_push2(`<!---->`);
|
|
}
|
|
_push2(`<div style="${ssrRenderStyle(!loading.value ? null : { display: "none" })}" class="w-full opacity-0 relative"${_scopeId}> load </div></div>`);
|
|
if (unref(getToken)()) {
|
|
_push2(`<div class="flex w-inherit fixed gap-1 items-center my-2 px2 py-1 bottom-1"${_scopeId}>`);
|
|
_push2(ssrRenderComponent(UserProfilePic, {
|
|
width: "40",
|
|
class: "w-40 ms-2",
|
|
src: unref(userStore).user?.avatar,
|
|
"just-show-profile": ""
|
|
}, null, _parent2, _scopeId));
|
|
_push2(`<div class="${ssrRenderClass([userReply.value ? "rounded-3xl" : "rounded-full", "border-solid flex-1 border-1 comment_input"])}"${_scopeId}>`);
|
|
if (userReply.value) {
|
|
_push2(`<div class="${ssrRenderClass([unref(config).isNightStore ? "bg-zinc-7 text-gray-2" : "bg-gray-50 text-gray-4", "rounded-t-3xl text-xs p3 mb1 flex justify-between"])}"${_scopeId}><div class="flex items-center"${_scopeId}><span${_scopeId}><span class="me-1"${_scopeId}>${ssrInterpolate(unref(config).useString("replyingTo"))}</span><span${_scopeId}>${ssrInterpolate(userReply.value?.user?.name)}</span></span></div>`);
|
|
_push2(ssrRenderComponent(BasicIconOld, {
|
|
icon: "vuesax-linear:add",
|
|
class: "rotate-45",
|
|
color: unref(config).isNightStore ? "bg-zinc-7" : "text-gray-4",
|
|
onClick: ($event) => userReply.value = void 0
|
|
}, null, _parent2, _scopeId));
|
|
_push2(`</div>`);
|
|
} else {
|
|
_push2(`<!---->`);
|
|
}
|
|
_push2(`<div class="flex items-center p1"${_scopeId}>`);
|
|
_push2(ssrRenderComponent(_component_a_mentions, {
|
|
value: messageText.value,
|
|
"onUpdate:value": ($event) => messageText.value = $event,
|
|
placeholder: unref(config).useString("yourComment"),
|
|
class: "comment_input"
|
|
}, null, _parent2, _scopeId));
|
|
_push2(ssrRenderComponent(BasicButton, {
|
|
onClick: addMessage,
|
|
class: "rounded-full w-3.5rem",
|
|
type: "primary",
|
|
loading: addMessageLoading.value
|
|
}, {
|
|
default: withCtx((_2, _push3, _parent3, _scopeId2) => {
|
|
if (_push3) {
|
|
_push3(ssrRenderComponent(BasicIconOld, { icon: "vuesax-linear:arrow-up" }, null, _parent3, _scopeId2));
|
|
} else {
|
|
return [
|
|
createVNode(BasicIconOld, { icon: "vuesax-linear:arrow-up" })
|
|
];
|
|
}
|
|
}),
|
|
_: 1
|
|
}, _parent2, _scopeId));
|
|
_push2(`</div></div></div>`);
|
|
} else {
|
|
_push2(`<!---->`);
|
|
}
|
|
_push2(`</div>`);
|
|
} else {
|
|
return [
|
|
createVNode("div", {
|
|
class: ["h-70vh w-full relative relative", unref(getToken)() ? "pb-4rem" : ""]
|
|
}, [
|
|
createVNode("div", {
|
|
class: "h-full px-4 overflow-auto",
|
|
ref_key: "scrollArea",
|
|
ref: scrollArea,
|
|
onScroll: handleScroll
|
|
}, [
|
|
(openBlock(true), createBlock(Fragment, null, renderList(comments.value, (comment) => {
|
|
return openBlock(), createBlock(_sfc_main$3, {
|
|
item: comment,
|
|
onLikeComment: handleLike,
|
|
onReply: ($event) => userReply.value = comment,
|
|
addLikeLoading: addLikeLoading.value
|
|
}, null, 8, ["item", "onReply", "addLikeLoading"]);
|
|
}), 256)),
|
|
loading.value ? (openBlock(), createBlock(Fragment, { key: 0 }, renderList(5, (item) => {
|
|
return createVNode(_sfc_main$2);
|
|
}), 64)) : createCommentVNode("", true),
|
|
withDirectives(createVNode("div", {
|
|
ref_key: "observer",
|
|
ref: observer,
|
|
class: "w-full opacity-0 relative"
|
|
}, " load ", 512), [
|
|
[vShow, !loading.value]
|
|
])
|
|
], 544),
|
|
unref(getToken)() ? (openBlock(), createBlock("div", {
|
|
key: 0,
|
|
class: "flex w-inherit fixed gap-1 items-center my-2 px2 py-1 bottom-1",
|
|
onFocusin: scrollInputIntoView,
|
|
onFocusout: ($event) => focusInput.value = false
|
|
}, [
|
|
createVNode(UserProfilePic, {
|
|
width: "40",
|
|
class: "w-40 ms-2",
|
|
src: unref(userStore).user?.avatar,
|
|
"just-show-profile": ""
|
|
}, null, 8, ["src"]),
|
|
createVNode("div", {
|
|
class: ["border-solid flex-1 border-1 comment_input", userReply.value ? "rounded-3xl" : "rounded-full"]
|
|
}, [
|
|
userReply.value ? (openBlock(), createBlock("div", {
|
|
key: 0,
|
|
class: ["rounded-t-3xl text-xs p3 mb1 flex justify-between", unref(config).isNightStore ? "bg-zinc-7 text-gray-2" : "bg-gray-50 text-gray-4"]
|
|
}, [
|
|
createVNode("div", { class: "flex items-center" }, [
|
|
createVNode("span", null, [
|
|
createVNode("span", { class: "me-1" }, toDisplayString(unref(config).useString("replyingTo")), 1),
|
|
createVNode("span", null, toDisplayString(userReply.value?.user?.name), 1)
|
|
])
|
|
]),
|
|
createVNode(BasicIconOld, {
|
|
icon: "vuesax-linear:add",
|
|
class: "rotate-45",
|
|
color: unref(config).isNightStore ? "bg-zinc-7" : "text-gray-4",
|
|
onClick: ($event) => userReply.value = void 0
|
|
}, null, 8, ["color", "onClick"])
|
|
], 2)) : createCommentVNode("", true),
|
|
createVNode("div", { class: "flex items-center p1" }, [
|
|
createVNode(_component_a_mentions, {
|
|
value: messageText.value,
|
|
"onUpdate:value": ($event) => messageText.value = $event,
|
|
placeholder: unref(config).useString("yourComment"),
|
|
class: "comment_input"
|
|
}, null, 8, ["value", "onUpdate:value", "placeholder"]),
|
|
createVNode(BasicButton, {
|
|
onClick: addMessage,
|
|
class: "rounded-full w-3.5rem",
|
|
type: "primary",
|
|
loading: addMessageLoading.value
|
|
}, {
|
|
default: withCtx(() => [
|
|
createVNode(BasicIconOld, { icon: "vuesax-linear:arrow-up" })
|
|
]),
|
|
_: 1
|
|
}, 8, ["loading"])
|
|
])
|
|
], 2)
|
|
], 40, ["onFocusout"])) : createCommentVNode("", true)
|
|
], 2)
|
|
];
|
|
}
|
|
}),
|
|
_: 1
|
|
}, _parent));
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup$1 = _sfc_main$1.setup;
|
|
_sfc_main$1.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("components/CommentAddEdit.vue");
|
|
return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
|
|
};
|
|
const CommentAddEdit = Object.assign(_sfc_main$1, { __name: "CommentAddEdit" });
|
|
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
__name: "moreOptionProduct",
|
|
__ssrInlineRender: true,
|
|
props: {
|
|
open: { type: Boolean },
|
|
id: {}
|
|
},
|
|
emits: ["update:open"],
|
|
setup(__props, { emit: __emit }) {
|
|
const router = useRouter$1();
|
|
const config = useConfigStore();
|
|
const sheetRef = ref(null);
|
|
const props = __props;
|
|
const emits = __emit;
|
|
async function openSheet() {
|
|
await nextTick();
|
|
await sheetRef.value?.setOpen();
|
|
}
|
|
async function closeSheet() {
|
|
await nextTick();
|
|
await sheetRef.value?.setClose();
|
|
}
|
|
async function confirmDeleteProduct() {
|
|
await baseConfirm(config.useString("areYouSureToDeleteThisProduct"), deleteProduct);
|
|
}
|
|
const percent = useProductStore();
|
|
async function deleteProduct() {
|
|
percent.percentUpload = 0;
|
|
percent.loading = true;
|
|
try {
|
|
await deleteProductById(props.id);
|
|
percent.percentUpload = 100;
|
|
api$1.success(config.useString("deletedSuccessfully"));
|
|
} catch (e) {
|
|
console.log(e);
|
|
api$1.error(config.useString("errorInAction"));
|
|
} finally {
|
|
percent.loading = false;
|
|
emits("update:open", false);
|
|
}
|
|
}
|
|
watch(props, (value) => {
|
|
if (value.open) {
|
|
openSheet();
|
|
} else {
|
|
closeSheet();
|
|
}
|
|
});
|
|
return (_ctx, _push, _parent, _attrs) => {
|
|
_push(ssrRenderComponent(BasicSheet, mergeProps({
|
|
title: "",
|
|
ref_key: "sheetRef",
|
|
ref: sheetRef,
|
|
headerCls: "",
|
|
closeOnClickOutside: "",
|
|
onOnClickOutside: ($event) => emits("update:open", false),
|
|
onOnClose: ($event) => emits("update:open", false)
|
|
}, _attrs), {
|
|
header: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
if (_push2) {
|
|
_push2(`<div flex justify-center items-center flex-col p-2${_scopeId}><div bg-gray-500 h-2px w-2.5rem${_scopeId}></div></div>`);
|
|
} else {
|
|
return [
|
|
createVNode("div", {
|
|
flex: "",
|
|
"justify-center": "",
|
|
"items-center": "",
|
|
"flex-col": "",
|
|
"p-2": ""
|
|
}, [
|
|
createVNode("div", {
|
|
"bg-gray-500": "",
|
|
"h-2px": "",
|
|
"w-2.5rem": ""
|
|
})
|
|
])
|
|
];
|
|
}
|
|
}),
|
|
default: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
if (_push2) {
|
|
_push2(`<div class="h-fit px-4"${_scopeId}><div class="flex flex-col gap-2 mt-5 mb-5"${_scopeId}><div class="flex items-center gap-3 p-3 rounded-lg bg-primary"${_scopeId}>`);
|
|
_push2(ssrRenderComponent(BasicIconOld, {
|
|
icon: "vuesax-linear:edit",
|
|
color: "white"
|
|
}, null, _parent2, _scopeId));
|
|
_push2(`<div class="text-sm text-white"${_scopeId}>${ssrInterpolate(unref(config).useString("edit"))}</div></div><div class="flex items-center gap-3 p-3 rounded-lg bg-red-100"${_scopeId}>`);
|
|
_push2(ssrRenderComponent(BasicIconOld, {
|
|
icon: "vuesax-linear:trash",
|
|
color: "red"
|
|
}, null, _parent2, _scopeId));
|
|
_push2(`<div class="text-red text-sm"${_scopeId}>${ssrInterpolate(unref(config).useString("delete"))}</div></div></div></div>`);
|
|
} else {
|
|
return [
|
|
createVNode("div", { class: "h-fit px-4" }, [
|
|
createVNode("div", { class: "flex flex-col gap-2 mt-5 mb-5" }, [
|
|
createVNode("div", {
|
|
class: "flex items-center gap-3 p-3 rounded-lg bg-primary",
|
|
onClick: ($event) => unref(router).push({ name: "edit-product-id", params: { id: props.id } })
|
|
}, [
|
|
createVNode(BasicIconOld, {
|
|
icon: "vuesax-linear:edit",
|
|
color: "white"
|
|
}),
|
|
createVNode("div", { class: "text-sm text-white" }, toDisplayString(unref(config).useString("edit")), 1)
|
|
], 8, ["onClick"]),
|
|
createVNode("div", {
|
|
class: "flex items-center gap-3 p-3 rounded-lg bg-red-100",
|
|
onClick: ($event) => confirmDeleteProduct()
|
|
}, [
|
|
createVNode(BasicIconOld, {
|
|
icon: "vuesax-linear:trash",
|
|
color: "red"
|
|
}),
|
|
createVNode("div", { class: "text-red text-sm" }, toDisplayString(unref(config).useString("delete")), 1)
|
|
], 8, ["onClick"])
|
|
])
|
|
])
|
|
];
|
|
}
|
|
}),
|
|
_: 1
|
|
}, _parent));
|
|
};
|
|
}
|
|
});
|
|
const _sfc_setup = _sfc_main.setup;
|
|
_sfc_main.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/home/components/moreOptionProduct.vue");
|
|
return _sfc_setup ? _sfc_setup(props, ctx) : void 0;
|
|
};
|
|
|
|
export { CommentAddEdit as C, _sfc_main as _, _sfc_main$7 as a, _sfc_main$5 as b, createPostLike as c, deletePostLike as d, _sfc_main$6 as e };
|
|
//# sourceMappingURL=moreOptionProduct-N01tC6Zc.mjs.map
|