PageSourceSearch

https://uhamka.ac.id/static/js/8382.9343f0b7.chunk.js

js uhamka.ac.id collected 2026-09-24 18:21:13 UTC 12,034 bytes, 2 lines download raw bytes

1"use strict";(self.webpackChunk_coreui_coreui_free_react_admin_template=self.webpackChunk_coreui_coreui_free_react_admin_template||[]).push([[8382],{88382:function(e,t,s){s.r(t);var r=s(4942),n=s(1413),a=s(15861),i=s(70885),l=s(87757),o=s.n(l),c=s(72791),d=s(16871),u=s(74569),g=s.n(u),h=s(21830),p=s.n(h),m=s(28187),x=s.n(m),f=(s(80729),s(13956)),v=(s(64861),s(80184)),j={buttonList:[["undo","redo"],["bold","underline","italic","strike"],["fontColor","hiliteColor"],["removeFormat"],["outdent","indent"],["align","horizontalRule","list"],["table","link"],["fullScreen","showBlocks","codeView"]],height:"200px"};t.default=function(){var e=(0,d.s0)(),t=(0,c.useState)([]),s=(0,i.Z)(t,2),l=s[0],u=s[1],h=(0,c.useState)([]),m=(0,i.Z)(h,2),b=m[0],S=m[1],N=(0,c.useState)(!0),C=(0,i.Z)(N,2),k=C[0],y=C[1],D=(0,c.useState)(!1),w=(0,i.Z)(D,2),G=w[0],Z=w[1],E=(0,c.useState)(!1),_=(0,i.Z)(E,2),I=_[0],L=_[1],T=(0,c.useState)(""),B=(0,i.Z)(T,2),q=B[0],A=B[1],F=(0,c.useState)(null),P=(0,i.Z)(F,2),z=P[0],V=P[1],R=(0,c.useState)(""),M=(0,i.Z)(R,2),O=M[0],U=M[1],Y=(0,c.useState)({id:"",lang:"ID",title:"",sub_title:"",description:"",code:"",image:""}),H=(0,i.Z)(Y,2),J=H[0],W=H[1],K=function(){var e=(0,a.Z)(o().mark((function e(){var t,s,r,n;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return y(!0),e.prev=1,e.next=4,g().get("".concat(f.Z.url.api,"/sdgs"),{headers:{Authorization:"Bearer ".concat(localStorage.getItem("token"))}});case 4:t=e.sent,u(t.data.data||[]),S(t.data.data||[]),e.next=15;break;case 9:e.prev=9,e.t0=e.catch(1),console.error("Error fetching SDGS:",e.t0),404!==(null===(s=e.t0.response)||void 0===s?void 0:s.status)&&p().fire({icon:"error",title:"Error!",text:(null===(r=e.t0.response)||void 0===r||null===(n=r.data)||void 0===n?void 0:n.message)||"Failed to fetch SDGS data"}),u([]),S([]);case 15:return e.prev=15,y(!1),e.finish(15);case 18:case"end":return e.stop()}}),e,null,[[1,9,15,18]])})));return function(){return e.apply(this,arguments)}}();(0,c.useEffect)((function(){K()}),[]),(0,c.useEffect)((function(){var e=l.filter((function(e){var t,s,r;return(null===(t=e.title)||void 0===t?void 0:t.toLowerCase().includes(q.toLowerCase()))||(null===(s=e.code)||void 0===s?void 0:s.toLowerCase().includes(q.toLowerCase()))||(null===(r=e.description)||void 0===r?void 0:r.toLowerCase().includes(q.toLowerCase()))}));S(e)}),[q,l]);var Q=function(e){var t=e.target,s=t.name,a=t.value;W((function(e){return(0,n.Z)((0,n.Z)({},e),{},(0,r.Z)({},s,a))}))},X=function(){var e=(0,a.Z)(o().mark((function e(t){var s,r,n,a,l;return o().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(t.preventDefault(),J.title&&J.description&&J.code){e.next=4;break}return p().fire({icon:"warning",title:"Validation Error",text:"Please fill all required fields"}),e.abrupt("return");case 4:if(e.prev=4,(s=new FormData).append("lang",J.lang),s.append("title",J.title),s.append("sub_title",J.sub_title),s.append("description",J.description),s.append("code",J.code),z&&s.append("image",z),!I){e.next=18;break}return e.next=15,g().post("".concat(f.Z.url.api,"/sdgs-update/").concat(J.id),s,{headers:{Authorization:"Bearer ".concat(localStorage.getItem("token")),"Content-Type":"multipart/form-data"}});case 15:p().fire({icon:"success",title:"Success!",text:"SDGS updated successfully"}),e.next=21;break;case 18:return e.next=20,g().post("".concat(f.Z.url.api,"/sdgs-insert"),s,{headers:{Authorization:"Bearer ".concat(localStorage.getItem("token")),"Content-Type":"multipart/form-data"}});case 20:p().fire({icon:"success",title:"Success!",text:"SDGS created successfully"});case 21:Z(!1),K(),e.next=40;break;case 25:if(e.prev=25,e.t0=e.catch(4),console.error("Error saving SDGS:",e.t0),r="Failed to save SDGS",!e.t0.response){e.next=38;break}if(n=e.t0.response,a=n.data,422!==n.status||!a.errors){e.next=35;break}return l=Object.entries(a.errors).map((function(e){var t=(0,i.Z)(e,2),s=t[0],r=t[1];return"".concat(s,": ").concat(r.join(", "))})).join("\n"),p().fire({icon:"error",title:"Validation Error",html:'<div style="text-align: left; white-space: pre-line;">'.concat(l,"</div>")}),e.abrupt("return");case 35:a.message?r=a.message:a.error&&(r=a.error),e.next=39;break;case 38:r=e.t0.request?"No response from server. Please check your connection.":e.t0.message||"An unexpected error occurred";case 39:p().fire({icon:"error",title:"Error!",text:r});case 40:case"end":return e.stop()}}),e,null,[[4,25]])})));return function(t){return e.apply(this,arguments)}}();return(0,v.jsxs)("div",{className:"sdgs-container",children:[(0,v.jsx)("div",{className:"sdgs-header",children:(0,v.jsxs)("h1",{children:[(0,v.jsx)("div",{className:"sdgs-header-icon",children:"\ud83c\udf0d"}),"Sustainable Development Goals (SDGS)"]})}),(0,v.jsxs)("div",{className:"sdgs-content-card",children:[(0,v.jsxs)("div",{className:"sdgs-toolbar",children:[(0,v.jsxs)("div",{className:"sdgs-search-box",children:[(0,v.jsx)("span",{className:"sdgs-search-icon",children:"\ud83d\udd0d"}),(0,v.jsx)("input",{type:"text",placeholder:"Search SDGS by title, code, or description...",value:q,onChange:function(e){return A(e.target.value)}})]}),(0,v.jsxs)("button",{className:"sdgs-btn-add",onClick:function(){L(!1),W({id:"",lang:"ID",title:"",sub_title:"",description:"",code:"",image:""}),V(null),U(""),Z(!0)},children:[(0,v.jsx)("span",{children:"\u2795"}),"Add New SDGS"]})]}),k?(0,v.jsxs)("div",{className:"sdgs-loading",children:[(0,v.jsx)("div",{className:"sdgs-spinner"}),(0,v.jsx)("p",{children:"Loading SDGS data..."})]}):0===b.length?(0,v.jsxs)("div",{className:"sdgs-empty-state",children:[(0,v.jsx)("div",{className:"sdgs-empty-icon",children:"\ud83d\udccb"}),(0,v.jsx)("h3",{children:"No SDGS Found"}),(0,v.jsx)("p",{children:q?"No results match your search. Try different keywords.":"Start by adding your first SDGS goal."})]}):(0,v.jsx)("div",{className:"sdgs-table-wrapper",children:(0,v.jsxs)("table",{className:"sdgs-table",children:[(0,v.jsx)("thead",{children:(0,v.jsxs)("tr",{children:[(0,v.jsx)("th",{children:"Code"}),(0,v.jsx)("th",{children:"Image"}),(0,v.jsx)("th",{children:"Title"}),(0,v.jsx)("th",{children:"Description"}),(0,v.jsx)("th",{children:"Language"}),(0,v.jsx)("th",{children:"Actions"})]})}),(0,v.jsx)("tbody",{children:b.map((function(t){return(0,v.jsxs)("tr",{children:[(0,v.jsx)("td",{children:(0,v.jsx)("div",{className:"sdgs-code-badge",children:t.code})}),(0,v.jsx)("td",{children:t.image?(0,v.jsx)("img",{src:"".concat(t.image),alt:t.title,className:"sdgs-table-image"}):(0,v.jsx)("div",{className:"sdgs-no-image",children:"No Image"})}),(0,v.jsx)("td",{children:(0,v.jsx)("strong",{children:t.title})}),(0,v.jsx)("td",{children:(0,v.jsx)("div",{className:"sdgs-description-preview",children:function(){var e=function(e){if(!e)return"";var t=document.createElement("div");return t.innerHTML=e,t.textContent||t.innerText||""}(t.description);return(null===e||void 0===e?void 0:e.length)>100?"".concat(e.substring(0,100),"..."):e}()})}),(0,v.jsx)("td",{children:(0,v.jsx)("span",{className:"sdgs-lang-badge",children:"ID"===t.lang?"\ud83c\uddee\ud83c\udde9 ID":"\ud83c\uddec\ud83c\udde7 EN"})}),(0,v.jsx)("td",{children:(0,v.jsxs)("div",{className:"sdgs-actions",children:[(0,v.jsx)("button",{className:"sdgs-btn sdgs-btn-view",onClick:function(){return e("/admin/manage-sdgs/detail/".concat(t.id))},children:"View"}),(0,v.jsx)("button",{className:"sdgs-btn sdgs-btn-delete",onClick:function(){return e=t.id,void p().fire({title:"Are you sure?",text:"You won't be able to revert this!",icon:"warning",showCancelButton:!0,confirmButtonColor:"#ef4444",cancelButtonColor:"#64748b",confirmButtonText:"Yes, delete it!",cancelButtonText:"Cancel"}).then(function(){var t=(0,a.Z)(o().mark((function t(s){var r,n,a,i,l;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!s.isConfirmed){t.next=14;break}return t.prev=1,t.next=4,g().delete("".concat(f.Z.url.api,"/sdgs-delete/").concat(e),{headers:{Authorization:"Bearer ".concat(localStorage.getItem("token"))}});case 4:p().fire({icon:"success",title:"Deleted!",text:"SDGS has been deleted."}),K(),t.next=14;break;case 8:t.prev=8,t.t0=t.catch(1),console.error("Error deleting SDGS:",t.t0),l="Failed to delete SDGS",null!==(r=t.t0.response)&&void 0!==r&&null!==(n=r.data)&&void 0!==n&&n.message?l=t.t0.response.data.message:null!==(a=t.t0.response)&&void 0!==a&&null!==(i=a.data)&&void 0!==i&&i.error?l=t.t0.response.data.error:t.t0.request&&(l="No response from server. Please check your connection."),p().fire({icon:"error",title:"Error!",text:l});case 14:case"end":return t.stop()}}),t,null,[[1,8]])})));return function(e){return t.apply(this,arguments)}}());var e},children:"Delete"})]})})]},t.id)}))})]})})]}),G&&(0,v.jsx)("div",{className:"sdgs-modal-overlay",onClick:function(){return Z(!1)},children:(0,v.jsxs)("div",{className:"sdgs-modal",onClick:function(e){return e.stopPropagation()},children:[(0,v.jsxs)("div",{className:"sdgs-modal-header",children:[(0,v.jsx)("h2",{children:I?"Edit SDGS Goal":"Add New SDGS Goal"}),(0,v.jsx)("button",{className:"sdgs-modal-close",onClick:function(){return Z(!1)},children:"\u2715"})]}),(0,v.jsxs)("form",{onSubmit:X,children:[(0,v.jsxs)("div",{className:"sdgs-modal-body",children:[(0,v.jsxs)("div",{className:"sdgs-form-group",children:[(0,v.jsxs)("label",{children:["Language ",(0,v.jsx)("span",{className:"required",children:"*"})]}),(0,v.jsxs)("select",{name:"lang",className:"sdgs-form-select",value:J.lang,onChange:Q,required:!0,children:[(0,v.jsx)("option",{value:"ID",children:"\ud83c\uddee\ud83c\udde9 Indonesia"}),(0,v.jsx)("option",{value:"EN",children:"\ud83c\uddec\ud83c\udde7 English"})]})]}),(0,v.jsxs)("div",{className:"sdgs-form-group",children:[(0,v.jsxs)("label",{children:["Code ",(0,v.jsx)("span",{className:"required",children:"*"})]}),(0,v.jsx)("input",{type:"text",name:"code",className:"sdgs-form-input",placeholder:"e.g., SDG-01, SDG-02",value:J.code,onChange:Q,required:!0})]}),(0,v.jsxs)("div",{className:"sdgs-form-group",children:[(0,v.jsxs)("label",{children:["Title ",(0,v.jsx)("span",{className:"required",children:"*"})]}),(0,v.jsx)("input",{type:"text",name:"title",className:"sdgs-form-input",placeholder:"e.g., No Poverty",value:J.title,onChange:Q,required:!0})]}),(0,v.jsxs)("div",{className:"sdgs-form-group",children:[(0,v.jsx)("label",{children:"Sub Title"}),(0,v.jsx)("input",{type:"text",name:"sub_title",className:"sdgs-form-input",placeholder:"e.g., End poverty in all its forms (optional)",value:J.sub_title,onChange:Q})]}),(0,v.jsxs)("div",{className:"sdgs-form-group",children:[(0,v.jsxs)("label",{children:["Description ",(0,v.jsx)("span",{className:"required",children:"*"})]}),(0,v.jsx)(x(),{setContents:J.description,onChange:function(e){W((function(t){return(0,n.Z)((0,n.Z)({},t),{},{description:e})}))},setOptions:j,placeholder:"Enter detailed description of the goal..."})]}),(0,v.jsxs)("div",{className:"sdgs-form-group",children:[(0,v.jsx)("label",{children:"Goal Image"}),(0,v.jsx)("input",{type:"file",accept:"image/*",className:"sdgs-form-input",onChange:function(e){var t=e.target.files[0];if(t){if(t.size>2097152)return p().fire({icon:"error",title:"File Too Large",text:"The image must not be greater than 2048 kilobytes (2MB)."}),void(e.target.value="");
1if(!["image/jpeg","image/jpg","image/png","image/gif","image/webp"].includes(t.type))return p().fire({icon:"error",title:"Invalid File Type",text:"Please upload a valid image file (JPEG, PNG, GIF, or WebP)."}),void(e.target.value="");V(t);var s=new FileReader;s.onloadend=function(){U(s.result)},s.readAsDataURL(t)}}}),O&&(0,v.jsx)("div",{className:"sdgs-image-preview",children:(0,v.jsx)("img",{src:O,alt:"Preview"})})]})]}),(0,v.jsxs)("div",{className:"sdgs-modal-footer",children:[(0,v.jsx)("button",{type:"button",className:"sdgs-btn-cancel",onClick:function(){return Z(!1)},children:"Cancel"}),(0,v.jsx)("button",{type:"submit",className:"sdgs-btn-submit",children:I?"Update SDGS":"Create SDGS"})]})]})]})})]})}},64861:function(){}}]);
2//# sourceMappingURL=8382.9343f0b7.chunk.js.map

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.