(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[849],{20849:function(e,n,t){"use strict";t.r(n),t.d(n,{default:function(){return update}});var a=t(67294),c=t(50029),i=t(72640),l=t(87794),s=t.n(l),r=t(9669),o=t.n(r),d=t(11163),u=t(2804),p=t(4559),h=t(23749),m=t(43977),_=t(62500),f=t.n(_),g=t(11701),x=t(39332),b=t(85893),qnaupdate=function(){(0,x.useSearchParams)();var e,n=(0,a.useState)({title:!1,content:!1,imagePath:!1}),t=n[0];n[1];var l=(0,d.useRouter)(),r=(0,p.ZP)(l.query.id).data,_=(0,a.useState)("REQUEST"),v=_[0],j=_[1],q=(0,a.useState)(""),y=q[0],N=q[1],w=(0,a.useState)(""),k=(w[0],w[1]),E=(0,a.useState)(!0),C=E[0],P=E[1],S=(0,a.useState)(""),$=S[0],I=S[1],D=(0,a.useState)(""),Z=D[0],B=D[1],L=(0,a.useState)([]),A=L[0],O=L[1],W=(0,h.Z)(),T=(0,i.Z)(W,1)[0],U=(0,u.FV)(g.B),F=(0,i.Z)(U,2),Q=F[0],R=F[1];(0,a.useEffect)(function(){var e=null==r?void 0:r.qnas.nodes[0];if(e){N(e.name);var n,t=null!=e&&!!e.public;k(e.password||""),P(t),I((null==e?void 0:e.title)||""),B((null==e?void 0:e.content)||""),j((null==e?void 0:e.category)||"REQUEST");var a=null===(n=e.imagePath)||void 0===n?void 0:n.split(","),c=[];if(a&&e.imagePath){for(var i=0;i<((null==a?void 0:a.length)||0);i++){var l={imagePath:a[i]};c.push(l)}O(c)}}},[r]),(0,a.useEffect)(function(){console.log(t)},[t]);var X=(0,a.useMemo)(function(){return Object.entries(m.ru).map(function(e){return(0,b.jsx)("option",{value:e[0],children:e[1]},e[0])})},[]),G=(e=(0,c.Z)(s().mark(function _callee(e){var n,t,a,c,i,l,r;return s().wrap(function(s){for(;;)switch(s.prev=s.next){case 0:if(!(null!==(n=e.target.files)&&void 0!==n&&n.length)){s.next=23;break}if(!Array.from(e.target.files).find(function(e){return null===e.name.match("\\.(bmp|gif|jpg|jpeg|png|HEIC)$")})){s.next=7;break}return alert("이미지파일이 아닙니다"),s.abrupt("return",!1);case 7:a=(t=A.slice()).length+e.target.files.length>3?3:t.length+e.target.files.length,c=0;case 10:if(!(c<a)){s.next=23;break}if(!(i=e.target.files[c])){s.next=19;break}return(l=new FormData).append("file",i),s.next=17,o().post("https://api.recl.me/aws/upload",l);case 17:r=s.sent,t.push({imagePath:r.data});case 19:O(t);case 20:c++,s.next=10;break;case 23:case"end":return s.stop()}},_callee)})),function(n){return e.apply(this,arguments)});return(0,b.jsxs)("div",{className:f().boardWrite,children:[(0,b.jsxs)("section",{style:{marginBottom:0},children:[(0,b.jsxs)("div",{className:f().topContainer,children:[(0,b.jsx)("div",{className:f().category,children:(0,b.jsx)("select",{placeholder:"문의 유형을 선택해주세요",disabled:!0,onChange:function(e){j(e.target.value)},value:v,children:X})}),(0,b.jsxs)("label",{className:f().checkbox,children:[(0,b.jsx)("i",{}),"비밀글",(0,b.jsx)("input",{type:"checkbox",id:"secret",name:"secret",checked:!C,onChange:function(e){P(!C)}})]})]}),(0,b.jsx)("div",{className:f().row,style:{width:"calc(100% - 20px)"},children:(0,b.jsxs)("div",{className:"".concat(f().col),children:[(0,b.jsx)("label",{htmlFor:"wr_name",className:f().label,children:"이름\xa0"}),(0,b.jsx)("div",{children:(0,b.jsx)("label",{className:"".concat(f().input),children:(0,b.jsx)("input",{type:"text",name:"wr_name",id:"name",size:10,value:y,className:"".concat(f().name),readOnly:!0,disabled:!0,maxLength:20,onChange:function(e){if(e.target.value.match(/\s/g))return e.target.value=e.target.value.replace(/\s/g,""),!1;N(e.target.value)}})})})]})}),(0,b.jsx)("div",{className:f().row,children:(0,b.jsxs)("div",{className:"".concat(f().col),style:{width:"1024px"},children:[(0,b.jsx)("div",{style:{display:"flex",justifyContent:"space-between"},children:(0,b.jsxs)("label",{className:f().label,children:["제목",(0,b.jsx)("span",{className:f().required,children:"*"})]})}),(0,b.jsx)("label",{className:"".concat(f().input),children:(0,b.jsx)("input",{type:"text",size:10,maxLength:20,className:"".concat(f().title," ").concat(t.title?f().error:""),value:$,onChange:function(e){I(e.target.value)}})})]})}),(0,b.jsx)("div",{className:f().row,children:(0,b.jsxs)("div",{className:"".concat(f().col," ").concat(f().content),style:{width:"1024px"},children:[(0,b.jsx)("div",{style:{display:"flex",justifyContent:"space-between"},children:(0,b.jsxs)("label",{className:"".concat(f().label," ").concat(f().content),children:["내용",(0,b.jsx)("span",{className:f().required,children:"*"})]})}),(0,b.jsx)("label",{className:"".concat(f().input," required-mark m-b-10"),children:(0,b.jsx)("textarea",{id:"wr_content",name:"wr_content",maxLength:65536,placeholder:"* 문의 내용 작성 전 연락 가능한 (회원의 경우 접수 당시 번호) 연락처 기재 부탁드립니다.",className:"".concat(f().content," ").concat(t.content?f().error:""),value:Z,onChange:function(e){B(e.target.value)}})})]})}),(0,b.jsx)("div",{className:f().row,children:(0,b.jsxs)("div",{className:"".concat(f().col," ").concat(f().col6," ").concat(f().imgContainer),style:{width:"100%",display:"flex"},children:[A.length<3&&(0,b.jsxs)("div",{className:f().addImage,onClick:function(){var e=document.getElementById("file");e&&e.click()},children:["+",(0,b.jsxs)("span",{className:f().count,children:[A.length,"/",(0,b.jsx)("span",{style:{color:"#D1D1D1"},children:"3"})]})]}),A.map(function(e,n){return(0,b.jsxs)("div",{onClick:function(){A.length>1?O(A.filter(function(n){return n.imagePath!==e.imagePath})):O([])},className:f().imgList,onMouseOver:function(){var e=document.getElementById("close".concat(n));e&&(e.style.display="block")},onMouseOut:function(){var e=document.getElementById("close".concat(n));e&&(e.style.display="none")},children:[(0,b.jsx)("span",{id:"close".concat(n),children:"삭제"}),(0,b.jsx)("img",{src:"https://d3eon3p6ldako6.cloudfront.net/".concat(e.imagePath)})]},n)}),(0,b.jsx)("input",{type:"file",hidden:!0,id:"file",onChange:function(e){G(e)}})]})})]}),(0,b.jsxs)("div",{className:"".concat(f().footer," text-center"),children:[(0,b.jsx)("a",{className:"".concat(f().btnE," ").concat(f().btnEXlg," ").concat(f().btnETeal),onClick:function(){var e="";A.forEach(function(n,t){e+=n.imagePath+(t<A.length-1?",":"")}),T({variables:{id:Number(l.query.id),password:Q,category:v,title:$,content:Z,imagePath:e,public:C}}).then(function(e){R(""),l.push({pathname:"/community/qna"})}).catch(function(e){console.log(e)})},children:"작성완료"}),(0,b.jsx)("a",{className:"".concat(f().btnE," ").concat(f().btnEDark),onClick:function(){l.push({pathname:"/community/qna"})},children:"취소"})]})]})},update=function(){return(0,a.useEffect)(function(){history.pushState(null,"",location.href),window.addEventListener("popstate",function(){location.reload()})},[]),(0,b.jsx)(qnaupdate,{})}},4559:function(e,n,t){"use strict";var a,c=t(71383);t(87794);var i=t(68806),l=t(37887),s=(0,i.Ps)(a||(a=(0,c.Z)(["\n  query GetQNA($id: ID) {\n    qnas(filter: { id: { eq: $id }, deleted: { in: [false]}}) {\n      nodes {\n        id\n        createdAt\n        createdUserId\n        updatedAt\n        updatedUserId\n        userId\n        title\n        content\n        name\n        status\n        imagePath,\n        public\n        category\n        adminUser {\n          name\n        }\n        replyContent\n        replyAt\n        user {\n          name\n          nickname\n          phoneNo\n        }\n      }\n    }\n  }\n"])));n.ZP=function(e){return(0,l.a)(s,{variables:{id:e},fetchPolicy:"cache-and-network"})}},23749:function(e,n,t){"use strict";var a,c=t(71383),i=t(68806),l=t(50319),s=(0,i.Ps)(a||(a=(0,c.Z)(["\n  mutation UpdateOneQna(\n    $id: ID!\n    $password: String!\n    $deleted: Boolean\n    $content: String\n    $imagePath: String\n    $title: String\n    $public: Boolean\n  ) {\n    updateOneQna(\n      input: {\n        id: $id\n        update: {\n          deleted: $deleted\n          content: $content\n          password: $password\n          title: $title\n          imagePath: $imagePath\n          public: $public\n        }\n      }\n    ) {\n      id\n    }\n  }\n"])));n.Z=function(e){return(0,l.D)(s,e)}},11701:function(e,n,t){"use strict";t.d(n,{B:function(){return a}});var a=(0,t(2804).cn)({key:"password",default:""})},62500:function(e){e.exports={boardWrite:"qnaupdate_boardWrite__Xdl27",boardWriteTitle:"qnaupdate_boardWriteTitle__O0YoF",topContainer:"qnaupdate_topContainer__gp8RL",category:"qnaupdate_category__jbd19",col3:"qnaupdate_col3__FZLkp",col6:"qnaupdate_col6__63A8P",col:"qnaupdate_col__G2vHj",content:"qnaupdate_content__qsxED",iconAppend:"qnaupdate_iconAppend__Ia7us",error:"qnaupdate_error__6gS8c",input:"qnaupdate_input__KMDJB",name:"qnaupdate_name__E_pWW",password:"qnaupdate_password__k67rE",title:"qnaupdate_title__vXjdz",label:"qnaupdate_label__Jpd9p",required:"qnaupdate_required__fGJse",checkbox:"qnaupdate_checkbox__PbDup",row:"qnaupdate_row__YlZC4",btnE:"qnaupdate_btnE__jSOb6",btnEXlg:"qnaupdate_btnEXlg__hyBKQ",btnETeal:"qnaupdate_btnETeal__Y4IWx",btnEDark:"qnaupdate_btnEDark__FbnLt",addImage:"qnaupdate_addImage__RG1jl",imgList:"qnaupdate_imgList__feeqP",footer:"qnaupdate_footer__iINwA",count:"qnaupdate_count__2JvUk",imgContainer:"qnaupdate_imgContainer__ZCi5d"}}}]);