lms/public/build/assets/blog-comments-D8HET_KS.js
2025-12-15 12:26:23 +01:00

2 lines
4.9 KiB
JavaScript

import{u as M,b as v,j as e,S as U,M as F,T as f}from"./vendor-BKmmeuxg.js";import{D as b}from"./delete-modal-D1GJlb1P.js";import{A as y,a as w,b as C}from"./avatar-j28afJTV.js";import{B as n}from"./button-BpNwv2aE.js";import{C as D,a as I,b as S}from"./card-D9_SJYq6.js";import{T as _}from"./textarea-CyndvowL.js";import{c as E}from"./utils-DxSsnXxD.js";import"./dialog-B2gN9MvT.js";import"./index-WW_1X1qx.js";const X=()=>{const{props:z}=M(),{auth:a,blog:c,translate:A}=z,{button:l,frontend:r,input:m}=A,{data:o,setData:P,post:R,processing:x,reset:T}=v({content:"",blog_id:c.id}),{data:i,setData:p,post:k,processing:h,reset:u}=v({content:"",blog_id:c.id,parent_id:null}),B=s=>{s.preventDefault(),o.content.trim()&&R(route("blogs.comments.store"),{preserveScroll:!0,onSuccess:()=>{T()}})},L=s=>{s.preventDefault(),i.content.trim()&&k(route("blogs.comments.store"),{preserveScroll:!0,onSuccess:()=>{u()}})},j=s=>new Date(s).toLocaleDateString("en-US",{year:"numeric",month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),g=s=>s.split(" ").map(d=>d.charAt(0)).join("").toUpperCase().slice(0,2);return e.jsxs("div",{className:E("space-y-6"),children:[e.jsxs(D,{children:[e.jsx(I,{children:e.jsx("h4",{className:"text-base font-medium",children:r.post_a_comment})}),e.jsx(S,{children:e.jsxs("form",{onSubmit:B,className:"space-y-4",children:[e.jsx(_,{placeholder:m.description,value:o.content,onChange:s=>P("content",s.target.value),className:"min-h-[100px] resize-none",maxLength:1e3}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-muted-foreground text-sm",children:[o.content.length,"/1000 ",r.characters]}),e.jsxs(n,{type:"submit",disabled:!o.content.trim()||x,className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-4 w-4"}),x?r.posting:l.post_comment]})]})]})})]}),e.jsx("div",{className:"space-y-4",children:c.comments.length===0?e.jsxs("div",{className:"py-8 text-center",children:[e.jsx(F,{className:"text-muted-foreground mx-auto mb-2 h-12 w-12"}),e.jsx("p",{className:"text-muted-foreground",children:r.no_comments_yet})]}):c.comments.map(s=>{var d;return e.jsx(D,{className:"overflow-hidden",children:e.jsxs(S,{className:"p-4",children:[e.jsxs("div",{className:"mb-3 flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(y,{className:"h-10 w-10",children:[e.jsx(w,{src:s.user.photo||"",alt:s.user.name}),e.jsx(C,{children:g(s.user.name)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.user.name}),e.jsx("p",{className:"text-muted-foreground text-sm",children:j(s.created_at)})]})]}),((d=a==null?void 0:a.user)==null?void 0:d.id)===s.user.id&&e.jsx(b,{routePath:route("blogs.comments.destroy",{id:s.id}),actionComponent:e.jsx(n,{variant:"ghost",className:"bg-destructive/8 hover:bg-destructive/6 h-8 w-8",children:e.jsx(f,{className:"text-destructive h-3 w-3"})})})]}),e.jsx("div",{className:"mb-3",children:e.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap",children:s.content})}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsx(n,{size:"sm",variant:"outline",onClick:()=>p("parent_id",s.id),className:"text-xs",children:l.reply})}),i.parent_id===s.id&&e.jsx("div",{className:"mt-4 space-y-3 border-t pt-4",children:e.jsxs("form",{onSubmit:L,className:"space-y-3",children:[e.jsx(_,{placeholder:m.description,value:i.content,onChange:t=>p("content",t.target.value),className:"min-h-[80px] resize-none",maxLength:1e3}),e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("span",{className:"text-muted-foreground text-xs",children:[i.content.length,"/1000 ",r.characters]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(n,{type:"button",variant:"outline",size:"sm",onClick:()=>u(),children:l.cancel}),e.jsx(n,{type:"submit",size:"sm",disabled:!i.content.trim()||h,children:h?r.replying:l.reply})]})]})]})}),s.replies&&s.replies.length>0&&e.jsx("div",{className:"mt-5 space-y-5",children:s.replies.map(t=>{var N;return e.jsxs("div",{className:"border-border space-y-2 border-l pl-4",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(y,{className:"h-8 w-8",children:[e.jsx(w,{src:t.user.photo||"",alt:t.user.name}),e.jsx(C,{className:"text-xs",children:g(t.user.name)})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-medium",children:t.user.name}),e.jsx("p",{className:"text-muted-foreground text-xs",children:j(t.created_at)})]})]}),((N=a==null?void 0:a.user)==null?void 0:N.id)===t.user.id&&e.jsx(b,{routePath:route("blogs.comments.destroy",{id:t.id}),actionComponent:e.jsx(n,{variant:"ghost",className:"bg-destructive/8 hover:bg-destructive/6 h-8 w-8",children:e.jsx(f,{className:"text-destructive h-3 w-3"})})})]}),e.jsx("p",{className:"pl-10 text-sm leading-relaxed whitespace-pre-wrap",children:t.content})]},t.id)})})]})},s.id)})})]})};export{X as default};