Files
HRM-System/public/build/assets/edit-xy6MHTWO.js
2026-04-20 00:35:46 +08:00

2 lines
27 KiB
JavaScript

import{r as p,j as e}from"./ui-Z445SNHD.js";import{P as Ve}from"./page-template-CDooloYn.js";import{u as Le,c as Re,C as b,m as w,n as F,l as N,L as l,I as m,g as Oe,o as v,P as Me,r as k,t as u}from"./app-BJfYyIIX.js";import{S as _,a as j,b as y,c as g,d as x}from"./select-v6HfP-lT.js";import{R as ze,a as A}from"./radio-group-KOpzhUXP.js";import{E as Ue}from"./eye-bHRQkV_M.js";import{T as fe}from"./trash-2-CUSPqIMQ.js";import{A as Ge}from"./arrow-left-CPwg9j8r.js";import"./textarea-Am1DxbQR.js";import"./react-country-flag.esm-Bs2jngHP.js";import"./language-BbwPiY59.js";import"./sparkles-DiRyEFzz.js";import"./loader-circle-BSOgoX7W.js";import"./copy-C-oQ_m_8.js";import"./CookieConsentBanner-C38N4PTk.js";import"./refresh-cw-ALYE7VHu.js";import"./globe-BDbxh4XP.js";import"./settings-iEK2zkZs.js";import"./switch-Cx2aNaqN.js";import"./index-9MclThM-.js";import"./chevron-up-C77P-Xnl.js";import"./chevron-right-C_sLmqOC.js";import"./layout-grid-CoeIbdlV.js";import"./briefcase-XD6VuWqm.js";import"./credit-card-7DJJO-Xg.js";import"./gift-BfcFhtsh.js";import"./users-TIev6QWg.js";import"./calendar-CbSq6zTy.js";import"./calendar-days-C8NX5zeY.js";import"./clock-Dx30a3fw.js";import"./timer-BEVp3YT6.js";import"./dollar-sign-GjiaL2_k.js";import"./coins-Bsoy02xu.js";import"./index-BFT_C1pH.js";import"./user-DLrpac_w.js";import"./log-out-BMSBi6tX.js";/* empty css *//* empty css */import"./utils-BWxnHGCV.js";import"./index-BdQq_4o_.js";import"./circle-DWyWs_iS.js";function Ir(){var U,G,H,W,J,K,Z,Q,X,Y,ee,re,se,te,ae,ie,ne,de,le,ce,oe,me,he,xe,pe,ue,_e,je,ye,ge;const{t}=Le(),{employee:d,branches:be,departments:V,designations:L,documentTypes:Ne,shifts:E,attendancePolicies:P}=Re().props,[n,I]=p.useState({name:d.name||"",employee_id:((U=d.employee)==null?void 0:U.employee_id)||"",biometric_emp_id:((G=d.employee)==null?void 0:G.biometric_emp_id)||"",email:d.email||"",password:"",phone:((H=d.employee)==null?void 0:H.phone)||"",date_of_birth:((W=d.employee)==null?void 0:W.date_of_birth)||"",gender:((J=d.employee)==null?void 0:J.gender)||"",branch_id:(K=d.employee)!=null&&K.branch_id?d.employee.branch_id.toString():"",department_id:(Z=d.employee)!=null&&Z.department_id?d.employee.department_id.toString():"",designation_id:(Q=d.employee)!=null&&Q.designation_id?d.employee.designation_id.toString():"",shift_id:(X=d.employee)!=null&&X.shift_id?d.employee.shift_id.toString():"",attendance_policy_id:(Y=d.employee)!=null&&Y.attendance_policy_id?d.employee.attendance_policy_id.toString():"",date_of_joining:((ee=d.employee)==null?void 0:ee.date_of_joining)||"",employment_type:((re=d.employee)==null?void 0:re.employment_type)||"Full-time",employee_status:((se=d.employee)==null?void 0:se.employee_status)||"active",address_line_1:((te=d.employee)==null?void 0:te.address_line_1)||"",address_line_2:((ae=d.employee)==null?void 0:ae.address_line_2)||"",city:((ie=d.employee)==null?void 0:ie.city)||"",state:((ne=d.employee)==null?void 0:ne.state)||"",country:((de=d.employee)==null?void 0:de.country)||"",postal_code:((le=d.employee)==null?void 0:le.postal_code)||"",emergency_contact_name:((ce=d.employee)==null?void 0:ce.emergency_contact_name)||"",emergency_contact_relationship:((oe=d.employee)==null?void 0:oe.emergency_contact_relationship)||"",emergency_contact_number:((me=d.employee)==null?void 0:me.emergency_contact_number)||"",bank_name:((he=d.employee)==null?void 0:he.bank_name)||"",account_holder_name:((xe=d.employee)==null?void 0:xe.account_holder_name)||"",account_number:((pe=d.employee)==null?void 0:pe.account_number)||"",bank_identifier_code:((ue=d.employee)==null?void 0:ue.bank_identifier_code)||"",bank_branch:((_e=d.employee)==null?void 0:_e.bank_branch)||"",tax_payer_id:((je=d.employee)==null?void 0:je.tax_payer_id)||"",salary:((ye=d.employee)==null?void 0:ye.base_salary)||"",documents:[]}),[s,C]=p.useState({}),[R,$]=p.useState(!1),[O,ve]=p.useState(null),[M,Ce]=p.useState(d.avatar?d.avatar:null),[D,Se]=p.useState(((ge=d.employee)==null?void 0:ge.documents)||[]),[f,T]=p.useState([]),[qe,we]=p.useState(!1),[Fe,z]=p.useState(!1),ke=qe&&n.branch_id?V.filter(r=>String(r.branch_id)===String(n.branch_id)):V,De=Fe&&n.department_id?L.filter(r=>String(r.department_id)===String(n.department_id)):L,o=(r,a)=>{I(i=>({...i,[r]:a})),s[r]&&C(i=>{const c={...i};return delete c[r],c}),r==="branch_id"&&(we(!0),z(!1),I(i=>({...i,branch_id:a,department_id:"",designation_id:""}))),r==="department_id"&&(z(!0),I(i=>({...i,department_id:a,designation_id:""})))},Ee=r=>{if(r.target.files&&r.target.files[0]){const a=r.target.files[0];ve(a),Ce(URL.createObjectURL(a)),s.profile_image&&C(i=>{const c={...i};return delete c.profile_image,c})}},B=(r,a,i)=>{const c=[...f];c[r]={...c[r],[a]:i},T(c);const h=`new_documents.${r}.${a}`;s[h]&&C(S=>{const q={...S};return delete q[h],q})},Pe=(r,a)=>{if(a.target.files&&a.target.files[0]){const i=a.target.files[0];B(r,"file",i)}},Ie=()=>{T([...f,{document_type_id:"",file:null,expiry_date:""}])},$e=r=>{const a=[...f];a.splice(r,1),T(a);const i={...s};Object.keys(i).forEach(c=>{c.startsWith(`new_documents.${r}.`)&&delete i[c]}),C(i)},Te=r=>{k.delete(route("hr.employees.documents.destroy",[d.id,r]),{preserveScroll:!0,preserveState:!0,onSuccess:a=>{u.dismiss(),a.props.flash.success?u.success(t(a.props.flash.success)):a.props.flash.error&&u.error(t(a.props.flash.error)),Se(D.filter(i=>i.id!==r))},onError:a=>{u.dismiss(),typeof a=="string"?u.error(t(a)):u.error(t("Failed to delete document: {{errors}}",{errors:Object.values(a).join(", ")}))}})},Be=r=>{var i;r.preventDefault(),$(!0);const a=new FormData;a.append("_method","PUT"),Object.entries(n).forEach(([c,h])=>{c!=="documents"&&h!=null&&h!==""&&a.append(c,h)}),O&&a.append("profile_image",O),f.forEach((c,h)=>{c.document_type_id&&a.append(`documents[${h}][document_type_id]`,c.document_type_id),c.file&&a.append(`documents[${h}][file]`,c.file),c.expiry_date&&a.append(`documents[${h}][expiry_date]`,c.expiry_date)}),k.post(route("hr.employees.update",(i=d.employee)==null?void 0:i.id),a,{onSuccess:c=>{$(!1),c.props.flash.success&&u.success(t(c.props.flash.success)),k.get(route("hr.employees.index"))},onError:c=>{$(!1),C(c),u.error(t("Please correct the errors in the form"))}})},Ae=[{title:t("Dashboard"),href:route("dashboard")},{title:t("HR Management"),href:route("hr.employees.index")},{title:t("Employees"),href:route("hr.employees.index")},{title:t("Edit Employee")}];return e.jsx(Ve,{title:t("Edit Employee"),url:`/hr/employees/${d.id}/edit`,breadcrumbs:Ae,actions:[{label:t("Back"),icon:e.jsx(Ge,{className:"h-4 w-4 mr-2"}),variant:"outline",onClick:()=>k.get(route("hr.employees.index"))}],children:e.jsxs("form",{onSubmit:Be,className:"space-y-6",children:[e.jsxs(b,{children:[e.jsx(w,{children:e.jsx(F,{children:t("Basic Information")})}),e.jsx(N,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"name",required:!0,children:t("Full Name")}),e.jsx(m,{id:"name",required:!0,value:n.name,onChange:r=>o("name",r.target.value),className:s.name?"border-red-500":""}),s.name&&e.jsx("p",{className:"text-red-500 text-xs",children:s.name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"employee_id",children:t("Employee ID")}),e.jsx(m,{id:"employee_id",value:n.employee_id,readOnly:!0,className:"bg-muted"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("Employee ID cannot be changed")})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"biometric_emp_id",required:!0,children:t("Employee Code")}),e.jsx(m,{id:"biometric_emp_id",required:!0,value:n.biometric_emp_id||"",onChange:r=>o("biometric_emp_id",r.target.value),placeholder:"",className:s.biometric_emp_id?"border-red-500":""}),e.jsx("p",{className:"text-sm text-muted-foreground",children:t("This ID will be used to map employee with biometric device.")}),s.biometric_emp_id&&e.jsx("p",{className:"text-red-500 text-xs",children:s.biometric_emp_id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"email",required:!0,children:t("Email")}),e.jsx(m,{id:"email",type:"email",required:!0,value:n.email,onChange:r=>o("email",r.target.value),className:s.email?"border-red-500":""}),s.email&&e.jsx("p",{className:"text-red-500 text-xs",children:s.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(l,{htmlFor:"password",children:[t("Password")," ",e.jsx("span",{className:"text-sm text-muted-foreground",children:t("(Leave blank to keep current)")})]}),e.jsx(m,{id:"password",type:"password",value:n.password,onChange:r=>o("password",r.target.value),className:s.password?"border-red-500":""}),s.password&&e.jsx("p",{className:"text-red-500 text-xs",children:s.password})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"phone",required:!0,children:t("Phone Number")}),e.jsx(m,{id:"phone",required:!0,value:n.phone,onChange:r=>o("phone",r.target.value),className:s.phone?"border-red-500":""}),s.phone&&e.jsx("p",{className:"text-red-500 text-xs",children:s.phone})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"date_of_birth",required:!0,children:t("Date of Birth")}),e.jsx("div",{className:"cursor-pointer",onClick:r=>{var i;const a=r.currentTarget.querySelector("input");try{(i=a==null?void 0:a.showPicker)==null||i.call(a)}catch{a==null||a.focus()}},children:e.jsx(m,{id:"date_of_birth",type:"date",required:!0,value:n.date_of_birth,onChange:r=>o("date_of_birth",r.target.value),className:`cursor-pointer ${s.date_of_birth?"border-red-500":""}`})}),s.date_of_birth&&e.jsx("p",{className:"text-red-500 text-xs",children:s.date_of_birth})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{required:!0,children:t("Gender")}),e.jsxs(ze,{value:n.gender,onValueChange:r=>o("gender",r),className:"flex space-x-4",children:[e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(A,{value:"male",id:"gender-male"}),e.jsx(l,{htmlFor:"gender-male",children:t("Male")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(A,{value:"female",id:"gender-female"}),e.jsx(l,{htmlFor:"gender-female",children:t("Female")})]}),e.jsxs("div",{className:"flex items-center space-x-2",children:[e.jsx(A,{value:"other",id:"gender-other"}),e.jsx(l,{htmlFor:"gender-other",children:t("Other")})]})]}),s.gender&&e.jsx("p",{className:"text-red-500 text-xs",children:s.gender})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{required:!0,children:t("Profile Image")}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx("div",{className:"border rounded-md p-4 flex items-center justify-center bg-muted/30 h-32",children:M?e.jsx("img",{src:M,alt:"Profile Image",className:"max-h-full max-w-full object-contain rounded-full"}):n.profile_image?e.jsx("img",{src:Oe(n.profile_image),alt:"Profile Image",className:"max-h-full max-w-full object-contain rounded-full"}):e.jsxs("div",{className:"text-muted-foreground flex flex-col items-center gap-2",children:[e.jsx("div",{className:"h-12 w-12 bg-muted flex items-center justify-center rounded-full border border-dashed",children:e.jsx("span",{className:"font-semibold text-xs text-muted-foreground",children:t("Image")})}),e.jsx("span",{className:"text-xs",children:t("No image selected")})]})}),e.jsx(m,{type:"file",accept:"image/*",onChange:Ee,className:"cursor-pointer"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Max file size: 2MB")})]}),s.profile_image&&e.jsx("p",{className:"text-red-500 text-xs",children:s.profile_image})]})]})})]}),e.jsxs(b,{children:[e.jsx(w,{children:e.jsx(F,{children:t("Employment Details")})}),e.jsx(N,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"branch_id",required:!0,children:t("Branch")}),e.jsxs(_,{value:n.branch_id,required:!0,onValueChange:r=>o("branch_id",r),children:[e.jsx(j,{className:s.branch_id?"border-red-500":"",children:e.jsx(y,{placeholder:t("Select Branch")})}),e.jsx(g,{searchable:!0,children:be.map(r=>e.jsx(x,{value:r.id.toString(),children:r.name},r.id))})]}),s.branch_id&&e.jsx("p",{className:"text-red-500 text-xs",children:s.branch_id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"department_id",required:!0,children:t("Department")}),e.jsxs(_,{value:n.department_id,required:!0,onValueChange:r=>o("department_id",r),disabled:!n.branch_id,children:[e.jsx(j,{className:s.department_id?"border-red-500":"",children:e.jsx(y,{placeholder:n.branch_id?t("Select Department"):t("Select Branch First")})}),e.jsx(g,{searchable:!0,children:ke.map(r=>e.jsx(x,{value:r.id.toString(),children:r.name},r.id))})]}),s.department_id&&e.jsx("p",{className:"text-red-500 text-xs",children:s.department_id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"designation_id",required:!0,children:t("Designation")}),e.jsxs(_,{value:n.designation_id,required:!0,onValueChange:r=>o("designation_id",r),disabled:!n.department_id,children:[e.jsx(j,{className:s.designation_id?"border-red-500":"",children:e.jsx(y,{placeholder:n.department_id?t("Select Designation"):t("Select Department First")})}),e.jsx(g,{searchable:!0,children:De.map(r=>e.jsx(x,{value:r.id.toString(),children:r.name},r.id))})]}),s.designation_id&&e.jsx("p",{className:"text-red-500 text-xs",children:s.designation_id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"date_of_joining",required:!0,children:t("Date of Joining")}),e.jsx("div",{className:"cursor-pointer",onClick:r=>{var i;const a=r.currentTarget.querySelector("input");try{(i=a==null?void 0:a.showPicker)==null||i.call(a)}catch{a==null||a.focus()}},children:e.jsx(m,{id:"date_of_joining",type:"date",required:!0,value:n.date_of_joining,onChange:r=>o("date_of_joining",r.target.value),className:`cursor-pointer ${s.date_of_joining?"border-red-500":""}`})}),s.date_of_joining&&e.jsx("p",{className:"text-red-500 text-xs",children:s.date_of_joining})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"employment_type",required:!0,children:t("Employment Type")}),e.jsxs(_,{value:n.employment_type,required:!0,onValueChange:r=>o("employment_type",r),children:[e.jsx(j,{className:s.employment_type?"border-red-500":"",children:e.jsx(y,{placeholder:t("Select Employment Type")})}),e.jsxs(g,{children:[e.jsx(x,{value:"Full-time",children:t("Full-time")}),e.jsx(x,{value:"Part-time",children:t("Part-time")}),e.jsx(x,{value:"Contract",children:t("Contract")}),e.jsx(x,{value:"Internship",children:t("Internship")}),e.jsx(x,{value:"Temporary",children:t("Temporary")})]})]}),s.employment_type&&e.jsx("p",{className:"text-red-500 text-xs",children:s.employment_type})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"employee_status",required:!0,children:t("Employee Status")}),e.jsxs(_,{value:n.employee_status,required:!0,onValueChange:r=>o("employee_status",r),children:[e.jsx(j,{className:s.employee_status?"border-red-500":"",children:e.jsx(y,{placeholder:t("Select Employee Status")})}),e.jsxs(g,{children:[e.jsx(x,{value:"active",children:t("Active")}),e.jsx(x,{value:"inactive",children:t("Inactive")}),e.jsx(x,{value:"probation",children:t("Probation")}),e.jsx(x,{value:"terminated",children:t("Terminated")})]})]}),s.employee_status&&e.jsx("p",{className:"text-red-500 text-xs",children:s.employee_status})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"shift_id",children:t("Shift")}),e.jsxs(_,{value:n.shift_id,onValueChange:r=>o("shift_id",r),children:[e.jsx(j,{className:s.shift_id?"border-red-500":"",children:e.jsx(y,{placeholder:t("Select Shift (Optional)")})}),e.jsx(g,{searchable:!0,children:E==null?void 0:E.map(r=>e.jsxs(x,{value:r.id.toString(),children:[r.name," (",r.start_time," - ",r.end_time,")"]},r.id))})]}),s.shift_id&&e.jsx("p",{className:"text-red-500 text-xs",children:s.shift_id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"attendance_policy_id",children:t("Attendance Policy")}),e.jsxs(_,{value:n.attendance_policy_id,onValueChange:r=>o("attendance_policy_id",r),children:[e.jsx(j,{className:s.attendance_policy_id?"border-red-500":"",children:e.jsx(y,{placeholder:t("Select Attendance Policy (Optional)")})}),e.jsx(g,{children:P==null?void 0:P.map(r=>e.jsx(x,{value:r.id.toString(),children:r.name},r.id))})]}),s.attendance_policy_id&&e.jsx("p",{className:"text-red-500 text-xs",children:s.attendance_policy_id})]})]})})]}),e.jsxs(b,{children:[e.jsx(w,{children:e.jsx(F,{children:t("Contact Information")})}),e.jsxs(N,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"address_line_1",required:!0,children:t("Address Line 1")}),e.jsx(m,{id:"address_line_1",required:!0,value:n.address_line_1,onChange:r=>o("address_line_1",r.target.value),className:s.address_line_1?"border-red-500":""}),s.address_line_1&&e.jsx("p",{className:"text-red-500 text-xs",children:s.address_line_1})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"address_line_2",children:t("Address Line 2")}),e.jsx(m,{id:"address_line_2",value:n.address_line_2,onChange:r=>o("address_line_2",r.target.value),className:s.address_line_2?"border-red-500":""}),s.address_line_2&&e.jsx("p",{className:"text-red-500 text-xs",children:s.address_line_2})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"city",required:!0,children:t("City")}),e.jsx(m,{id:"city",value:n.city,required:!0,onChange:r=>o("city",r.target.value),className:s.city?"border-red-500":""}),s.city&&e.jsx("p",{className:"text-red-500 text-xs",children:s.city})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"state",required:!0,children:t("State/Province")}),e.jsx(m,{id:"state",required:!0,value:n.state,onChange:r=>o("state",r.target.value),className:s.state?"border-red-500":""}),s.state&&e.jsx("p",{className:"text-red-500 text-xs",children:s.state})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"country",required:!0,children:t("Country")}),e.jsx(m,{id:"country",required:!0,value:n.country,onChange:r=>o("country",r.target.value),className:s.country?"border-red-500":""}),s.country&&e.jsx("p",{className:"text-red-500 text-xs",children:s.country})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"postal_code",required:!0,children:t("Postal/Zip Code")}),e.jsx(m,{id:"postal_code",required:!0,value:n.postal_code,onChange:r=>o("postal_code",r.target.value),className:s.postal_code?"border-red-500":""}),s.postal_code&&e.jsx("p",{className:"text-red-500 text-xs",children:s.postal_code})]})]}),e.jsxs("div",{className:"mt-6",children:[e.jsx("h3",{className:"text-lg font-medium mb-4",children:t("Emergency Contact")}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"emergency_contact_name",required:!0,children:t("Name")}),e.jsx(m,{id:"emergency_contact_name",value:n.emergency_contact_name,required:!0,onChange:r=>o("emergency_contact_name",r.target.value),className:s.emergency_contact_name?"border-red-500":""}),s.emergency_contact_name&&e.jsx("p",{className:"text-red-500 text-xs",children:s.emergency_contact_name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"emergency_contact_relationship",required:!0,children:t("Relationship")}),e.jsx(m,{id:"emergency_contact_relationship",required:!0,value:n.emergency_contact_relationship,onChange:r=>o("emergency_contact_relationship",r.target.value),className:s.emergency_contact_relationship?"border-red-500":""}),s.emergency_contact_relationship&&e.jsx("p",{className:"text-red-500 text-xs",children:s.emergency_contact_relationship})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"emergency_contact_number",required:!0,children:t("Phone Number")}),e.jsx(m,{id:"emergency_contact_number",required:!0,value:n.emergency_contact_number,onChange:r=>o("emergency_contact_number",r.target.value),className:s.emergency_contact_number?"border-red-500":""}),s.emergency_contact_number&&e.jsx("p",{className:"text-red-500 text-xs",children:s.emergency_contact_number})]})]})]})]})]}),e.jsxs(b,{children:[e.jsx(w,{children:e.jsx(F,{children:t("Banking Information")})}),e.jsx(N,{className:"space-y-4",children:e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"bank_name",required:!0,children:t("Bank Name")}),e.jsx(m,{id:"bank_name",value:n.bank_name,required:!0,onChange:r=>o("bank_name",r.target.value),className:s.bank_name?"border-red-500":""}),s.bank_name&&e.jsx("p",{className:"text-red-500 text-xs",children:s.bank_name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"account_holder_name",required:!0,children:t("Account Holder Name")}),e.jsx(m,{id:"account_holder_name",required:!0,value:n.account_holder_name,onChange:r=>o("account_holder_name",r.target.value),className:s.account_holder_name?"border-red-500":""}),s.account_holder_name&&e.jsx("p",{className:"text-red-500 text-xs",children:s.account_holder_name})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"account_number",children:t("Account Number")}),e.jsx(m,{id:"account_number",value:n.account_number,required:!0,onChange:r=>o("account_number",r.target.value),className:s.account_number?"border-red-500":""}),s.account_number&&e.jsx("p",{className:"text-red-500 text-xs",children:s.account_number})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"bank_identifier_code",required:!0,children:t("Bank Identifier Code (BIC/SWIFT)")}),e.jsx(m,{id:"bank_identifier_code",value:n.bank_identifier_code,required:!0,onChange:r=>o("bank_identifier_code",r.target.value),className:s.bank_identifier_code?"border-red-500":""}),s.bank_identifier_code&&e.jsx("p",{className:"text-red-500 text-xs",children:s.bank_identifier_code})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"bank_branch",required:!0,children:t("Bank Branch")}),e.jsx(m,{id:"bank_branch",value:n.bank_branch,required:!0,onChange:r=>o("bank_branch",r.target.value),className:s.bank_branch?"border-red-500":""}),s.bank_branch&&e.jsx("p",{className:"text-red-500 text-xs",children:s.bank_branch})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"tax_payer_id",children:t("Tax Payer ID")}),e.jsx(m,{id:"tax_payer_id",value:n.tax_payer_id,onChange:r=>o("tax_payer_id",r.target.value),className:s.tax_payer_id?"border-red-500":""}),s.tax_payer_id&&e.jsx("p",{className:"text-red-500 text-xs",children:s.tax_payer_id})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:"salary",required:!0,children:t("Base Salary")}),e.jsx(m,{id:"salary",required:!0,type:"number",step:"0.01",value:n.salary,onChange:r=>o("salary",r.target.value),className:s.salary?"border-red-500":""}),s.salary&&e.jsx("p",{className:"text-red-500 text-xs",children:s.salary})]})]})})]}),e.jsxs(b,{children:[e.jsx(w,{children:e.jsx(F,{children:t("Documents")})}),e.jsxs(N,{className:"space-y-4",children:[D.length>0&&e.jsxs("div",{className:"mb-6",children:[e.jsx("h3",{className:"text-lg font-medium mb-4",children:t("Existing Documents")}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:D.map(r=>{var a;return e.jsx(b,{className:"border",children:e.jsx(N,{className:"p-4",children:e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsx("div",{className:"flex items-center",children:e.jsxs("div",{children:[e.jsx("h4",{className:"font-medium",children:(a=r.document_type)==null?void 0:a.name}),e.jsx("p",{className:"text-sm text-muted-foreground",children:r.expiry_date?`${t("Expires")}: ${new Date(r.expiry_date).toLocaleDateString()}`:t("No expiry date")}),e.jsx("div",{className:`inline-flex items-center rounded-md px-2 py-1 text-xs font-medium mt-2 ${r.verification_status==="verified"?"bg-green-50 text-green-700 ring-1 ring-inset ring-green-600/20":r.verification_status==="rejected"?"bg-red-50 text-red-700 ring-1 ring-inset ring-red-600/20":"bg-yellow-50 text-yellow-700 ring-1 ring-inset ring-yellow-600/20"}`,children:r.verification_status==="verified"?t("Verified"):r.verification_status==="rejected"?t("Rejected"):t("Pending")})]})}),e.jsxs("div",{className:"flex space-x-2",children:[e.jsx(v,{type:"button",variant:"outline",size:"sm",onClick:()=>window.open(r.document_url||r.file_path,"_blank"),children:e.jsx(Ue,{className:"h-4 w-4"})}),e.jsx(v,{type:"button",variant:"outline",size:"sm",onClick:()=>Te(r.id),children:e.jsx(fe,{className:"h-4 w-4 text-red-500"})})]})]})})},r.id)})})]}),e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium mb-4",children:t("Add New Documents")}),f.map((r,a)=>e.jsxs("div",{className:"border rounded-md p-4 space-y-4 mb-4",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("h3",{className:"text-lg font-medium",children:[t("Document")," #",a+1]}),e.jsx(v,{type:"button",variant:"ghost",size:"sm",onClick:()=>$e(a),children:e.jsx(fe,{className:"h-4 w-4 text-red-500"})})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsxs(l,{htmlFor:`document_type_${a}`,children:[t("Document Type")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs(_,{value:r.document_type_id,onValueChange:i=>B(a,"document_type_id",i),children:[e.jsx(j,{className:s[`documents.${a}.document_type_id`]?"border-red-500":"",children:e.jsx(y,{placeholder:t("Select Document Type")})}),e.jsx(g,{children:Ne.filter(i=>{if(i.id.toString()===r.document_type_id)return!0;const c=D.some(S=>{var q;return((q=S.document_type_id)==null?void 0:q.toString())===i.id.toString()}),h=f.some(S=>S.document_type_id===i.id.toString());return!c&&!h}).map(i=>e.jsxs(x,{value:i.id.toString(),children:[i.name," ",i.is_required&&e.jsx("span",{className:"text-red-500",children:"*"})]},i.id))})]}),s[`documents.${a}.document_type_id`]&&e.jsx("p",{className:"text-red-500 text-xs",children:s[`documents.${a}.document_type_id`]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs(l,{children:[t("File")," ",e.jsx("span",{className:"text-red-500",children:"*"})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsx(m,{type:"file",onChange:i=>Pe(a,i),className:s[`documents.${a}.file`]?"border-red-500":""}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t("Max file size: 5MB")})]}),s[`documents.${a}.file`]&&e.jsx("p",{className:"text-red-500 text-xs",children:s[`documents.${a}.file`]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(l,{htmlFor:`document_expiry_${a}`,children:t("Expiry Date")}),e.jsx("div",{className:"cursor-pointer",onClick:i=>{var h;const c=i.currentTarget.querySelector("input");try{(h=c==null?void 0:c.showPicker)==null||h.call(c)}catch{c==null||c.focus()}},children:e.jsx(m,{id:`document_expiry_${a}`,type:"date",value:r.expiry_date,onChange:i=>B(a,"expiry_date",i.target.value),className:`cursor-pointer ${s[`documents.${a}.expiry_date`]?"border-red-500":""}`})}),s[`documents.${a}.expiry_date`]&&e.jsx("p",{className:"text-red-500 text-xs",children:s[`documents.${a}.expiry_date`]})]})]})]},a)),e.jsxs(v,{type:"button",variant:"outline",onClick:Ie,className:"mt-4",children:[e.jsx(Me,{className:"h-4 w-4 mr-2"}),t("Add Document")]})]})]})]}),e.jsxs("div",{className:"flex justify-end space-x-4",children:[e.jsx(v,{type:"button",variant:"outline",onClick:()=>k.get(route("hr.employees.index")),children:t("Cancel")}),e.jsx(v,{type:"submit",disabled:R,children:t(R?"Saving...":"Update Employee")})]})]})})}export{Ir as default};