1import{o as K}from"./rolldown-runtime-ifEikEFx.js";import{at as de}from"./react-vendor-CM1iR3-9.js";import{$ as o,B as ce,Dt as E,Et as ue,It as F,Mt as Q,On as me,P as Y,Q as pe,R as Z,Tt as L,U as fe,Z as B,dt as w,it as y,lt as N,qt as I,st as d,tt as ge,z as T}from"./antd-vendor-D7gwNWgM.js";import{a as he,i as xe}from"./utils-vendor-D29tbpjP.js";import{m as ye}from"./query-vendor-Cvd8942y.js";import{a as ve,c as J,n as je,r as X,s as ke}from"./AuthContext-DfUhvON3.js";import{a as be,i as _,n as D}from"./useApiQuery-B7HY4T8t.js";import{n as Se}from"./usePermissions-CL4A21Xo.js";import{$n as U,En as Ee,Fn as we,Ft as Te,Wt as ze,it as Ae,lr as $,q as Ne}from"./icons-vendor-CSnqyHkR.js";import{t as p}from"./HIcon-hlKShEDM.js";import{t as z}from"./apiChannels-4YZw6XOH.js";import{Ft as Ie}from"./index-DOYYfOv6.js";import{a as _e}from"./userApi-BivjvyGV.js";import{r as Pe}from"./useUserProfile-CmTfNCl0.js";import{n as Re,r as q,t as Ce}from"./TenantInfo-DHqoiiqM.js";(function(){try{var i=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};i.SENTRY_RELEASE={id:"[email protected]+202610012304"};var a=new i.Error().stack;a&&(i._sentryDebugIds=i._sentryDebugIds||{},i._sentryDebugIds[a]="8cf05ea3-4b20-4ff8-9ca9-d5007369f346",i._sentryDebugIdIdentifier="sentry-dbid-8cf05ea3-4b20-4ff8-9ca9-d5007369f346")}catch{}})();var j=K(me(),1),Me=(i={})=>be({queryKey:["tenantUsers",i],channel:z.USER_MANAGEMENT.LIST,params:i,keepPreviousData:!0,staleTime:3e4}),Le=()=>_({channel:z.USER_MANAGEMENT.CREATE,onSuccess:()=>{D(["tenantUsers"])}}),Fe=()=>_({channel:z.USER_MANAGEMENT.RESEND_INVITE}),Ue=()=>_({channel:z.USER_MANAGEMENT.UPDATE,onSuccess:()=>{D(["tenantUsers"])}}),Ke=()=>_({channel:z.USER_MANAGEMENT.REMOVE,onSuccess:()=>{D(["tenantUsers"])}}),e=ye(),De=X.map(i=>({value:i,...ve[i]})),Ge=({open:i,onCancel:a,onSubmit:v,loading:f,editingUser:m})=>{const[n]=d.useForm(),r=!!m,k=d.useWatch("setupMode",n);(0,j.useEffect)(()=>{i&&(n.resetFields(),m?n.setFieldsValue({tenantRoles:m.tenantRoles,isActive:m.isActive}):n.setFieldsValue({tenantRoles:["tenant-user"],isActive:!0,setupMode:"invite"}))},[i,m,n]);const b=async()=>{try{const c=await n.validateFields(),{confirmPassword:g,...u}=c;v(r?{tenantRoles:c.tenantRoles,isActive:c.isActive}:u)}catch{}},S=(c,g)=>{const u=g??"",h=_e(u);return h.isValid?[n.getFieldValue("firstName"),n.getFieldValue("lastName"),n.getFieldValue("email")?.split("@")[0]].flatMap(x=>typeof x=="string"?x.toLowerCase().split(/[^a-z0-9]+/):[]).filter(x=>x.length>=3).some(x=>u.toLowerCase().includes(x))?Promise.reject(new Error("Åifre ad, soyad veya e-posta bilgisini içeremez")):Promise.resolve():Promise.reject(new Error(h.feedback[0]??"Åifre gereksinimleri karÅılanmıyor"))};return(0,e.jsx)(pe,{title:r?"Kullanıcı Düzenle":"Kullanıcı Ekle",open:i,onCancel:a,onOk:b,okText:r?"Güncelle":"Ekle",okButtonProps:{"data-guide":"settings-profile-user-save"},cancelText:"İptal",confirmLoading:f,destroyOnHidden:!0,children:(0,e.jsxs)(d,{"data-guide":"settings-profile-user-form",form:n,layout:"vertical",style:{marginTop:16},children:[r?(0,e.jsx)(d.Item,{label:"E-posta",children:(0,e.jsx)(y,{value:m?.email,disabled:!0})}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(d.Item,{"data-guide":"settings-profile-user-email",name:"email",label:"E-posta",rules:[{required:!0,message:"E-posta adresi gereklidir"},{type:"email",message:"Geçerli bir e-posta adresi girin"}],children:(0,e.jsx)(y,{placeholder:"[email protected]"})}),(0,e.jsxs)(w,{style:{width:"100%"},size:"middle",children:[(0,e.jsx)(d.Item,{name:"firstName",label:"Ad",style:{flex:1},children:(0,e.jsx)(y,{placeholder:"Ad"})}),(0,e.jsx)(d.Item,{name:"lastName",label:"Soyad",style:{flex:1},children:(0,e.jsx)(y,{placeholder:"Soyad"})})]}),(0,e.jsx)(d.Item,{name:"phone",label:"Telefon",children:(0,e.jsx)(y,{placeholder:"+90 5xx xxx xx xx"})}),(0,e.jsx)(d.Item,{"data-guide":"settings-profile-user-setup",name:"setupMode",label:"Hesap kurulumu",rules:[{required:!0,message:"Hesap kurulum yöntemini seçin"}],children:(0,e.jsx)(L.Group,{children:(0,e.jsxs)(w,{orientation:"vertical",children:[(0,e.jsx)(L,{value:"invite",children:"Davet e-postası gönder"}),(0,e.jsx)(L,{value:"temporary-password",children:"Geçici Åifreyi yönetici belirlesin"})]})})}),k==="temporary-password"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(I,{type:"info",showIcon:!0,title:"Kullanıcı ilk giriÅte bu geçici Åifreyi deÄiÅtirmek zorunda olacaktır.",style:{marginBottom:16}}),(0,e.jsx)(d.Item,{name:"password",label:"Geçici Åifre",preserve:!1,rules:[{validator:S}
1],validateFirst:!0,children:(0,e.jsx)(y.Password,{autoComplete:"new-password",placeholder:"En az 12 karakter"})}),(0,e.jsx)(d.Item,{name:"confirmPassword",label:"Geçici Åifre tekrar",preserve:!1,dependencies:["password"],rules:[{required:!0,message:"Åifre tekrarını girin"},({getFieldValue:c})=>({validator(g,u){return!u||c("password")===u?Promise.resolve():Promise.reject(new Error("Åifreler eÅleÅmiyor"))}})],children:(0,e.jsx)(y.Password,{autoComplete:"new-password",placeholder:"Geçici Åifreyi tekrarlayın"})})]}):(0,e.jsx)(I,{type:"info",showIcon:!0,title:"Kullanıcıya 24 saat geçerli bir Åifre oluÅturma baÄlantısı gönderilecektir.",style:{marginBottom:16}})]}),(0,e.jsx)(d.Item,{"data-guide":"settings-profile-user-roles",name:"tenantRoles",label:"Roller",rules:[{required:!0,message:"En az bir rol seçilmelidir"}],children:(0,e.jsx)(F,{mode:"multiple",placeholder:"Rol seçin",options:De.map(c=>({value:c.value,label:(0,e.jsx)(T,{color:c.color,style:{margin:0},children:c.label})}))})}),r&&(0,e.jsx)(d.Item,{"data-guide":"settings-profile-user-status",name:"isActive",label:"Durum",valuePropName:"checked",children:(0,e.jsx)(fe,{checkedChildren:"Aktif",unCheckedChildren:"Pasif"})})]})})},G=K(ue(),1),Oe=K(he(),1),ns=xe();G.default.extend(Oe.default);G.default.locale("tr");var{Text:A}=Y,Be=X.map(i=>({value:i,label:J(i)})),$e=()=>{const{user:i}=je(),{token:a}=Z.useToken(),[v,f]=(0,j.useState)(1),[m,n]=(0,j.useState)(""),[r,k]=(0,j.useState)(""),[b,S]=(0,j.useState)(""),[c,g]=(0,j.useState)(!1),[u,h]=(0,j.useState)(null),{data:x,isLoading:ee,isFetching:se}=Me({page:v,limit:20,search:m||void 0,role:r||void 0,isActive:b||void 0}),P=x,O=Le(),R=Ue(),te=Ke(),C=Fe(),ie=t=>{O.mutate(t,{onSuccess:s=>{s.isNew?s.emailSent?s.setupResult==="invited"?o.success("Kullanıcı oluÅturuldu ve davet e-postası gönderildi"):o.success("Kullanıcı geçici Åifreyle oluÅturuldu"):o.warning("Kullanıcı oluÅturuldu ancak e-posta gönderilemedi. Kullanıcı satırından baÄlantıyı yeniden gönderebilirsiniz."):o.success("Mevcut kullanıcı maÄazaya eklendi; mevcut Åifresi deÄiÅtirilmedi"),g(!1),h(null)},onError:s=>{const l=s?.response?.data?.error||s?.message||"Kullanıcı eklenemedi";o.error(l)}})},ae=t=>{u&&R.mutate({id:u.id,...t},{onSuccess:()=>{o.success("Kullanıcı güncellendi"),g(!1),h(null)},onError:s=>{const l=s?.response?.data?.error||s?.message||"Güncelleme baÅarısız";o.error(l)}})},re=t=>{C.mutate({id:t},{onSuccess:()=>{o.success("Åifre oluÅturma baÄlantısı gönderildi")},onError:s=>{const l=s?.response?.data?.error||s?.message||"Davet gönderilemedi";o.error(l)}})},ne=t=>{te.mutate({id:t},{onSuccess:()=>{o.success("Kullanıcı maÄazadan kaldırıldı")},onError:s=>{const l=s?.response?.data?.error||s?.message||"Kaldırma baÅarısız";o.error(l)}})},le=t=>{R.mutate({id:t.id,isActive:!t.isActive},{onSuccess:()=>{o.success(t.isActive?"Kullanıcı pasif yapıldı":"Kullanıcı aktif yapıldı")},onError:s=>{const l=s?.response?.data?.error||s?.message||"Durum deÄiÅtirilemedi";o.error(l)}})},M=t=>i?.id===t,oe=t=>t.firstName&&t.lastName?`${t.firstName[0]}${t.lastName[0]}`.toUpperCase():(t.email[0]??"?").toUpperCase();return(0,e.jsxs)("div",{children:[(0,e.jsxs)(N,{justify:"space-between",align:"center",style:{marginBottom:16},children:[(0,e.jsxs)(w,{children:[(0,e.jsx)(y.Search,{"data-guide":"settings-profile-users-search",placeholder:"E-posta veya isim ara...",allowClear:!0,style:{width:250},prefix:(0,e.jsx)(p,{icon:Ne}),onSearch:t=>{n(t),f(1)},onChange:t=>{t.target.value||(n(""),f(1))}}),(0,e.jsx)(F,{"data-guide":"settings-profile-users-role",placeholder:"Rol",allowClear:!0,style:{width:160},value:r||void 0,onChange:t=>{k(t||""),f(1)},options:Be}),(0,e.jsx)(F,{"data-guide":"settings-profile-users-status",placeholder:"Durum",allowClear:!0,style:{width:120},value:b||void 0,onChange:t=>{S(t||""),f(1)},options:[{value:"true",label:"Aktif"},{value:"false",label:"Pasif"}]})]}),(0,e.jsx)(E,{"data-guide":"settings-profile-users-add",type:"primary",icon:(0,e.jsx)(p,{icon:Ae}),onClick:()=>{h(null),g(!0)},children:"Kullanıcı Ekle"})]}),(0,e.jsx)(ce,{"data-guide":"settings-profile-users-table",dataSource:P?.docs||[],columns:[{title:"Kullanıcı",key:"user",render:(t,s)=>(0,e.jsxs)(N,{gap:12,align:"center",children:[(0,e.jsx)(Q,{size:36,style:{backgroundColor:M(s.id
1)?a.colorPrimary:a.colorTextQuaternary,fontSize:14,fontWeight:600,flexShrink:0},children:oe(s)}),(0,e.jsxs)("div",{style:{minWidth:0},children:[(0,e.jsxs)("div",{children:[(0,e.jsx)(A,{strong:!0,style:{fontSize:13},children:s.firstName&&s.lastName?`${s.firstName} ${s.lastName}`:s.email}),M(s.id)&&(0,e.jsx)(T,{color:"blue",style:{marginLeft:6,fontSize:10},children:"Sen"})]}),(s.firstName||s.lastName)&&(0,e.jsx)(A,{type:"secondary",style:{fontSize:12},children:s.email})]})]})},{title:"Rol",key:"roles",width:200,render:(t,s)=>(0,e.jsx)(w,{size:[0,4],wrap:!0,children:s.tenantRoles.map(l=>(0,e.jsx)(T,{color:ke(l),children:J(l)},l))})},{title:"Durum",key:"status",width:100,render:(t,s)=>(0,e.jsx)(T,{icon:s.isActive?(0,e.jsx)(p,{icon:U}):(0,e.jsx)(p,{icon:$}),color:s.isActive?"success":"default",children:s.isActive?"Aktif":"Pasif"})},{title:"Son GiriÅ",key:"lastLogin",width:150,render:(t,s)=>s.lastLogin?(0,e.jsx)(A,{type:"secondary",style:{fontSize:12},children:(0,G.default)(s.lastLogin).fromNow()}):(0,e.jsx)(A,{type:"secondary",style:{fontSize:12},children:"-"})},{title:"",key:"actions",width:160,render:(t,s)=>M(s.id)?null:(0,e.jsxs)(w,{size:"small",children:[s.lastLogin?null:(0,e.jsx)(B,{title:"Yeni bir Åifre oluÅturma baÄlantısı gönderilsin mi?",description:"Daha önce gönderilen baÄlantı geçersiz olacaktır.",onConfirm:()=>re(s.id),okText:"Gönder",cancelText:"İptal",children:(0,e.jsx)(E,{"data-guide":"settings-profile-users-invite",type:"text",size:"small","aria-label":"Åifre oluÅturma baÄlantısı gönder",loading:C.isPending&&C.variables?.id===s.id,icon:(0,e.jsx)(p,{icon:Te})})}),(0,e.jsx)(E,{"data-guide":"settings-profile-users-edit",type:"text",size:"small",icon:(0,e.jsx)(p,{icon:Ee}),onClick:()=>{h(s),g(!0)}}),(0,e.jsx)(E,{"data-guide":"settings-profile-users-toggle",type:"text",size:"small",icon:s.isActive?(0,e.jsx)(p,{icon:$}):(0,e.jsx)(p,{icon:U}),onClick:()=>le(s)}),(0,e.jsx)(B,{title:"Bu kullanıcıyı maÄazadan kaldırmak istediÄinize emin misiniz?",onConfirm:()=>ne(s.id),okText:"Kaldır",cancelText:"İptal",okButtonProps:{danger:!0},children:(0,e.jsx)(E,{"data-guide":"settings-profile-users-remove",type:"text",size:"small",danger:!0,icon:(0,e.jsx)(p,{icon:we})})})]})}],rowKey:"id",loading:ee||se,pagination:{current:P?.page||v,pageSize:20,total:P?.totalDocs||0,showSizeChanger:!1,showTotal:t=>`Toplam ${t} kullanıcı`,onChange:t=>f(t)},size:"middle",locale:{emptyText:"Henüz kullanıcı yok"}}),(0,e.jsx)(Ge,{open:c,onCancel:()=>{g(!1),h(null)},onSubmit:u?ae:ie,loading:O.isPending||R.isPending,editingUser:u})]})},{Title:V,Text:H}=Y,W={personal:{title:"KiÅisel Bilgiler",description:"KiÅisel ve hesap bilgilerinizi görüntüleyin ve yönetin."},security:{title:"Güvenlik",description:"Åifrenizi deÄiÅtirin ve hesabınızın güvenliÄini artırın."},tenants:{title:"MaÄazalar",description:"BaÄlı olduÄunuz maÄazaları ve rollerinizi görüntüleyin."},users:{title:"Kullanıcı Yönetimi",description:"MaÄazanıza baÄlı kullanıcıları yönetin, roller atayın ve eriÅim izinlerini düzenleyin."}},ls=()=>{const{section:i="personal"}=de(),{data:a,isLoading:v,isError:f,error:m}=Pe(),{isTenantAdmin:n}=Se(),{token:r}=Z.useToken(),k=W[i]??W.personal??{title:"",description:""};if(v)return(0,e.jsx)(N,{justify:"center",style:{padding:"80px 0"},children:(0,e.jsx)(ge,{size:"large",indicator:(0,e.jsx)(p,{icon:ze,size:36})})});if(f)return(0,e.jsx)(I,{title:"Hata",description:m instanceof Error?m.message:"Profil bilgileri yüklenirken bir hata oluÅtu. Lütfen sayfayı yenileyin.",type:"error",showIcon:!0});if(!a)return(0,e.jsx)(I,{title:"Uyarı",description:"Profil bilgileri bulunamadı. Lütfen tekrar giriÅ yapın.",type:"warning",showIcon:!0});if(i==="users"&&!n)return(0,e.jsx)(Ie,{description:"Kullanıcı yönetimi yalnızca maÄaza yöneticileri tarafından görüntülenebilir."});const b=()=>a.firstName&&a.lastName?`${a.firstName[0]}${a.lastName[0]}`.toUpperCase():(a.email[0]??"?").toUpperCase(),S=()=>{switch(i){case"personal":return(0,e.jsx)(q,{user:a});case"security":return(0,e.jsx)(Re,{user:a});case"tenants":return(0,e.jsx)(Ce,{user:a});case"users":return(0,e.jsx)($e,{});default:return(0,e.jsx)(q,{user:a})}};return(0,e.jsxs)("div",{children:[i!=="users"&&(0,e.jsxs)(N,{gap:20,align:"center",style:{padding:r.paddingLG,marginBottom:r.marginLG,background:r.colorFillQuaternary,border:`1px solid ${r.colorBorderSecondary}`,borderRadius:r.borderRadiusLG},children:[(0,e.jsx)(Q,{size:56,style:{backgroundColor:r.colorPrimary,fontSize:22,fontWeight:600,flexShrink:0},children:b()}),(0,e.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,e.jsx)(V,{level:5,style:{margin:0,lineHeight:1.3},children:a.firstName&&a.lastName?`${a.firstName} ${a.lastName}`:a.email}),(0,e.jsx)(H,{type:"secondary",style:{fontSize:13},children:a.email}),a.emailVerified&&(0,e.jsx)("div",{children:(0,e.jsx)(T,{icon:(0,e.jsx)(p,{icon:U}),color:"success",style:{marginTop:4,borderRadius:4,fontSize:11},children:"DoÄrulanmıÅ"})})]})]}),(0,e.jsxs)("div",{"data-guide":"profilesettings-header",style:{marginBottom:r.marginLG},children:[(0,e.jsx)(V,{level:4,style:{margin:"0 0 4px 0"},children:k.title}),(0,e.jsx)(H,{type:"secondary",children:k.description})]}),(0,e.jsx)("div",{"data-guide":"profilesettings-form",children:S()})]})};export{ls as ProfileSection};
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.