1import{h as W,u as A,a9 as q,r as s,f as O,j as e,b as p}from"./index-CitDxPDD.js";import{L as w}from"./LMSLayout-BNIclSg2.js";import{C as N}from"./CourseHome-w3-VxeQW.js";import{T as G}from"./TiptapEditor-CXjQtmf_.js";import{t as J}from"./dateUtils-BPzYxBeH.js";/* empty css */import"./LMSHeader-BkpnkaSX.js";import"./LMSSidebar-CkyrX723.js";import"./LearningActivityIcon-Cz49P-1A.js";import"./TiptapEditor-Bs-meWAo.js";import"./with-selector-CPBoAPpH.js";const ae=()=>{const{uuid:t,noticeId:l}=W(),c=A(),{user:h}=q(),[d,_]=s.useState(""),[m,L]=s.useState(null),[R]=O(),[S,C]=s.useState(!1),[z,f]=s.useState(!1),[I,T]=s.useState(!0),n=!!l,[g,$]=s.useState(""),[j,B]=s.useState(""),[y,P]=s.useState(!1),[b,H]=s.useState("");s.useEffect(()=>{(async()=>{if(t)try{const r=await p.get(`/lms/cws/${t}`);_(r.data.title||r.data.cw_kor_title||"");const i=r.data.institution_id,v=r.data.cohorts,E=R.get("cohort");if(v&&v.length>=2&&E){const x=v.find(a=>a.cohort_id===E);x&&L(x.name)}if(h)if(h.role==="admin")f(!0);else if(h.role==="ins_admin"&&h.institution_id===i)f(!0);else try{const a=(await p.get("/lms/instructors/my-courses")).data.courses?.some(u=>u.cw_uuid===t);f(a)}catch{f(!1)}if(n)try{const a=(await p.get(`/lms/cws-notices/${t}/${l}`)).data;$(a.title||"");const u=a.body||"",F=/<[a-z][\s\S]*>/i.test(u);B(F?u:u.split(` 2`).map(M=>`<p>${M||"<br>"}</p>`).join("")),P(a.notices||!1),a.notice_enddate&&H(J(a.notice_enddate))}catch(x){console.error("Failed to load notice:",x),alert("ê³µì§ì¬íì ë¶ë¬ì¬ ì ììµëë¤."),c(`/lms/cws/home/${t}/notice`);return}}catch(r){console.error("Failed to load course info:",r)}finally{T(!1)}})()},[t,h,l,n]);const k=async o=>{if(o.preventDefault(),!g.trim()){alert("ì 목ì ì ë ¥í´ì£¼ì¸ì.");return}if(!j.replace(/<[^>]*>/g,"").trim()){alert("ë´ì©ì ì ë ¥í´ì£¼ì¸ì.");return}C(!0);try{const i={title:g.trim(),body:j,notices:y};y&&b&&(i.notice_enddate=new Date(b).toISOString()),n?(await p.put(`/lms/cws-notices/${t}/${l}`,i),alert("ê³µì§ì¬íì´ ìì ëììµëë¤."),c(`/lms/cws/home/${t}/notice/${l}`)):(await p.post(`/lms/cws-notices/${t}`,i),alert("ê³µì§ì¬íì´ ë±ë¡ëììµëë¤."),c(`/lms/cws/home/${t}/notice`))}catch(i){alert(`${n?"ìì ":"ë±ë¡"} ì¤í¨: ${i.response?.data?.detail||i.message}`)}finally{C(!1)}},D=()=>{(g||j.replace(/<[^>]*>/g,"").trim())&&!window.confirm("ìì± ì¤ì¸ ë´ì©ì´ ììµëë¤. ì ë§ ì·¨ìíìê² ìµëê¹?")||c(n?`/lms/cws/home/${t}/notice/${l}`:`/lms/cws/home/${t}/notice`)};return I?e.jsxs(w,{children:[d&&e.jsx("header",{style:{width:"100%",marginBottom:"24px",paddingBottom:"16px",borderBottom:"2px solid #1E4199"},children:e.jsxs("h1",{style:{fontSize:"28px",fontWeight:"600",color:"#333333",fontFamily:"Pretendard-SemiBold, Helvetica",margin:"0"},children:[d,m&&e.jsxs("span",{style:{fontSize:"20px",fontWeight:"400",color:"#666666",marginLeft:"8px"},children:["(",m,")"]})]})}),e.jsxs("div",{className:"course-home-container",children:[e.jsx(N,{uuid:t}),e.jsx("div",{className:"course-main-content",children:e.jsx("div",{style:{textAlign:"center",padding:"4rem"},children:e.jsx("p",{children:"ë¡ë© ì¤..."})})})]})]}):z?e.jsxs(w,{children:[d&&e.jsx("header",{style:{width:"100%",marginBottom:"24px",paddingBottom:"16px",borderBottom:"2px solid #1E4199"},children:e.jsxs("h1",{style:{fontSize:"28px",fontWeight:"600",color:"#333333",fontFamily:"Pretendard-SemiBold, Helvetica",margin:"0"},children:[d,m&&e.jsxs("span",{style:{fontSize:"20px",fontWeight:"400",color:"#666666",marginLeft:"8px"},children:["(",m,")"]})]})}),e.jsxs("div",{className:"course-home-container",children:[e.jsx(N,{uuid:t}),e.jsx("div",{className:"course-main-content",children:e.jsxs("section",{className:"flex flex-col items-start gap-6 px-6 py-6 max-md:px-4 max-md:py-5 w-full bg-x-ffffff",children:[e.jsxs("h2",{className:"text-xl font-semibold text-[#333333] font-['Pretendard-SemiBold',Helvetica]",children:["ê³µì§ì¬í ",n?"ìì ":"ìì±"]}),e.jsxs("form",{onSubmit:k,className:"w-full flex flex-col gap-6",children:[e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{htmlFor:"title",className:"font-['Pretendard-Medium',Helvetica] font-medium text-[#333333] text-sm",children:["ì 목 ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx("input",{type:"text",id:"title",value:g,onChange:o=>$(o.target.value),placeholder:"ì 목ì ì ë ¥íì¸ì",className:"w-full h-10 px-3 border border-line2-d9d9d9 rounded bg-white font-['Pretendard-Regular',Helvetica] text-sm text-[#333333] outline-none focus:border-green1-007062",required:!0})]}),e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:y,onChange:o=>P(o.target.checked),className:"w-4 h-4 accent-green1-007062"}),e.jsx("span",{className:"font-['Pretendard-Regular',Helvetica] text-sm text-[#333333]",children:"ì¤ì ê³µì§ (ìë¨ ê³ ì )"})]}),y&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("label",{className:"font-['Pretendard-Regular',Helvetica] text-sm text-[#696969]",children:"ì¢ ë£ì¼:"}),e.jsx("input",{type:"datetime-local",value:b,onChange:o=>H(o.target.value),className:"h-8 px-2 border border-line2-d9d9d9 rounded bg-white font-['Pretendard-Regular',Helvetica] text-sm text-[#333333] outline-none"})]})]}),e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("label",{className:"font-['Pretendard-Medium',Helvetica] font-medium text-[#333333] text-sm",children:["ë´ì© ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsx(G,{content:j,onChange:B,placeholder:"ë´ì©ì ì ë ¥íì¸ì",minHeight:"400px"})]}),e.jsxs("div",{className:"flex items-center justify-center gap-3 pt-4",children:[e.jsx("button",{type:"button",onClick:D,className:"w-[100px] h-10 flex items-center justify-center bg-gray-500 text-white rounded hover:bg-gray-600 transition-colors font-['Pretendard-Medium',Helvetica]",children:"ì·¨ì"}),e.jsx("button",{type:"submit",disabled:S,className:"w-[100px] h-10 flex items-center justify-center bg-green1-007062 text-white rounded hover:bg-green2-005248 transition-colors font-['Pretendard-Medium',Helvetica] disabled:opacity-50",children:S?n?"ìì ì¤...":"ë±ë¡ ì¤...":n?"ìì ":"ë±ë¡"})]})]})]})})]})]}):e.jsxs(w,{children:[d&&e.jsx("header",{style:{width:"100%",marginBottom:"24px",paddingBottom:"16
2px",borderBottom:"2px solid #1E4199"},children:e.jsxs("h1",{style:{fontSize:"28px",fontWeight:"600",color:"#333333",fontFamily:"Pretendard-SemiBold, Helvetica",margin:"0"},children:[d,m&&e.jsxs("span",{style:{fontSize:"20px",fontWeight:"400",color:"#666666",marginLeft:"8px"},children:["(",m,")"]})]})}),e.jsxs("div",{className:"course-home-container",children:[e.jsx(N,{uuid:t}),e.jsx("div",{className:"course-main-content",children:e.jsxs("div",{style:{textAlign:"center",padding:"4rem"},children:[e.jsxs("p",{style:{color:"red",marginBottom:"1rem"},children:["ê³µì§ì¬í ",n?"ìì ":"ìì±"," ê¶íì´ ììµëë¤."]}),e.jsx("button",{onClick:()=>c(`/lms/cws/home/${t}/notice`),className:"px-4 py-2 bg-green1-007062 text-white rounded hover:bg-green2-005248",children:"목ë¡ì¼ë¡ ëìê°ê¸°"})]})})]})]})};export{ae as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.