PageSourceSearch

https://www.hussde.com/assets/CourseNoticeCreate-GDIUp5nu.js

js hussde.com collected 2026-09-29 02:04:58 UTC 7,273 bytes, 2 lines download raw bytes

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.