PageSourceSearch

https://alkhwarizmi.ai/assets/crm.profile-XNgD2RGk.js

js alkhwarizmi.ai collected 2026-10-05 11:48:55 UTC 5,627 bytes, 1 lines download raw bytes

1import{u as y,b as F,ag as v,ah as w,r as E,ac as N,a3 as d,j as s,aR as k,a2 as c,I as b,t as S,d as C,ap as A,ar as P}from"./index-DBfAN6NX.js";import{q as T,t as I,v as U,A as L,f as V,g as D}from"./userSchemas-C5LD1PTY.js";import{C as p,a as x,b as f,c as h,d as j}from"./card-B9Y7moEg.js";import{P as g}from"./password-input-Do-cGgBV.js";import{S as H}from"./separator-Clb1HcdH.js";import{C as R}from"./CrmListShell-CV-ZCp3q.js";import{u as q}from"./useAuth-CEWv8zEb.js";import"./eye-DP7DafJB.js";const B=A({full_name:P().trim().max(120),avatar_url:P().trim().max(500)});function M(e,r){return(e?.trim()||r||"?").split(/[\s@]+/).slice(0,2).map(t=>t.charAt(0).toUpperCase()).join("")}function $(){const{t:e}=y(),{user:r}=q(),n=F(a=>a.refreshUser),t=v({resolver:w(B),defaultValues:{full_name:"",avatar_url:""}}),l=v({resolver:w(T),defaultValues:{current_password:"",password:"",confirm_password:""}});E.useEffect(()=>{r&&t.reset({full_name:r.full_name??"",avatar_url:r.avatar_url??""})},[r,t]);const m=N({mutationFn:async a=>I({full_name:a.full_name.trim()||null,avatar_url:a.avatar_url.trim()||null}),onSuccess:async()=>{await n(),d.success(e("crm.profile.saved"))},onError:a=>d.error(a instanceof Error?a.message:e("crm.profile.saveFailed"))}),u=N({mutationFn:async a=>{const _=await U(a.current_password,a.password);localStorage.setItem("access_token",_.access_token),localStorage.setItem("refresh_token",_.refresh_token),await n()},onSuccess:()=>{l.reset(),d.success(e("crm.profile.passwordChanged"))},onError:a=>d.error(a instanceof Error?a.message:e("crm.profile.passwordChangeFailed"))});if(!r)return null;const o=t.formState.errors,i=l.formState.errors;return s.jsxs(R,{children:[s.jsx(k,{className:"mb-0 shrink-0",title:e("crm.profile.title"),description:e("crm.profile.subtitle")}),s.jsxs("div",{className:"mt-6 grid gap-6 lg:grid-cols-2",children:[s.jsxs(p,{children:[s.jsxs(x,{children:[s.jsx(f,{children:e("crm.profile.accountTitle")}),s.jsx(h,{children:e("crm.profile.accountSubtitle")})]}),s.jsxs(j,{className:"space-y-6",children:[s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsxs(L,{className:"h-16 w-16",children:[s.jsx(V,{src:r.avatar_url??void 0,alt:""}),s.jsx(D,{className:"text-lg",children:M(r.full_name,r.email)})]}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"font-medium truncate",children:r.full_name||r.email}),s.jsx("p",{className:"text-sm text-muted-foreground truncate",children:r.email})]})]}),s.jsx(H,{}),s.jsxs("dl",{className:"grid gap-3 text-sm",children:[s.jsxs("div",{className:"grid grid-cols-[8rem_1fr] gap-2",children:[s.jsx("dt",{className:"text-muted-foreground",children:e("crm.profile.fields.role")}),s.jsx("dd",{children:r.role??"—"})]}),s.jsxs("div",{className:"grid grid-cols-[8rem_1fr] gap-2",children:[s.jsx("dt",{className:"text-muted-foreground",children:e("crm.profile.fields.category")}),s.jsx("dd",{children:r.category?e(`crm.users.categories.${r.category}`,{defaultValue:r.category}):"—"})]}),s.jsxs("div",{className:"grid grid-cols-[8rem_1fr] gap-2",children:[s.jsx("dt",{className:"text-muted-foreground",children:e("crm.profile.fields.tenant")}),s.jsx("dd",{children:r.tenant?.name??"—"})]}),s.jsxs("div",{className:"grid grid-cols-[8rem_1fr] gap-2",children:[s.jsx("dt",{className:"text-muted-foreground",children:e("crm.profile.fields.defaultDashboard")}),s.jsx("dd",{children:r.default_dashboard??"—"})]})]})]})]}),s.jsxs("div",{className:"space-y-6",children:[s.jsxs(p,{children:[s.jsxs(x,{children:[s.jsx(f,{children:e("crm.profile.editTitle")}),s.jsx(h,{children:e("crm.profile.editSubtitle")})]}),s.jsx(j,{children:s.jsxs("form",{onSubmit:t.handleSubmit(a=>m.mutate(a)),className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(c,{htmlFor:"full_name",children:e("crm.users.form.fullName")}),s.jsx(b,{id:"full_name",...t.register("full_name")}),o.full_name&&s.jsx("p",{className:"text-xs text-destructive mt-1",children:o.full_name.message})]}),s.jsxs("div",{children:[s.jsx(c,{htmlFor:"avatar_url",children:e("crm.profile.fields.avatarUrl")}),s.jsx(b,{id:"avatar_url",...t.register("avatar_url"),placeholder:"https://"}),o.avatar_url&&s.jsx("p",{className:"text-xs text-destructive mt-1",children:o.avatar_url.message})]}),s.jsxs(S,{type:"submit",disabled:m.isPending,children:[m.isPending&&s.jsx(C,{className:"h-4 w-4 me-2 animate-spin"}),e("crm.profile.save")]})]})})]}),s.jsxs(p,{children:[s.jsxs(x,{children:[s.jsx(f,{children:e("crm.profile.passwordTitle")}),s.jsx(h,{children:e("crm.profile.passwordSubtitle")})]}),s.jsx(j,{children:s.jsxs("form",{onSubmit:l.handleSubmit(a=>u.mutate(a)),className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx(c,{children:e("crm.profile.fields.currentPassword")}),s.jsx(g,{...l.register("current_password"),autoComplete:"current-password"}),i.current_password&&s.jsx("p",{className:"text-xs text-destructive mt-1",children:i.current_password.message})]}),s.jsxs("div",{children:[s.jsx(c,{children:e("crm.users.form.password")}),s.jsx(g,{...l.register("password"),autoComplete:"new-password"}),i.password&&s.jsx("p",{className:"text-xs text-destructive mt-1",children:i.password.message})]}),s.jsxs("div",{children:[s.jsx(c,{children:e("crm.users.form.confirmPassword")}),s.jsx(g,{...l.register("confirm_password"),autoComplete:"new-password"}),i.confirm_password&&s.jsx("p",{className:"text-xs text-destructive mt-1",children:i.confirm_password.message})]}),s.jsxs(S,{type:"submit",disabled:u.isPending,children:[u.isPending&&s.jsx(C,{className:"h-4 w-4 me-2 animate-spin"}),e("crm.profile.changePassword")]})]})})]})]})]})]})}const Y=$;export{Y as component};

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.