1import{q as R,fd as v,fe as M,ff as N,fg as S,fh as z,r as h,j as t,G as x,s as T}from"./theme-3dfVej7W.js";import{F as n}from"./index-BzeA_MbD.js";import{R as E}from"./EditOutlined-Dtr1qgwG.js";import{P as G}from"./index-BZy7ibvr.js";import{R as O}from"./DeleteOutlined-A7wxyeiA.js";import{T as q}from"./index-I1ZxXO3B.js";import{R as A}from"./PlusOutlined-DO9FITow.js";import{A as D}from"./index-wH3ULS13.js";import{F as K}from"./index-C86gn5Ct.js";import{M as Q}from"./index-C016Db5J.js";import{S as V}from"./AntdIcon-B8e_FEAo.js";import{I as o}from"./index-CQ9iPbHV.js";import"./vite-preload-helper-BXl3LOEh.js";import"./useBreakpoint-DBaSuQQQ.js";import"./useForm-Cmblz3t1.js";import"./row-M1qaIYld.js";import"./index-DqejBB-o.js";import"./PurePanel-CIovuaru.js";import"./index-CwLtvCkV.js";import"./Sider-CaqjhNAo.js";import"./EllipsisOutlined-fLaExTxN.js";import"./index-C63dYVM1.js";import"./index-D10blwUV.js";import"./EyeOutlined-DGpwx6h2.js";function pt(){const{t:e,i18n:y}=R("profile"),l=y.language.startsWith("kz"),r=v(),d=M(),[j]=N(),[b]=S(),[g]=z(),[m,u]=h.useState(null),[I,i]=h.useState(!1),[c]=n.useForm(),p=e("contacts.emptyValue"),_=(d.data??[]).map(a=>({value:a.code,label:(l?a.name_kz:a.name_ru)??a.code})),C=a=>{const s=(d.data??[]).find(f=>f.code===a.country_code);return(l?s?.name_kz:s?.name_ru)??a.country_name??p},F=[{title:e("contacts.countryCode"),dataIndex:"country_code"},{title:e("contacts.country"),key:"country_name",render:(a,s)=>C(s)},{title:e("contacts.address"),key:"address",render:(a,s)=>(l?s.address_kz:s.address)||p},{title:e("contacts.phone"),dataIndex:"phone",render:a=>a||p},{title:e("contacts.actions"),key:"actions",render:(a,s)=>s.editable?t.jsxs("span",{className:"flex gap-2",children:[t.jsx(x,{icon:t.jsx(E,{}),onClick:()=>{u(s),c.setFieldsValue({country_code:s.country_code??void 0,state:s.state,city:s.city,street:s.street,building:s.building,appartment:s.appartment,phone:s.phone}),i(!0)}}),t.jsx(G,{title:e("contacts.deleteConfirm"),onConfirm:()=>g(s.id).unwrap().then(()=>r.refetch()),children:t.jsx(x,{danger:!0,icon:t.jsx(O,{})})})]}):null}],k=async a=>{try{m?await b({id:m.id,...a}).unwrap():await j(a).unwrap(),i(!1),u(null),c.resetFields(),r.refetch()}catch(s){const f=s?.data?.detail;T.error(f||e("registration.saveError"))}},P=(r.data??[]).some(a=>!a.editable);return t.jsxs("div",{className:"container mx-auto w-full",children:[t.jsxs("div",{className:"flex justify-between items-center mb-4",children:[t.jsx(q.Title,{level:4,children:e("contacts.title")}),t.jsx(x,{type:"primary",icon:t.jsx(A,{}),onClick:()=>{u(null),c.resetFields(),i(!0)},children:e("contacts.add")})]}),P&&t.jsx(D,{className:"mb-4",type:"info",showIcon:!0,message:e("contacts.integrationNote")}),t.jsx(K,{bordered:!0,loading:r.isFetching,columns:F,dataSource:r.data??[],rowKey:"id",pagination:!1,scroll:{x:800}}),t.jsx(Q,{open:I,title:e(m?"contacts.edit":"contacts.add"),onCancel:()=>i(!1),onOk:()=>c.submit(),children:t.jsxs(n,{form:c,layout:"vertical",onFinish:k,children:[t.jsx(n.Item,{name:"country_code",label:e("contacts.country"),rules:[{required:!0}],children:t.jsx(V,{options:_,loading:d.isFetching,showSearch:!0,optionFilterProp:"label"})}),t.jsx(n.Item,{name:"state",label:e("contacts.state"),children:t.jsx(o,{})}),t.jsx(n.Item,{name:"city",label:e("contacts.city"),children:t.jsx(o,{})}),t.jsx(n.Item,{name:"street",label:e("contacts.street"),children:t.jsx(o,{})}),t.jsx(n.Item,{name:"building",label:e("contacts.building"),children:t.jsx(o,{})}),t.jsx(n.Item,{name:"appartment",label:e("contacts.appartment"),children:t.jsx(o,{})}),t.jsx(n.Item,{name:"phone",label:e("contacts.phone"),children:t.jsx(o,{})})]})})]})}export{pt 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.