PageSourceSearch

https://goboat.id/assets/EmployeeFilePage-DDaV0SW6.js

js goboat.id collected 2026-10-02 23:07:36 UTC 5,835 bytes, 1 lines download raw bytes

1import{j as e,t as o}from"./vendor-ui-CGzpp04F.js";import{l as D,e as w,r as g}from"./vendor-react-BAKR1cxU.js";import{f as i,q as T,C as E,a as S,b as k,c as L,t as U,v as F,w as P,x as V,y as A,I as j,L as C,s as B}from"./index-B6g8kMT1.js";import{L as x}from"./label-5k2SFvuI.js";import{B as N}from"./badge-BC2UN5bO.js";import{T as $,a as I,b as z,c as K}from"./tabs-652WO8ns.js";import{D as M,a as q,b as H,c as O,e as R}from"./dialog-CU1Q5w2r.js";import{u as G}from"./useEmployees-CpKt1qjx.js";import{u as J,a as Q,b as W,c as X}from"./useEmployeeFile-MZE6SYk2.js";import{U as Y}from"./upload-B46pNL_k.js";import{F as Z}from"./file-text-gQrI0y6v.js";import{C as ee}from"./check-circle-2-Bxs7hRCM.js";import{T as ae}from"./trash-2-CgNkccin.js";import"./vendor-supabase-D-vHfFRB.js";import"./index-BMwnJT7l.js";const f=[{value:"identity",label:"Identity"},{value:"contract",label:"Contract"},{value:"bpjs",label:"BPJS"},{value:"certifications",label:"Certifications"},{value:"probation",label:"Probation"},{value:"pp_acknowledgements",label:"PP Acknowledgements"},{value:"payroll",label:"Payroll"},{value:"leave",label:"Leave"},{value:"disciplinary",label:"Disciplinary"},{value:"exit",label:"Exit"}];function se({employeeId:l,category:c}){const{data:d=[],isLoading:u}=Q(l,c),m=W(),y=X();return u?e.jsx("div",{className:"flex justify-center py-4",children:e.jsx(C,{className:"h-5 w-5 animate-spin text-gray-400"})}):d.length===0?e.jsx("p",{className:"text-sm text-gray-400 py-4 text-center",children:"No documents in this category."}):e.jsx("div",{className:"space-y-2",children:d.map(s=>e.jsxs("div",{className:"flex items-center gap-3 border rounded-lg px-3 py-2",children:[e.jsx(Z,{className:"h-4 w-4 text-gray-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:s.file_name}),e.jsxs("p",{className:"text-xs text-gray-400",children:[s.document_type," — ",new Date(s.uploaded_at).toLocaleDateString()]})]}),s.expiry_date&&e.jsxs(N,{variant:"outline",className:new Date(s.expiry_date)<new Date?"border-red-200 bg-red-50 text-red-700":"border-gray-200 text-gray-500",children:["Exp: ",s.expiry_date]}),s.is_verified?e.jsxs(N,{variant:"outline",className:"border-green-200 bg-green-50 text-green-700",children:[e.jsx(ee,{className:"h-3 w-3 mr-1"})," Verified"]}):e.jsx(i,{variant:"ghost",size:"sm",className:"text-xs",onClick:()=>y.mutateAsync({id:s.id,employee_id:l}).then(()=>o.success("Verified")),children:"Verify"}),e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>m.mutateAsync({id:s.id,employee_id:l}).then(()=>o.success("Deleted")),children:e.jsx(ae,{className:"h-3 w-3 text-red-500"})})]},s.id))})}function je(){const{id:l}=D(),c=w(),{data:d=[]}=G(),u=J(),m=d.find(a=>a.id===l),[y,s]=g.useState(!1),[r,p]=g.useState({category:"identity",document_type:"",expiry_date:""}),[h,v]=g.useState(!1);async function _(a){if(!l||!r.document_type.trim()){o.error("Document type is required");return}v(!0);try{const t=a.name.split(".").pop(),n=`${l}/${r.category}/${Date.now()}.${t}`,{error:b}=await B.storage.from("employee-documents").upload(n,a);if(b)throw b;await u.mutateAsync({employee_id:l,category:r.category,document_type:r.document_type.trim(),file_name:a.name,file_url:n,expiry_date:r.expiry_date||void 0}),o.success("Document uploaded"),s(!1),p({category:"identity",document_type:"",expiry_date:""})}catch(t){o.error(t.message||"Failed to upload")}finally{v(!1)}}return m?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(i,{variant:"ghost",size:"icon",onClick:()=>c(`/dashboard/hr/employees/${l}`),children:e.jsx(T,{className:"h-5 w-5"})}),e.jsxs("div",{className:"flex-1",children:[e.jsxs("h1",{className:"text-xl font-bold text-gray-900",children:["Employee File — ",m.full_name]}),e.jsx("p",{className:"text-sm text-gray-500",children:"10-tab document management"})]}),e.jsxs(i,{onClick:()=>s(!0),children:[e.jsx(Y,{className:"h-4 w-4 mr-2"})," Upload Document"]})]}),e.jsxs($,{defaultValue:"identity",children:[e.jsx(I,{className:"flex-wrap",children:f.map(a=>e.jsx(z,{value:a.value,className:"text-xs",children:a.label},a.value))}),f.map(a=>e.jsx(K,{value:a.value,className:"mt-4",children:e.jsxs(E,{children:[e.jsx(S,{children:e.jsxs(k,{children:[a.label," Documents"]})}),e.jsx(L,{children:e.jsx(se,{employeeId:l,category:a.value})})]})},a.value))]}),e.jsx(M,{open:y,onOpenChange:s,children:e.jsxs(q,{children:[e.jsx(H,{children:e.jsx(O,{children:"Upload Document"})}),e.jsxs("div",{className:"space-y-4 py-4",children:[e.jsxs("div",{children:[e.jsx(x,{children:"Category"}),e.jsxs(U,{value:r.category,onValueChange:a=>p(t=>({...t,category:a})),children:[e.jsx(F,{children:e.jsx(P,{})}),e.jsx(V,{children:f.map(a=>e.jsx(A,{value:a.value,children:a.label},a.value))})]})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Document Type *"}
1),e.jsx(j,{value:r.document_type,onChange:a=>p(t=>({...t,document_type:a.target.value})),placeholder:"e.g. KTP, SKK Certificate, Payslip"})]}),e.jsxs("div",{children:[e.jsx(x,{children:"Expiry Date (if applicable)"}),e.jsx(j,{type:"date",value:r.expiry_date,onChange:a=>p(t=>({...t,expiry_date:a.target.value}))})]}),e.jsxs("div",{children:[e.jsx(x,{children:"File"}),e.jsx(j,{type:"file",accept:".pdf,.jpg,.jpeg,.png",onChange:a=>{var n;const t=(n=a.target.files)==null?void 0:n[0];t&&_(t)},disabled:h})]})]}),e.jsxs(R,{children:[e.jsx(i,{variant:"outline",onClick:()=>s(!1),disabled:h,children:"Cancel"}),h&&e.jsx(C,{className:"h-4 w-4 animate-spin"})]})]})})]}):e.jsxs("div",{className:"text-center py-16",children:[e.jsx("p",{className:"text-gray-500",children:"Employee not found."}),e.jsx(i,{variant:"outline",className:"mt-4",onClick:()=>c("/dashboard/hr/employees"),children:"Back"})]})}export{je as EmployeeFilePage,je as default};

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.