1 line
15 KiB
JavaScript
1 line
15 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[97],{745:(e,t,a)=>{"use strict";a.d(t,{bq:()=>u,eb:()=>p,gC:()=>m,l6:()=>d,yv:()=>c});var s=a(5155);a(2115);var r=a(1149),l=a(1719),n=a(8867),i=a(1902),o=a(9602);function d(e){let{...t}=e;return(0,s.jsx)(r.bL,{"data-slot":"select",...t})}function c(e){let{...t}=e;return(0,s.jsx)(r.WT,{"data-slot":"select-value",...t})}function u(e){let{className:t,children:a,...n}=e;return(0,s.jsxs)(r.l9,{"data-slot":"select-trigger",className:(0,o.cn)("border-input data-[placeholder]:text-muted-foreground [&_svg:not([class*='text-'])]:text-muted-foreground focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive flex h-9 w-fit items-center justify-between gap-2 rounded-md border bg-transparent px-3 py-2 text-sm whitespace-nowrap shadow-xs transition-[color,box-shadow] outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-2 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",t),...n,children:[a,(0,s.jsx)(r.In,{asChild:!0,children:(0,s.jsx)(l.A,{className:"size-4 opacity-50"})})]})}function m(e){let{className:t,children:a,position:l="popper",...n}=e;return(0,s.jsx)(r.ZL,{children:(0,s.jsxs)(r.UC,{"data-slot":"select-content",className:(0,o.cn)("bg-popover text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 relative z-50 max-h-96 min-w-[8rem] overflow-hidden rounded-md border shadow-md","popper"===l&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",t),position:l,...n,children:[(0,s.jsx)(x,{}),(0,s.jsx)(r.LM,{className:(0,o.cn)("p-1","popper"===l&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)] scroll-my-1"),children:a}),(0,s.jsx)(h,{})]})})}function p(e){let{className:t,children:a,...l}=e;return(0,s.jsxs)(r.q7,{"data-slot":"select-item",className:(0,o.cn)("focus:bg-accent focus:text-accent-foreground [&_svg:not([class*='text-'])]:text-muted-foreground relative flex w-full cursor-default items-center gap-2 rounded-sm py-1.5 pr-8 pl-2 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",t),...l,children:[(0,s.jsx)("span",{className:"absolute right-2 flex size-3.5 items-center justify-center",children:(0,s.jsx)(r.VF,{children:(0,s.jsx)(n.A,{className:"size-4"})})}),(0,s.jsx)(r.p4,{children:a})]})}function x(e){let{className:t,...a}=e;return(0,s.jsx)(r.PP,{"data-slot":"select-scroll-up-button",className:(0,o.cn)("flex cursor-default items-center justify-center py-1",t),...a,children:(0,s.jsx)(i.A,{className:"size-4"})})}function h(e){let{className:t,...a}=e;return(0,s.jsx)(r.wn,{"data-slot":"select-scroll-down-button",className:(0,o.cn)("flex cursor-default items-center justify-center py-1",t),...a,children:(0,s.jsx)(l.A,{className:"size-4"})})}},2324:(e,t,a)=>{"use strict";a.d(t,{default:()=>g});var s=a(5155),r=a(2115),l=a(125),n=a(2336),i=a(4085),o=a(2651),d=a(745),c=a(7006),u=a(1466),m=a(5236),p=a(2423),x=a(9348);a(6871);var h=a(6046),v=a(6868);function g(){let e=(0,h.useSearchParams)(),[t,a]=(0,r.useState)(!1),[g,b]=(0,r.useState)(null),f=(0,h.useRouter)(),{username:j}=(0,v.A)(),[y,w]=(0,r.useState)(""),[N,k]=(0,r.useState)(""),[_,S]=(0,r.useState)(""),[C,A]=(0,r.useState)(""),[z,E]=(0,r.useState)(""),[L,P]=(0,r.useState)(""),[M,I]=(0,r.useState)(!1),[T,D]=(0,r.useState)(""),[O,G]=(0,r.useState)(),[U,B]=(0,r.useState)(),[q,H]=(0,r.useState)(!1),[W,$]=(0,r.useState)(!1),[F,J]=(0,r.useState)(!1),[V,R]=(0,r.useState)(!1);(0,r.useEffect)(()=>{let t=e.get("edit");if(t)try{var s,r,l,n;let e=JSON.parse(t);a(!0),b(e.id),k(e.nomor_surat_completion),E(null!==(r=e.nomor_induk_mahasiswa)&&void 0!==r?r:""),G(new Date(e.start_date)),B(new Date(e.completion_date)),w(null!==(l=null===(s=e.letter_scope)||void 0===s?void 0:s.toLowerCase())&&void 0!==l?l:""),S(null!==(n=e.address_to)&&void 0!==n?n:""),P(e.program_studi_mahasiswa),D(e.tahun_ajaran),A(e.nama_mahasiswa)}catch(e){console.error("Failed to parse edit param:",e)}},[e]),(0,r.useEffect)(()=>{let e=e=>{let t=e.target;t.closest("#letter-dropdown")||t.closest("#letter-button")||R(!1),t.closest("#profile-dropdown")||t.closest("#profile-button")||J(!1)};return document.addEventListener("click",e),()=>document.removeEventListener("click",e)},[]);let X=async()=>{if(!y||!N||!_||!C||!z||!L||!T||!O||!U){alert("Please fill in all the required fields.");return}let e=N.padStart(3,"0"),a=(0,c.GP)(new Date,"dd.MM.yyyy"),s=t?N:"HUMIC/".concat("INTERNAL"===y.toUpperCase()?"INT":"EXT","/").concat(a,"/").concat(e),r={nama_mahasiswa:C,letter_scope:y,nomor_surat_acceptance:"-",nomor_surat_completion:s,address_to:_,nomor_induk_mahasiswa:z,program_studi_mahasiswa:L,tahun_ajaran:T,start_date:(0,c.GP)(O,"yyyy-MM-dd"),completion_date:(0,c.GP)(U,"yyyy-MM-dd"),is_completion:1,is_acceptance:0};try{let e;let a=localStorage.getItem("authToken");if(!a){alert("Unauthorized! Please log in.");return}console.log("Submitting data:",r),(e=t?await o.A.put("https://cetaksuratkp-api.humicprototyping.net/api/letter/".concat(g),r,{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(a)}}):await o.A.post("https://cetaksuratkp-api.humicprototyping.net/api/letter",r,{headers:{"Content-Type":"application/json",Accept:"application/json",Authorization:"Bearer ".concat(a)}})).data.success?(console.log("Letter submitted successfully:",e.data),f.push("/letter/completionletter")):alert(e.data.message||"Submission failed")}catch(e){if(console.error("Error submitting letter:",e),o.A.isAxiosError(e)){var l,n,i;console.error("Server response:",null===(l=e.response)||void 0===l?void 0:l.data),alert("Error: ".concat((null===(n=e.response)||void 0===n?void 0:n.data.message)||JSON.stringify(null===(i=e.response)||void 0===i?void 0:i.data)))}else alert("Error submitting letter. Please try again later.")}};return(0,s.jsxs)("div",{className:"min-h-screen bg-gray-100",children:[(0,s.jsxs)("nav",{className:"bg-white shadow-md px-10 py-4 flex items-center justify-between",children:[(0,s.jsxs)("div",{className:"flex items-center",children:[(0,s.jsx)("img",{src:"/logo-humic-text.png",alt:"HUMIC Engineering",className:"h-12 mr-3"}),(0,s.jsxs)("div",{className:"flex space-x-8",children:[(0,s.jsx)("a",{href:"/homepage",className:"text-gray-700 hover:text-[#B4262A] font-medium",children:"Home"}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("button",{id:"letter-button",onClick:()=>R(!V),className:"text-[#B4262A] border-b-2 border-[#B4262A]",children:"Letter"}),V&&(0,s.jsxs)("div",{id:"letter-dropdown",className:"absolute mt-2 bg-white shadow-md rounded-md w-48 z-50",children:[(0,s.jsx)("button",{onClick:()=>f.push("/letter/acceptanceletter"),className:"block w-full text-left px-4 py-2 hover:bg-gray-100",children:"Acceptance Letter"}),(0,s.jsx)("button",{onClick:()=>f.push("/letter/completionletter"),className:"block w-full text-left px-4 py-2 hover:bg-gray-100",children:"Completion Letter"})]})]})]})]}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)("button",{id:"profile-button",onClick:()=>J(!F),className:"text-gray-700 hover:text-black",children:(0,s.jsx)(u.A,{})}),F&&(0,s.jsxs)("div",{id:"profile-dropdown",className:"absolute right-0 mt-2 w-48 bg-white shadow-md rounded-lg",children:[(0,s.jsx)("div",{className:"p-4 bg-gray-100 text-black text-center",children:(0,s.jsx)("p",{className:"font-semibold",children:j||"Guest"})}),(0,s.jsxs)("button",{onClick:async()=>{I(!0),await new Promise(e=>setTimeout(e,1e3)),I(!1),f.push("/login")},disabled:M,className:"w-full flex items-center justify-center px-4 py-2 text-sm text-black hover:bg-gray-200",children:[M?(0,s.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,s.jsx)("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),(0,s.jsx)("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8v8H4z"})]}):(0,s.jsx)(m.A,{className:"mr-2",size:18}),M?"Logging out...":"Log Out"]})]})]})]}),(0,s.jsxs)("div",{className:"px-20 py-10",children:[(0,s.jsx)("h1",{className:"text-2xl font-semibold text-black mb-8",children:t?"Update Completion Work Letter":"Apply Completion Work Letter"}),(0,s.jsxs)("div",{className:"bg-white rounded-lg p-8 shadow-md",children:[(0,s.jsxs)("div",{className:"grid grid-cols-3 gap-6",children:[(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-black block mb-1",children:"Letter Scope"}),(0,s.jsxs)(d.l6,{value:y,onValueChange:w,disabled:t,children:[(0,s.jsx)(d.bq,{className:"w-full",children:(0,s.jsx)(d.yv,{placeholder:"Select..."})}),(0,s.jsxs)(d.gC,{children:[(0,s.jsx)(d.eb,{value:"internal",children:"Internal"}),(0,s.jsx)(d.eb,{value:"external",children:"External"})]})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-black block mb-1",children:"Letter Number"}),(0,s.jsx)(n.p,{value:null!=N?N:"",onChange:e=>k(e.target.value),disabled:t})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-black block mb-1",children:"Addressed To"}),(0,s.jsx)(n.p,{value:null!=_?_:"",onChange:e=>S(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-black block mb-1",children:"Student Name"}),(0,s.jsx)(n.p,{value:null!=C?C:"",onChange:e=>A(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-black block mb-1",children:"Student Identification Number (NIM)"}),(0,s.jsx)(n.p,{value:null!=z?z:"",onChange:e=>E(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-black block mb-1",children:"Student Study Program"}),(0,s.jsx)(n.p,{value:null!=L?L:"",onChange:e=>P(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-black block mb-1",children:"Academic Year"}),(0,s.jsx)(n.p,{value:null!=T?T:"",placeholder:"e.g. Genap 2022/2023",onChange:e=>D(e.target.value)})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-black block mb-1",children:"Starting Date"}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(n.p,{value:O&&(0,l.f)(O)?(0,c.GP)(O,"yyyy-MM-dd"):"",placeholder:"Select Start Date",readOnly:!0,className:"pr-10",onClick:()=>H(!q)}),(0,s.jsx)(p.A,{size:18,className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 cursor-pointer",onClick:()=>H(!q)}),q&&(0,s.jsx)(x.hv,{mode:"single",selected:O,onSelect:e=>{G(e),H(!1)},className:"absolute z-10 mt-2 bg-white border rounded shadow"})]})]}),(0,s.jsxs)("div",{children:[(0,s.jsx)("label",{className:"text-black block mb-1",children:"Date of Completion"}),(0,s.jsxs)("div",{className:"relative",children:[(0,s.jsx)(n.p,{value:U&&(0,l.f)(null!=U?U:new Date)?(0,c.GP)(U,"yyyy-MM-dd"):"",placeholder:"Select End Date",readOnly:!0,className:"pr-10",onClick:()=>$(!W)}),(0,s.jsx)(p.A,{size:18,className:"absolute right-3 top-1/2 -translate-y-1/2 text-gray-500 cursor-pointer",onClick:()=>$(!W)}),W&&(0,s.jsx)(x.hv,{mode:"single",selected:U,onSelect:e=>{B(e),$(!1)},className:"absolute z-10 mt-2 bg-white border rounded shadow"})]})]})]}),(0,s.jsxs)("div",{className:"flex gap-4 mt-10",children:[(0,s.jsx)(i.$,{onClick:X,className:"bg-red-600 hover:bg-red-700",children:t?"Update Letter":"Submit"}),(0,s.jsx)(i.$,{variant:"outline",onClick:()=>f.back(),children:"Cancel"})]})]})]})]})}},2336:(e,t,a)=>{"use strict";a.d(t,{p:()=>l});var s=a(5155);a(2115);var r=a(9602);function l(e){let{className:t,type:a,...l}=e;return(0,s.jsx)("input",{type:a,"data-slot":"input",className:(0,r.cn)("border-input file:text-foreground placeholder:text-muted-foreground selection:bg-primary selection:text-primary-foreground flex h-9 w-full min-w-0 rounded-md border bg-transparent px-3 py-1 text-base shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent file:text-sm file:font-medium disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50 md:text-sm","focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]","aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",t),...l})}},4085:(e,t,a)=>{"use strict";a.d(t,{$:()=>o});var s=a(5155);a(2115);var r=a(2317),l=a(1027),n=a(9602);let i=(0,l.F)("inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-md text-sm font-medium transition-[color,box-shadow] disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",{variants:{variant:{default:"bg-primary text-primary-foreground shadow-xs hover:bg-primary/90",destructive:"bg-destructive text-white shadow-xs hover:bg-destructive/90 focus-visible:ring-destructive/20 dark:focus-visible:ring-destructive/40",outline:"border border-input bg-background shadow-xs hover:bg-accent hover:text-accent-foreground",secondary:"bg-secondary text-secondary-foreground shadow-xs hover:bg-secondary/80",ghost:"hover:bg-accent hover:text-accent-foreground",link:"text-primary underline-offset-4 hover:underline"},size:{default:"h-9 px-4 py-2 has-[>svg]:px-3",sm:"h-8 rounded-md gap-1.5 px-3 has-[>svg]:px-2.5",lg:"h-10 rounded-md px-6 has-[>svg]:px-4",icon:"size-9"}},defaultVariants:{variant:"default",size:"default"}});function o(e){let{className:t,variant:a,size:l,asChild:o=!1,...d}=e,c=o?r.DX:"button";return(0,s.jsx)(c,{"data-slot":"button",className:(0,n.cn)(i({variant:a,size:l,className:t})),...d})}},6868:(e,t,a)=>{"use strict";a.d(t,{A:()=>i,AuthProvider:()=>n});var s=a(5155),r=a(2115);let l=(0,r.createContext)(void 0);function n(e){let{children:t}=e,[a,n]=(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)&&n(t.name)}},[]),(0,s.jsx)(l.Provider,{value:{username:a,setUsername:n,logout:()=>{localStorage.removeItem("authToken"),localStorage.removeItem("user"),n("")}},children:t})}function i(){let e=(0,r.useContext)(l);if(!e)throw Error("useAuth must be used within an AuthProvider");return e}},8308:(e,t,a)=>{Promise.resolve().then(a.bind(a,2324))},9602:(e,t,a)=>{"use strict";a.d(t,{cn:()=>l});var s=a(3463),r=a(9795);function l(){for(var e=arguments.length,t=Array(e),a=0;a<e;a++)t[a]=arguments[a];return(0,r.QP)((0,s.$)(t))}}},e=>{var t=t=>e(e.s=t);e.O(0,[478,251,501,651,941,599,441,587,358],()=>t(8308)),_N_E=e.O()}]); |