PageSourceSearch

https://bluerevolution-cc.manus.space/assets/EditProfile-CoYS_qzc.js

js bluerevolution-cc.manus.space collected 2026-10-03 05:00:54 UTC 11,230 bytes, 1 lines download raw bytes

1import{j as e}from"./editor-BhGk7_S1.js";import{B as N}from"./button-CK76V7Lo.js";import{C as z,a as D,b as J,d as K}from"./card-CaSmhJ1l.js";import{I as p}from"./input-BtSXPsMX.js";import{T as oe}from"./textarea-C8AkMAaz.js";import{u as V,d as re,b as C,t as u}from"./index-BjIHAQhU.js";import{b as o}from"./leaflet-DcfcX7a_.js";import{W as le}from"./languages-CKIgFA9r.js";import{s as ie,g as L}from"./languageTranslations-BWtqfsq5.js";import{C as ce}from"./CityAutocomplete-t8y1NAcF.js";import{A as ne}from"./arrow-left-DCV3pRgt.js";import{U as de}from"./upload-B4mJ3u4C.js";import"./mapbox-BPFQ-Sfv.js";import"./dialog-DDbhAKMR.js";import"./index-CmmlU_cv.js";import"./x-rm1_-8OE.js";import"./trpc-DqtxhgQo.js";function ue(){const{t:s}=V(),[n,a]=o.useState(""),[d,x]=o.useState(""),[i,f]=o.useState(""),m=C.profile.changePassword.useMutation({onSuccess:()=>{u.success(s("profile.passwordChanged")),a(""),x(""),f("")},onError:l=>{u.error(l.message)}}),h=()=>{if(d!==i){u.error(s("profile.passwordMismatch"));return}if(d.length<8){u.error(s("profile.passwordTooShort"));return}m.mutate({currentPassword:n,newPassword:d})};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:48",children:[e.jsx("label",{"data-loc":"client/src/pages/EditProfile.tsx:49",htmlFor:"currentPassword",className:"block text-sm font-medium text-muted-foreground mb-1",children:s("profile.currentPassword")}),e.jsx(p,{"data-loc":"client/src/pages/EditProfile.tsx:52",id:"currentPassword",type:"password",value:n,onChange:l=>a(l.target.value),placeholder:"Enter current password"})]}),e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:60",children:[e.jsx("label",{"data-loc":"client/src/pages/EditProfile.tsx:61",htmlFor:"newPassword",className:"block text-sm font-medium text-muted-foreground mb-1",children:s("profile.newPassword")}),e.jsx(p,{"data-loc":"client/src/pages/EditProfile.tsx:64",id:"newPassword",type:"password",value:d,onChange:l=>x(l.target.value),placeholder:"Enter new password (min 8 characters)"})]}),e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:72",children:[e.jsx("label",{"data-loc":"client/src/pages/EditProfile.tsx:73",htmlFor:"confirmPassword",className:"block text-sm font-medium text-muted-foreground mb-1",children:s("profile.confirmPassword")}),e.jsx(p,{"data-loc":"client/src/pages/EditProfile.tsx:76",id:"confirmPassword",type:"password",value:i,onChange:l=>f(l.target.value),placeholder:"Confirm new password"})]}),e.jsx("div",{"data-loc":"client/src/pages/EditProfile.tsx:84",className:"flex justify-end",children:e.jsx(N,{"data-loc":"client/src/pages/EditProfile.tsx:85",onClick:h,disabled:m.isPending||!n||!d||!i,children:m.isPending?s("common.loading"):s("profile.changePassword")})})]})}function ke(){const{t:s}=V(),n=o.useMemo(()=>ie(le,s("_lang")),[s]);re();const{data:a,isLoading:d,refetch:x}=C.auth.me.useQuery(),{data:i}=C.countries.list.useQuery(),[f,m]=o.useState(""),[h,l]=o.useState(""),[k,F]=o.useState(void 0),[I,M]=o.use
1State(""),[T,U]=o.useState(""),[P,E]=o.useState(""),[y,j]=o.useState(""),[X,b]=o.useState(null),[Z,v]=o.useState(null),[ee,w]=o.useState(null),[A,R]=o.useState(""),[_,B]=o.useState(""),[G,O]=o.useState(""),[Y,Q]=o.useState(""),[W,$]=o.useState(!1),H=o.useRef(null);o.useEffect(()=>{if(a){m(a.firstName||""),l(a.lastName||""),F(a.profilePicture||void 0),M(a.country||"");const t=i?.find(r=>r.name===a.country);U(t?.iso2||""),E(a.city||""),j(a.region||""),b(a.latitude||null),v(a.longitude||null),w(a.geonameId||null),R(a.bio||""),B(a.language1||""),O(a.language2||""),Q(a.language3||"")}},[a,i]);const S=C.profile.updateProfile.useMutation({onSuccess:()=>{u.success(s("profile.profileUpdated")),x()},onError:t=>{u.error(t.message)}}),te=()=>{S.mutate({firstName:f,lastName:h,profilePicture:k,country:I,city:P,region:y,latitude:X||void 0,longitude:Z||void 0,geonameId:ee||void 0,bio:A,language1:_,language2:G,language3:Y})},se=async t=>{const r=t.target.files?.[0];if(!r)return;$(!0);const c=new FormData;c.append("profilePicture",r);try{const g=await fetch("/api/profile/upload-picture",{method:"POST",body:c});if(!g.ok)throw new Error("Failed to upload image");const ae=await g.json();F(ae.url)}catch(g){u.error(g.message)}finally{$(!1)}};if(d)return e.jsx("div",{"data-loc":"client/src/pages/EditProfile.tsx:202",className:"p-8",children:s("common.loading")});if(!a)return e.jsx("div",{"data-loc":"client/src/pages/EditProfile.tsx:206",className:"p-8",children:"Please log in to edit your profile."});const q=i?.reduce((t,r)=>(t[r.continent]||(t[r.continent]=[]),t[r.continent].push(r),t),{});return e.jsx("div",{"data-loc":"client/src/pages/EditProfile.tsx:218",className:"min-h-screen bg-background text-foreground p-4 sm:p-8",children:e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:219",className:"max-w-3xl mx-auto",children:[e.jsxs(N,{"data-loc":"client/src/pages/EditProfile.tsx:220",variant:"ghost",onClick:()=>window.history.go(-2),className:"mb-4",children:[e.jsx(ne,{"data-loc":"client/src/pages/EditProfile.tsx:221",className:"w-4 h-4 mr-2"}),s("common.back")]}),e.jsxs(z,{"data-loc":"client/src/pages/EditProfile.tsx:225",className:"bg-card border-border",children:[e.jsx(D,{"data-loc":"client/src/pages/EditProfile.tsx:226",children:e.jsx(J,{"data-loc":"client/src/pages/EditProfile.tsx:227",className:"text-2xl",children:s("profile.editProfile")})}),e.jsxs(K,{"data-loc":"client/src/pages/EditProfile.tsx:229",className:"space-y-6",children:[e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:231",children:[e.jsx("label",{"data-loc":"client/src/pages/EditProfile.tsx:232",htmlFor:"firstName",className:"block text-sm font-medium text-muted-foreground mb-1",children:s("profile.firstName")}),e.jsx(p,{"data-loc":"client/src/pages/EditProfile.tsx:233",id:"firstName",value:f,onChange:t=>m(t.target.value),placeholder:"Your first name"})]}),e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:242",children:[e.jsx("label",{"data-loc":"client/src/pages/EditProfile.tsx:243",htmlFor:"lastName",className:"block text-sm font-medium text-muted-foreground mb-1",children:s("profile.lastName")}),e.jsx(p,{"data-loc":"client/src/pages/EditProfile.tsx:244",id:"lastName",value:h,onChange:t=>l(t.target.value),placeholder:"Your last name"})]}),e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:253",className:"flex items-center gap-6",children:[e.jsx("img",{"data-loc":"client/src/pages/EditProfile.tsx:254",src:k||"/default-avatar.svg",alt:"Profile",className:"w-24 h-24 rounded-full object-cover"}),e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:259",children:[e.jsxs(N,{"data-loc":"client/src/pages/EditProfile.tsx:260",onClick:()=>H.current?.click(),disabled:W,children:[e.jsx(de,{"data-loc":"client/src/pages/EditProfile.tsx:261",className:"w-4 h-4 mr-2"}),s(W?"common.loading":"profile.uploadPhoto")]}),e.jsx("input",{"data-loc":"client/src/pages/EditProfile.tsx:264",type:"file",ref:H,onChange:se,className:"hidden",accept:"image/*"})]})]}),e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:275",children:[e.jsx("label",{"data-loc":"client/src/pages/EditProfile.tsx:276",htmlFor:"country",className:"block text-sm font-medium text-muted-foreground mb-1",children:s("profile.country")}),e.jsxs("select",{"data-loc":"client/src/pages/EditProfile.tsx:277",id:"country",value:I,onChange:t=>{const r=t.target.value;M(r);const c=i?.find(g=>g.name===r);U(c?.iso2||""),E(""),j(""),b(null),v(null),w(null)},className:"w-full bg-input border border-border rounded-md p-2 text-foreground",children:[e.jsx("option",{"data-loc":"client/src/pages/EditProfile.tsx:295",value:"",children:"Select a country"}),q&&Object.entries(q).map(([t,r])=>e.jsx("optgroup",{"data-loc":"client/src/pages/EditProfile.tsx:297",label:t,children:r.map(c=>e.jsx("option",{"data-loc":"client/src/pages/EditProfile.tsx:299",value:c.name,children:c.name},c.id))},t))]})]}),e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:307",children:[e.jsx("label",{"data-loc":"client/src/pages/EditProfile.tsx:308",htmlFor:"city",className:"block text-sm font-medium text-muted-foreground mb-1",children:s("profile.city")}),e.jsx(ce,{"data-loc":"client/src/pages/EditProfile.tsx:309",countryCode:T,value:P&&y?`${P}, ${y}`:P,onChange:t=>{t?(E(t.city),j(t.region),b(t.latitude),v(t.longitude),w(t.geonameId)):(E(""),j(""),b(null),v(null),w(null))},disabled:!T,placeholder:"Your city"})]}),e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:333",children:[e.jsx("label",{"data-loc":"client/src/pages/EditProfile.tsx:334",htmlFor:"bio",className:"block text-sm font-medium text-muted-foreground mb-1",children:s("profile.bio")}),e.jsx(oe,{"data-loc":"client/src/pages/EditProfile.tsx:335",id:"bio",value:A,onChange:t=>R(t.target.value),placeholder:"Tell us a bit about yourself...",rows:5})]}),e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:345",children:[e.jsx("label",{"data-loc":"client/src/pages/EditProfile.tsx:346",className:"block text-sm font-medium text-muted-foreground mb-2",children:s("profile.languages")}),e.jsxs("div",{"data-loc":"client/src/pages/EditProfile.tsx:347",className:"space-y-2",children:[e.jsxs("select",{"data-loc":"client/src/pages/EditProfile.tsx:348",value:_,onCh
1ange:t=>B(t.target.value),className:"w-full bg-input border border-border rounded-md p-2 text-foreground",children:[e.jsx("option",{"data-loc":"client/src/pages/EditProfile.tsx:353",value:"",children:s("welcome.selectLanguage1")}),n.map(t=>e.jsx("option",{"data-loc":"client/src/pages/EditProfile.tsx:355",value:t,children:L(t,s("_lang"))},t))]}),e.jsxs("select",{"data-loc":"client/src/pages/EditProfile.tsx:359",value:G,onChange:t=>O(t.target.value),className:"w-full bg-input border border-border rounded-md p-2 text-foreground",children:[e.jsx("option",{"data-loc":"client/src/pages/EditProfile.tsx:364",value:"",children:s("welcome.selectLanguage2")}),n.map(t=>e.jsx("option",{"data-loc":"client/src/pages/EditProfile.tsx:366",value:t,children:L(t,s("_lang"))},t))]}),e.jsxs("select",{"data-loc":"client/src/pages/EditProfile.tsx:370",value:Y,onChange:t=>Q(t.target.value),className:"w-full bg-input border border-border rounded-md p-2 text-foreground",children:[e.jsx("option",{"data-loc":"client/src/pages/EditProfile.tsx:375",value:"",children:s("welcome.selectLanguage3")}),n.map(t=>e.jsx("option",{"data-loc":"client/src/pages/EditProfile.tsx:377",value:t,children:L(t,s("_lang"))},t))]})]})]}),e.jsx("div",{"data-loc":"client/src/pages/EditProfile.tsx:384",className:"flex justify-end",children:e.jsx(N,{"data-loc":"client/src/pages/EditProfile.tsx:385",onClick:te,disabled:S.isPending,children:S.isPending?s("common.loading"):s("profile.saveChanges")})})]})]}),a.loginMethod==="local"&&e.jsxs(z,{"data-loc":"client/src/pages/EditProfile.tsx:394",className:"bg-card border-border mt-6",children:[e.jsx(D,{"data-loc":"client/src/pages/EditProfile.tsx:395",children:e.jsx(J,{"data-loc":"client/src/pages/EditProfile.tsx:396",className:"text-xl",children:s("profile.changePassword")})}),e.jsx(K,{"data-loc":"client/src/pages/EditProfile.tsx:398",className:"space-y-4",children:e.jsx(ue,{"data-loc":"client/src/pages/EditProfile.tsx:399"})})]})]})})}export{ke 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.