PageSourceSearch

https://smartwine.ai/assets/Profile-m-73YNXx.js

js smartwine.ai collected 2026-10-05 13:47:30 UTC 4,628 bytes, 1 lines download raw bytes

1import{a as E,r as o,j as e,I as i,M as U,B as C,q as S,b as q}from"./index-DuOtGTXu.js";import{u as A}from"./useQuery-eKKsLX5t.js";import{u as F}from"./useMutation-DXuvYIvw.js";import{A as L,S as M}from"./AdminLayout-ChCU7m7a.js";import{C as p,a as x,b as h,c as j,d as w}from"./card-vpNBcg3l.js";import{L as d}from"./label-Bz7aq9YN.js";import{U as k}from"./user-AQkYeqXg.js";import{L as R}from"./lock-B81FBZY0.js";import"./package-DKVJWOgz.js";import"./chart-column-CcQZ4VcV.js";import"./users-Bskp-b6J.js";import"./file-text-C0CCVb3k.js";import"./trending-up-B1Rj4oGM.js";import"./log-out-B9rTtgIw.js";function Z(){const{toast:t}=E(),[c,f]=o.useState(""),[m,g]=o.useState(""),[n,v]=o.useState(""),[u,P]=o.useState(""),{data:a,isLoading:y}=A({queryKey:["/api/admin/me"]});o.useEffect(()=>{a!=null&&a.user&&f(a.user.email||"")},[a]);const l=F({mutationFn:async s=>q("PATCH","/api/admin/me",s),onSuccess:()=>{S.invalidateQueries({queryKey:["/api/admin/me"]}),t({title:"Profile updated successfully"}),g(""),v(""),P("")},onError:s=>{t({title:"Error",description:s.message||"Failed to update profile",variant:"destructive"})}}),N=()=>{if(!c){t({title:"Error",description:"Please enter an email address",variant:"destructive"});return}l.mutate({email:c})},b=()=>{if(!m||!n||!u){t({title:"Error",description:"Please fill in all password fields",variant:"destructive"});return}if(n!==u){t({title:"Error",description:"New passwords do not match",variant:"destructive"});return}if(n.length<8){t({title:"Error",description:"Password must be at least 8 characters",variant:"destructive"});return}l.mutate({currentPassword:m,newPassword:n})},r=a==null?void 0:a.user;return e.jsx(L,{children:e.jsxs("div",{className:"p-4 sm:p-6 lg:p-8 space-y-4 sm:space-y-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl sm:text-3xl font-bold","data-testid":"text-page-title",children:"Profile Settings"}),e.jsx("p",{className:"text-sm sm:text-base text-muted-foreground",children:"Manage your account settings and preferences"})]}),e.jsxs("div",{className:"grid gap-4 sm:gap-6 max-w-2xl",children:[e.jsxs(p,{children:[e.jsxs(x,{children:[e.jsxs(h,{className:"flex items-center gap-2",children:[e.jsx(k,{className:"h-5 w-5"}),"Account Information"]}),e.jsx(j,{children:"View your account details"})]}),e.jsxs(w,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(d,{children:"Username"}),e.jsx(i,{value:(r==null?void 0:r.username)||"",disabled:!0,className:"bg-muted","data-testid":"input-username-display"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Username cannot be changed"})]}),e.jsxs("div",{children:[e.jsx(d,{children:"Role"}),e.jsx(i,{value:(r==null?void 0:r.role)||"",disabled:!0,className:"bg-muted","data-testid":"input-role-display"})]})]})]}),e.jsxs(p,{children:[e.jsxs(x,{children:[e.jsxs(h,{className:"flex items-center gap-2",children:[e.jsx(U,{className:"h-5 w-5"}),"Email Address"]}),e.jsx(j,{children:"Update your email address for notifications"})]}),e.jsxs(w,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(d,{htmlFor:"email",children:"Email"}),e.jsx(i,{id:"email",type:"email",value:c,onChange:s=>f(s.target.value),placeholder:"[email protected]","data-testid":"input-email"})]}),e.jsx(C,{onClick:N,disabled:l.isPending||y,"data-testid":"button-update-email",children:"Update Email"})]})]}),e.jsxs(p,{children:[e.jsxs(x,{children:[e.jsxs(h,{className:"flex items-center gap-2",children:[e.jsx(R,{className:"h-5 w-5"}),"Change Password"]}),e.jsx(j,{children:"Update your password to keep your account secure"})]}),e.jsxs(w,{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(d,{htmlFor:"currentPassword",children:"Current Password"}),e.jsx(i,{id:"currentPassword",type:"password",value:m,onChange:s=>g(s.target.value),placeholder:"Enter current password","data-testid":"input-current-password"})]}),e.jsx(M,{}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"newPassword",children:"New Password"}),e.jsx(i,{id:"newPassword",type:"password",value:n,onChange:s=>v(s.target.value),placeholder:"At least 8 characters","data-testid":"input-new-password"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Minimum 8 characters required"})]}),e.jsxs("div",{children:[e.jsx(d,{htmlFor:"confirmPassword",children:"Confirm New Password"}),e.jsx(i,{id:"confirmPassword",type:"password",value:u,onChange:s=>P(s.target.value),placeholder:"Re-enter new password","data-testid":"input-confirm-password"})]}),e.jsx(C,{onClick:b,disabled:l.isPending||y,"data-testid":"button-update-password",children:"Change Password"})]})]})]})]})})}export{Z 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.