Files
humicletter/_next/static/chunks/app/letter/acceptanceletter/page-f5aeb68c5b1400de.js
T
2026-06-09 16:57:55 +07:00

1 line
13 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[223],{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:()=>n,AuthProvider:()=>c});var a=s(5155),r=s(2115);let l=(0,r.createContext)(void 0);function c(e){let{children:t}=e,[s,c]=(0,r.useState)("");return(0,r.useEffect)(()=>{let e=localStorage.getItem("user");if(e){let t=JSON.parse(e);(null==t?void 0:t.name)&&c(t.name)}},[]),(0,a.jsx)(l.Provider,{value:{username:s,setUsername:c,logout:()=>{localStorage.removeItem("authToken"),localStorage.removeItem("user"),c("")}},children:t})}function n(){let e=(0,r.useContext)(l);if(!e)throw Error("useAuth must be used within an AuthProvider");return e}},7325:(e,t,s)=>{"use strict";s.r(t),s.d(t,{default:()=>p});var a=s(5155),r=s(2115),l=s(6868),c=s(6046),n=s(2651),i=s(1466),o=s(5236),d=s(2060),x=s(6659),h=s(2598),m=s(8491),u=s(9993);function p(){let[e,t]=(0,r.useState)(""),s=(0,c.useRouter)(),{username:p}=(0,l.A)(),[b,y]=(0,r.useState)(1),[j,g]=(0,r.useState)([]),[f,N]=(0,r.useState)([]),[v,w]=(0,r.useState)(!1),[k,A]=(0,r.useState)(!1),[C,S]=(0,r.useState)(!1),[_,L]=(0,r.useState)(!1),[z,M]=(0,r.useState)(null),[E,P]=(0,r.useState)(null),[D,I]=(0,r.useState)(!1),O=e=>{P(e),I(!0)};(0,r.useEffect)(()=>{(async()=>{try{let e=localStorage.getItem("authToken"),t=(await n.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_acceptance:",e.is_acceptance),1==e.is_acceptance));console.log("Filtered data:",s),g(s)}catch(e){console.error("Error fetching completion letters:",e)}})()},[]),(0,r.useEffect)(()=>{""===e.trim()?N(j):N(j.filter(t=>{var s,a,r,l;let c=null!==(r=null===(s=t.nomor_induk_mahasiswa)||void 0===s?void 0:s.toLowerCase())&&void 0!==r?r:"",n=null!==(l=null===(a=t.nomor_surat_acceptance)||void 0===a?void 0:a.toLowerCase())&&void 0!==l?l:"",i=e.toLowerCase(),o=c.includes(i),d=n.includes(i);return o||d}))},[j,e]);let B=e=>{M(e),L(!0)},H=async e=>{try{let t=localStorage.getItem("authToken");await n.A.delete("https://cetaksuratkp-api.humicprototyping.net/api/letter/".concat(e.id),{headers:{Authorization:"Bearer ".concat(t),Accept:"application/json"}});let s=j.filter(t=>t.id!==e.id);g(s),localStorage.setItem("acceptanceLetters",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{L(!1),M(null)}},T=e=>{console.log(e),s.push("/letter/acceptanceletter/applyLetter?edit=".concat(JSON.stringify(e)))},V=Math.ceil(f.length/5),F=(b-1)*5,R=f.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-10 py-4 flex items-center justify-between",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:()=>S(!C),className:"text-[#B4262A] font-semibold border-b-2 border-[#B4262A] cursor-pointer transition duration-300",children:"Letter"}),C&&(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:()=>w(!v),children:(0,a.jsx)(i.A,{})}),v&&(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()=>{A(!0),await new Promise(e=>setTimeout(e,1e3)),A(!1),s.push("/login")},disabled:k,className:"w-full flex items-center justify-center px-4 py-2 text-sm text-black hover:bg-gray-200",children:[k?(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}),k?"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 Acceptance Letter"}),(0,a.jsx)("p",{className:"text-gray-500 mb-6",children:"Kelola surat penerimaan kerja praktik mahasiswa"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-3 mb-4",children:[(0,a.jsxs)("button",{onClick:()=>s.push("/letter/acceptanceletter/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/acceptanceletter/viewTemplate"),className:"bg-white text-black border px-4 py-2 rounded flex items-center gap-2",children:[(0,a.jsx)(x.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_acceptance}),(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)(m.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.jsxs)("span",{children:["Showing ",F+1," to"," ",Math.min(F+5,f.length)," of"," ",f.length," entries"]}),(0,a.jsxs)("div",{className:"flex items-center gap-1",children:[(0,a.jsx)("button",{onClick:()=>y(e=>Math.max(1,e-1)),disabled:1===b,className:"px-2 py-1 border rounded ".concat(1===b?"text-gray-400":""),children:"← Previous"}),[...Array(V)].map((e,t)=>(0,a.jsx)("button",{onClick:()=>y(t+1),className:"px-3 py-1 border rounded ".concat(b===t+1?"bg-red-600 text-white":""),children:t+1},t)),(0,a.jsx)("button",{onClick:()=>y(e=>Math.min(V,e+1)),disabled:b===V,className:"px-2 py-1 border rounded ".concat(b===V?"text-gray-400":""),children:"Next →"})]})]})]})]}),_&&z&&(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:()=>L(!1),className:"px-4 py-2 bg-gray-200 rounded hover:bg-gray-300 text-sm",children:"Cancel"}),(0,a.jsx)("button",{onClick:()=>H(z),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_acceptance})]}),(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/acceptanceletter/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"})})]})})]})}},7401:(e,t,s)=>{"use strict";s.d(t,{A:()=>i});var a=s(2115);let r=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),l=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 c={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 n=(0,a.forwardRef)((e,t)=>{let{color:s="currentColor",size:r=24,strokeWidth:n=2,absoluteStrokeWidth:i,className:o="",children:d,iconNode:x,...h}=e;return(0,a.createElement)("svg",{ref:t,...c,width:r,height:r,stroke:s,strokeWidth:i?24*Number(n)/Number(r):n,className:l("lucide",o),...h},[...x.map(e=>{let[t,s]=e;return(0,a.createElement)(t,s)}),...Array.isArray(d)?d:[d]])}),i=(e,t)=>{let s=(0,a.forwardRef)((s,c)=>{let{className:i,...o}=s;return(0,a.createElement)(n,{ref:c,iconNode:t,className:l("lucide-".concat(r(e)),i),...o})});return s.displayName="".concat(e),s}},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"}]])},9811:(e,t,s)=>{Promise.resolve().then(s.bind(s,7325))},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(9811)),_N_E=e.O()}]);