1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[6594],{32644:function(e,s,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/esg/new",function(){return t(85841)}])},92288:function(e,s,t){"use strict";t.d(s,{Z:function(){return BlankWrapper}});var l=t(85893),r=t(80166);function BlankWrapper(e){let{title:s,children:t,show:n=!0,url:a}=e;return(0,l.jsxs)("div",{className:"flex flex-col max-w-screen-xl",children:[(0,l.jsx)("div",{className:"",children:(0,l.jsxs)("h1",{className:"titulo-pagina flex gap-[0.5rem] items-center",children:[s,(0,l.jsx)(r.Z,{url:a,show:n})]})}),(0,l.jsx)("hr",{className:"border-1 my-6 mt-1"}),(0,l.jsx)("div",{className:"-my-2 ",children:(0,l.jsx)("div",{className:"py-2 align-middle inline-block min-w-full sm:px-6 lg:px-8",children:(0,l.jsx)("div",{className:"border-b border-gray-200 sm:rounded-lg",children:(0,l.jsx)("div",{className:"overflow-x-auto",children:(0,l.jsx)("div",{className:"bg-white px-[1rem] sm:px-[3rem]",children:t})})})})})]})}},14411:function(e,s,t){"use strict";var l=t(85893),r=t(35773),n=t(42746),a=t(67294);s.Z=e=>{let{choices:s,setChoices:t,matrix:i,questions:o,setQuestions:u,edit:c=!1,esgForms:d,setEsgForms:m,mapIndex:x,payload:h}=e,v=(0,n.useTranslations)("buttons"),[p,b]=(0,a.useState)(""),[f,j]=(0,a.useState)(""),handleRemoveChoice=e=>{if(c){let t=[...s];t.splice(e,1);let l=[...d];l[x].choices=t,m(l)}else{let l=[...s];l.splice(e,1),t(l)}},handleRemoveQuestions=e=>{if(c){let s=[...o];s.splice(e,1);let t=[...d];
1t[x].questions=s,m(t)}else{let s=[...o];s.splice(e,1),u(s)}};return(0,l.jsxs)(l.Fragment,{children:[i&&(0,l.jsxs)("div",{className:"pb-2",children:[(0,l.jsx)("div",{className:"information_Label",children:v("questions")}),(0,l.jsx)("ul",{children:o.map((e,s)=>(0,l.jsx)("li",{children:(0,l.jsxs)("span",{className:"items-center flex font-[500] gap-[0.5rem]",children:[e,(0,l.jsx)("button",{type:"button",onClick:()=>{handleRemoveQuestions(s)},className:"text-[1.5rem] hover:cursor-pointer",children:"\xd7"})]})},(0,r.fV)()))}),(0,l.jsx)("input",{className:"inputFormClass !w-full !border-blue-100 ",type:"text",value:f,onChange:e=>j(e.target.value)}),""!=f&&(0,l.jsx)("div",{id:"input_and_button",className:"flex justify-center",children:(0,l.jsx)("button",{type:"button",className:"border border-blue-300 rounded-lg p-1",onClick:()=>{c||""===f.trim()?o.push(f):u([...o,f]),j("")},children:v("addQuestion")})})]}),(0,l.jsxs)("div",{children:[(0,l.jsx)("div",{className:"information_Label",children:v("choices")}),(0,l.jsx)("ul",{children:s.map((e,s)=>(0,l.jsx)("li",{children:(0,l.jsxs)("span",{className:"items-center flex font-[500] gap-[0.5rem]",children:[e,(0,l.jsx)("button",{type:"button",onClick:()=>{handleRemoveChoice(s)},className:"text-[1.5rem] hover:cursor-pointer",children:"\xd7"})]})},(0,r.fV)()))}),(0,l.jsx)("input",{className:"inputFormClass !w-full !border-blue-100 ",type:"text",value:p,onChange:e=>b(e.target.value)}),""!=p&&(0,l.jsx)("div",{id:"questionInput_and_button",className:"flex justify-center",children:(0,l.jsx)("button",{type:"button",className:"border border-blue-300 rounded-lg p-1",onClick:()=>{c||""===p.trim()?s.push(p):t([...s,p]),b("")},children:v("addChoice")})})]})]})}},80166:function(e,s,t){"use strict";var l=t(85893),r=t(42746),n=t(25675),a=t.n(n),i=t(11163);s.Z=e=>{let{show:s,url:t}=e,n=(0,i.useRouter)(),o=(0,r.useTranslations)("buttons"),handleClick=()=>{t?n.replace(t):n.back()};return s?(0,l.jsx)("button",{onClick:()=>{handleClick()},className:"text-green-500 hover:text-green-700",title:o("return"),children:(0,l.jsx)(a(),{width:20,height:15,src:"/icon/redirectDark.svg",alt:"SVG",className:"!text-pink-500"})}):null}},85841:function(e,s,t){"use strict";t.r(s),t.d(s,{default:function(){return esg_new}});var l=t(85893),r=t(67294),n=t(11163),a=t(4023),i=t(30727),o=t(22920),u=t(35773),c=t(42746),d=t(99971),m=t(15333),x=t(9198),h=t.n(x);t(35890);var v=t(14411);function ESGForm(e){let{save:s,isLoading:t,set:n,payload:a,edit:i,errors:o}=e,x=(0,c.useTranslations)("tables"),p=(0,c.useTranslations)("buttons"),b=(0,c.useTranslations)("toast"),[f,j]=(0,r.useState)(null),[g,y]=(0,r.useState)(a.sustainabilitySurveyPostRequests),[C,N]=(0,r.useState)("CHECKBOX"),[w,E]=(0,r.useState)(""),[q,S]=(0,r.useState)(""),handleEsgChoice=e=>{if(""!==q){let s,t={typeInputEsg:C,question:q};P.length>0&&(t.questions=P),T.length>0&&(t.choices=T),null!=e?(s=[...g])[e]=t:s=[...g,t],y(s),S(""),I([]),_([]),R(null),a.sustainabilitySurveyPostRequests=s}else E(b("mandatoryError"))},removeEsgFormRequest=e=>{if(e>=0&&e<g.length){let s=[...g];s.splice(e,1),y(s),a.sustainabilitySurveyPostRequests=s}},[k,R]=(0,r.useState)(null),updateEsgFormRequest=e=>{R(e);let s=g[e];N(s.typeInputEsg),S(s.question),s.choices&&_(s.choices),s.questions&&I(s.questions)},cancelEditEsgFormRequest=()=>{S(""),I([]),_([]),R(null)},[T,_]=(0,r.useState)([]),[P,I]=(0,r.useState)([]),getButtonName=function(e){let s=!(arguments.length>1)||void 0===arguments[1]||arguments[1],t=s?" - ".concat(x("description")):"";switch(e){case"CHECKBOX":return p("checkbox")+t;case"TEXT":default:return p("text")+t;case"MULTIPLE_CHOICE":return p("multipleChoice")+t;case"MATRIX":return p("matrix")+t}};return(0,l.jsxs)("form",{onSubmit:s,className:"flex mt-2 py-4 xl:flex-row flex-col xl:gap-[2rem] ",children:[(0,l.jsxs)("div",{className:"flex flex-col min-w-[13rem] xl:w-[32rem]",children:[(0,l.jsxs)("div",{id:"esgYear",className:"relative mb-[1rem] xl:mb-0 xl:mt-[0] rounded-xl w-[8rem]",children:[(0,l.jsx)(h(),{selected:f,onChange:e=>{if(e){j(e);let s=e.toISOString(),t=s.split("-")[0];a.year=t}},dateFormat:"yyyy",autoComplete:"off",showPopperArrow:!0,className:"h-[2.5rem] w-[8rem] border rounded-lg border-black pl-[0.5rem] mt-[0.2rem]",placeholderText:x("startDate"),id:"startDate",name:"startDate",showYearPicker:!0}),(null==o?void 0:o.year)&&(0,l.jsx)("span",{className:"error",children:null==o?void 0:o.year}),null!=f&&(0,l.jsx)("button",{onClick:()=>{j(null)},className:"absolute top-0 right-0 bottom-0 flex items-center pr-[0.5rem] hover:cursor-pointer",children:"\xd7"})]}),(0,l.jsxs)("div",{id:"esgChoicesCreator",className:"flex flex-col gap-3 border-[0.14rem] border-[#ad8b19] my-[2rem] rounded-xl p-[1rem]",children:[(0,l.jsx)("div",{id:"selectBox",className:"max-w-[10rem]",children:(0,l.jsxs)("select",{className:"information_input w-full",value:C,onChange:e=>{("CHECKBOX"===e.target.value||"TEXT"===e.target.value)&&(_([]),I([])),"MULTIPLE_CHOICE"===e.target.value&&_([]),N(e.target.value)},children:[(0,l.jsx)("option",{value:"CHECKBOX",children:p("checkbox")}
1),(0,l.jsx)("option",{value:"TEXT",children:p("text")}),(0,l.jsx)("option",{value:"MULTIPLE_CHOICE",children:p("multipleChoice")}),(0,l.jsx)("option",{value:"MATRIX",children:p("matrix")})]})}),(0,l.jsx)("div",{children:(0,l.jsx)(m.Kx,{type:"text",onChange:e=>{E(""),S(e.target.value)},label:x("description"),defaultValue:q,name:"description",twClass:"w-full",error:w})}),"MULTIPLE_CHOICE"===C&&(0,l.jsx)(v.Z,{choices:T,setChoices:_}),"MATRIX"===C&&(0,l.jsx)(v.Z,{choices:T,setChoices:_,questions:P,setQuestions:I,matrix:!0}),(e=>{switch(e){case"CHECKBOX":case"TEXT":default:return""!=q.trim();case"MULTIPLE_CHOICE":return T.length>0&&""!=q.trim();case"MATRIX":return P.length>0&&T.length>0&&""!=q.trim()}})(C)&&(0,l.jsx)("button",{type:"button",className:"flex justify-center hover:cursor-pointer",onClick:()=>handleEsgChoice(k),children:(0,l.jsxs)("div",{id:"addChoice",className:"font-[700] border border-[#ad8b19] rounded-xl inline-block p-2",children:["+ ",p("add")]})})]}),(0,l.jsx)("div",{className:"pt-4 flex justify-end",children:(0,l.jsx)(d.z,{action:()=>{},name:p("save"),twClass:"!text-white !text-base drop-shadow-xl",loading:t})})]}),(0,l.jsxs)("div",{className:"flex flex-col gap-2 overflow-auto mt-[2rem] xl:mt-0 h-[28rem]",children:[(null==o?void 0:o.sustainabilitySurveyPostRequests)&&(0,l.jsx)("span",{className:"error",children:null==o?void 0:o.sustainabilitySurveyPostRequests}),null==g?void 0:g.map((e,s)=>{var t,r;return(0,l.jsxs)("div",{className:"border rounded-2xl p-5 flex flex-row gap-2 max-w-[30rem] justify-between ".concat(s===k?"border-yellow-500":"border-[#7e96a1]"),children:[(0,l.jsxs)("div",{className:"",children:[(0,l.jsx)("span",{className:"font-[500]",children:getButtonName(e.typeInputEsg,!1)}),(0,l.jsx)("div",{className:"w-[15rem] overflow-auto",children:e.question}),(null==e?void 0:e.questions)&&(0,l.jsx)("div",{className:"w-[15rem] overflow-auto font-[500] mt-[0.1rem]",children:p("questions")}),(0,l.jsx)("div",{className:"w-[15rem] overflow-auto",children:null==e?void 0:null===(t=e.questions)||void 0===t?void 0:t.map(e=>(0,l.jsx)("span",{children:e},(0,u.fV)()))}),(null==e?void 0:e.choices)&&(0,l.jsx)("div",{className:"w-[15rem] overflow-auto font-[500] mt-[0.1rem]",children:p("choices")}),(0,l.jsx)("div",{className:"w-[15rem] overflow-auto",children:null==e?void 0:null===(r=e.choices)||void 0===r?void 0:r.map(e=>(0,l.jsx)("span",{children:e},(0,u.fV)()))})]}),(0,l.jsx)("div",{className:"",children:(0,l.jsxs)("div",{className:"flex items-center gap-1",children:[s===k?(0,l.jsx)("button",{onClick:()=>cancelEditEsgFormRequest(),type:"button",children:p("cancel")}):(0,l.jsx)("button",{onClick:()=>{updateEsgFormRequest(s)},type:"button",children:p("edit")}),(0,l.jsx)("button",{type:"button",onClick:()=>{removeEsgFormRequest(s)},className:"text-[1.5rem] hover:cursor-pointer",children:"\xd7"})]})})]},(0,u.fV)())})]})]})}var p=t(92288),esg_new=()=>{let e=(0,c.useTranslations)("titles"),s=(0,c.useTranslations)("toast"),{token:t,APIURL:d}=(0,a.qD)(),[m,x]=(0,r.useState)(!1),[h,v]=(0,r.useState)({year:null,sustainabilitySurveyPostRequests:[]}),[b,f]=(0,r.useState)({}),j={year:s("mandatoryError"),sustainabilitySurveyPostRequests:s("mandatoryError")},g=(0,r.useMemo)(()=>new i.Z(d,t),[t]),y=(0,n.useRouter)(),save=async e=>{e.preventDefault();let t={};if("string"==typeof h.year&&""===h.year.trim()?t.year=j.year:delete j.year,0===h.sustainabilitySurveyPostRequests.length?t.sustainabilitySurveyPostRequests=j.sustainabilitySurveyPostRequests:delete j.sustainabilitySurveyPostRequests,f(t),0===Object.keys(t).length){let e=(0,u.Cs)(h);null==g||g.postObject("esg",e).then(e=>{x(!1),(0,o.Am)(s("createDone")),y.back()}).catch(e=>{var s,t,l,r,n,a,i,u,c;x(!1),o.Am.error((null===(r=e.response)||void 0===r?void 0:null===(l=r.data)||void 0===l?void 0:null===(t=l.errorsDetails)||void 0===t?void 0:null===(s=t.debugMessage[0])||void 0===s?void 0:s.message)||(null===(i=e.response)||void 0===i?void 0:null===(a=i.data)||void 0===a?void 0:null===(n=a.errorsDetails)||void 0===n?void 0:n.debugMessage)||(null===(c=e.response)||void 0===c?void 0:null===(u=c.data)||void 0===u?void 0:u.message))})}};return(0,l.jsxs)(p.Z,{title:"".concat(e("new")," ").concat(e("esg")),children:[(0,l.jsx)(ESGForm,{edit:!1,errors:b,isLoading:m,save:save,payload:h,set
1:e=>{v(s=>((0,u.F1)(s,e.target.name,e.target.value),s))}})," "]})}}},function(e){e.O(0,[8040,9741,9774,2888,179],function(){return e(e.s=32644)}),_N_E=e.O()}]);
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.