1import{d7 as s,X as b,aW as A,bt as E,dH as C,dB as B,d$ as T,A as h,br as n,bm as z,cY as p,dW as x,dA as I,eo as M,er as S,et as N,em as q,ek as _,ev as Q,bw as F,b as O,ae as W,cU as $,bx as K,c5 as f,eE as P}from"./index-Dr-S3kPX.js";import{T as V}from"./TableBuilder-BAjrpO9F.js";import{S as U}from"./copy-icon-Zuf7yl1E.js";import{p as D}from"./types-CQJb8W1f.js";const X=({route:t,isMobile:l})=>s.jsxs(b,{align:"center",gap:l?"4":"8",children:[t!=null&&t.hasAirportStop?s.jsx(A,{width:16,height:16}):null,s.jsx(E,{to:C.routeEdit(t.id),size:l?"xs":"s",color:"dark",ellipsis:3,wordBreak:"break-word",title:t.title,children:t.title})]}),Y="_trashIcon_vlect_1",G={trashIcon:Y},J=({onDuplicateRoute:t,onRemoveRoute:l,className:R})=>{const[a,r]=B.useState(!1),d=T(),g=()=>{l()},j=()=>{d.add({contentTitle:"УдалиÑÑ Ð²ÑбÑаннÑй маÑÑÑÑÑ?",okText:"УдалиÑÑ",okType:"danger",onOk:g}),r(!1)},w=()=>{t(),r(!1)};return s.jsxs(h,{direction:"left-bottom",active:a,setActive:r,width:220,children:[s.jsx(h.MoreButton,{className:a?"":R}),s.jsxs(h.List,{children:[s.jsxs(h.ListItem,{onClick:w,children:[s.jsx(U,{}),s.jsx(n,{size:"s",children:"СкопиÑоваÑÑ Ð¼Ð°ÑÑÑÑÑ"})]}),s.jsxs(h.ListItem,{onClick:j,children:[s.jsx(z,{className:G.trashIcon}),s.jsx(n,{size:"s",color:"danger",children:"УдалиÑÑ"})]})]})]})},y={getRoutesList:async()=>{const t=await p.get(x.routes.getRoutesList());return t==null?void 0:t.data},deleteRoute:async t=>(await p.delete(x.routes.removeRoute(t)),t),postEnableRoute:async({routeId:t,isEnabled:l})=>(await p.post(x.routes.enableRoute(t),{isEnabled:l}),{routeId:t,isEnabled:l}),postCopyRoute:async t=>{await p.post(x.routes.copyRoute(t))}},Z="routes-list",m={routesList:()=>[Z,"items"]},ee={routesList:()=>I({queryKey:m.routesList(),queryFn:y.getRoutesList,refetchOnWindowFocus:!1,select:D})},se="_tableHidden_vi132_1",te="_pageHeader_vi132_5",oe="_tableHeader_vi132_13",ie="_tableBodyRow_vi132_21",ne="_tableBodyCell_vi132_31",le="_routeActions_vi132_35",ce="_tableBodyRowHover_vi132_40",re="_routeActionsMenu_vi132_44",ue="_table_vi132_1",c={tableHidden:se,pageHeader:te,tableHeader:oe,tableBodyRow:ie,tableBodyCell:ne,routeActions:le,tableBodyRowHover:ce,routeActionsMenu:re,table:ue},pe=()=>{M("ÐаÑÑÑÑÑÑ");const{data:t=[],isLoading:l}=S(ee.routesList()),[R,a]=B.useState({}),r=N(),d=P(),g=q(),j=_({mutationFn:y.deleteRoute,onSuccess(e){r.setQueryData(m.routesList(),i=>i==null?void 0:i.filter(u=>u.id!==e)),d.success("ÐаÑÑÑÑÑ ÑÑпеÑно Ñдален")}}),w=_({mutationFn:y.postEnableRoute,onSuccess(e){r.setQueryData(m.routesList(),i=>{var u;return i?(u=i||[])==null?void 0:u.map(v=>v.id===e.routeId?{...v,isEnabled:e.isEnabled}:v):[]}),d.success(`ÐаÑÑÑÑÑ ÑÑпеÑно ${e.isEnabled?"вклÑÑен":"оÑклÑÑен"}`),a(({[e.routeId]:i,...u})=>u)}}),H=_({mutationFn:y.postCopyRoute,onSuccess(){r.invalidateQueries({queryKey:m.routesList()}),d.success("ÐаÑÑÑÑÑ ÑÑпеÑно ÑкопÑиÑован")}}),k=e=>{e!=null&&e.id&&(w.mutate({routeId:e.id,isEnabled:!e.isEnabled}),a(i=>({...i,[e.id]:!0})))},{isMobileResolution:o}=Q(),L=e=>{e&&g(C.routeEdit(e))};return s.jsxs(b,{vertical:!0,as:"section",children:[s.jsxs(b,{className:c.pageHeader,align:"center",justify:"space-between",children:[s.jsx(F,{size:o?"l":"2xl",children:"ÐаÑÑÑÑÑÑ"}),s.jsx(O,{variant:"primary",fullWidth:o,component:s.jsx(W,{to:C.routeAdd()}),children:s.jsx(n,{size:"s",align:"center",children:"+ ÐобавиÑÑ Ð½Ð¾Ð²Ñй маÑÑÑÑÑ"})})]}),s.jsx(V,{className:{table:f(c.table,!(t!=null&&t.length)&&!l&&c.tableHidden,o&&"off-scroll-bar"),header:c.tableHeader,bodyRow:f(c.tableBodyRow,!l&&c.tableBodyRowHover),bodyCell:c.tableBodyCell,headerCell:c.tableHeaderCell},rows:t,skeletonConfig:{count:5,isVisible:l,heightItem:28,heightRow:40},onClickRow:e=>{var i;return L((i=e==null?void 0:e.data)==null?void 0:i.id)},columns:[{name:"route-id",width:o?38:76,cellHead:s.jsx(n,{size:o?"xs":"s",weight:600,children:"ID"}),cellBody:({data:e})=>s.jsx(n,{size:o?"xs":"s",title:`ID ${e==null?void 0:e.id}`,children:e==null?void 0:e.id})},{name:"route-name",width:o?118:340,cellHead:s.jsx(n,{size:o?"xs":"s",weight:600,children:"Ðазвание"}),cellBody:({data:e})=>s.jsx(X,{route:e,isMobile:o})},{name:"route-number",width:o?48:76,cellHead:s.jsx(n,{size:o?"xs":"s",weight:600,children:"ÐомеÑ"}),cellBody:({data:e})=>s.jsx(n,{size:o?"xs":"s",title:e==null?void 0:e.number,color:"dark",ellipsis:!0,children:e==null?void 0:e.number})},{name:"route-type-vehicle",width:o?38:100,cellHead:s.jsx(n,{size:o?"xs":"s",weight:600,children:o?"Тип":"Тип ТС"}),cellBody:({data:e})=>s.jsx(b,{align:"center",gap:"6",children:s.jsx(n,{size:o?"xs":"s",color:"dark",ellipsis:!0,children:$(e==null?void 0:e.vehicleType)})})},{name:"route-description",width:338,isUnmounted:o,cellHead:s.jsx(n,{size:"s",weight:600,children:"ÐпиÑание"}),cellBody:({data:e})=>s.jsx(n,{ellipsis:2,title:e==null?void 0:e.description,color:"dark",wordBreak:"break-word",children:e==null?void 0:e.description})},{name:"route-actions",width:90,cellHead:s.jsx(n,{size:o?"xs":"s",weight:600,children:"ÐкÑивнÑй"}),cellBody:({data:e})=>s.jsxs(b,{className:c.routeActions,align:"center",gap:"20",justify:"end",fullWidth:!0,onClick:i=>i.stopPropagation(),children:[s.jsx(K,{name:"route-active",title:e!=null&&e.isEnabled?"ÐклÑÑен":"ÐÑклÑÑен",isChecked:e==null?void 0:e.isEnabled,isDisabled:R[e==null?void 0:e.id],onChange:()=>k(e)}),s.jsx(J,{className:c.routeActionsMenu,onDuplicateRoute:()=>H.mutate(e==null?void 0:e.id),onRemoveRoute:()=>j.mutate(e==null?void 0:e.id)})]})}]})]})};export{pe 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.