1import{f as R,bs as $,u as T,r as l,s as h,j as e,h as C,i as P,k as S,l as _,m as O,B as n,H as G,t as H,I as W,L as Y,A as V,g as c}from"./index-DLd_kDlx.js";import{L as x}from"./label-D4-ENrYn.js";import{S as q,a as z,b as J,c as M,d as K}from"./select-RSrodAEw.js";import{C as Q}from"./calendar-CX7fcgXP.js";import{P as X,a as Z,b as ee}from"./popover-BMD5FOmU.js";import{a as B,e as k,c as se}from"./AssessmentUI-DW2eB-aa.js";import{c as re}from"./countries-D6ab3bU5.js";import{C as L}from"./camera-CjU4dBqw.js";import{U as ae}from"./upload-CCEcMTV9.js";import{A as te}from"./arrow-left-BXtn7MCa.js";import{S as oe}from"./save-DnzFMk1L.js";import{f as ie}from"./format-BTXglRCX.js";import"./index-BdQq_4o_.js";import"./index-Deh-4PO1.js";import"./chevron-down-DpJJsCer.js";import"./chevron-up-M4SAwIjf.js";import"./endOfWeek-6cC00CtY.js";import"./en-US-9SRVm7yB.js";import"./endOfMonth-CYn6pTOm.js";import"./differenceInCalendarMonths-BA0TPVs2.js";import"./subDays-B5afKHU7.js";import"./isAfter-DDRF2ylA.js";import"./chevron-right-CD1gvy-q.js";import"./chevron-left-Wewsh5d7.js";function Le(){const{user:f}=R(),{assessmentStatus:a,updateAssessmentStage:j}=$(),g=T(),[o,d]=l.useState({dateOfBirth:null,country:"",phoneNumber:""}),[m,U]=l.useState(null),[t,N]=l.useState(null),[v,u]=l.useState(!1),[y,b]=l.useState(!1);l.useEffect(()=>{D()},[a==null?void 0:a.id]),l.useEffect(()=>()=>{t&&t.startsWith("blob:")&&URL.revokeObjectURL(t)},[t]);const D=async()=>{if(a!=null&&a.id)try{const{data:s,error:r}=await h.from("xtern_assessment_biodata").select("*").eq("assessment_id",a.id).maybeSingle();if(r)throw r;s&&(d({dateOfBirth:s.date_of_birth?new Date(s.date_of_birth):null,country:s.country||"",phoneNumber:s.phone_number||""}),N(s.profile_picture_path||null))}catch(s){console.error("Error loading existing data:",s)}},E=s=>{var i;const r=(i=s.target.files)==null?void 0:i[0];if(r)if(r.type.startsWith("image/")){t&&t.startsWith("blob:")&&URL.revokeObjectURL(t),U(r);const p=URL.createObjectURL(r);N(p)}else c.error("Please upload an image file")},F=async()=>{if(!m||!f)return null;try{const s=`${f.id}_${Date.now()}_${m.name}`,r=`${f.id}/${s}`,{error:i}=await h.storage.from("profile-pictures").upload(r,m);if(i)throw i;return r}catch(s){return console.error("Error uploading profile picture:",s),c.error("Failed to upload profile picture"),null}},w=async()=>{var s;if(a!=null&&a.id){b(!0);try{let r=t;if(m){const p=await F();p&&(r=p)}const{error:i}=await h.from("xtern_assessment_biodata").upsert({assessment_id:a.id,profile_picture_path:r,date_of_birth:((s=o.dateOfBirth)==null?void 0:s.toISOString().split("T")[0])||null,country:o.country||null,phone_number:o.phoneNumber||null},{onConflict:"assessment_id"});if(i)throw i;c.success("Progress saved successfully")}catch(r){console.error("Error saving data:",r),c.error("Failed to save progress")}finally{b(!1)}}},A=async()=>{u(!0);try{await j(2,!0),g("/assessment/stage-3")}catch(s){console.error("Error skipping stage:",s),c.error("Failed to skip stage")}finally{u(!1)}},I=async()=>{u(!0);try{await w(),await j(2,!0),g("/assessment/stage-3")}catch(s){console.error("Error continuing:",s),c.error("Failed to continue")}finally{u(!1)}};return e.jsx("div",{className:"min-h-screen bg-gray-50 px-4 py-8 font-sans text-gray-950 sm:px-6 sm:py-12",children:e.jsxs("div",{className:"mx-auto max-w-3xl",children:[e.jsxs("div",{className:"text-center mb-8",children:[e.jsx("h1",{className:"mb-2 font-display text-3xl font-normal tracking-tight text-xterns-navy sm:text-4xl",children:"Stage 2: Bio Data"}),e.jsx("p",{className:"text-base text-gray-500",children:"Add your personal information and profile picture"})]}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("div",{className:"flex justify-between items-center mb-2",children:[e.jsx("span",{className:"text-sm text-muted-foreground",children:"Stage 2 of 3"}),e.jsx("span",{className:"text-sm text-muted-foreground",children:"67% Complete"})]}),e.jsx("div",{className:"h-2 w-full overflow-hidden rounded-full bg-gray-200/70",children:e.jsx("div",{className:"h-2 w-2/3 rounded-full bg-gradient-to-r from-xterns-blue to-xterns-teal transition-all duration-300"})})]}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs(C,{className:B,children:[e.jsxs(P,{children:[e.jsxs(S,{className:"flex items-center gap-2",children:[e.jsx(L,{className:"w-5 h-5"}),"Profile Picture (Optional)"]}),e.jsx(_,{children:"Upload a professional photo to personalize your profile"})]}),e.jsx(O,{children:e.jsxs("div",{className:"flex items-center space-x-6",children:[e.jsx("div",{className:"relative",children:e.jsx("div",{className:"w-24 h-24 rounded-full bg-secondary flex items-center justify-center overflow-hidden",children:t?e.jsx("img",{src:t,alt:"Profile",className:"w-full h-full object-cover"}):e.jsx(L,{className:"w-8 h-8 text-muted-foreground"})})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("input",{type:"file",accept:"image/*",onChange:E,className:"hidden",id:"profile-picture-upload"}),e.jsx("label",{htmlFor:"profile-picture-upload",children:e.jsx(n,{variant:"outline",className:"cursor-pointer",asChild:!0,children:e.jsxs("span",{children:[e.jsx(ae,{className:"w-4 h-4 mr-2"}),"Choose Photo"]})})}),e.jsx("p",{className:"text-sm text-muted-foreground mt-2",children:"PNG, JPG, GIF up to 10MB"})]})]})})]}),e.jsxs(C,{className:B,children:[e.jsxs(P,{children:[e.jsx(S,{children:"Personal Information"}),e.jsx(_,{children:"Help us understand your background better"})]}),e.jsxs(O,{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:"Date of Birth (Optional)"}),e.jsxs(X,{children:[e.jsx(Z,{asChild:!0,children:e.jsxs(n,{variant:"outline",className:H("w-full justify-start text-left font-normal",!o.dateOfBirth&&"text-muted-foreground"),children:[e.jsx(G,{className:"mr-2 h-4 w-4"}),o.dateOfBirth?ie(o.dateOfBirth,"PPP"):e.jsx("span",{children:"Pick a date"})]})}),e.jsx(ee,{className:"w-auto p-0",children:e.jsx(Q,{mode:"single",selected:o.dateOfBirth,onSelect:s=>d(r=>({...r,dateOfBirth:s})),disabled:s=>s>new Date||s<new Date("1900-01-01"),initialFocus:!0,captionLayout:"dropdown",fromYear:1900,toYear:new Date().getFullYear(),className:"p-3 pointer-events-auto"})})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{children:"Country (Optional)"}),e.jsxs(q,{value:o.country,onValueChange:s=>d(r=>({...r,country:s})),children:[e.jsx(z,{children:e.jsx(J,{placeholder:"Select your country"})}),e.jsx(M,{children:re.map(s=>e.jsx(K,{value:s.code,children:s.name},s.code))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(x,{htmlFor:"phone",children:"Phone Number (Optional)"}),e.jsx(W,{id:"phone",type:"tel",value:o.phoneNumber,onChange:s=>d(r=>({...r,phoneNumber:s.target.value})),placeholder:"+1 (555) 123-4567"})]})]})]}),e.jsxs("div",{className:"flex flex-col-reverse gap-3 pt-2 sm:flex-row sm:items-center sm:justify-between",children:[e.jsx(n,{variant:"outline",className:k,asChild:!0,children:e.jsxs(Y,{to:"/assessment/stage-1",children:[e.jsx(te,{className:"w-4 h-4 mr-2"}),"Back"]})}),e.jsxs("div",{className:"flex flex-col gap-2 sm:flex-row",children:[e.jsxs(n,{variant:"outline",className:k,onClick:w,disabled:y,children:[e.jsx(oe,{className:"w-4 h-4 mr-2"}),y?"Saving...":"Save Progress"]}),e.jsx(n,{variant:"secondary",onClick:A,disabled:v,children:"Skip for now"}),e.jsxs(n,{className:se,onClick:I,disabled:v,children:["Continue",e.jsx(V,{className:"w-4 h-4 ml-2"})]})]})]})]})]})})}export{Le 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.