1import{_ as q}from"./BSS67al9.js";import{a6 as H,ar as G,i as J,o as K,ae as U,e as Q,f as I,g as W,k as s,w as t,l as g,V as c,B as x,q as r,af as N,h as a,an as X,j as _,s as S,n as z,r as F,y as Y,z as Z,x as ee,L as d,M as T,b as ae,aD as se}from"./DkI6cOfr.js";import{u as le}from"./QSYtxhKH.js";import{u as te}from"./Cz0lD1ws.js";(function(){try{var u=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new u.Error().stack;n&&(u._sentryDebugIds=u._sentryDebugIds||{},u._sentryDebugIds[n]="73b01f6e-e9ec-4e0d-ad9e-118654cb7bde",u._sentryDebugIdIdentifier="sentry-dbid-73b01f6e-e9ec-4e0d-ad9e-118654cb7bde")}catch{}})();const oe={class:"text-caption font-weight-medium text-medium-emphasis"},ne={class:"d-flex ga-2"},me={__name:"profile",setup(u){const n=H(),C=G(),m=le(),D=J("showSnackbar"),{scrollFirstErrorIntoView:A,scrollTargetIntoView:L}=te(),v=d(null),y=d(!0),h=d(null),V=d(!1),P=d(!1),f=d(""),l=d({firstName:"",lastName:"",email:"",password:""}),w=d(""),b=T(()=>C.clientFormSettings?.uneditable_fields||[]),B=T(()=>{const p=b.value;return p.includes("firstname")&&p.includes("lastname")&&p.includes("email")}),k=T(()=>l.value.email!==w.value&&w.value!==""),M=()=>{n.user&&(l.value.firstName=n.user.firstname||"",l.value.lastName=n.user.lastname||"",l.value.email=n.user.email||"",l.value.password="",w.value=n.user.email||"")},O=()=>{l.value.email===w.value&&(l.value.password="",f.value="")}
1,$=async()=>{const{valid:p}=await v.value.validate();if(!p){await A(v);return}f.value="",P.value=!0;try{const{$apiFetch:e}=ae(),i={firstname:m.normalizePersonName(l.value.firstName),lastname:m.normalizePersonName(l.value.lastName),email:String(l.value.email||"").trim()};k.value&&(i.password=l.value.password);const o=await e("/api/user/update-user",{method:"POST",body:i});if(o.result==="success"){D?.(o.message||"Personal information updated successfully","success");try{const{trackEvent:E,EVENTS:j}=se();E(j.SETTINGS_UPDATE_COMPLETED,{client_id:clientStore.clientData?.id,category:"profile"})}catch{}l.value.password="",k.value&&(w.value=l.value.email);try{await n.initializeClientDetails()}catch(E){console.error("Failed to refresh user data:",E)}}}catch(e){console.error("Error saving personal info:",e);const i=e?.data?.statusMessage||e?.statusMessage||"Failed to update personal information";(e?.data?.data||e?.data||{}).field==="password"||i.toLowerCase().includes("password")?(f.value=i,await L(h)):D?.(i,"error")}finally{P.value=!1}},R=()=>{M(),f.value="",U(()=>v.value?.validate())};return K(async()=>{M(),await U(),await v.value?.validate()}),Q({title:"Profile - Personal Information"}),(p,e)=>{const i=q;return I(),W("div",null,[s(ee,{ref_key:"personalInfoForm",ref:v,modelValue:a(y),"onUpdate:modelValue":e[6]||(e[6]=o=>Z(y)?y.value=o:null),onSubmit:Y($,["prevent"])},{default:t(()=>[s(i,{title:"Personal Information",subtitle:"Manage your authentication user details","show-divider":!1}),s(g,null,{default:t(()=>[s(c,{cols:"12",md:"6"},{default:t(()=>[s(x,null,{default:t(()=>[...e[7]||(e[7]=[r("First Name",-1)])]),_:1}),s(N,{modelValue:a(l).firstName,"onUpdate:modelValue":e[0]||(e[0]=o=>a(l).firstName=o),placeholder:"Enter first name",rules:[a(m).nameValid],disabled:a(b).includes("firstname")},null,8,["modelValue","rules","disabled"])]),_:1}),s(c,{cols:"12",md:"6"},{default:t(()=>[s(x,null,{default:t(()=>[...e[8]||(e[8]=[r("Last Name",-1)])]),_:1}),s(N,{modelValue:a(l).lastName,"onUpdate:modelValue":e[1]||(e[1]=o=>a(l).lastName=o),placeholder:"Enter last name",rules:[a(m).nameValid],disabled:a(b).includes("lastname")},null,8,["modelValue","rules","disabled"])]),_:1})]),_:1}),s(g,null,{default:t(()=>[s(c,{cols:"12",md:"6"},{default:t(()=>[s(x,null,{default:t(()=>[...e[9]||(e[9]=[r("Email Address",-1)])]),_:1}),s(N,{modelValue:a(l).email,"onUpdate:modelValue":e[2]||(e[2]=o=>a(l).email=o),placeholder:"Enter email address",type:"email",rules:[a(m).emailValid],disabled:a(b).includes("email"),onInput:O},null,8,["modelValue","rules","disabled"])]),_:1})]),_:1}),s(X,null,{default:t(()=>[a(k)?(I(),_(g,{key:0},{default:t(()=>[s(c,{cols:"12",md:"6"},{default:t(()=>[s(x,null,{default:t(()=>[...e[10]||(e[10]=[r("Current Password",-1)])]),_:1}),s(N,{ref_key:"passwordField",ref:h,modelValue:a(l).password,"onUpdate:modelValue":e[3]||(e[3]=o=>a(l).password=o),placeholder:"Enter your password to confirm",type:a(V)?"text":"password","append-inner-icon":a(V)?"$eyeIcon":"$eyeOffOutlineIcon","onClick:appendInner":e[4]||(e[4]=o=>V.value=!a(V)),rules:a(k)?[a(m).passwordValid]:[],"error-messages":a(f),"persistent-hint":"",hint:"Email change requires password confirmation",onInput:e[5]||(e[5]=o=>f.value="")},null,8,["modelValue","type","append-inner-icon","rules","error-messages"])]),_:1})]),_:1})):S("",!0)]),_:1}),a(B)?(I(),_(g,{key:0},{default:t(()=>[s(c,{cols:"12",class:"d-flex flex-row"},{default:t(()=>[z("span",oe,[e[12]||(e[12]=r(" Profile Information changes are not allowed. Please contact support if you need to make changes ",-1)),s(F,{style:{"margin-top":"-2px !important"},variant:"plain",color:"blackAccent",class:"text-decoration-underline pa-0 text-caption",href:"/support/open-ticket"},{default:t(()=>[...e[11]||(e[11]=[r(" contact support ",-1)])]),_:1}),e[13]||(e[13]=r(" . ",-1))])]),_:1})]),_:1})):S("",!0),a(B)?S("",!0):(I(),_(g,{key:1},{default:t(()=>[s(c,{cols:"12"},{default:t(()=>[z("div",ne,[s(F,{color:"primaryButtons",height:"40",loading:a(P),disabled:!a(y),type:"submit",class:"px-4"},{default:t(()=>[...e[14]||(e[14]=[r(" Save Changes ",-1)])]),_:1},8,["loading","disabled"]),s(F,{color:"secondaryButtons",height:"40",variant:"outlined",class:"px-4",onClick:R},{default:t(()=>[...e[15]||(e[15]=[r(" Reset ",-1)])]),_:1})])]),_:1})]),_:1}))]),_:1},8,["modelValue"])])}}};export{me 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.