Files
2026-06-09 16:57:55 +07:00

1 line
13 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[58],{1466:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(7401).A)("User",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]])},2060:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(7401).A)("CirclePlus",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]])},2598:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(7401).A)("Eye",[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]])},5236:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(7401).A)("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]])},6659:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(7401).A)("File",[["path",{d:"M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z",key:"1rqfz7"}],["path",{d:"M14 2v4a2 2 0 0 0 2 2h4",key:"tnqrlb"}]])},6868:(e,t,s)=>{"use strict";s.d(t,{A:()=>c,AuthProvider:()=>i});var a=s(5155),l=s(2115);let r=(0,l.createContext)(void 0);function i(e){let{children:t}=e,[s,i]=(0,l.useState)("");return(0,l.useEffect)(()=>{let e=localStorage.getItem("user");if(e){let t=JSON.parse(e);(null==t?void 0:t.name)&&i(t.name)}},[]),(0,a.jsx)(r.Provider,{value:{username:s,setUsername:i,logout:()=>{localStorage.removeItem("authToken"),localStorage.removeItem("user"),i("")}},children:t})}function c(){let e=(0,l.useContext)(r);if(!e)throw Error("useAuth must be used within an AuthProvider");return e}},7401:(e,t,s)=>{"use strict";s.d(t,{A:()=>n});var a=s(2115);let l=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),r=function(){for(var e=arguments.length,t=Array(e),s=0;s<e;s++)t[s]=arguments[s];return t.filter((e,t,s)=>!!e&&""!==e.trim()&&s.indexOf(e)===t).join(" ").trim()};var i={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};let c=(0,a.forwardRef)((e,t)=>{let{color:s="currentColor",size:l=24,strokeWidth:c=2,absoluteStrokeWidth:n,className:o="",children:d,iconNode:m,...h}=e;return(0,a.createElement)("svg",{ref:t,...i,width:l,height:l,stroke:s,strokeWidth:n?24*Number(c)/Number(l):c,className:r("lucide",o),...h},[...m.map(e=>{let[t,s]=e;return(0,a.createElement)(t,s)}),...Array.isArray(d)?d:[d]])}),n=(e,t)=>{let s=(0,a.forwardRef)((s,i)=>{let{className:n,...o}=s;return(0,a.createElement)(c,{ref:i,iconNode:t,className:r("lucide-".concat(l(e)),n),...o})});return s.displayName="".concat(e),s}},7634:(e,t,s)=>{Promise.resolve().then(s.bind(s,8484))},8484:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>p});var a=s(5155),l=s(2115),r=s(6868),i=s(6046),c=s(2651),n=s(1466),o=s(5236),d=s(2060),m=s(6659),h=s(2598),x=s(8491),u=s(9993);function p(){let[e,t]=(0,l.useState)(""),s=(0,i.useRouter)(),{username:p}=(0,r.A)(),[b,y]=(0,l.useState)(!1),[g,j]=(0,l.useState)(null),[f,N]=(0,l.useState)(1),[w,v]=(0,l.useState)([]),[k,A]=(0,l.useState)([]),[C,S]=(0,l.useState)(!1),[_,L]=(0,l.useState)(!1),[z,M]=(0,l.useState)(!1),[E,P]=(0,l.useState)(null),[D,I]=(0,l.useState)(!1),O=e=>{P(e),I(!0)};(0,l.useEffect)(()=>{(async()=>{try{let e=localStorage.getItem("authToken"),t=(await c.A.get("https://cetaksuratkp-api.humicprototyping.net/api/letter",{headers:{Authorization:"Bearer ".concat(e),Accept:"application/json"}})).data.data;console.log("Raw data:",t);let s=t.filter(e=>(console.log("letter object:",e),console.log("is_completion:",e.is_completion),1==e.is_completion));console.log("Filtered data:",s),v(s)}catch(e){console.error("Error fetching completion letters:",e)}})()},[]),(0,l.useEffect)(()=>{""===e.trim()?A(w):A(w.filter(t=>{var s,a,l,r;let i=null!==(l=null===(s=t.nomor_induk_mahasiswa)||void 0===s?void 0:s.toLowerCase())&&void 0!==l?l:"",c=null!==(r=null===(a=t.nomor_surat_completion)||void 0===a?void 0:a.toLowerCase())&&void 0!==r?r:"",n=e.toLowerCase(),o=i.includes(n),d=c.includes(n);return o||d}))},[w,e]),(0,l.useEffect)(()=>{console.log("Letters State:",w)},[w]);let B=e=>{j(e),y(!0)},H=async e=>{try{let t=localStorage.getItem("authToken");await c.A.delete("https://cetaksuratkp-api.humicprototyping.net/api/letter/".concat(e.id),{headers:{Authorization:"Bearer ".concat(t),Accept:"application/json"}});let s=w.filter(t=>t.id!==e.id);v(s),localStorage.setItem("completionLetters",JSON.stringify(s)),console.log("Deleted successfully")}catch(e){console.error("Failed to delete letter:",e),alert("Failed to delete letter. Please try again.")}finally{y(!1),j(null)}},T=e=>{console.log(e),s.push("/letter/completionletter/applyLetter?edit=".concat(JSON.stringify(e)))},V=Math.ceil(k.length/5),F=(f-1)*5,R=k.slice(F,F+5);return(0,a.jsxs)("div",{className:"min-h-screen bg-gray-100",children:[(0,a.jsxs)("nav",{className:"bg-white shadow-md px-6 md:px-10 py-4 flex justify-between items-center",children:[(0,a.jsxs)("div",{className:"flex items-center gap-8",children:[(0,a.jsx)("img",{src:"/logo-humic-text.png",alt:"Logo",className:"h-12 mr-3"}),(0,a.jsx)("a",{href:"/homepage",className:"text-gray-700 hover:text-[#B4262A] font-medium cursor-pointer transition duration-300",children:"Home"}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("button",{onClick:()=>M(!z),className:"text-[#B4262A] font-semibold border-b-2 border-[#B4262A] cursor-pointer transition duration-300",children:"Letter"}),z&&(0,a.jsxs)("div",{className:"absolute mt-2 bg-white shadow rounded w-48 z-10",children:[(0,a.jsx)("button",{onClick:()=>s.push("/letter/acceptanceletter"),className:"block px-4 py-2 text-left w-full hover:bg-gray-100 cursor-pointer",children:"Acceptance Letter"}),(0,a.jsx)("button",{onClick:()=>s.push("/letter/completionletter"),className:"block px-4 py-2 text-left w-full hover:bg-gray-100 cursor-pointer",children:"Completion Letter"})]})]})]}),(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)("button",{onClick:()=>S(!C),children:(0,a.jsx)(n.A,{})}),C&&(0,a.jsxs)("div",{id:"profile-dropdown",className:"absolute right-0 mt-2 w-48 bg-white shadow-md rounded-lg z-50",children:[(0,a.jsx)("div",{className:"p-4 bg-gray-100 text-black text-center",children:(0,a.jsx)("p",{className:"font-semibold",children:p||"Guest"})}),(0,a.jsxs)("button",{onClick:async()=>{L(!0),await new Promise(e=>setTimeout(e,1e3)),L(!1),s.push("/login")},disabled:_,className:"w-full flex items-center justify-center px-4 py-2 text-sm text-black hover:bg-gray-200",children:[_?(0,a.jsxs)("svg",{className:"animate-spin h-4 w-4 mr-2 text-black",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[(0,a.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,a.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8H4z"})]}):(0,a.jsx)(o.A,{className:"mr-2",size:18}),_?"Logging out...":"Log Out"]})]})]})]}),(0,a.jsxs)("div",{className:"px-4 md:px-20 py-10",children:[(0,a.jsx)("h1",{className:"text-2xl font-semibold text-black mb-1",children:"Practical Work Completion Letter"}),(0,a.jsx)("p",{className:"text-gray-500 mb-6",children:"Kelola surat keterangan selesai kerja praktik mahasiswa"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 mb-4",children:[(0,a.jsxs)("button",{onClick:()=>s.push("/letter/completionletter/applyLetter"),className:"bg-red-600 text-white px-4 py-2 rounded flex items-center gap-2",children:[(0,a.jsx)(d.A,{size:18})," Apply letter"]}),(0,a.jsxs)("button",{onClick:()=>s.push("/letter/completionletter/viewTemplate"),className:"bg-white text-black border px-4 py-2 rounded flex items-center gap-2",children:[(0,a.jsx)(m.A,{size:18})," View template"]}),(0,a.jsx)("input",{type:"text",placeholder:"Search...",value:e,onChange:e=>t(e.target.value),className:"border px-4 py-2 rounded-md text-sm w-full max-w-xs"})]}),(0,a.jsxs)("div",{className:"bg-white p-6 rounded shadow overflow-x-auto",children:[(0,a.jsxs)("table",{className:"w-full text-sm text-left border",children:[(0,a.jsx)("thead",{className:"bg-gray-100 text-black",children:(0,a.jsxs)("tr",{children:[(0,a.jsx)("th",{className:"py-2 px-4",children:"Submission Date"}),(0,a.jsx)("th",{className:"py-2 px-4",children:"Letter Number"}),(0,a.jsx)("th",{className:"py-2 px-4",children:"NIM"}),(0,a.jsx)("th",{className:"py-2 px-4 text-center",children:"Action"})]})}),(0,a.jsx)("tbody",{children:R.map((e,t)=>(0,a.jsxs)("tr",{className:"border-t",children:[(0,a.jsx)("td",{className:"py-2 px-4",children:new Date(e.created_at).toLocaleDateString()}),(0,a.jsx)("td",{className:"py-2 px-4",children:e.nomor_surat_completion}),(0,a.jsx)("td",{className:"py-2 px-4",children:e.nomor_induk_mahasiswa}),(0,a.jsx)("td",{className:"py-2 px-4 text-center",children:(0,a.jsxs)("div",{className:"flex justify-center gap-2",children:[(0,a.jsx)("button",{onClick:()=>O(e),className:"p-2 text-gray-600 hover:bg-gray-100 rounded-md",children:(0,a.jsx)(h.A,{className:"h-4 w-4"})}),(0,a.jsx)("button",{onClick:()=>T(e),className:"p-2 rounded bg-gray-100 hover:bg-gray-200",children:(0,a.jsx)(x.A,{size:16})}),(0,a.jsx)("button",{onClick:()=>B(e),className:"p-2 rounded bg-red-100 hover:bg-red-200 text-red-600",children:(0,a.jsx)(u.A,{size:16})})]})})]},t))})]}),(0,a.jsxs)("div",{className:"flex justify-between items-center px-4 py-4 text-sm",children:[(0,a.jsx)("span",{children:0===k.length?"Showing 0 to 0 of 0 entries":"Showing ".concat(F+1," to ").concat(Math.min(F+5,k.length)," of ").concat(k.length," entries")}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("button",{onClick:()=>N(e=>Math.max(1,e-1)),disabled:1===f,className:"px-2 py-1 border rounded ".concat(1===f?"text-gray-400":""),children:"← Previous"}),[...Array(V)].map((e,t)=>(0,a.jsx)("button",{onClick:()=>N(t+1),className:"px-3 py-1 border rounded ".concat(f===t+1?"bg-red-600 text-white":""),children:t+1},t)),(0,a.jsx)("button",{onClick:()=>N(e=>Math.min(V,e+1)),disabled:f===V,className:"px-2 py-1 border rounded ".concat(f===V?"text-gray-400":""),children:"Next →"})]})]})]})]}),b&&(0,a.jsx)("div",{className:"fixed inset-0 backdrop-blur-sm bg-white/30 flex justify-center items-center z-50",children:(0,a.jsxs)("div",{className:"bg-white rounded-md shadow-lg w-[400px]",children:[(0,a.jsx)("div",{className:"flex justify-between items-center px-6 py-4 border-b",children:(0,a.jsx)("h2",{className:"font-semibold text-black text-lg",children:"Delete Confirmation"})}),(0,a.jsx)("div",{className:"px-6 py-4 text-sm text-black",children:(0,a.jsx)("p",{children:"Are you sure you want to delete this letter?"})}),(0,a.jsxs)("div",{className:"px-6 py-4 border-t flex justify-end gap-2",children:[(0,a.jsx)("button",{onClick:()=>y(!1),className:"px-4 py-2 bg-gray-200 rounded hover:bg-gray-300 text-sm",children:"Cancel"}),(0,a.jsx)("button",{onClick:()=>H(g),className:"px-4 py-2 bg-red-600 text-white rounded hover:bg-red-700 text-sm",children:"Delete"})]})]})}),D&&E&&(0,a.jsx)("div",{className:"fixed inset-0 backdrop-blur-sm bg-white/30 flex justify-center items-center z-50",children:(0,a.jsxs)("div",{className:"bg-white rounded-md shadow-lg w-[600px]",children:[(0,a.jsxs)("div",{className:"flex justify-between items-center px-6 py-4 border-b",children:[(0,a.jsx)("h2",{className:"font-semibold text-black text-lg",children:"Letter Details"}),(0,a.jsx)("button",{onClick:()=>I(!1),className:"text-gray-500 hover:text-red-600",children:"✕"})]}),(0,a.jsxs)("div",{className:"px-6 py-4 space-y-2 text-sm text-black",children:[(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"font-semibold",children:"Letter Number"}),(0,a.jsx)("span",{children:E.nomor_surat_completion})]}),(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"font-semibold",children:"Student Name"}),(0,a.jsx)("span",{children:E.nama_mahasiswa})]}),(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"font-semibold",children:"Student Identification Number"}),(0,a.jsx)("span",{children:E.nomor_induk_mahasiswa})]}),(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"font-semibold",children:"Student Study Program"}),(0,a.jsx)("span",{children:E.program_studi_mahasiswa})]}),(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"font-semibold",children:"Academic Year"}),(0,a.jsx)("span",{children:E.tahun_ajaran})]}),(0,a.jsxs)("div",{className:"flex justify-between",children:[(0,a.jsx)("span",{className:"font-semibold",children:"Starting Date"}),(0,a.jsx)("span",{children:E.start_date})]})]}),(0,a.jsx)("div",{className:"px-6 py-4 border-t flex justify-end",children:(0,a.jsx)("button",{onClick:()=>s.push("/letter/completionletter/showLetter?id=".concat(E.id)),className:"bg-red-600 text-white px-4 py-2 rounded hover:bg-red-700 text-sm",children:"Show Letter"})})]})})]})}},8491:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(7401).A)("Pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]])},9993:(e,t,s)=>{"use strict";s.d(t,{A:()=>a});let a=(0,s(7401).A)("Trash",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}]])}},e=>{var t=t=>e(e.s=t);e.O(0,[251,651,441,587,358],()=>t(7634)),_N_E=e.O()}]);