Files
Rasadyar_FrontEnd/build/assets/InspectorEditAviculture-MsTqlKJp.js
2026-01-19 15:40:45 +03:30

2 lines
13 KiB
JavaScript

import{a as k,u as S}from"./redux-vendor-B7uoacJt.js";import{j as W,A as q,u as H,c as O,M as y,b as x,v as w,L as E,h as N,G as l,S as G,W as Z,e4 as L,N as R}from"./index-CeyyVc1v.js";import{j as e,ak as s,B as M,p as o,al as D,ag as uu,av as eu,aw as ru,ax as a}from"./mui-vendor-CkIVaoQP.js";import{r as t}from"./react-vendor-CmFgShSM.js";import{c as U,a as Y}from"./city-get-city-qTSRxslT.js";const iu=k("INSPECTOR_CHANGE_USER_STATE",async C=>{const{data:p,status:m}=await W.delete("system_user_profile/0/",{params:C});return{data:p,status:m}}),z=k("INSPECTOR_UPDATE_USER_PROFILE",async C=>{const{data:p,status:m}=await W.put("system_user_profile/0/",C);return{data:p,status:m}}),au=({id:C,birthday:p,nationalCode:m,nationalId:b,firstName:F,lastName:f,password:j,phone:B})=>{const[d]=t.useContext(q),[,_]=t.useState([]),[,T]=t.useState([]),[A]=t.useState(),[,P]=t.useState(!0),i=S(),r=H({initialValues:{fname:F||"",lname:f||"",nationalcode:b||"",nationalId:m||"",password:j||"",phone:B||"",birthday:p||w(Date()).format("YYYY-MM-DD hh:mm:ss")},validationSchema:O({fname:y().typeError("لطفا فیلد را پر کنید!"),lname:y().typeError("لطفا فیلد را پر کنید!"),nationalcode:y().typeError("لطفا مقادیر را به درستی وارد کنید!"),nationalId:x().test("len","کد ملی میبایست ده رقم باشد.",(c,v)=>{if(v.originalValue)return v.originalValue.length===10}),password:y().typeError("لطفا مقادیر را به درستی وارد کنید!")})});return t.useEffect(()=>{r.validateForm()},[]),t.useEffect(()=>{var c;(c=i(U()))==null||c.then(v=>{_(v.payload.data)})},[]),t.useEffect(()=>{A&&(i(E()),i(Y(A)).then(c=>{T(c.payload.data),P(!1),i(N())}))},[A]),e.jsx(e.Fragment,{children:e.jsx(l,{children:e.jsxs(l,{container:!0,gap:G.SMALL,direction:"column",children:[e.jsx(l,{children:e.jsx(s,{id:"fname",label:"نام",variant:"outlined",sx:{width:"100%"},value:r.values.fname,error:r.touched.fname?!!r.errors.fname:null,onChange:r.handleChange,onBlur:r.handleBlur,helperText:r.touched.fname&&r.errors.fname?r.errors.fname:null})}),e.jsx(l,{children:e.jsx(s,{id:"lname",label:"نام خانوادگی ",variant:"outlined",sx:{width:"100%"},value:r.values.lname,error:r.touched.lname?!!r.errors.lname:null,onChange:r.handleChange,onBlur:r.handleBlur,helperText:r.touched.lname&&r.errors.lname?r.errors.lname:null})}),e.jsx(l,{children:e.jsx(Z,{fullWidth:!0,label:"تاریخ تولد",id:"birthday",renderInput:c=>e.jsx(s,{...c}),value:r.values.birthday,error:r.touched.birthday?!!r.errors.birthday:null,onChange:c=>{r.setFieldValue("birthday",w(c).format("YYYY-MM-DD hh:mm:ss"))},onBlur:r.handleBlur,helperText:r.touched.birthday&&r.errors.birthday?r.errors.birthday:null})}),e.jsx(l,{children:e.jsx(s,{id:"nationalcode",label:"شماره شناسنامه",variant:"outlined",sx:{width:"100%"},value:r.values.nationalcode,error:r.touched.nationalcode?!!r.errors.nationalcode:null,onChange:r.handleChange,onBlur:r.handleBlur,helperText:r.touched.nationalcode&&r.errors.nationalcode?r.errors.nationalcode:null})}),e.jsx(l,{children:e.jsx(s,{id:"nationalId",label:"کد ملی",type:"nationalId",variant:"outlined",sx:{width:"100%"},value:r.values.nationalId,error:r.touched.nationalId?!!r.errors.nationalId:null,onChange:r.handleChange,onBlur:r.handleBlur,helperText:r.touched.nationalId&&r.errors.nationalId?r.errors.nationalId:null})}),e.jsx(l,{children:e.jsx(s,{id:"phone",label:"تلفن",variant:"outlined",sx:{width:"100%"},value:r.values.phone,error:r.touched.phone?!!r.errors.phone:null,onChange:r.handleChange,onBlur:r.handleBlur,helperText:r.touched.phone&&r.errors.phone?r.errors.phone:null})}),e.jsx(l,{children:e.jsx(s,{id:"password",label:"کلمه عبور",variant:"outlined",sx:{width:"100%"},value:r.values.password,error:r.touched.password?!!r.errors.password:null,onChange:r.handleChange,onBlur:r.handleBlur,helperText:r.touched.password&&r.errors.password?r.errors.password:null})}),e.jsx(M,{fullWidth:!0,color:"primary",variant:"contained",onClick:()=>{i(E()),i(z({type:"self_profile",person_type:"operator",userprofile_key:C,fullname:r.values.fname+" "+r.values.lname,first_name:r.values.fname,last_name:r.values.lname,national_code:r.values.nationalcode,national_id:r.values.nationalId,birthday:r.values.birthday,password:r.values.password,image:"",second_mobile_number:r.values.phone})).then(c=>{c.error?c.error.message.includes("403")?d({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):d({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):d({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),i(N()),i(L(C)),i(R({right:!1,bottom:!1,content:null}))})},children:"ارسال اطلاعات"})]})})})};au.propTypes={id:o.PropTypes.any,firstName:o.PropTypes.any,lastName:o.PropTypes.any,birthday:o.PropTypes.any,nationalCode:o.PropTypes.any,nationalId:o.PropTypes.any,password:o.PropTypes.any};const lu=({id:C,address:p,postal:m,name_of_bank_user:b,card:F,shaba:f,account:j,accountHolder:B,type:d,poultry:_,halls:T,uniqueId:A,farmName:P})=>{const[i]=t.useContext(q),[r,c]=t.useState(),[v,K]=t.useState(),[I,V]=t.useState(),[$,J]=t.useState(),[Q,X]=t.useState(!0);t.useEffect(()=>{var n;h(E()),(n=h(U()))==null||n.then(g=>{h(N()),c(g.payload.data)})},[]),t.useEffect(()=>{I&&(h(E()),h(Y(I)).then(n=>{K(n.payload.data),X(!1),h(N())}))},[I]);const h=S(),u=H({initialValues:{address:p||"",postal:m||"",bankName:b||"",cardNumber:F||"",accountNumber:j||"",shabaNumber:f||"",accountHolder:B||"",halls:T||"",uniqueId:A||"",farmName:P||""},validationSchema:O({cardNumber:x().typeError("لطفا شماره کارتتان را وارد کنید!"),accountNumber:x().typeError("لطفا شماره حسابتان را وارد کنید!"),shabaNumber:x().typeError("لطفا شماره شبا را وارد کنید!"),accountHolder:y().typeError("لطفا نام صاحب حساب را وارد کنید!"),address:y().typeError("لطفا آدرس را وارد کنید!"),postal:x().typeError("لطفا عدد وارد کنید!"),halls:x().typeError("لطفا عدد وارد کنید!"),uniqueId:x().typeError("لطفا عدد وارد کنید!")})});return t.useEffect(()=>{u.validateForm()},[]),e.jsx(e.Fragment,{children:e.jsx(l,{children:e.jsxs(l,{container:!0,gap:G.SMALL,direction:"column",children:[e.jsx(l,{children:e.jsx(s,{fullWidth:!0,id:"farmName",label:"نام فارم",value:u.values.farmName,error:u.touched.farmName?!!u.errors.farmName:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.farmName&&u.errors.farmName?u.errors.farmName:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(l,{children:e.jsx(s,{fullWidth:!0,id:"uniqueId",label:"شناسه یکتا",value:u.values.uniqueId,error:u.touched.uniqueId?!!u.errors.uniqueId:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.uniqueId&&u.errors.uniqueId?u.errors.uniqueId:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(l,{children:e.jsx(s,{fullWidth:!0,id:"address",label:"آدرس",value:u.values.address,error:u.touched.address?!!u.errors.address:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.address&&u.errors.address?u.errors.address:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(l,{children:e.jsx(s,{fullWidth:!0,id:"postal",label:"کد پستی",value:u.values.postal,error:u.touched.postal?!!u.errors.postal:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.postal&&u.errors.postal?u.errors.postal:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(l,{children:e.jsx(s,{fullWidth:!0,id:"halls",label:"تعداد سالن",value:u.values.halls,error:u.touched.halls?!!u.errors.halls:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.halls&&u.errors.halls?u.errors.halls:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(l,{children:e.jsx(D,{disablePortal:!0,id:"province",options:r?r==null?void 0:r.map(n=>({id:n.key,label:n.name})):[],onChange:(n,g)=>{V(g.id)},renderInput:n=>e.jsx(s,{...n,label:"استان را انتخاب کنید"})})}),e.jsx(l,{children:e.jsx(D,{disabled:Q,disablePortal:!0,id:"city",options:v?v.map(n=>({id:n.key,label:n.name})):[],onChange:(n,g)=>{J(g.id)},renderInput:n=>e.jsx(s,{...n,label:"شهر را انتخاب کنید"})})}),e.jsx(l,{children:e.jsxs(uu,{fullWidth:!0,disabled:d==="ProvinceOperator"||d==="ProvinceInspector",children:[e.jsx(eu,{id:"demo-simple-select-label",children:"بانک"}),e.jsxs(ru,{fullWidth:!0,value:u.values.bankName,id:"bankName",label:"بانک",onChange:n=>{u.setFieldValue("bankName",n.target.value)},children:[e.jsx(a,{value:"موسسه افضل توس",children:"موسسه افضل توس"}),e.jsx(a,{value:"انصار",children:"انصار"}),e.jsx(a,{value:"سپه",children:"سپه"}),e.jsx(a,{value:"دی",children:"دی"}),e.jsx(a,{value:"کاب",children:"اقتصاد نوین"}),e.jsx(a,{value:"گردشگری",children:"گردشگری"}),e.jsx(a,{value:"حکمت ایرانیان",children:"حکمت ایرانیان"}),e.jsx(a,{value:"ایران زمین",children:"ایران زمین"}),e.jsx(a,{value:"کشاورزی",children:"کشاورزی"}),e.jsx(a,{value:"مسکن",children:"مسکن"}),e.jsx(a,{value:"مهر ایران",children:"مهر ایران"}),e.jsx(a,{value:"مهر اقتصاد",children:"مهر اقتصاد"}),e.jsx(a,{value:"ملت",children:"ملت"}),e.jsx(a,{value:"ملی",children:"ملی"}),e.jsx(a,{value:"پارسیان",children:"پارسیان"}),e.jsx(a,{value:"پاسارگاد",children:"پاسارگاد"}),e.jsx(a,{value:"پست بانک ایران",children:"پست بانک ایران"}),e.jsx(a,{value:"صادرات",children:"صادرات"}),e.jsx(a,{value:"سامان",children:"سامان"}),e.jsx(a,{value:"صنعت و معدن",children:"صنعت و معدن"}),e.jsx(a,{value:"سرمایه",children:"سرمایه"}),e.jsx(a,{value:"شهر",children:"شهر"}),e.jsx(a,{value:"سینا",children:"سینا"}),e.jsx(a,{value:"تجارت",children:"تجارت"}),e.jsx(a,{value:"موسسه اعتباری توسعه",children:"موسسه اعتباری توسعه"}),e.jsx(a,{value:"خاورمیانه",children:"خاورمیانه"})]})]})}),e.jsx(l,{children:e.jsx(s,{disabled:d==="ProvinceOperator"||d==="ProvinceInspector",fullWidth:!0,id:"cardNumber",label:"شماره کارت",value:u.values.cardNumber,error:u.touched.cardNumber?!!u.errors.cardNumber:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.cardNumber&&u.errors.cardNumber?u.errors.cardNumber:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(l,{children:e.jsx(s,{disabled:d==="ProvinceOperator"||d==="ProvinceInspector",fullWidth:!0,id:"accountNumber",label:"شماره حساب",value:u.values.accountNumber,error:u.touched.accountNumber?!!u.errors.accountNumber:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.accountNumber&&u.errors.accountNumber?u.errors.accountNumber:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(l,{children:e.jsx(s,{disabled:d==="ProvinceOperator"||d==="ProvinceInspector",fullWidth:!0,id:"shabaNumber",label:"شماره شبا",value:u.values.shabaNumber,error:u.touched.shabaNumber?!!u.errors.shabaNumber:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.shabaNumber&&u.errors.shabaNumber?u.errors.shabaNumber:null,autoComplete:"current-password",variant:"outlined"})}),e.jsx(l,{children:e.jsx(s,{disabled:d==="ProvinceOperator"||d==="ProvinceInspector",fullWidth:!0,id:"accountHolder",label:"نام صاحب حساب",value:u.values.accountHolder,error:u.touched.accountHolder?!!u.errors.accountHolder:null,onChange:u.handleChange,onBlur:u.handleBlur,helperText:u.touched.accountHolder&&u.errors.accountHolder?u.errors.accountHolder:null,variant:"outlined"})}),e.jsx(M,{fullWidth:!0,color:"primary",variant:"contained",onClick:()=>{h(E()),h(z({user_bank_info:{name_of_bank_user:u.values.accountHolder,bank_name:u.values.bankName,card:u.values.cardNumber,shaba:u.values.shabaNumber,account:u.values.accountNumber},address:{address:u.values.address,postal_code:u.values.postal,city:$,province:I},poultry_key:_,type:d,person_type:"operator",userprofile_key:C,halls:u.values.halls,breeding_unique_id:u.values.uniqueId,unit_name:u.values.farmName})).then(n=>{n.error?n.error.message.includes("403")?i({vertical:"top",horizontal:"center",msg:"مرغداری از قبل موجود است!",severity:"error"}):n.error.message.includes("400")?i({vertical:"top",horizontal:"center",msg:"شناسه یکتا تکراریست!",severity:"error"}):i({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):i({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),h(N()),h(L(C)),h(R({right:!1,bottom:!1,content:null}))})},children:"ارسال اطلاعات"})]})})})};lu.propTypes={id:o.PropTypes.any,address:o.PropTypes.any,postal:o.PropTypes.any,name_of_bank_user:o.PropTypes.any,bank_name:o.PropTypes.any,card:o.PropTypes.any,shaba:o.PropTypes.any,account:o.PropTypes.any,accountHolder:o.PropTypes.any,type:o.PropTypes.any,poultry:o.PropTypes.any,halls:o.PropTypes.any,uniqueId:o.PropTypes.any};export{au as I,iu as a,lu as b,z as i};