317 lines
14 KiB
JavaScript
317 lines
14 KiB
JavaScript
import { defineComponent, ref, watch, mergeProps, withCtx, unref, createVNode, toDisplayString, resolveDirective, reactive, nextTick, useSSRContext } from 'vue';
|
|
import { ssrRenderComponent, ssrInterpolate, ssrRenderAttrs, ssrRenderAttr, ssrGetDirectiveProps, ssrRenderList } from 'vue/server-renderer';
|
|
import { B as BasicSheet } from './index-DVD7vSfp.mjs';
|
|
import { a as formatTimeShort } from './useDateTime-D8RCoGwW.mjs';
|
|
import { e as empty_user } from './empty_user-BaUNCdgf.mjs';
|
|
import { _ as _sfc_main$4 } from './like-BhIOg3YL.mjs';
|
|
import { u as useRouter$1, a as useConfigStore, b as useUserStore, t as reactiveProjectName, x as getSupabaseStorageUrl, z as useElementSize, at as baseConfirm, au as deleteProductById, e as api$1 } from './server.mjs';
|
|
import { ContentLoader } from 'vue-content-loader';
|
|
import { B as BasicIconOld } from './BasicIconOld-I4c2ShMu.mjs';
|
|
import { u as useProductStore } from './product-DaDj7A6D.mjs';
|
|
|
|
const _sfc_main$3 = /* @__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) => {
|
|
var _a2;
|
|
var _a, _b, _c, _d;
|
|
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)((_b = (_a = _ctx.item) == null ? void 0 : _a.user) == null ? void 0 : _b.avatar), loading: unref(empty_user), error: unref(empty_user) })))}>${"textContent" in _temp0 ? ssrInterpolate(_temp0.textContent) : (_a2 = _temp0.innerHTML) != null ? _a2 : ""}</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$4, {
|
|
"is-gray": "",
|
|
"is-liked": (_c = _ctx.item.like) == null ? void 0 : _c.some((x) => {
|
|
var _a22;
|
|
return x.user_id === ((_a22 = unref(user).user) == null ? void 0 : _a22.id);
|
|
})
|
|
}, null, _parent));
|
|
_push(`<div>${ssrInterpolate((_d = _ctx.item.like) == null ? void 0 : _d.length)}</div></div></div></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/SubCommentCard.vue");
|
|
return _sfc_setup$3 ? _sfc_setup$3(props, ctx) : void 0;
|
|
};
|
|
const _sfc_main$2 = /* @__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) => {
|
|
var _a2;
|
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
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) : (_a2 = _temp0.innerHTML) != null ? _a2 : ""}</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$4, {
|
|
"is-gray": "",
|
|
"is-liked": (_a = _ctx.item.like) == null ? void 0 : _a.some((x) => {
|
|
var _a22;
|
|
return x.user_id === ((_a22 = unref(user).user) == null ? void 0 : _a22.id);
|
|
})
|
|
}, null, _parent));
|
|
_push(`<div>${ssrInterpolate((_b = _ctx.item.like) == null ? void 0 : _b.length)}</div></div></div>`);
|
|
if (((_d = (_c = _ctx.item) == null ? void 0 : _c.replies) == null ? void 0 : _d.length) > 0) {
|
|
_push(`<!--[-->`);
|
|
if (!showReply.value) {
|
|
_push(`<div class="text-zinc-5 text-xs mt-2 ms-20">${ssrInterpolate(unref(config).useString("viewMoreReplies", (_f = (_e = _ctx.item) == null ? void 0 : _e.replies) == null ? void 0 : _f.length))}</div>`);
|
|
} else {
|
|
_push(`<div class="ms11"><!--[-->`);
|
|
ssrRenderList((_g = _ctx.item) == null ? void 0 : _g.replies, (subItem) => {
|
|
_push(ssrRenderComponent(_sfc_main$3, {
|
|
item: subItem,
|
|
onLikeComment: ($event) => {
|
|
var _a22;
|
|
return emits("likeComment", (_a22 = subItem.like) == null ? void 0 : _a22.some((x) => {
|
|
var _a3;
|
|
return x.user_id === ((_a3 = unref(user).user) == null ? void 0 : _a3.id);
|
|
}), subItem.id, true, _ctx.item.id);
|
|
},
|
|
addLikeLoading: _ctx.addLikeLoading
|
|
}, null, _parent));
|
|
});
|
|
_push(`<!--]--></div>`);
|
|
}
|
|
_push(`<!--]-->`);
|
|
} else {
|
|
_push(`<!---->`);
|
|
}
|
|
_push(`</div>`);
|
|
};
|
|
}
|
|
});
|
|
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/CommentCard.vue");
|
|
return _sfc_setup$2 ? _sfc_setup$2(props, ctx) : void 0;
|
|
};
|
|
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
__name: "CommentCardSkeleton",
|
|
__ssrInlineRender: true,
|
|
setup(__props) {
|
|
const isLoaded = ref(false);
|
|
const skeletonRatio = ref(null);
|
|
const skeletonSize = reactive(
|
|
useElementSize(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$1 = _sfc_main$1.setup;
|
|
_sfc_main$1.setup = (props, ctx) => {
|
|
const ssrContext = useSSRContext();
|
|
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("views/base/pages/home/components/CommentCardSkeleton.vue");
|
|
return _sfc_setup$1 ? _sfc_setup$1(props, ctx) : void 0;
|
|
};
|
|
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() {
|
|
var _a;
|
|
await nextTick();
|
|
await ((_a = sheetRef.value) == null ? void 0 : _a.setOpen());
|
|
}
|
|
async function closeSheet() {
|
|
var _a;
|
|
await nextTick();
|
|
await ((_a = sheetRef.value) == null ? void 0 : _a.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 { _sfc_main as _, _sfc_main$2 as a, _sfc_main$1 as b };
|
|
//# sourceMappingURL=moreOptionProduct-DIWh2yKL.mjs.map
|