1const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/fileStorage-CwBiakkj.js","assets/index-C6--jTPa.js","assets/index-oAtxEtcC.css"])))=>i.map(i=>d[i]); 2import{Z as V,a6 as G,r as f,j as e,aM as J,e as Z,B as w,am as Q,C as o,ap as m,aq as x,d as h,au as P,U as W,I as l,bF as X,P as ee,R as se,bG as ae,s as T}from"./index-C6--jTPa.js";import{a as ne,b as re}from"./useTeamMembers-DEggBTa0.js";import{j as ie,A as le,B as te}from"./useTeamSystem-DhfRksuQ.js";import{P as de}from"./PageHero-C3CUhOZ_.js";import{L as r}from"./label-CdYthYdK.js";import{T as ce}from"./textarea-CMbBoEE6.js";import{B as E}from"./badge-BpH-XLTX.js";import{T as oe,a as me,b as A,c as R}from"./tabs-D8fM3BSH.js";import{g as xe}from"./generatePayslip-Cj8FD8UY.js";import{L as U}from"./lock-B3JHZidr.js";import{C as F}from"./credit-card-Cq0A4JMc.js";import{M as he}from"./map-pin-CvHYnikx.js";import{S as ue}from"./shield-BDDcqeG5.js";import{S as je}from"./save-Cvpsr1FL.js";import{C as pe}from"./calendar-BwhCPqqo.js";import{D as ge}from"./download-Ik9YNL_L.js";import"./jspdf.es.min-D9Iy4Q0L.js";const Re=()=>{const{user:j,loading:B}=V(),{data:s,isLoading:I}=ne(),C=re(),{data:p}=ie(s==null?void 0:s.id),K=le(),{data:u}=te(s==null?void 0:s.id),{toast:y}=G(),n=(s==null?void 0:s.is_locked)===!0;s!=null&&s.id;const[i,b]=f.useState({display_name:"",bio:"",photo_url:"",linkedin_url:"",phone:"",date_of_birth:"",national_id:"",emergency_contact_name:"",emergency_contact_phone:"",address:"",city:"",country:"",personal_email:"",company_email:""}),[d,S]=f.useState({bank_name:"",bank_account_number:"",bank_iban:"",salary_amount:"",salary_currency:"PKR",tax_id:""}),[D,M]=f.useState(!1);if(f.useEffect(()=>{s?b({display_name:s.display_name||"",bio:s.bio||"",photo_url:s.photo_url||"",linkedin_url:s.linkedin_url||"",phone:s.phone||"",date_of_birth:s.date_of_birth||"",national_id:s.national_id||"",emergency_contact_name:s.emergency_contact_name||"",emergency_contact_phone:s.emergency_contact_phone||"",address:s.address||"",city:s.city||"",country:s.country||"",personal_email:s.personal_email||"",company_email:s.company_email||""}):j&&b(a=>{var t;return{...a,display_name:((t=j.user_metadata)==null?void 0:t.full_name)||""}})},[s,j]),f.useEffect(()=>{var a;p&&S({bank_name:p.bank_name||"",bank_account_number:p.bank_account_number||"",bank_iban:p.bank_iban||"",salary_amount:((a=p.salary_amount)==null?void 0:a.toString())||"",salary_currency:p.salary_currency||"PKR",tax_id:p.tax_id||""})},[p]),B||I)return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("div",{className:"animate-spin h-8 w-8 border-4 border-primary border-t-transparent rounded-full"})});if(!j)return e.jsx(J,{to:"/login",replace:!0});const H=async a=>{var g;if(n)return;const t=(g=a.target.files)==null?void 0:g[0];if(t){M(!0);try{const{uploadFile:k,isHostingerStorageEnabled:$}=await ae(async()=>{const{uploadFile:N,isHostingerStorageEnabled:_}=await import("./fileStorage-CwBiakkj.js");return{uploadFile:N,isHostingerStorageEnabled:_}},__vite__mapDeps([0,1,2]));if($()){const N=await k(t,"team-photos");b(_=>({..._,photo_url:N.publicUrl}))}else{const N=t.name.split(".").pop(),_=`${j.id}/${Date.now()}.${N}`,{error:L}=await T.storage.from("team-photos").upload(_,t,{upsert:!0});if(L)throw L;const{data:{publicUrl:q}}=T.storage.from("team-photos").getPublicUrl(_);b(z=>({...z,photo_url:q}))}y({title:"Photo uploaded successfully!"})}catch(k){y({title:"Upload failed",description:k.message,variant:"destructive"})}finally{M(!1)}}},O=async a=>{if(a.preventDefault(),n){y({title:"Profile is locked",description:"Your profile has been locked by admin. Contact admin for changes.",variant:"destructive"});return}try{const t={...i,role_title:(s==null?void 0:s.role_title)||"Team Member",is_visible:(s==null?void 0:s.is_visible)??!0,department:(s==null?void 0:s.department)||null,display_order:(s==null?void 0:s.display_order)??0};await C.mutateAsync(t),s!=null&&s.id&&(d.bank_name||d.bank_account_number||d.salary_amount)&&await K.mutateAsync({member_id:s.id,...d,salary_amount:d.salary_amount?parseFloat(d.salary_amount):null}),y({title:"Profile saved successfully!"})}catch(t){y({title:"Error saving profile",description:t.message,variant:"destructive"})}},c=a=>t=>b(g=>({...g,[a]:t.target.value})),v=a=>t=>S(g=>({...g,[a]:t.target.value})),Y=(u==null?void 0:u.reduce((a,t)=>a+Number(t.amount),0))||0;return e.jsxs("div",{className:"min-h-screen",children:[e.jsx(de,{title:e.jsxs(e.Fragment,{children:["Manage Your ",e.jsx("span",{className:"gradient-text-brand",children:"Team Profile"})]}),subtitle:"Update your information. Sensitive data is encrypted and only visible to you and admins."}),e.jsx("div",{className:"container mx-auto px-4 lg:px-8 py-12",children:e.jsxs("div",{className:"max-w-2xl mx-auto
2space-y-8",children:[e.jsxs("div",{className:"flex gap-2 items-center",children:[e.jsx(Z,{to:"/team-dashboard",children:e.jsxs(w,{variant:"ghost",className:"gap-2",children:[e.jsx(Q,{className:"h-4 w-4"})," Team Dashboard"]})}),n&&e.jsxs(E,{variant:"destructive",className:"gap-1",children:[e.jsx(U,{className:"h-3 w-3"})," Profile Locked"]})]}),s&&e.jsxs(o,{className:"glass-card border-primary/20",children:[e.jsx(m,{children:e.jsx(x,{className:"text-sm text-muted-foreground",children:"Assigned by Admin (Read-only)"})}),e.jsx(h,{children:e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 text-sm",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Role / Title"}),e.jsx("p",{className:"font-medium",children:s.role_title||"â"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Department"}),e.jsx("p",{className:"font-medium",children:s.department||"â"})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Display Order"}),e.jsxs("p",{className:"font-medium",children:["#",s.display_order||0]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-muted-foreground",children:"Joining Date"}),e.jsx("p",{className:"font-medium",children:s.joining_date?P(new Date(s.joining_date),"MMM d, yyyy"):"â"})]})]})})]}),e.jsxs(oe,{defaultValue:"profile",children:[e.jsxs(me,{className:"w-full",children:[e.jsx(A,{value:"profile",className:"flex-1",children:"Profile"}),e.jsxs(A,{value:"pay",className:"flex-1 gap-1",children:[e.jsx(F,{className:"h-3 w-3"})," Pay"]})]}),e.jsx(R,{value:"profile",children:e.jsxs("form",{onSubmit:O,className:"space-y-6 mt-4",children:[e.jsxs(o,{className:"glass-card",children:[e.jsx(m,{children:e.jsxs(x,{className:"flex items-center gap-2",children:[e.jsx(W,{className:"h-5 w-5"})," Profile Photo"]})}),e.jsxs(h,{className:"space-y-4",children:[i.photo_url&&e.jsx("div",{className:"w-32 h-32 rounded-2xl overflow-hidden border-2 border-border",children:e.jsx("img",{src:i.photo_url,alt:"Profile",className:"w-full h-full object-cover"})}),!n&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx(r,{htmlFor:"photo",children:"Upload Photo"}),e.jsx(l,{id:"photo",type:"file",accept:"image/*",onChange:H,disabled:D}),D&&e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Uploading..."})]}),e.jsxs("div",{children:[e.jsx(r,{htmlFor:"photo_url",children:"Or paste image URL"}),e.jsx(l,{id:"photo_url",value:i.photo_url,onChange:c("photo_url"),placeholder:"https://..."})]})]})]})]}),e.jsxs(o,{className:"glass-card",children:[e.jsx(m,{children:e.jsx(x,{children:"Basic Information"})}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Display Name *"}),e.jsx(l,{value:i.display_name,onChange:c("display_name"),required:!0,disabled:n})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Bio / Description"}),e.jsx(ce,{value:i.bio,onChange:c("bio"),placeholder:"A short description...",rows:4,disabled:n})]})]})]}),e.jsxs(o,{className:"glass-card",children:[e.jsx(m,{children:e.jsxs(x,{className:"flex items-center gap-2",children:[e.jsx(X,{className:"h-5 w-5"})," Email Addresses"]})}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Personal Email"}),e.jsx(l,{value:i.personal_email,onChange:c("personal_email"),placeholder:"[email protected]",disabled:n})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Company Email"}),e.jsx(l,{value:i.company_email,onChange:c("company_email"),placeholder:"[email protected]",disabled:n})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Email addresses are private and only visible to you and admins."})]})]}),e.jsxs(o,{className:"glass-card",children:[e.jsx(m,{children:e.jsxs(x,{className:"flex items-center gap-2",children:[e.jsx(ee,{className:"h-5 w-5"})," Contact & Personal"]})}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Phone"}),e.jsx(l,{value:i.phone,onChange:c("phone"),placeholder:"+92...",disabled:n})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Date of Birth"}),e.jsx(l,{type:"date",value:i.date_of_birth,onChange:c("date_of_birth"),disabled:n})]})]}),e.jsxs("div",{children:[e.jsx(r,{children:"National ID / Passport"}),e.jsx(l,{value:i.national_id,onChange:c("national_id"),disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Emergency Contact Name"}),e.jsx(l,{value:i.emergency_contact_name,onChange:c("emergency_contact_name"),disabled:n})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Emergency Contact Phone"}),e.jsx(l,{value:i.emergency_contact_phone,onChange:c("emergency_contact_phone"),disabled:n})]})]})]})]}),e.jsxs(o,{className:"glass-card",children:[e.jsx(m,{children:e.jsxs(x,{className:"flex items-center gap-2",children:[e.jsx(he,{className:"h-5 w-5"})," Address"]})}),e.jsxs(h,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Address"}),e.jsx(l,{value:i.address,onChange:c("address"),disabled:n})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"City"}),e.jsx(l,{value:i.city,onChange:c("city"),disabled:n})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Country"}),e.jsx(l,{value:i.country,onChange:c("country"),disabled:n})]})]})]})]}),e.jsxs(o,{className:"glass-card",children:[e.jsx(m,{children:e.jsxs(x,{className:"flex items-center gap-2",children:[e.jsx(se,{className:"h-5 w-5"})," Social Links"]})}),e.jsx(h,{children:e.jsxs("div",{children:[e.jsx(r,{children:"LinkedIn URL"}),e.jsx(l,{value:i.linkedin_url,onChange:c("linkedin_url"),placeholder:"https://linkedin.com/in/...",disabled:n})]})})]}),e.jsxs(o,{className:"glass-card border-destructive/20",children:[e.jsx(m,{children:e.jsxs(x,{className:"flex items-center gap-2",children:[e.jsx(ue,{className:"h-5 w-5 text-destructive"})," Financial Information ",e.jsx("span",{className:"text-xs text-destructive",children:"(Secure)"})]})}),e.jsxs(h,{className:"space-y-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:"This data is encrypted and only visible to you and super admins."}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Bank Name"}),e.jsx(l,{value:d.bank_name,onChange:v("bank_name"),disabled:n})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Account Number"}),e.jsx(l,{value:d.bank_account_number,onChange:v("bank_account_number"),disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"IBAN"}),e.jsx(l,{value:d.bank_iban,onChange:v("bank_iban"),disabled:n})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Tax ID"}),e.jsx(l,{value:d.tax_id,onChange:v("tax_id"),disabled:n})]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"Salary Amount"}),e.jsx(l,{type:"number",value:d.salary_amount,onChange:v("salary_amount"),disabled:n})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Currency"}),e.jsx(l,{value:"PKR",disabled:!0,className:"bg-muted"})]})]})]})]}),!n&&e.jsxs(w,{type:"submit",size:"lg",className:"w-full hero-gradient text-primary-foreground gap-2",disabled:C.isPending,children:[e.jsx(je,{className:"h-4 w-4"}),C.isPending?"Saving...":"Save Profile"]}),n&&e.jsxs("p",{className:"text-center text-sm text-muted-foreground",children:[e.jsx(U,{className:"inline h-4 w-4 mr-1"}),"Your profile is locked. Contact your admin for any changes."]})]})}),e.jsxs(R,{value:"pay",className:"mt-4 space-y-6",children:[e.jsxs(o,{className:"glass-card",children:[e.jsx(m,{children:e.jsxs(x,{className:"flex items-center gap-2",children:[e.jsx(F,{className:"h-5 w-5"})," Payment Summary"]})}),e.jsx(h,{children:e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{className:"text-center p-4 bg-muted/50 rounded-lg",children:[e.jsxs("p",{className:"text-2xl font-bold",children:["PKR ",Y.toLocaleStr
2ing()]}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Total Received"})]}),e.jsxs("div",{className:"text-center p-4 bg-muted/50 rounded-lg",children:[e.jsx("p",{className:"text-2xl font-bold",children:(u==null?void 0:u.length)||0}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Payments"})]})]})})]}),e.jsxs(o,{className:"glass-card",children:[e.jsx(m,{children:e.jsx(x,{children:"Payment History"})}),e.jsx(h,{children:u&&u.length>0?e.jsx("div",{className:"space-y-3",children:u.map(a=>e.jsxs("div",{className:"p-4 rounded-lg bg-muted/50 space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:a.description||"Payment"}),e.jsxs("div",{className:"flex gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[e.jsx(pe,{className:"inline h-3 w-3 mr-1"}),P(new Date(a.payment_date),"MMM d, yyyy")]}),a.payment_method&&e.jsx("span",{children:a.payment_method})]}),(a.period_from||a.peri
2od_to)&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["Period: ",a.period_from?P(new Date(a.period_from),"MMM d"):"?"," â ",a.period_to?P(new Date(a.period_to),"MMM d, yyyy"):"?",a.period_type==="daily"?" (Daily)":" (Monthly)"]})]}),e.jsxs("div",{className:"text-right",children:[e.jsxs("p",{className:"font-bold text-primary",children:["PKR ",Number(a.amount).toLocaleString()]}),e.jsx(E,{variant:a.status==="paid"?"default":"secondary",className:"text-xs",children:a.status}),e.jsx("div",{className:"mt-2",children:e.jsxs(w,{size:"sm",variant:"outline",onClick:()=>xe({employee:{name:(s==null?void 0:s.display_name)||i.display_name||"Employee",role:s==null?void 0:s.role_title,email:i.company_email||i.personal_email||(j==null?void 0:j.email),employeeId:s==null?void 0:s.employee_code,bankName:d.bank_name,bankAccount:d.bank_account_number,iban:d.bank_iban,taxId:d.tax_id},payment:a}),children:[e.jsx(ge,{className:"h-3 w-3 mr-1"})," Payslip PDF"]})})]})]}),(a.basic_pay||a.bonus)&&e.jsxs("div",{className:"flex gap-4 text-xs text-muted-foreground border-t border-border pt-2",children:[a.basic_pay>0&&e.jsxs("span",{children:["Basic: PKR ",Number(a.basic_pay).toLocaleString()]}),a.bonus>0&&e.jsxs("span",{className:"text-green-600",children:["Bonus: PKR ",Number(a.bonus).toLocaleString()]})]})]},a.id))}):e.jsx("p",{className:"text-center text-muted-foreground py-8",children:"No payment records yet."})})]})]})]})]})})]})};export{Re 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.