2 lines
18 KiB
JavaScript
2 lines
18 KiB
JavaScript
|
|
import{j as u,a5 as j,aj as S,an as w,ay as X,az as Y,aA as _,aX as J,ac as lu,T as z,ak as nu,al as Q,am as Z,B as W,ao as su,b8 as iu,d as cu,aM as du,I as hu,b3 as Cu,aq as pu,b7 as K,as as H,at as q,b as yu}from"./mui-vendor-D_SVL-Dx.js";import{L,j as T,h as f,A as M,u as eu,a0 as m,b6 as B,W as R,b7 as mu,c as ru,V as k,b8 as U,G as I,S as O,b9 as xu}from"./index-D80MdVQn.js";import{r as y}from"./react-vendor-CmFgShSM.js";import{a as P,u as D,f as V}from"./redux-vendor-CfkcHgWN.js";import{C as Au}from"./CarPelak-BUqZflo3.js";import{a as vu}from"./index.esm-C1-dCPnj.js";import{d as _u}from"./Tune-BBzxV8DK.js";import{d as ju}from"./EditOutlined-CdYoJAhn.js";import{d as fu}from"./DeleteOutline-DhriepRs.js";import{R as uu}from"./ResponsiveTable-bUYl0qDM.js";import{c as G}from"./checkPathStartsWith-DedybDvj.js";import"./FilterAlt-DZsHj-WQ.js";import"./styled-components.browser.esm-gS9mh05b.js";const Fu=P("PROVINCE_REGISTER_CAR_SERVICE",async(r,{dispatch:a})=>{try{a(L());const{data:t,status:i}=await T.post("kill_house_driver/",r);return a(f()),{data:t,status:i}}catch(t){return a(f()),{error:t.response.data.result}}}),gu=P("PROVINCE_EDIT_CAR_SERVICE",async(r,{dispatch:a})=>{try{a(L());const{data:t,status:i}=await T.put("kill_house_driver/0/",r);return a(f()),{data:t,status:i}}catch(t){return a(f()),{error:t.response.data.result}}}),bu=ru({driver_mobile:k().required("شماره موبایل راننده الزامی است"),last_name:k().required("نام خانوادگی الزامی است"),first_name:k().required("نام الزامی است"),city_name:k().required("نام شهر الزامی است"),type_car:k().required("نوع خودرو الزامی است"),pelak:k().required("پلاک الزامی است"),capocity:k().required("ظرفیت الزامی است"),health_code:k().required("کد سلامت الزامی است")}),tu=({first_name:r,last_name:a,driver_mobile:t,city_name:i,type_car:C,pelak:x,capocity:h,health_code:s,driverKey:l,type:o})=>{const c=D(),[p]=y.useContext(M),{provinceGetCities:g}=V(n=>n.provinceSlice),e=eu({initialValues:{driver_mobile:t,last_name:a,first_name:r,city_name:i,type_car:C,pelak:"",capocity:h,health_code:s,type:o||"exclusive"},validationSchema:bu,onSubmit:()=>{v()}}),[F,A]=y.useState([]);y.useEffect(()=>{if(x){const n=x.split(" ");A(n)}},[x]),y.useEffect(()=>{e.setFieldValue("pelak",F.length?F.join(" ").trim():"")},[F]);const v=()=>{const{values:n,errors:b}=e;b!=null&&b.length||(l?c(gu({driver_mobile:n.driver_mobile,last_name:n.last_name,first_name:n.first_name,city_name:n.city_name,type_car:n.type_car,pelak:F.join(" "),capocity:n.capocity,health_code:n.health_code,role:m(),driver_key:l,type:n.type})).then(E=>{E.payload.error?p({vertical:"top",horizontal:"center",msg:E.payload.error,severity:"error"}):(c(B()),c(R({right:!1,bottom:!1,content:null})),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))}):c(Fu({driver_mobile:n.driver_mobile,last_name:n.last_name,first_name:n.first_name,city_name:n.city_name,type_car:n.type_car,pelak:F.join(" "),capocity:n.capocity,health_code:n.health_code,role:m(),type:n.type})).then(E=>{E.payload.error?p({vertical:"top",horizontal:"center",msg:E.payload.error,severity:"error"}):(c(B()),c(R({right:!1,bottom:!1,content:null})),p({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))}))},d=(n,b,E,N)=>{A([n,b,E,N])};return y.useEffect(()=>{c(mu()).then(()=>e.setFieldValue("city_name",i))},[]),u.jsx("form",{onSubmit:e.handleSubmit,children:u.jsxs(j,{container:!0,spacing:2,children:[u.jsx(j,{item:!0,xs:12,children:u.jsx(S,{fullWidth:!0,children:u.jsx(w,{id:"first_name",name:"first_name",label:"نام",value:e.values.first_name,onChange:e.handleChange,onBlur:e.handleBlur,error:e.touched.first_name&&!!e.errors.first_name,helperText:e.touched.first_name&&e.errors.first_name})})}),u.jsx(j,{item:!0,xs:12,children:u.jsx(S,{fullWidth:!0,children:u.jsx(w,{id:"last_name",name:"last_name",label:"نام خانوادگی",value:e.values.last_name,o
|