import{j as e,T as d,d as h,I as f,ca as y,ak as j,B as p}from"./mui-vendor-CkIVaoQP.js";import{r as i}from"./react-vendor-CmFgShSM.js";import{L as A,j as v,h as m,A as E,G as l,O as T,C as x,X as _}from"./index-Cr86_nOs.js";import{a as g,u as D}from"./redux-vendor-B7uoacJt.js";const F=g("VET_FARM_EDIT_TRAFFIC_CODE_SERVICE",async(t,{dispatch:r})=>{r(A());try{const{data:s,status:u}=await v.put("kill_house_request/0/",t);return r(m()),{data:s,status:u}}catch(s){return r(m()),{error:s.response.data.result}}}),b=({trafficCode:t,killHouseRequestKey:r,updateTable:s,isEditable:u=!0})=>{const a=D(),[n]=i.useContext(E);if(!u)return e.jsx(d,{variant:"body2",sx:{display:"flex",alignItems:"center"},children:t||"-"});const o=()=>{a(T({title:"ویرایش کد حمل و نقل",size:"auto",content:e.jsx(I,{initialValue:t||"",onSubmit:C=>{a(F({key:r,traffic_code:C,role:_()})).then(c=>{c.payload.error?n({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),s(),a(x()))})},onCancel:()=>a(x())})}))};return e.jsxs(l,{container:!0,alignItems:"center",justifyContent:"center",gap:.5,sx:{width:"140px"},children:[e.jsx(d,{variant:"body2",children:t||"-"}),e.jsx(h,{title:"ویرایش کد حمل و نقل",placement:"top",children:e.jsx(f,{size:"small",color:"primary","aria-label":"edit",onClick:o,children:e.jsx(y,{fontSize:"small"})})})]})},I=({initialValue:t,onSubmit:r,onCancel:s})=>{const[u,a]=i.useState(t);i.useEffect(()=>{a(t)},[t]);const n=()=>{u&&r(u)};return e.jsxs(l,{container:!0,direction:"column",gap:2,minWidth:260,children:[e.jsx(j,{variant:"outlined",value:u,size:"small",placeholder:"کد حمل و نقل",onChange:o=>a(o.target.value),inputProps:{inputMode:"numeric",pattern:"[0-9]*"},fullWidth:!0}),e.jsxs(l,{container:!0,justifyContent:"flex-end",gap:1,xs:12,children:[e.jsx(p,{size:"small",variant:"contained",color:"primary",onClick:n,disabled:!u||u===t,sx:{flex:1},children:"ثبت"}),e.jsx(p,{size:"small",variant:"outlined",color:"primary",onClick:s,sx:{flex:1},children:"لغو"})]})]})};export{b as V,F as v};
