1import{l as R,r as x,z as u,j as e,aj as J,aC as f,d as D,Z as F,ag as P,aI as g}from"./vendor-react-aro8yD9l.js";import{a as X}from"./index-CAwCAWZT.js";import"./vendor-charts-DStlN2dP.js";import"./vendor-pdf-BLcQqIzu.js";const N="voluntar_profile_setup_draft_v1";function Y(){const y=R(),[o,h]=x.useState(1),[S,C]=x.useState(!1),[$,A]=x.useState(!0),[j,z]=x.useState(""),[a,b]=x.useState({prenume:"",nume:"",telefon:"",birth_day:"",birth_month:"",birth_year:"",data_nasterii:"",sex:"",email:"",tara:"România",strada:"",numar:"",bloc:"",scara:"",etaj:"",apartament:"",localitate:"",judet:"",cod_postal:"",cnp:"",ci_serie:"",ci_numar:"",ci_eliberat_de:"",ci_valabil_pana:"",ci_valabil_zi:"",ci_valabil_luna:"",ci_valabil_an:"",ci_photo:null});x.useEffect(()=>{O()},[]);const w=i=>{try{const r={...i};r.ci_photo instanceof File&&(r.ci_photo=null,r.ci_photo_name=i.ci_photo.name),localStorage.setItem(N,JSON.stringify(r))}catch{}},E=()=>{try{localStorage.removeItem(N)}catch{}},O=async()=>{try{const i=JSON.parse(localStorage.getItem("user")||"{}");if(!i.user_id){u.error("Trebuie sÄ fii autentificat"),y("/login");return}const r=await X.postJSON({mode:"voluntar",action:"get_profile",user_id:i.user_id});let l={};try{l=JSON.parse(localStorage.getItem(N)||"{}")||{}}catch{l={}}b(p=>{const s={...p};i.first_name&&(s.prenume=i.first_name),i.last_name&&(s.nume=i.last_name),i.telefon&&(s.telefon=i.telefon),s.email=i.email||"";const c=r.success&&(r.voluntar||r.profile)||null;if(c){Object.keys(c).forEach(d=>{if(d==="email"||d==="ci_photo_url")return;const _=c[d];_!=null&&String(_).trim()!==""&&(s[d]=_)}),!s.numar&&c.numar_strada&&(s.numar=c.numar_strada),!s.ci_serie&&c.serie_ci&&(s.ci_serie=c.serie_ci),!s.ci_numar&&c.numar_ci&&(s.ci_numar=c.numar_ci);const n=c.data_nasterii||"";if(n&&n.includes("-")){const d=n.split("-");d.length===3&&(s.birth_year=d[0],s.birth_month=String(parseInt(d[1],10)),s.birth_day=String(parseInt(d[2],10)))}const v=c.ci_valabil_pana||"";if(v&&v.includes("-")){const d=v.split("-");d.length===3&&(s.ci_valabil_an=d[0],s.ci_valabil_luna=String(parseInt(d[1],10)),s.ci_valabil_zi=String(parseInt(d[2],10)))}c.ci_photo_url&&z(c.ci_photo_url)}const m=!r.success&&r.user_prefill||null;return m&&(m.first_name&&!s.prenume&&(s.prenume=m.first_name),m.last_name&&!s.nume&&(s.nume=m.last_name),m.telefon&&!s.telefon&&(s.telefon=m.telefon)),Object.keys(l||{}).forEach(n=>{n==="ci_photo"||n==="ci_photo_name"||n==="email"||l[n]!==null&&l[n]!==void 0&&String(l[n]).trim()!==""&&(s[n]=l[n])}),s})}catch(i){console.error("Load profile error:",i)}finally{A(!1)}},t=i=>{const{name:r,value:l}=i.target;b(p=>{const s={...p,[r]:l};return w(s),s})},I=i=>{const{name:r,files:l}=i.target;if(l&&l[0]){if(r==="ci_photo"){const p=new FileReader;p.onloadend=()=>z(p.result),p.readAsDataURL(l[0])}b(p=>{const s={...p,[r]:l[0]};return w(s),s})}},q=i=>{if(i.preventDefault(),!a.prenume||!a.nume||!a.telefon){u.error("Te rog completeazÄ toate câmpurile obligatorii");return}if(!a.birth_day||!a.birth_month||!a.birth_year){u.error("Te rog selecteazÄ data naÈterii");return}h(2)},L=i=>{if(i.preventDefault(),!a.strada||!a.localitate||!a.judet){u.error("Te rog completeazÄ adresa completÄ");return}h(3)},T=i=>{if(i.preventDefault(),!a.cnp){u.error("Te rog completeazÄ CNP-ul");return}h(4)},M=async i=>{i.preventDefault(),C(!0);try{const r=JSON.parse(localStorage.getItem("user")||"{}"),l=new FormData;l.append("mode","voluntar"),l.append("action","update_profile"),l.append("user_id",r.user_id);const p=a.birth_year&&a.birth_month&&a.birth_day?`${a.birth_year}-${String(a.birth_month).padStart(2,"0")}-${String(a.birth_day).padStart(2,"0")}`:a.data_nasterii,s=a.ci_valabil_an&&a.ci_valabil_luna&&a.ci_valabil_zi?`${a.ci_valabil_an}-${String(a.ci_valabil_luna).padStart(2,"0")}-${String(a.ci_valabil_zi).padStart(2,"0")}`:a.ci_valabil_pana,c=new Set(["ci_photo","birth_day","birth_month","birth_year","data_nasterii","ci_valabil_zi","ci_valabil_luna","ci_valabil_an","ci_valabil_pana"]);Object.keys(a).forEach(n=>{!c.has(n)&&a[n]!==null&&a[n]!==void 0&&a[n]!==""&&l.append(n,a[n])}),p&&l.append("data_nasterii",p),s&&l.append("ci_valabil_pana",s),a.ci_photo instanceof File&&l.append("ci_photo",a.ci_photo);const m=await X.postFormData(l);m.success?(E(),u.success("Profil actualizat cu succes!"),setTimeout(()=>y("/contul-meu"),1e3)):u.error(m.message||"Eroare la actualizare profil")}catch(r){console.error("Update profile error:",r),u.error("Eroare la actualizare profil.")}finally{C(!1)}};return $?e.jsx("div",{className:"media-page",children:e.jsx("div",{className:"loading",children:"Se încarcÄ..."})}):e.jsxs("div",{className:"media-page",children:[e.jsx(J,{position:"top-center"}),e.jsxs("div",{className:"accreditation-wizard",children:[e.jsxs("div",{className:"wizard-progress",children:[e.jsxs("div",{className:`progress-step ${o>=1?"active":""} ${o>1?"completed":""}`,children:[e.jsx("div",{className:"step-circle",children:o>1?e.jsx(f,{size:20}):"1"}),e.jsx("span",{className:"step-label",children:"Date Personale"})]}),e.jsxs("div",{className:`progress-step ${o>=2?"active":""} ${o>2?"completed":""}`,children:[e.jsx("div",{className:"step-circle",children:o>2?e.jsx(f,{size:20}):"2"}),e.jsx("span",{className:"step-label",children:"AdresÄ"})]}),e.jsxs("div",{className:`progress-step ${o>=3?"active":""} ${o>3?"completed":""}`,children:[e.jsx("div",{className:"step-circle",children:o>3?e.jsx(f,{size:20}):"3"}),e.jsx("span",{className:"step-label",children:"Identitate"})]}),e.jsxs("div",{className:`progress-step ${o>=4?"active":""}`,children:[e.jsx("div",{className:"step-circle",children:"4"}),e.jsx("span",{className:"step-label",children:"Confirmare"})]})]}),e.jsxs("div",{className:"wizard-body",children:[o===1&&e.jsxs("form",{className:"wizard-step",onSubmit:q,children:[e.jsxs("h2",{children:[e.jsx(D,{size:28})," Date Personale"]}),e.jsx("p",{className:"subtitle",children:"CompleteazÄ datele tale personale pentru a deveni voluntar"}),e.jsxs("div",{className:"form-section",children:[e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Prenume *"}),e.jsx("input",{type:"text",name:"prenume",value:a.prenume,onChange:t,required:!0})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Nume *"}),e.jsx("input",{type:"text",name:"nume",value:a.nume,onChange:t,required:!0})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Telefon *"}),e.jsx("input",{type:"tel",name:"telefon",value:a.telefon,onChange:t,placeholder:"+40 XXX XXX XXX",required:!0})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Data naÈterii *"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsxs("select",{name:"birth_day",value:a.birth_day,onChange:t,style:{flex:1},required:!0,children:[e.jsx("option",{value:"",children:"Zi"}),Array.from({length:31},(i,r)=>r+1).map(i=>e.jsx("option",{value:i,children:i},i))]}),e.jsxs("select",{name:"birth_month",value:a.birth_month,onChange:t,style:{flex:2},required:!0,children:[e.jsx("option",{value:"",children:"LunÄ"}),["Ianuarie","Februarie","Martie","Aprilie","Mai","Iunie","Iulie","August","Septembrie","Octombrie","Noiembrie","Decembrie"].map((i,r)=>e.jsx("option",{value:r+1,children:i},r+1))]}),e.jsxs("select",{name:"birth_year",value:a.birth_year,onChange:t,style:{flex:2},required:!0,children:[e.jsx("option",{value:"",children:"An"}),Array.from({length:80},(i,r)=>new Date().getFullYear()-10-r).map(i=>e.jsx("option",{value:i,children:i},i))]})]})]})]}),e.jsx("div",{className:"form-row",children:e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Sex *"}),e.jsxs("select",{name:"sex",value:a.sex,onChange:t,required:!0,children:[e.jsx("option",{value:"",children:"SelecteazÄ"}),e.jsx("option",{value:"M",children:"Masculin"}),e.jsx("option",{value:"F",children:"Feminin"})]})]})}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Email"}),e.jsx("input",{type:"email",name:"email",value:a.email,readOnly:!0,style:{background:"#f4f4f4",cursor:"not-allowed",opacity:.8}})]})]}),e.jsx("div",{className:"wizard-actions",children:e.jsx("button",{type:"submit",className:"btn btn-primary",children:"ContinuÄ"})})]}),o===2&&e.jsxs("form",{className:"wizard-step",onSubmit:L,children:[e.jsxs("h2",{children:[e.jsx(F,{size:28})," AdresÄ de domiciliu"]}),e.jsx("p",{className:"subtitle",children:"Adresa ta completÄ pentru documentele oficiale"}),e.jsxs("div",{className:"form-section",children:[e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Strada *"}),e.jsx("input",{type:"text",name:"strada",value:a.strada,onChange:t,required:!0})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"NumÄr *"}),e.jsx("input",{type:"text",name:"numar",value:a.numar,onChange:t,required:!0})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Bloc"}),e.jsx("input",{type:"text",name:"bloc",value:a.bloc,onChange:t})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"ScarÄ"}),e.jsx("input",{type:"text",name:"scara",value:a.scara,onChange:t})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Etaj"}),e.jsx("input",{type:"text",name:"etaj",value:a.etaj,onChange:t})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Apartament"}),e.jsx("input",{type:"text",name:"apartament",value:a.apartament,onChange:t})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Localitate *"}),e.jsx("input",{type:"text",name:"localitate",value:a.localitate,onChange:t,required:!0})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"JudeÈ *"}),e.jsx("input",{type:"text",name:"judet",value:a.judet,onChange:t,required:!0})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Cod poÈtal"}),e.jsx("input",{type:"text",name:"cod_postal",value:a.cod_postal,onChange:t,placeholder:"XXXXXX"})]})]}),e.jsxs("div",{className:"wizard-actions",children:[e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>h(1),children:"Ãnapoi"}),e.jsx("button",{type:"submit",className:"btn btn-primary",children:"ContinuÄ"})]})]}),o===3&&e.jsxs("form",{className:"wizard-step",onSubmit:T,children:[e.jsxs("h2",{children:[e.jsx(P,{size:28})," Date de identitate"]}),e.jsx("p",{className:"subtitle",children:"InformaÈii din cartea de identitate"}),e.jsxs("div",{className:"form-section",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"CNP *"}),e.jsx("input",{type:"text",name:"cnp",value:a.cnp,onChange:t,placeholder:"13 cifre",maxLength:"13",required:!0})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Serie CI"}),e.jsx("input",{type:"text",name:"ci_serie",value:a.ci_serie,onChange:t,placeholder:"XX"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"NumÄr CI"}),e.jsx("input",{type:"text",name:"ci_numar",value:a.ci_numar,onChange:t,placeholder:"XXXXXX"})]})]}),e.jsxs("div",{className:"form-row",children:[e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Eliberat de"}),e.jsx("input",{type:"text",name:"ci_eliberat_de",value:a.ci_eliberat_de,onChange:t,placeholder:"ex: SPCLEP BucureÈti"})]}),e.jsxs("div",{className:"form-group",children:[e.jsx("label",{children:"Valabil pânÄ la"}),e.jsxs("div",{style:{display:"flex",gap:"0.5rem"},children:[e.jsxs("select",{name:"ci_valabil_zi",value:a.ci_valabil_zi,onChange:t,style:{flex:1},children:[e.jsx("option",{value:"",children:"Zi"}),Array.from({length:31},(i,r)=>r+1).map(i=>e.jsx("option",{value:i,children:i},i))]}),e.jsxs("select",{name:"ci_valabil_luna",value:a.ci_valabil_luna,onChange:t,style:{flex:2},children:[e.jsx("option",{value:"",children:"LunÄ"}),["Ianuarie","Februarie","Martie","Aprilie","Mai","Iunie","Iulie","August","Septembrie","Octombrie","Noiembrie","Decembrie"].map((i,r)=>e.jsx("option",{value:r+1,children:i},r+1))]}),e.jsxs("select",{name:"ci_valabil_an",value:a.ci_valabil_an,onChange:t,style:{flex:2},children:[e.jsx("option",{value:"",children:"An"}),Array.from({length:20},(i,r)=>new Date().getFullYear()+r).map(i=>e.jsx("option",{value:i,children:i},i))]})]})]})]}),e.jsxs("div",{className:"form-group",children:[e.jsxs("p",{style:{fontWeight:600,marginBottom:"0.5rem",display:"flex",alignItems:"center",gap:"0.4rem"},children:[e.jsx(g,{size:18}),"Fotografie / Copie CI (faÈÄ + spate)"]}),j?e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[j.startsWith("data:image")||j.startsWith("http")&&!j.toLowerCase().endsWith(".pdf")?e.jsx("img",{src:j,alt:"CI",style:{width:120,height:80,objectFit:"cover",borderRadius:6,border:"1px solid #334155"}}):e.jsx("span",{style:{color:"#22c55e",fontWeight:600},children:"ð PDF încÄrcat"}),e.jsxs("label",{style:{cursor:"pointer",color:"#e5252b",fontWeight:600},children:[e.jsx(g,{size:16,style:{marginRight:4}}),"SchimbÄ",e.jsx("input",{type:"file",name:"ci_photo",accept:"image/*,application/pdf",onChange:I,style:{display:"none"}})]})]}):e.jsxs("label",{className:"ci-upload-dropzone",style:{cursor:"pointer"},children:[e.jsx(g,{size:28}),e.jsx("p",{className:"ci-upload-title",children:"Click pentru a selecta fiÈierul"}),e.jsx("p",{className:"ci-upload-subtitle",children:"JPG, PNG sau PDF (max 5MB)"}),e.jsx("input",{type:"file",name:"ci_photo",onChange:I,accept:"image/*,application/pdf",style:{display:"none"}})]})]})]}),e.jsxs("div",{className:"wizard-actions",children:[e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>h(2),children:"Ãnapoi"}),e.jsx("button",{type:"submit",className:"btn btn-primary",children:"ContinuÄ"})]})]}),o===4&&e.jsxs("form",{className:"wizard-step",onSubmit:M,children:[e.jsxs("h2",{children:[e.jsx(f,{size:28})," ConfirmÄ datele"]}),e.jsx("p",{className:"subtitle",children:"VerificÄ cÄ toate informaÈiile sunt corecte"}),e.jsxs("div",{className:"summary-section",children:[e.jsxs("h3",{children:[e.jsx(D,{size:20})," Date Personale"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Nume:"})," ",a.prenume," ",a.nume]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Telefon:"})," ",a.telefon]}),e.jsxs("p",{children:[e.jsx("strong",{children:"Data naÈterii:"})," ",a.birth_year&&a.birth_month&&a.birth_day?`${String(a.birth_day).padStart(2,"0")}.${String(a.birth_month).padStart(2,"0")}.${a.birth_year}`:a.data_nasterii||"-"]}
1),a.sex&&e.jsxs("p",{children:[e.jsx("strong",{children:"Sex:"})," ",a.sex==="M"?"Masculin":a.sex==="F"?"Feminin":a.sex]}),a.email&&e.jsxs("p",{children:[e.jsx("strong",{children:"Email:"})," ",a.email]})]}),e.jsxs("div",{className:"summary-section",children:[e.jsxs("h3",{children:[e.jsx(F,{size:20})," AdresÄ"]}),e.jsxs("p",{children:[a.strada," ",a.numar,a.bloc&&`, Bl. ${a.bloc}`,a.scara&&`, Sc. ${a.scara}`,a.etaj&&`, Et. ${a.etaj}`,a.apartament&&`, Ap. ${a.apartament}`]}),e.jsxs("p",{children:[a.localitate,", ",a.judet]}),a.cod_postal&&e.jsxs("p",{children:["Cod poÈtal: ",a.cod_postal]})]}),e.jsxs("div",{className:"summary-section",children:[e.jsxs("h3",{children:[e.jsx(P,{size:20})," Identitate"]}),e.jsxs("p",{children:[e.jsx("strong",{children:"CNP:"})," ",a.cnp]}),(a.ci_serie||a.ci_numar)&&e.jsxs("p",{children:[e.jsx("strong",{children:"CI:"})," ",a.ci_serie," ",a.ci_numar]}),a.ci_eliberat_de&&e.jsxs("p",{children:[e.jsx("strong",{children:"Eliberat de:"})," ",a.ci_eliberat_de]}),a.ci_valabil_pana&&e.jsxs("p",{children:[e.jsx("strong",{children:"Valabil pânÄ:"})," ",a.ci_valabil_pana]}),a.ci_photo&&e.jsxs("p",{children:[e.jsx("strong",{children:"Fotografie CI:"})," ",a.ci_photo instanceof File?a.ci_photo.name:"ÃncÄrcat"]})]}),e.jsxs("div",{className:"wizard-actions",children:[e.jsx("button",{type:"button",className:"btn btn-secondary",onClick:()=>h(3),children:"Ãnapoi"}),e.jsx("button",{type:"submit",className:"btn btn-primary",disabled:S,children:S?"Se salveazÄ...":"SalveazÄ profil"})]})]})]})]})]})}export{Y 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.