lms/public/build/assets/forum-DlTvqVAi.js
2025-12-15 12:26:23 +01:00

2 lines
4.7 KiB
JavaScript

import{u as L,b as P,j as s,q as x,b7 as h,i as u,M as k,x as q}from"./vendor-BKmmeuxg.js";import{D as p}from"./delete-modal-D1GJlb1P.js";import{I as j}from"./input-error-LaPr_4wd.js";import{L as B}from"./loading-button-BnTVAMJ7.js";import{A as g,a as N,b as f}from"./avatar-j28afJTV.js";import{B as r}from"./button-BpNwv2aE.js";import{D as v,a as w,b,c as o}from"./dropdown-menu-DO-po5c1.js";import{I as H}from"./input-DM0goJrn.js";import{L as y}from"./label-HmIcv5Yx.js";import{S as C}from"./separator-_3LZ_wAA.js";import{o as R}from"./inertia-SZXqLvQm.js";import{k as T,e as M}from"./richtor-CRcM6Du2.js";import V from"./forum-edit-DhPDzc5t.js";import D from"./forum-reply-Cbdqxv1w.js";import"./dialog-B2gN9MvT.js";import"./utils-DxSsnXxD.js";import"./index-WW_1X1qx.js";const ns=()=>{const{props:a,url:n}=L(),{translate:_}=a,{button:c,input:i,frontend:z}=_,A=a.watching,{data:l,setData:d,post:I,errors:m,processing:S,reset:F}=P({url:n,title:"",description:"",user_id:a.auth.user.id,course_id:a.course.id,section_lesson_id:a.watching.id}),E=e=>{e.preventDefault(),I(route("course-forums.store"),{onSuccess:()=>{F()}})};return s.jsxs("div",{children:[s.jsxs("form",{onSubmit:E,className:"space-y-4 p-0.5",children:[s.jsxs("div",{children:[s.jsx(y,{children:i.title}),s.jsx(H,{required:!0,type:"text",name:"title",value:l.title,placeholder:i.title_placeholder,onChange:e=>R(e,d)}),s.jsx(j,{message:m.title})]}),s.jsxs("div",{children:[s.jsx(y,{children:i.description}),s.jsx(T,{ssr:!0,output:"html",placeholder:{paragraph:i.description,imageCaption:i.image_url_placeholder},contentMinHeight:160,contentMaxHeight:400,initialContent:l.description,onContentChange:e=>d("description",e)}),s.jsx(j,{message:m.description})]}),s.jsx(B,{loading:S,children:c.submit})]}),s.jsx(C,{className:"my-6"}),A.forums.map(e=>s.jsxs("div",{className:"space-y-4 rounded-lg border p-6",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(g,{className:"h-8 w-8",children:[s.jsx(N,{src:e.user.photo||"",alt:e.user.name,className:"object-cover"}),s.jsx(f,{children:e.user.name.charAt(0)})]}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold",children:e.user.name}),s.jsx("p",{className:"text-muted-foreground text-xs",children:x(new Date(e.created_at),"MMM d, yyyy h:mm a")})]})]}),e.user_id===a.auth.user.id&&s.jsxs(v,{children:[s.jsx(w,{children:s.jsx(r,{variant:"secondary",size:"icon",className:"size-8",children:s.jsx(h,{})})}),s.jsxs(b,{align:"end",children:[s.jsx(o,{asChild:!0,children:s.jsx(V,{url:n,forum:e})}),s.jsx(o,{asChild:!0,children:s.jsx(p,{routePath:route("course-forums.destroy",e.id),actionComponent:s.jsxs(r,{size:"sm",variant:"ghost",className:"w-full cursor-pointer justify-start px-2",children:[s.jsx(u,{className:"h-4 w-4"}),s.jsx("span",{children:c.delete})]})})})]})]})]}),s.jsxs("div",{children:[s.jsx("p",{className:"text-lg font-medium",children:e.title}),s.jsx(M,{value:e.description})]}),s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsx(D,{url:n,forum:e,user:a.auth.user,actionComponent:s.jsxs(r,{variant:"outline",size:"sm",className:"flex items-center gap-2 shadow-none",children:[s.jsx(k,{className:"h-4 w-4"}),s.jsx("span",{children:c.reply})]})}),s.jsxs("p",{className:"text-muted-foreground text-xs",children:[e.replies.length," ",z.replies]})]}),s.jsx(C,{className:"my-6"}),s.jsx("div",{className:"space-y-8 pl-6",children:e.replies.map(t=>s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsxs(g,{className:"h-8 w-8",children:[s.jsx(N,{src:t.user.photo||"",alt:t.user.name,className:"object-cover"}),s.jsx(f,{children:t.user.name.charAt(0)})]}),s.jsxs("div",{children:[s.jsx("p",{className:"font-semibold",children:t.user.name}),s.jsx("p",{className:"text-muted-foreground text-xs",children:x(new Date(t.created_at),"MMM d, yyyy h:mm a")})]})]}),t.user_id===a.auth.user.id&&s.jsxs(v,{children:[s.jsx(w,{children:s.jsx(r,{variant:"secondary",size:"icon",className:"size-8",children:s.jsx(h,{})})}),s.jsxs(b,{align:"end",children:[s.jsx(o,{asChild:!0,children:s.jsx(D,{url:n,forum:e,reply:t,user:a.auth.user,actionComponent:s.jsxs(r,{size:"sm",variant:"ghost",className:"w-full cursor-pointer justify-start px-2",children:[s.jsx(q,{className:"h-4 w-4"}),s.jsx("span",{children:c.edit})]})})}),s.jsx(o,{asChild:!0,children:s.jsx(p,{routePath:route("course-forum-replies.destroy",t.id),actionComponent:s.jsxs(r,{size:"sm",variant:"ghost",className:"w-full cursor-pointer justify-start px-2",children:[s.jsx(u,{className:"h-4 w-4"}),s.jsx("span",{children:"Delete"})]})})})]})]})]}),s.jsx(M,{value:t.description})]},t.id))})]},e.id))]})};export{ns as default};