Files
Rasadyar_FrontEnd/build/assets/ProvinceUserManagement-D7PqB1MC.js

2 lines
46 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{j as u,T as w,p as e6,ak as i,I as du,aU as r6,al as z,ag as Q,av as Z,aw as uu,ax as l,am as q,ar as $,B as fu,d as Su,b0 as l6,an as a6,b4 as Ku,ap as Bu,aq as Iu,b as n6}from"./mui-vendor-CkIVaoQP.js";import{G as a,S as f,p as s6,A as Ou,u as eu,c as ru,v as Vu,M as Y,b as W,L as V,h as _,N as au,W as t6,b4 as ou,j as Hu,X as lu,b5 as o6,b6 as i6,b7 as Tu,b8 as c6,f as d6}from"./index-Cr86_nOs.js";import{r as A,b as C6,u as h6}from"./react-vendor-CmFgShSM.js";import{u as Mu,f as A6}from"./redux-vendor-B7uoacJt.js";import{R as p6}from"./ResponsiveTable-Dua7tTwQ.js";import{d as v6}from"./VpnKey-B0UaRxCm.js";import{p as x6,a as iu,d as m6}from"./province-register-user-ztT_AwoI.js";import{d as b6}from"./Tune-m0V6JHJm.js";import{d as Wu}from"./Delete-CTUmuli-.js";import{d as Lu}from"./Add-CdBsyA2e.js";import{c as j6,a as cu}from"./city-get-city-C8V6PIyp.js";import{d as F6}from"./Search-DLgMQCPC.js";import{N as f6}from"./NumberFormatCustom-DwWPj40N.js";import{p as y6}from"./province-get-kill-houses-DhVWeok5.js";import{d as g6}from"./Check-CtJeUoc2.js";import{C as k6}from"./CarPelak-Ddy5J5I5.js";import{R as P6,a as N6}from"./index.esm-Bu7XMDZU.js";import{S as E6}from"./SelectCheck-CAe89SYT.js";import"./FilterAlt-RwhTl5ac.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./iconBase-BEJYyZsk.js";const Ru=({userData:y})=>{var g,x,nu;return u.jsx(u.Fragment,{children:u.jsxs(a,{container:!0,gap:f.SMALL,direction:"column",flex:"1",height:"100%",justifyContent:"space-between",children:[u.jsxs(a,{display:"flex",children:[u.jsx(w,{variant:"body1",mr:f.TINY,color:v=>v.palette.grey.A700,children:"نام کامل:"}),u.jsx(w,{mr:f.TINY,fontWeight:"bold",children:y.fullname})," "]}),u.jsxs(a,{display:"flex",children:[u.jsx(w,{variant:"body1",mr:f.TINY,color:v=>v.palette.grey.A700,children:"موبایل:"}),u.jsx(w,{mr:f.TINY,fontWeight:"bold",children:y.mobile})]}),u.jsxs(a,{display:"flex",children:[u.jsx(w,{variant:"body1",mr:f.TINY,color:v=>v.palette.grey.A700,children:"استان:"}),u.jsx(w,{mr:f.TINY,fontWeight:"bold",children:y.province})," "]}),u.jsxs(a,{display:"flex",children:[u.jsx(w,{variant:"body1",mr:f.TINY,color:v=>v.palette.grey.A700,children:"شهر:"}),u.jsx(w,{mr:f.TINY,fontWeight:"bold",children:y.city})]}),u.jsxs(a,{display:"flex",children:[u.jsx(w,{variant:"body1",mr:f.TINY,color:v=>v.palette.grey.A700,children:"تاریخ تولد:"}),u.jsx(w,{mr:f.TINY,fontWeight:"bold",children:s6(y==null?void 0:y.birthday)})]}),(y==null?void 0:y.role.length)>0&&u.jsxs(a,{display:"flex",children:[u.jsx(w,{variant:"body1",mr:f.TINY,color:v=>v.palette.grey.A700,children:((g=y==null?void 0:y.role)==null?void 0:g.length)>1?"نقش ها:":"نقش:"}),u.jsx(w,{mr:f.TINY,fontWeight:"bold",children:(x=y==null?void 0:y.role)==null?void 0:x.map((v,L)=>{var N="";switch(v){case"ProvinceOperator":N="اپراتور تخصیص استان";break;case"CityOperator":N="اپراتور شهرستان";break;case"KillHouseVet":N="دامپزشک کشتارگاه";break;case"Poultry":N="مرغدار";break;case"KillHouse":N="کشتارگاه";break;case"VetFarm":N="دامپزشک";break;case"Vet":N="دامپزشک";break;case"ProvinceInspector":N="بازرس استان";break;case"ProvinceFinancial":N="اپراتور مالی";break;case"Driver":N="راننده";break;case"Admin":N="راننده";break}return[u.jsxs(a,{display:"flex",gap:f.TINY,children:[u.jsx(g6,{color:"primary"}),u.jsx(w,{children:N})]},L)]})})]}),((nu=y==null?void 0:y.image)==null?void 0:nu.length)>5&&u.jsx(u.Fragment,{children:u.jsxs(a,{display:"flex",children:[u.jsx(w,{variant:"body1",mr:f.TINY,color:v=>v.palette.grey.A700,children:"پروفایل:"}),u.jsx(a,{mr:f.TINY,children:u.jsx("a",{href:y.image,children:u.jsx("img",{width:"100",height:"100",alt:"img",src:y.image})})})]})})]})})};Ru.propTypes={userData:e6.PropTypes.any};const _6=y=>{const[g]=A.useContext(Ou),[x,nu]=A.useState([]),[v,L]=A.useState([]),[N,Au]=A.useState(),[D,pu]=A.useState(),[su,vu]=A.useState(),[O,yu]=A.useState(),[Cu,gu]=A.useState(),[X,xu]=A.useState(),[hu,ku]=A.useState(),[mu,Pu]=A.useState(),[tu,Nu]=A.useState(),[Eu,bu]=A.useState(),[C,h]=A.useState(!1),[I,M]=A.useState(!0),[m,G]=A.useState(),o=Mu(),s=eu({initialValues:{mobile:"",fname:"",lname:"",nationalcode:"",password:"",birthday:Vu(Date()).format("YYYY-MM-DD hh:mm:ss")},validationSchema:ru({mobile:W().required("این فیلد اجباری است!").typeError("لطفا فیلد را به صورت عددی وارد کنید!").test("len","شماره تلفن باید با 0 شروع شود",(e,r)=>r.originalValue&&r.originalValue.startsWith("0")).test("len","شماره تماس 11 رقم باید باشد",(e,r)=>{if(r.originalValue)return r.originalValue.length===11}),fname:Y().required("این فیلد اجباری است!").typeError("لطفا فیلد را پر کنید!"),lname:Y().required("این فیلد اجباری است!").typeError("لطفا فیلد را پر کنید!"),nationalcode:W().required("این فیلد اجباری است!").test("len","کد ملی میبایست ده رقم باشد.",(e,r)=>{if(r.originalValue)return r.originalValue.length===10}),password:Y().required("این فیلد اجباری است!").typeError("لطفا مقادیر را به درستی وارد کنید!")})}),E=eu({initialValues:{KillHousePostal:"",KillHouseCapacity:"",KillHousePhone:"",KillHouseAddress:""},validationSchema:ru({KillHousePostal:W().typeError("لطفا فیلد را به درستی وارد کنید!"),KillHouseCapacity:W().typeError("لطفا فیلد را به صورت عددی وارد کنید!"),KillHousePhone:W().typeError("لطفا فیلد را به صورت عددی وارد کنید!").test("len","شماره تلفن باید با 0 شروع شود",(e,r)=>r.originalValue&&r.originalValue.startsWith("0")).test("len","شماره تماس 11 رقم باید باشد",(e,r)=>{if(r.originalValue)return r.originalValue.length===11}),KillHouseAddress:Y().typeError("لطفا فیلد را به درستی وارد کنید!")})}),P=eu({initialValues:{KillHouseVetPostal:"",KillHouseVetAddress:""},validationSchema:ru({KillHouseVetPostal:W().typeError("لطفا فیلد را به درستی وارد کنید!"),KillHouseVetAddress:Y().typeError("لطفا فیلد را به درستی وارد کنید!")})}),k=eu({initialValues:{cityProvinceAddress:"",cityProvincePostalCode:""},validationSchema:ru({cityProvinceAddress:Y().required("این فیلد اجباری است!").typeError("لطفا فیلد را به درستی وارد کنید!"),cityProvincePostalCode:W().required("این فیلد اجباری است!").typeError("لطفا فیلد را به درستی وارد کنید!")})}),c=eu({initialValues:{bankName:"",cardNumber:"",accountNumber:"",shabaNumber:"",accountHolder:""},validationSchema:ru({cardNumber:W().typeError("لطفا شماره کارتتان را وارد کنید!"),accountNumber:W().typeError("لطفا شماره حسابتان را وارد کنید!"),shabaNumber:W().typeError("لطفا شماره شبا را وارد کنید!"),accountHolder:Y().typeError("لطفا نام صاحب حساب را وارد کنید!")})}),j=eu({initialValues:{type_car:"ایسوزو",type_weight:"سنگین",capocity:"",health_code:""},validationSchema:ru({type_weight:Y().typeError("لطفا فیلد را به درستی وارد کنید!"),capocity:Y().typeError("لطفا فیلد را به درستی وارد کنید!"),name:Y().typeError("لطفا فیلد را به درستی وارد کنید!"),health_code:W().typeError("لطفا فیلد را به درستی وارد کنید!").required("این فیلد اجباری است!")})});A.useEffect(()=>{s.validateForm(),R.validateForm(),E.validateForm(),k.validateForm(),c.validateForm(),j.validateForm(),P.validateForm()},[]);const R=eu({initialValues:{userInfoCheck:""},validationSchema:ru({userInfoCheck:W().required("این فیلد اجباری است!").typeError("لطفا فیلد را به درستی وارد کنید!")})}),[F,zu]=C6.useState(),Uu=e=>{zu(e.target.value)};A.useEffect(()=>{var e;o(V()),(e=o(j6()))==null||e.then(r=>{o(_()),nu(r.payload.data)})},[]),A.useEffect(()=>{o(_()),N?(o(V()),o(cu(N)).then(e=>{L(e.payload.data),M(!1),o(_())})):su?(o(V()),o(cu(su)).then(e=>{L(e.payload.data),M(!1),o(_())})):O?(o(V()),o(cu(O)).then(e=>{L(e.payload.data),M(!1),o(_())})):tu?(o(V()),o(cu(tu)).then(e=>{L(e.payload.data),M(!1),o(_())})):hu&&(o(V()),o(cu(hu)).then(e=>{L(e.payload.data),M(!1),o(_())}),o(_()))},[N,su,tu,hu,O]);const[U,wu]=A.useState(!1),[ju,Yu]=A.useState([]),qu=(e,r,p,t)=>{Yu([e,r,p,t])};A.useEffect(()=>{(m||s.isValid&&D&&N)&&wu(!0)},[m]);const $u=e=>{if(m)switch(e){case"Poultry":return!(U&&mu);case"KillHouse":return!(U&&Cu);case"Driver":return!(U&&j.isValid);case"ProvinceOperator":return!(U&&k.isValid);case"CityOperator":return!(U&&k.isValid);case"VetFarm":return!(U&&k.isValid);case"ProvinceInspector":return!(U&&k.isValid);case"ProvinceFinancial":return!(U&&k.isValid);case"KillHouseVet":return!(U&&O&&X&&P.isValid);default:return!(U&&e)}else return!(s.isValid&&D&&N)},[J,S]=A.useState([{id:0,killHouseAddress:"",postal:"",shift_work_from:"",shift_work_to:"",province:"",city:"",name:"",capacity:"",killing_race:"",phone:"",bankName:"",cardNumber:"",accountNumber:"",shabaNumber:"",accountHolder:""}]),Du=()=>{S(e=>[...e,{id:e.length,killHouseAddress:"",postal:"",shift_work_from:"",shift_work_to:"",province:"",city:"",name:"",capacity:"",killing_race:"",phone:"",bankName:"",cardNumber:"",accountNumber:"",shabaNumber:"",accountHolder:""}])},Gu=e=>{let r=J.length-1;if(r!==0){let p=J.filter((t,n)=>n<r);S(p)}},T=(e,r,p)=>{let t,n,B;r?(t=r,[n,,B]=e.target.id.split("-")):(t=e.target.value,[n,B]=e.target.name.split("-")),n==="shift_work_from"?S(b=>{const d=b;return d[B].shift_work_from=t,d}):n==="shift_work_to"?S(b=>{const d=b;return d[B].shift_work_to=t,d}):n==="killHouseAddress"?S(b=>{const d=b;return d[B].killHouseAddress=t,d}):n==="postal"?S(b=>{const d=b;return d[B].postal=t,d}):n==="capacity"?S(b=>{const d=b;return d[B].capacity=Number(t),d}):n==="name"?S(b=>{const d=b;return d[B].name=t,d}):n==="killing_race"?S(b=>{const d=b;return d[B].killing_race=t,d}):n==="phone"?S(b=>{const d=b;return d[B].phone=Number(t),d}):n==="province"?(o(V()),o(cu(t)).then(b=>{L(b.payload.data),M(!1),o(_())}),S(b=>{const d=b;return d[p].province=t,d})):n==="city"?S(b=>{const d=b;return d[p].city=t,d}):n==="bankName"?S(b=>{const d=b;return d[B].bankName=e.target.value,d}):n==="cardNumber"?S(b=>{const d=b;return d[B].cardNumber=Number(e.target.value),d}):n==="accountNumber"?S(b=>{const d=b;return d[B].accountNumber=Number(e.target.value),d}):n==="shabaNumber"?S(b=>{const d=b;return d[B].shabaNumber=Number(e.target.value),d}):n==="accountHolder"&&S(b=>{const d=b;return d[B].accountHolder=e.target.value,d})},[Fu,H]=A.useState([{id:0,uniqueID:"",poultryAddress:"",halls:"",systemCode:"",epidemiologicalCode:"",unitName:"",capacity:"",licenseNumber:"",postal:"",bankName:"",cardNumber:"",accountNumber:"",shabaNumber:"",accountHolder:"",province:"",city:""}]),Xu=()=>{H(e=>[...e,{id:e.length,uniqueID:"",poultryAddress:"",halls:"",systemCode:"",epidemiologicalCode:"",unitName:"",capacity:"",licenseNumber:"",postal:"",bankName:"",cardNumber:"",accountNumber:"",shabaNumber:"",accountHolder:"",province:"",city:""}])},Ju=e=>{let r=Fu.length-1;if(r!==0){let p=Fu.filter((t,n)=>n<r);H(p)}},K=e=>{const[r,p]=e.target.name.split("-");r==="uniqueID"?H(t=>{const n=t;return n[p].uniqueID=e.target.value,n}):r==="poultryAddress"?H(t=>{const n=t;return n[p].poultryAddress=e.target.value,n}):r==="halls"?H(t=>{const n=t;return n[p].halls=Number(e.target.value),n}):r==="systemCode"?H(t=>{const n=t;return n[p].systemCode=Number(e.target.value),n}):r==="epidemiologicalCode"?H(t=>{const n=t;return n[p].epidemiologicalCode=Number(e.target.value),n}):r==="ownerName"?H(t=>{const n=t;return n[p].ownerName=e.target.value,n}):r==="unitName"?H(t=>{const n=t;return n[p].unitName=e.target.value,n}):r==="capacity"?H(t=>{const n=t;return n[p].capacity=Number(e.target.value),n}):r==="licenseNumber"?H(t=>{const n=t;return n[p].licenseNumber=Number(e.target.value),n}):r==="postal"?H(t=>{const n=t;return n[p].postal=Number(e.target.value),n}):r==="bankName"?H(t=>{const n=t;return n[p].bankName=e.target.value,n}):r==="cardNumber"?H(t=>{const n=t;return n[p].cardNumber=Number(e.target.value),n}):r==="accountNumber"?H(t=>{const n=t;return n[p].accountNumber=Number(e.target.value),n}):r==="shabaNumber"?H(t=>{const n=t;return n[p].shabaNumber=Number(e.target.value),n}):r==="accountHolder"?H(t=>{const n=t;return n[p].accountHolder=e.target.value,n}):r==="province"?(ku(e.target.value),H(t=>{const n=t;return n[p].province=e.target.value,n})):r==="city"&&(Pu(e.target.value),H(t=>{const n=t;return n[p].city=e.target.value,n}))},[_u,Qu]=A.useState(),[Zu,u6]=A.useState();return A.useEffect(()=>{F==="KillHouseVet"&&(o(V()),o(y6()).then(e=>{Qu(e.payload.data),o(_())}))},[F]),u.jsx(a,{container:!0,display:"block",gap:f.SMALL,direction:"column",flex:"1",height:"100%",justifyContent:"space-between",children:u.jsxs(a,{container:!0,direction:"column",gap:f.SMALL,children:[!C&&u.jsxs(u.Fragment,{children:[u.jsx(w,{children:"بررسی کاربر"}),u.jsxs(a,{display:"flex",width:1,children:[u.jsx(i,{fullWidth:!0,id:"userInfoCheck",label:"شماره موبایل، کد کاربری یا کد ملی",variant:"outlined",value:R.values.userInfoCheck,error:R.touched.userInfoCheck?!!R.errors.userInfoCheck:null,onChange:R.handleChange,onBlur:R.handleBlur,helperText:R.touched.userInfoCheck&&R.errors.userInfoCheck?R.errors.userInfoCheck:null}),u.jsx(du,{disabled:!R.isValid,"aria-label":"delete",color:"primary",onClick:()=>{o(V()),o(x6({type:"check_user",value:R.values.userInfoCheck})).then(e=>{o(_()),e.error?e.error.message.includes("409")&&g({vertical:"top",horizontal:"center",msg:"کاربر پیدا نشد، یک کاربر جدید بسازید!",severity:"error"}):e.payload.data?G(e.payload.data.profile):(g({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}),o(au({right:!1,bottom:!1,content:null})))}),h(!0)},children:u.jsx(F6,{})})]}),u.jsx(r6,{children:"شماره موبایل با صفر شروع می‌شود!"})]}),C&&u.jsxs(u.Fragment,{children:[m?u.jsx(Ru,{userData:m}):u.jsxs(u.Fragment,{children:[u.jsx(a,{children:u.jsx(i,{id:"fname",label:"نام",variant:"outlined",sx:{width:"100%"},value:s.values.fname,error:s.touched.fname?!!s.errors.fname:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.fname&&s.errors.fname?s.errors.fname:null})}),u.jsx(a,{children:u.jsx(i,{id:"lname",label:"نام خانوادگی ",variant:"outlined",sx:{width:"100%"},value:s.values.lname,error:s.touched.lname?!!s.errors.lname:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.lname&&s.errors.lname?s.errors.lname:null})}),u.jsx(a,{children:u.jsx(i,{id:"mobile",label:"موبایل",variant:"outlined",sx:{width:"100%"},value:s.values.mobile,error:s.touched.mobile?!!s.errors.mobile:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.mobile&&s.errors.mobile?s.errors.mobile:null})}),u.jsx(a,{children:u.jsx(t6,{fullWidth:!0,label:"تاریخ تولد",id:"birthday",renderInput:e=>u.jsx(i,{...e}),value:s.values.birthday,error:s.touched.birthday?!!s.errors.birthday:null,onChange:e=>{s.setFieldValue("birthday",Vu(e).format("YYYY-MM-DD hh:mm:ss"))},onBlur:s.handleBlur,helperText:s.touched.birthday&&s.errors.birthday?s.errors.birthday:null})}),u.jsx(a,{children:u.jsx(z,{disablePortal:!0,id:"province",options:x==null?void 0:x.map(e=>({id:e.key,label:e.name})),onChange:(e,r)=>{Au(r.id)},renderInput:e=>u.jsx(i,{...e,label:"استان را انتخاب کنید*"})})}),u.jsx(a,{children:u.jsx(z,{disabled:I,disablePortal:!0,id:"city",options:v==null?void 0:v.map(e=>({id:e.key,label:e.name})),onChange:(e,r)=>{pu(r.id)},renderInput:e=>u.jsx(i,{...e,label:"شهر را انتخاب کنید*"})})}),u.jsx(a,{children:u.jsx(i,{id:"password",label:"رمز عبور",type:"password",variant:"outlined",sx:{width:"100%"},value:s.values.password,error:s.touched.password?!!s.errors.password:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.password&&s.errors.password?s.errors.password:null})}),u.jsx(a,{children:u.jsx(i,{id:"nationalcode",label:"کد ملی",variant:"outlined",sx:{width:"100%"},value:s.values.nationalcode,error:s.touched.nationalcode?!!s.errors.nationalcode:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.nationalcode&&s.errors.nationalcode?s.errors.nationalcode:null})})]}),m&&u.jsx(a,{children:u.jsxs(Q,{children:[u.jsx(Z,{id:"demo-simple-select-helper-label",children:m?"افزودن نقش":"نوع کاربر"}),u.jsxs(uu,{fullWidth:!0,value:F,label:m?"افزودن نقش":"نوع کاربر",onChange:Uu,children:[!m.role.includes("CityOperator")&&u.jsx(l,{value:"CityOperator",children:"شهرستان"}),!m.role.includes("ProvinceOperator")&&u.jsx(l,{value:"ProvinceOperator",children:"استان"}),!m.role.includes("KillHouse")&&u.jsx(l,{value:"KillHouse",children:"کشتارگاه"}),u.jsx(l,{value:"Poultry",children:"مرغدار"}),!m.role.includes("VetFarm")&&u.jsx(l,{value:"VetFarm",children:"دامپزشک"}),!m.role.includes("ProvinceFinancial")&&u.jsx(l,{value:"ProvinceFinancial",children:"اپراتور مالی"}),!m.role.includes("ProvinceInspector")&&u.jsx(l,{value:"ProvinceInspector",children:"بازرس استان"}),!m.role.includes("Driver")&&u.jsx(l,{value:"Driver",children:"راننده"}),!m.role.includes("KillHouseVet")&&u.jsx(l,{disabled:m==null?void 0:m.role.includes("KillHouseVet"),value:"KillHouseVet",children:"دامپزشک کشتارگاه"})]})]})}),Fu.map((e,r)=>u.jsx(u.Fragment,{children:F==="Poultry"&&u.jsxs(u.Fragment,{children:[u.jsx(q,{children:u.jsx($,{label:"اطلاعات مرغدار "+(r+1)})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"شناسه یکتا مرغدار",variant:"outlined",onChange:K,name:"uniqueID-"+r})}),u.jsx(a,{children:u.jsxs(Q,{fullWidth:!0,children:[u.jsx(Z,{id:"demo-simple-select-label",children:"استان *"}),u.jsx(uu,{fullWidth:!0,id:"province",label:"استان *",onChange:K,name:"province-"+r,children:x==null?void 0:x.map(p=>[u.jsx(l,{value:p.key,children:p.name},p.key)])})]})}),u.jsx(a,{children:u.jsxs(Q,{fullWidth:!0,disabled:I,children:[u.jsx(Z,{id:"demo-simple-select-label",children:"شهر *"}),u.jsx(uu,{fullWidth:!0,id:"city",label:"شهر *",onChange:K,name:"city-"+r,children:v?v.map(p=>[u.jsx(l,{value:p.key,children:p.name},p.key)]):[]})]})}),u.jsx(a,{children:u.jsx(i,{error:!1,fullWidth:!0,label:"آدرس مرغداری",variant:"outlined",onChange:K,name:"poultryAddress-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"تعداد سالن",variant:"outlined",onChange:K,name:"halls-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"کد سیستمی",variant:"outlined",onChange:K,name:"systemCode-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"کد اپیدمیولوژیک",variant:"outlined",onChange:K,name:"epidemiologicalCode-"+r})}),u.jsx(a,{children:u.jsx(i,{error:!1,fullWidth:!0,label:"نام واحد",variant:"outlined",onChange:K,name:"unitName-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"ظرفیت",variant:"outlined",onChange:K,name:"capacity-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"شماره گواهی بهداشتی",variant:"outlined",onChange:K,name:"licenseNumber-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"کد پستی",variant:"outlined",onChange:K,name:"postal-"+r})}),u.jsx(q,{children:u.jsx($,{label:"اطلاعات بانکی مرغدار "+(r+1)})}),u.jsx(a,{children:u.jsxs(Q,{fullWidth:!0,children:[u.jsx(Z,{id:"demo-simple-select-label",children:"بانک"}),u.jsxs(uu,{fullWidth:!0,id:"bankName",label:"بانک",onChange:K,name:"bankName-"+r,children:[u.jsx(l,{value:"موسسه افضل توس",children:"موسسه افضل توس"}),u.jsx(l,{value:"انصار",children:"انصار"}),u.jsx(l,{value:"سپه",children:"سپه"}),u.jsx(l,{value:"دی",children:"دی"}),u.jsx(l,{value:"کاب",children:"اقتصاد نوین"}),u.jsx(l,{value:"گردشگری",children:"گردشگری"}),u.jsx(l,{value:"حکمت ایرانیان",children:"حکمت ایرانیان"}),u.jsx(l,{value:"ایران زمین",children:"ایران زمین"}),u.jsx(l,{value:"کشاورزی",children:"کشاورزی"}),u.jsx(l,{value:"مسکن",children:"مسکن"}),u.jsx(l,{value:"مهر ایران",children:"مهر ایران"}),u.jsx(l,{value:"مهر اقتصاد",children:"مهر اقتصاد"}),u.jsx(l,{value:"ملت",children:"ملت"}),u.jsx(l,{value:"ملی",children:"ملی"}),u.jsx(l,{value:"پارسیان",children:"پارسیان"}),u.jsx(l,{value:"پاسارگاد",children:"پاسارگاد"}),u.jsx(l,{value:"پست بانک ایران",children:"پست بانک ایران"}),u.jsx(l,{value:"صادرات",children:"صادرات"}),u.jsx(l,{value:"سامان",children:"سامان"}),u.jsx(l,{value:"صنعت و معدن",children:"صنعت و معدن"}),u.jsx(l,{value:"سرمایه",children:"سرمایه"}),u.jsx(l,{value:"شهر",children:"شهر"}),u.jsx(l,{value:"سینا",children:"سینا"}),u.jsx(l,{value:"تجارت",children:"تجارت"}),u.jsx(l,{value:"موسسه اعتباری توسعه",children:"موسسه اعتباری توسعه"}),u.jsx(l,{value:"خاورمیانه",children:"خاورمیانه"})]})]})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"شماره کارت",variant:"outlined",onChange:K,name:"cardNumber-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"شماره حساب",variant:"outlined",onChange:K,name:"accountNumber-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"شماره شبا",variant:"outlined",onChange:K,name:"shabaNumber-"+r})}),u.jsx(a,{children:u.jsx(i,{error:!1,fullWidth:!0,label:"نام صاحب حساب",variant:"outlined",onChange:K,name:"accountHolder-"+r})}),u.jsxs(a,{container:!0,direction:"row",children:[u.jsx(du,{"aria-label":"delete",color:"success",children:u.jsx(Lu,{onClick:Xu})}),u.jsx(du,{"aria-label":"delete",color:"secondary",children:u.jsx(Wu,{onClick:Ju})})]})]})})),F==="Driver"&&u.jsxs(u.Fragment,{children:[u.jsx(q,{children:u.jsx($,{label:"اطلاعات راننده"})}),u.jsxs(a,{container:!0,mt:f.SMALL,gap:f.SMALL,alignSelf:"center",direction:{xs:"column",sm:"row"},children:[u.jsxs(Q,{fullWidth:!0,children:[u.jsx(Z,{id:"demo-simple-select-label",children:"مدل خودرو"}),u.jsxs(uu,{labelId:"demo-simple-select-label",id:"type_car",label:"مدل خودرو",value:j.values.type_car,onChange:e=>{j.setFieldValue("type_car",e.target.value)},error:j.touched.type_car?!!j.errors.type_car:null,onBlur:j.handleBlur,helperText:j.touched.type_car&&j.errors.type_car?j.errors.type_car:null,children:[u.jsx(l,{value:"ایسوزو",children:"ایسوزو"}),u.jsx(l,{value:"نیسان",children:"نیسان"}),u.jsx(l,{value:"وانت",children:"وانت"}),u.jsx(l,{value:"اف ام",children:"اف ام"}),u.jsx(l,{value:"کامیون",children:"کامیون"}),u.jsx(l,{value:"هیوندا کروس",children:"هیوندا کروس"}),u.jsx(l,{value:"بادسان",children:"بادسان"}),u.jsx(l,{value:"هیوندا",children:"هیوندا"}),u.jsx(l,{value:"کامیونت ایسوزو",children:"کامیونت ایسوزو"}),u.jsx(l,{value:"خاور بنز",children:"خاور بنز"})]})]}),u.jsx(f6,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"capocity",label:"ظرفیت خودرو (قطعه)",variant:"outlined",value:j.values.capocity,error:j.touched.capocity?!!j.errors.capocity:null,onChange:j.handleChange,onBlur:j.handleBlur,helperText:j.touched.capocity&&j.errors.capocity?j.errors.capocity:null}),u.jsx(i,{fullWidth:!0,id:"health_code",label:"کد بهداشتی*",variant:"outlined",value:j.values.health_code,error:j.touched.health_code?!!j.errors.health_code:null,onChange:j.handleChange,onBlur:j.handleBlur,helperText:j.touched.health_code&&j.errors.health_code?j.errors.health_code:null})]}),u.jsx(w,{children:"مشخصات پلاک"}),u.jsx(a,{mt:f.TINY,justifyContent:"center",sx:{display:"flex",flexDirection:"row"},children:u.jsx(k6,{width:"100%",handleChange:qu})})]}),F==="KillHouse"&&u.jsxs(u.Fragment,{children:[u.jsx(q,{children:u.jsx($,{label:"اطلاعات پایه کشتارگاه"})}),u.jsx(a,{children:u.jsx(z,{disablePortal:!0,id:"province",options:x==null?void 0:x.map(e=>({id:e.key,label:e.name})),onChange:(e,r)=>{vu(r.id)},renderInput:e=>u.jsx(i,{...e,label:"استان کشتارگاه*"})})}),u.jsx(a,{children:u.jsx(z,{disabled:I,disablePortal:!0,id:"city",options:v==null?void 0:v.map(e=>({id:e.key,label:e.name})),onChange:(e,r)=>{gu(r.id)},renderInput:e=>u.jsx(i,{...e,label:"شهر کشتارگاه*"})})}),u.jsx(a,{children:u.jsx(i,{id:"KillHouseAddress",label:"آدرس کشتارگاه",variant:"outlined",sx:{width:"100%"},value:E.values.KillHouseAddress,error:E.touched.KillHouseAddress?!!E.errors.KillHouseAddress:null,onChange:E.handleChange,onBlur:E.handleBlur,helperText:E.touched.KillHouseAddress&&E.errors.KillHouseAddress?E.errors.KillHouseAddress:null})}),u.jsx(a,{children:u.jsx(i,{id:"KillHousePostal",label:"کد پستی",variant:"outlined",sx:{width:"100%"},value:E.values.KillHousePostal,error:E.touched.KillHousePostal?!!E.errors.KillHousePostal:null,onChange:E.handleChange,onBlur:E.handleBlur,helperText:E.touched.KillHousePostal&&E.errors.KillHousePostal?E.errors.KillHousePostal:null})}),J==null?void 0:J.map((e,r)=>{var p;return u.jsxs(u.Fragment,{children:[u.jsx(q,{children:u.jsx($,{label:"کشتارگاه "+(r+1)})}),u.jsx(a,{children:u.jsx(i,{error:!1,fullWidth:!0,label:"نام کشتارگاه",variant:"outlined",onChange:T,name:"name-"+r})}),u.jsx(a,{children:u.jsx(z,{disablePortal:!0,id:"province",options:x==null?void 0:x.map(t=>({id:t.key,label:t.name})),onChange:(t,n)=>{T(t,n.id,r)},name:"province-"+r,renderInput:t=>u.jsx(i,{name:"province-"+r,...t,label:"استان *"})})}),u.jsx(a,{children:u.jsx(z,{disabled:!((p=J[0])!=null&&p.province),id:"city",options:v==null?void 0:v.map(t=>({id:t.key,label:t.name})),name:"city-"+r,onChange:(t,n)=>{T(t,n.id,r)},renderInput:t=>u.jsx(i,{name:"city-"+r,...t,label:"شهر *"})})}),u.jsx(a,{children:u.jsx(i,{error:!1,fullWidth:!0,label:"آدرس",variant:"outlined",onChange:T,name:"killHouseAddress-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"کد پستی",variant:"outlined",onChange:T,name:"postal-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"ظرفیت",variant:"outlined",onChange:T,name:"capacity-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"موبایل",variant:"outlined",onChange:T,name:"phone-"+r})}),u.jsx(q,{children:u.jsx($,{label:"اطلاعات بانکی کشتارگاه "+(r+1)})}),u.jsx(a,{children:u.jsxs(Q,{fullWidth:!0,children:[u.jsx(Z,{id:"demo-simple-select-label",children:"بانک"}),u.jsxs(uu,{fullWidth:!0,id:"bankName",label:"بانک",onChange:T,name:"bankName-"+r,children:[u.jsx(l,{value:"موسسه افضل توس",children:"موسسه افضل توس"}),u.jsx(l,{value:"انصار",children:"انصار"}),u.jsx(l,{value:"سپه",children:"سپه"}),u.jsx(l,{value:"دی",children:"دی"}),u.jsx(l,{value:"کاب",children:"اقتصاد نوین"}),u.jsx(l,{value:"گردشگری",children:"گردشگری"}),u.jsx(l,{value:"حکمت ایرانیان",children:"حکمت ایرانیان"}),u.jsx(l,{value:"ایران زمین",children:"ایران زمین"}),u.jsx(l,{value:"کشاورزی",children:"کشاورزی"}),u.jsx(l,{value:"مسکن",children:"مسکن"}),u.jsx(l,{value:"مهر ایران",children:"مهر ایران"}),u.jsx(l,{value:"مهر اقتصاد",children:"مهر اقتصاد"}),u.jsx(l,{value:"ملت",children:"ملت"}),u.jsx(l,{value:"ملی",children:"ملی"}),u.jsx(l,{value:"پارسیان",children:"پارسیان"}),u.jsx(l,{value:"پاسارگاد",children:"پاسارگاد"}),u.jsx(l,{value:"پست بانک ایران",children:"پست بانک ایران"}),u.jsx(l,{value:"صادرات",children:"صادرات"}),u.jsx(l,{value:"سامان",children:"سامان"}),u.jsx(l,{value:"صنعت و معدن",children:"صنعت و معدن"}),u.jsx(l,{value:"سرمایه",children:"سرمایه"}),u.jsx(l,{value:"شهر",children:"شهر"}),u.jsx(l,{value:"سینا",children:"سینا"}),u.jsx(l,{value:"تجارت",children:"تجارت"}),u.jsx(l,{value:"موسسه اعتباری توسعه",children:"موسسه اعتباری توسعه"}),u.jsx(l,{value:"خاورمیانه",children:"خاورمیانه"})]})]})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"شماره کارت",variant:"outlined",onChange:T,name:"cardNumber-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"شماره حساب",variant:"outlined",onChange:T,name:"accountNumber-"+r})}),u.jsx(a,{children:u.jsx(i,{inputProps:{inputMode:"numeric",pattern:"[0-9]*"},error:!1,fullWidth:!0,label:"شماره شبا",variant:"outlined",onChange:T,name:"shabaNumber-"+r})}),u.jsx(a,{children:u.jsx(i,{error:!1,fullWidth:!0,label:"نام صاحب حساب",variant:"outlined",onChange:T,name:"accountHolder-"+r})}),u.jsxs(a,{container:!0,direction:"row",children:[u.jsx(du,{"aria-label":"delete",color:"success",children:u.jsx(Lu,{onClick:Du})}),u.jsx(du,{"aria-label":"delete",color:"secondary",children:u.jsx(Wu,{onClick:Gu})})]})]})})]}),F==="KillHouseVet"&&u.jsxs(u.Fragment,{children:[u.jsx(q,{children:u.jsx($,{label:"اطلاعات دامپزشک کشتارگاه"})}),u.jsx(a,{children:u.jsx(z,{disablePortal:!0,id:"province",options:_u==null?void 0:_u.map(e=>({id:e.key,label:e.name})),onChange:(e,r)=>{u6(r.id)},renderInput:e=>u.jsx(i,{...e,label:"انتخاب کشتارگاه"})})}),u.jsx(a,{children:u.jsx(z,{disablePortal:!0,id:"province",options:x==null?void 0:x.map(e=>({id:e.key,label:e.name})),onChange:(e,r)=>{yu(r.id)},renderInput:e=>u.jsx(i,{...e,label:"استان کشتارگاه*"})})}),u.jsx(a,{children:u.jsx(z,{disabled:I,disablePortal:!0,id:"city",options:v==null?void 0:v.map(e=>({id:e.key,label:e.name})),onChange:(e,r)=>{xu(r.id)},renderInput:e=>u.jsx(i,{...e,label:"شهر کشتارگاه*"})})}),u.jsx(a,{children:u.jsx(i,{id:"KillHouseVetAddress",label:"آدرس ",variant:"outlined",sx:{width:"100%"},value:P.values.KillHouseVetAddress,error:P.touched.KillHouseAddress?!!P.errors.KillHouseVetAddress:null,onChange:P.handleChange,onBlur:P.handleBlur,helperText:P.touched.KillHouseVetAddress&&P.errors.KillHouseVetAddress?P.errors.KillHouseVetAddress:null})}),u.jsx(a,{children:u.jsx(i,{id:"KillHouseVetPostal",label:"کد پستی",variant:"outlined",sx:{width:"100%"},value:P.values.KillHouseVetPostal,error:P.touched.KillHouseVetPostal?!!P.errors.KillHouseVetPostal:null,onChange:P.handleChange,onBlur:P.handleBlur,helperText:P.touched.KillHouseVetPostal&&P.errors.KillHouseVetPostal?P.errors.KillHouseVetPostal:null})})]}),(F==="CityOperator"||F==="ProvinceOperator"||F==="VetFarm"||F==="ProvinceInspector"||F==="ProvinceFinancial")&&u.jsxs(u.Fragment,{children:[u.jsx(q,{children:u.jsx($,{label:"اطلاعات اپراتور"})}),u.jsx(a,{children:u.jsx(z,{disablePortal:!0,id:"province",options:x==null?void 0:x.map(e=>({id:e.key,label:e.name})),onChange:(e,r)=>{Nu(r.id)},renderInput:e=>u.jsx(i,{...e,label:"استان *"})})}),u.jsx(a,{children:u.jsx(z,{disabled:I,disablePortal:!0,id:"city",options:v==null?void 0:v.map(e=>({id:e.key,label:e.name})),onChange:(e,r)=>{bu(r.id)},renderInput:e=>u.jsx(i,{...e,label:"شهر *"})})}),u.jsx(a,{children:u.jsx(i,{id:"cityProvinceAddress",label:"آدرس",variant:"outlined",sx:{width:"100%"},value:k.values.cityProvinceAddress,error:k.touched.cityProvinceAddress?!!k.errors.cityProvinceAddress:null,onChange:k.handleChange,onBlur:k.handleBlur,helperText:k.touched.cityProvinceAddress&&k.errors.cityProvinceAddress?k.errors.cityProvinceAddress:null})}),u.jsx(a,{children:u.jsx(i,{id:"cityProvincePostalCode",label:"کد پستی",variant:"outlined",sx:{width:"100%"},value:k.values.cityProvincePostalCode,error:k.touched.cityProvincePostalCode?!!k.errors.cityProvincePostalCode:null,onChange:k.handleChange,onBlur:k.handleBlur,helperText:k.touched.cityProvincePostalCode&&k.errors.cityProvincePostalCode?k.errors.cityProvincePostalCode:null})})]}),(F==="CityOperator"||F==="KillHouseVet"||F==="VetFarm"||F==="ProvinceOperator"||F==="Driver"||F==="ProvinceFinancial")&&u.jsxs(u.Fragment,{children:[u.jsx(q,{children:u.jsx($,{label:"اطلاعات بانکی"})}),u.jsx(a,{children:u.jsxs(Q,{fullWidth:!0,children:[u.jsx(Z,{id:"demo-simple-select-label",children:"بانک"}),u.jsxs(uu,{fullWidth:!0,value:c.values.bankName,id:"bankName",label:"بانک",onChange:e=>{c.setFieldValue("bankName",e.target.value)},children:[u.jsx(l,{value:"موسسه افضل توس",children:"موسسه افضل توس"}),u.jsx(l,{value:"انصار",children:"انصار"}),u.jsx(l,{value:"سپه",children:"سپه"}),u.jsx(l,{value:"دی",children:"دی"}),u.jsx(l,{value:"کاب",children:"اقتصاد نوین"}),u.jsx(l,{value:"گردشگری",children:"گردشگری"}),u.jsx(l,{value:"حکمت ایرانیان",children:"حکمت ایرانیان"}),u.jsx(l,{value:"ایران زمین",children:"ایران زمین"}),u.jsx(l,{value:"کشاورزی",children:"کشاورزی"}),u.jsx(l,{value:"مسکن",children:"مسکن"}),u.jsx(l,{value:"مهر ایران",children:"مهر ایران"}),u.jsx(l,{value:"مهر اقتصاد",children:"مهر اقتصاد"}),u.jsx(l,{value:"ملت",children:"ملت"}),u.jsx(l,{value:"ملی",children:"ملی"}),u.jsx(l,{value:"پارسیان",children:"پارسیان"}),u.jsx(l,{value:"پاسارگاد",children:"پاسارگاد"}),u.jsx(l,{value:"پست بانک ایران",children:"پست بانک ایران"}),u.jsx(l,{value:"صادرات",children:"صادرات"}),u.jsx(l,{value:"سامان",children:"سامان"}),u.jsx(l,{value:"صنعت و معدن",children:"صنعت و معدن"}),u.jsx(l,{value:"سرمایه",children:"سرمایه"}),u.jsx(l,{value:"شهر",children:"شهر"}),u.jsx(l,{value:"سینا",children:"سینا"}),u.jsx(l,{value:"تجارت",children:"تجارت"}),u.jsx(l,{value:"موسسه اعتباری توسعه",children:"موسسه اعتباری توسعه"}),u.jsx(l,{value:"خاورمیانه",children:"خاورمیانه"})]})]})}),u.jsx(a,{children:u.jsx(i,{fullWidth:!0,id:"cardNumber",label:"شماره کارت",value:c.values.cardNumber,error:c.touched.cardNumber?!!c.errors.cardNumber:null,onChange:c.handleChange,onBlur:c.handleBlur,helperText:c.touched.cardNumber&&c.errors.cardNumber?c.errors.cardNumber:null,autoComplete:"current-password",variant:"outlined"})}),u.jsx(a,{children:u.jsx(i,{fullWidth:!0,id:"accountNumber",label:"شماره حساب",value:c.values.accountNumber,error:c.touched.accountNumber?!!c.errors.accountNumber:null,onChange:c.handleChange,onBlur:c.handleBlur,helperText:c.touched.accountNumber&&c.errors.accountNumber?c.errors.accountNumber:null,autoComplete:"current-password",variant:"outlined"})}),u.jsx(a,{children:u.jsx(i,{fullWidth:!0,id:"shabaNumber",label:"شماره شبا",value:c.values.shabaNumber,error:c.touched.shabaNumber?!!c.errors.shabaNumber:null,onChange:c.handleChange,onBlur:c.handleBlur,helperText:c.touched.shabaNumber&&c.errors.shabaNumber?c.errors.shabaNumber:null,autoComplete:"current-password",variant:"outlined"})}),u.jsx(a,{children:u.jsx(i,{fullWidth:!0,id:"accountHolder",label:"نام صاحب حساب",value:c.values.accountHolder,error:c.touched.accountHolder?!!c.errors.accountHolder:null,onChange:c.handleChange,onBlur:c.handleBlur,helperText:c.touched.accountHolder&&c.errors.accountHolder?c.errors.accountHolder:null,variant:"outlined"})})]}),u.jsx(a,{mb:f.SMALL,children:u.jsx(fu,{fullWidth:!0,variant:"contained",disabled:$u(F),onClick:()=>{o(V()),m?F==="ProvinceOperator"||F==="CityOperator"||F==="VetFarm"||F==="ProvinceInspector"||F==="ProvinceFinancial"?o(iu({type:F,userprofile_key:m.key,city:Eu,province:tu,address:k.values.cityProvinceAddress,postal_code:k.values.cityProvincePostalCode,user_bank_info:{name_of_bank_user:c.values.accountHolder,bank_name:c.values.bankName,card:c.values.cardNumber,shaba:c.values.shabaNumber,account:c.values.accountNumber}})).then(e=>{o(_()),e.error?e.error.message.includes("403")?g({vertical:"top",horizontal:"center",msg:"کاربر از قبل موجود است!",severity:"error"}):e.error.message.includes("406")?g({vertical:"top",horizontal:"center",msg:"اپراتور تکراری قابل ثبت نیست!",severity:"error"}):g({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(g({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),o(ou()),o(au({right:!1,bottom:!1,content:null})))}):F==="KillHouse"?o(iu({type:"KillHouse",userprofile_key:m.key,city:Cu,province:su,address:E.values.KillHouseAddress,postal_code:E.values.KillHousePostal,killhouse_data:J.map((e,r)=>({address:{city_key:e.city,province_key:e.province,address:e.killHouseAddress,postal_code:e.postal},user_bank_info:{name_of_bank_user:e.accountHolder,bank_name:e.bankName,card:e.cardNumber,shaba:e.shabaNumber,account:e.accountNumber},name:e.name,capacity:e.capacity,phone:e.phone}))})).then(e=>{o(_()),e.error?e.error.message.includes("403")?g({vertical:"top",horizontal:"center",msg:"کشتارگاه با این مشخصات از قبل موجود است!",severity:"error"}):g({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(g({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),o(ou()),o(au({right:!1,bottom:!1,content:null})))}):F==="Poultry"?o(iu({type:"Poultry",owner_key:m.key,poultry_list:Fu.map((e,r)=>({address:{province_key:e.province,city_key:e.city,address:e.poultryAddress,postal_code:e.postal},user_bank_info:{name_of_bank_user:e.accountHolder,bank_name:e.bankName,card:e.cardNumber,shaba:e.shabaNumber,account:e.accountNumber},epidemiological_code:e.epidemiologicalCode,system_code:e.systemCode,number_of_halls:e.halls,breeding_unique_id:e.uniqueID,unit_name:e.unitName,licence_number:e.licenseNumber,total_capacity:e.capacity,health_certificate_number:e.licenseNumber}))})).then(e=>{o(_()),e.payload.error?g({vertical:"top",horizontal:"center",msg:e.payload.error,severity:"error"}):(g({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),o(ou()),o(au({right:!1,bottom:!1,content:null})))}):F==="Driver"?o(iu({type:"Driver",userprofile_key:m.key,driver_name:m.fullname,driver_mobile:m.mobile,type_car:j.values.type_car,capocity:j.values.capocity,weight_without_load:"0",health_code:j.values.health_code,pelak:ju[0]+" "+ju[1]+" "+ju[2]+" "+ju[3],user_bank_info:{name_of_bank_user:c.values.accountHolder,bank_name:c.values.bankName,card:c.values.cardNumber,shaba:c.values.shabaNumber,account:c.values.accountNumber}})).then(e=>{o(au({right:!1,bottom:!1,content:null})),o(_()),e.error?e.error.message.includes("403")?g({vertical:"top",horizontal:"center",msg:"راننده با این مشخصات از قبل موجود است!",severity:"error"}):g({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(g({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),o(ou()))}):F==="KillHouseVet"&&o(iu({userprofile_key:m.key,type:"KillHouseVet",kill_house_key:Zu,city:X,province:O,address:P.values.KillHouseVetAddress,postal_code:P.values.KillHouseVetPostal,user_bank_info:{name_of_bank_user:c.values.accountHolder,bank_name:c.values.bankName,card:c.values.cardNumber,shaba:c.values.shabaNumber,account:c.values.accountNumber}})).then(e=>{o(_()),e.error?e.error.message.includes("403")?g({vertical:"top",horizontal:"center",msg:"دامپزشک کشتارگاه با این مشخصات از قبل موجود است!",severity:"error"}):g({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(g({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),o(ou()),o(au({right:!1,bottom:!1,content:null})))}):o(iu({type:"profile",fullname:s.values.fname+" "+s.values.lname,first_name:s.values.fname,last_name:s.values.lname,national_code:s.values.nationalcode,national_id:s.values.national_id,birthday:s.values.birthday,mobile:s.values.mobile,password:s.values.password,city:D,province:N,image:""})).then(e=>{o(_()),e.payload.error?g({vertical:"top",horizontal:"center",msg:e.payload.error,severity:"error"}):(g({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),G(e.payload.data),o(ou()))})},children:"ثبت اطلاعات"})})]})]})})},H6=()=>{const y=h6(),g=A6(C=>C.userSlice.authToken);A.useContext(Ou);const x=Mu(),nu=({item:C})=>{const[h,I]=A.useState(null),M=!!h,m=P=>{I(P.currentTarget)},G=()=>{I(null)},o=()=>{y(lu()==="AdminX"?o6+(C==null?void 0:C.key):lu()==="SuperAdmin"?i6+(C==null?void 0:C.key):lu()==="ProvinceOperator"?Tu+(C==null?void 0:C.key):Tu+(C==null?void 0:C.key)),G()},s=()=>{x(c6(g)),x(V()),x(d6({mobile:C==null?void 0:C.mobile,password:C==null?void 0:C.password})).then(()=>{x(_()),y("/")}),G()},E=lu()==="AdminX"||lu()==="SuperAdmin";return u.jsxs(a,{children:[u.jsx(Su,{title:"تنظیمات",placement:"right-start",children:u.jsx(du,{"aria-label":"actions",color:"primary",className:"avicultureActiveRequestsBtn",onClick:m,children:u.jsx(b6,{})})}),u.jsx(l6,{open:M,anchorEl:h,onClose:G,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},children:u.jsxs(a6,{sx:{minWidth:200,p:1},children:[u.jsxs(Ku,{onClick:o,children:[u.jsx(Bu,{children:u.jsx(m6,{fontSize:"small",color:"primary"})}),u.jsx(Iu,{primary:u.jsx(w,{variant:"body2",sx:{color:"primary.main"},children:"پرونده کاربر"})})]}),E&&u.jsxs(Ku,{onClick:s,children:[u.jsx(Bu,{children:u.jsx(v6,{fontSize:"small",color:"success"})}),u.jsx(Iu,{primary:u.jsx(w,{variant:"body2",sx:{color:"success.main"},children:"ورود به پنل"})})]})]})})]})},v=C=>{gu(C.target.value)},[L,N]=A.useState([]),Au=L.length?L.join():"",[D,pu]=A.useState([]),[su,vu]=A.useState(0),[O,yu]=A.useState(10),[Cu,gu]=A.useState(""),[X,xu]=A.useState(1),[hu,ku]=A.useState([]),mu=async C=>{x(V());const h=await Hu.get(`system_user_profile/?users_info&search=filter&value=${Cu||""}&page=${C}&page_size=${O}&roles=${Au}`);x(_()),pu(h.data.results),vu(h.data.count)},Pu=C=>{mu(C),xu(C)},tu=C=>{yu(C),xu(1)},Nu=C=>lu()!=="ProvinceOperator"?[C==null?void 0:C.password]:[],Eu=()=>lu()!=="ProvinceOperator"?["کلمه عبور"]:[];A.useEffect(()=>{const C=D==null?void 0:D.map((h,I)=>{var M,m;return[X===1?I+1:I+O*(X-1)+1,h!=null&&h.fullname?h==null?void 0:h.fullname:(h==null?void 0:h.firstName)+" "+(h==null?void 0:h.lastName),u.jsxs(a,{children:[!(((M=h==null?void 0:h.role)==null?void 0:M.length)>0)&&"کاربر پایه",(m=h==null?void 0:h.role)==null?void 0:m.map((G,o)=>{let s="";switch(G){case"ProvinceOperator":s="اپراتور تخصیص استان";break;case"CityOperator":s="اپراتور شهرستان";break;case"KillHouseVet":s="دامپزشک کشتارگاه";break;case"VetFarm":s="دامپزشک";break;case"Poultry":s="مرغدار";break;case"KillHouse":s="کشتارگاه";break;case"Vet":s="دامپزشک";break;case"ProvinceInspector":s="بازرس استان";break;case"ProvinceFinancial":s="اپراتور مالی";break;case"Driver":s="راننده";break;case"Admin":s="ادمین";break}return u.jsx(a,{children:s},o)})]},I),h==null?void 0:h.mobile,h==null?void 0:h.baseOrder,h==null?void 0:h.city,...Nu(h),u.jsx(nu,{item:h},I)]});ku(C)},[D]),A.useEffect(()=>{mu(1)},[x,O]);const bu=async C=>{C.preventDefault(),x(V());try{const h=await Hu.get(`system_user_profile/?users_info&search=filter&value=${Cu||""}&page=${X}&page_size=${O}&roles=${Au}`);pu(h.data.results),vu(h.data.count),x(_())}catch(h){console.error("Error fetching data:",h)}};return u.jsxs(a,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(a,{container:!0,alignItems:"center",mb:f.SMALL,gap:f.SMALL,children:[u.jsx(w,{children:"کاربران"}),u.jsx(fu,{className:"first-step",variant:"contained",onClick:()=>{x(au({title:"ثبت کاربر جدید",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(_6,{})}))},children:"ثبت کاربر جدید"}),u.jsx(E6,{size:"small",label:"فیلتر نقش",onChange:C=>N(C),options:[{label:"اپراتور تخصیص استان",value:"ProvinceOperator"},{label:"اپراتور شهرستان",value:"CityOperator"},{label:"بازرس استان",value:"ProvinceInspector"},{label:"دامپزشک",value:"VetFarm"},{label:"کشتارگاه",value:"KillHouse"},{label:"دامپزشک کشتارگاه",value:"KillHouseVet"},{label:"مرغدار",value:"Poultry"},{label:"اپراتور مالی",value:"ProvinceFinancial"},{label:"راننده",value:"Driver"},{label:"ادمین",value:"Admin"}]}),u.jsx("form",{onSubmit:bu,children:u.jsxs(a,{container:!0,alignItems:"center",gap:f.SMALL,children:[u.jsx(i,{size:"small",autoComplete:"off",label:"جستجو",variant:"outlined",style:{width:250},onChange:v}),u.jsx(fu,{type:"submit",onClick:bu,endIcon:u.jsx(P6,{}),children:"جستجو"})]})}),u.jsx(a,{children:u.jsx(Su,{title:"خروجی اکسل",children:u.jsx("a",{href:`${Hu.defaults.baseURL}get_all_user_excel/`,rel:"noreferrer",children:u.jsx(fu,{color:"success",children:u.jsx(N6,{size:32})})})})})]}),u.jsx(p6,{data:hu,columns:["ردیف","نام کامل","نوع کاربری","شماره تلفن","کد کاربری","شهر",...Eu(),"عملیات"],handlePageChange:Pu,totalRows:su,page:X,perPage:O,handlePerRowsChange:tu,title:"مدیریت کاربران"})]})},w6=()=>u.jsx(a,{container:!0,xs:12,alignItems:"start",gap:f.SMALL,direction:"column",children:u.jsx(a,{width:"100%",mt:f.SMALL,children:u.jsx(H6,{})})}),Z6=()=>u.jsx(u.Fragment,{children:u.jsx(n6,{display:"flex",justifyContent:"center",children:u.jsx(a,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,children:u.jsx(a,{container:!0,justifyContent:"space-between",gap:f.SMALL,children:u.jsx(a,{xs:12,children:u.jsx(w6,{})})})})})});export{Z6 as default};