Files
Rasadyar_FrontEnd/build/assets/ProvinceJahadRequests-BBBiyhzq.js
2026-01-19 16:15:09 +03:30

2 lines
112 KiB
JavaScript
Raw 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,a3 as au,ak as w,al as Du,T as tu,B as V,I as m,b0 as zu,d as Z,ai as _u,b5 as Yu,i as M6,aU as c0,ag as qu,bi as i0,ah as q6,aj as u6,b2 as Y6,b3 as e6,aX as Gu,av as i6,aw as C6,ax as ju,$ as C0,ae as h0,b as r6,Y as d0,cC as Ku,cD as g0,cE as p0,cF as A0,cG as x0}from"./mui-vendor-CkIVaoQP.js";import{r as o,f as G6}from"./react-vendor-CmFgShSM.js";import{L as z,j as D,h as P,A as nu,c as $u,M as G,u as Bu,N as eu,S as lu,G as d,O as pu,C as vu,X as O,b as gu,r as K6,a7 as v0,lr as y0,c5 as a6,ls as h6,lt as Z6,lu as X6,lv as mu,lw as d6,lx as g6,ly as Q6,lz as m6,lA as p6,lB as A6,lC as x6,v as su,V as U6,_ as t6,W as Fu,m as j0,kv as f0,kw as _0,lD as F0,lE as S0,lF as E0,lG as b0,lH as k0,lI as I0,lJ as P0,ky as w0,lK as T0,lL as L0,lM as R0,lN as $0,lO as B0,lP as O0}from"./index-BHF9XhlR.js";import{R as yu,a as fu}from"./index.esm-Bu7XMDZU.js";import{R as ou}from"./ResponsiveTable-cmj--TTX.js";import{a as Q,u as X,f as Nu}from"./redux-vendor-B7uoacJt.js";import{d as Wu}from"./Tune-rHyTJYQA.js";import{d as Uu}from"./Edit-DE-0ja3Q.js";import{d as y6}from"./Delete-BMbGwban.js";import{c as j6,a as f6}from"./city-get-city-CdvCnXwQ.js";import{S as o6}from"./SimpleTable-OFQqh0WK.js";import{d as D0}from"./Search-D4DyWpQE.js";import{d as N0}from"./Add-B14uoYzg.js";import{N as Zu}from"./NavLink-D2GD_ItM.js";import{L as Xu}from"./LinkItem-B0NRrkKX.js";import{n as z0,o as W0,p as U0,q as J0}from"./index.esm-CjWvmHks.js";import{B as V0}from"./BackButton-C3p7AEJl.js";import{N as Mu}from"./NumberFormatCustom-DwWPj40N.js";import{d as l6}from"./ToggleOffOutlined-BtQ-d6uH.js";import{d as s6}from"./ToggleOn-9h7KsYVp.js";import"./iconBase-BEJYyZsk.js";import"./FilterAlt-C5yvLNoT.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./index-CV2Xug6a.js";import"./Close-Daz6UZes.js";const H0=Q("PROVINCE-JAHAD-DELETE-UNIONS-SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.delete("/LiveStock/union/union-view/0/?key="+e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),u0=Q("PROVINCE_JAHAD_UPDATE_PRODUCT_SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.put("LiveStock/union/union-view/0/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),M0=Q("PROVINCE_JAHAD_SUBMIT_PRODUCT_SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.post("LiveStock/union/union-view/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),e0=({updateTable:e,item:r})=>{var q,I,T,F,p,B,K;const[a,n]=o.useState([]),[x,t]=o.useState([]),[s,v]=o.useState(),[i,f]=o.useState(),[_,C]=o.useState(!0),[N]=o.useContext(nu),E=X(),l=$u().shape({name:G().required("این فیلد الزامی است"),first_name:G().required("این فیلد الزامی است"),last_name:G().required("این فیلد الزامی است"),address:G().required("این فیلد الزامی است"),nationalId:G().matches(/^\d+$/,"لطفا فقط عدد وارد کنید").length(10,"کد ملی باید ۱۰ رقم باشد").required("این فیلد الزامی است"),postalCode:G().matches(/^\d+$/,"لطفا فقط عدد وارد کنید").length(10,"کد پستی باید ۱۰ رقم باشد").required("این فیلد الزامی است"),mobile:G().matches(/^\d+$/,"لطفا فقط عدد وارد کنید").length(11,"شماره موبایل باید ۱۱ رقم باشد").required("این فیلد الزامی است")});o.useEffect(()=>{var L;E(z()),(L=E(j6()))==null||L.then(U=>{E(P()),n(U.payload.data)})},[]),o.useEffect(()=>{E(P()),s&&(E(z()),E(f6(s)).then(L=>{t(L.payload.data),C(!1),E(P())}))},[s]);const c=Bu({initialValues:{name:(r==null?void 0:r.name)||"",first_name:((q=r==null?void 0:r.user)==null?void 0:q.firstName)||"",last_name:((I=r==null?void 0:r.user)==null?void 0:I.lastName)||"",mobile:((T=r==null?void 0:r.user)==null?void 0:T.mobile)||"",address:((F=r==null?void 0:r.address)==null?void 0:F.address)||"",nationalId:(r==null?void 0:r.nationalId)||"",postalCode:((p=r==null?void 0:r.address)==null?void 0:p.postalCode)||""},validationSchema:l,enableReinitialize:!0,onSubmit:L=>{var U,$,M,J;r?E(u0({union_key:r==null?void 0:r.key,first_name:L.first_name,last_name:L.last_name,name:L.name,address:L.address,mobile:L.mobile,national_id:L.nationalId,postal_code:L.postalCode,city:i||(($=(U=r==null?void 0:r.address)==null?void 0:U.city)==null?void 0:$.name)})).then(Y=>{Y.payload.error?N({vertical:"top",horizontal:"center",msg:Y.payload.error,severity:"error"}):(N({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),E(eu({right:!1,bottom:!1,content:null})),e())}):E(M0({first_name:L.first_name,last_name:L.last_name,name:L.name,address:L.address,mobile:L.mobile,national_id:L.nationalId,postal_code:L.postalCode,city:i||((J=(M=r==null?void 0:r.address)==null?void 0:M.city)==null?void 0:J.name)})).then(Y=>{Y.payload.error?N({vertical:"top",horizontal:"center",msg:Y.payload.error,severity:"error"}):(N({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),E(eu({right:!1,bottom:!1,content:null})),e())})}}),g=()=>r?c.isValid:c.isValid&&i;return u.jsx(au,{container:!0,direction:"column",gap:lu.SMALL,children:u.jsx("form",{onSubmit:c.handleSubmit,children:u.jsxs(au,{container:!0,direction:"column",gap:lu.TINY,children:[u.jsx(w,{name:"name",label:" نام اتحادیه",fullWidth:!0,value:c.values.name,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.name&&!!c.errors.name,helperText:c.touched.name&&c.errors.name}),u.jsx(Du,{disablePortal:!0,id:"province",options:a==null?void 0:a.map(L=>({id:L.key,label:L.name})),onChange:(L,U)=>{v(U.id)},renderInput:L=>u.jsx(w,{...L,label:"استان را انتخاب کنید*"})}),u.jsx(Du,{disabled:_,disablePortal:!0,id:"city",options:x==null?void 0:x.map(L=>({id:L.key,label:L.name})),onChange:(L,U)=>{f(U.label)},renderInput:L=>u.jsx(w,{...L,label:"شهر را انتخاب کنید*"})}),r&&!i&&u.jsxs(tu,{variant:"caption",color:"error",children:["شهر: ",(K=(B=r==null?void 0:r.address)==null?void 0:B.city)==null?void 0:K.name]}),u.jsx(w,{name:"first_name",label:"نام ",fullWidth:!0,value:c.values.first_name,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.first_name&&!!c.errors.first_name,helperText:c.touched.first_name&&c.errors.first_name}),u.jsx(w,{name:"last_name",label:" نام خانوادگی",fullWidth:!0,value:c.values.last_name,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.last_name&&!!c.errors.last_name,helperText:c.touched.last_name&&c.errors.last_name}),u.jsx(w,{name:"mobile",label:"تلفن",fullWidth:!0,value:c.values.mobile,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.mobile&&!!c.errors.mobile,helperText:c.touched.mobile&&c.errors.mobile}),u.jsx(w,{name:"address",label:"آدرس ",fullWidth:!0,value:c.values.address,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.address&&!!c.errors.address,helperText:c.touched.address&&c.errors.address}),u.jsx(w,{name:"nationalId",label:"کد ملی",inputProps:{inputMode:"numeric",pattern:"[0-9]*"},fullWidth:!0,value:c.values.nationalId,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.nationalId&&!!c.errors.nationalId,helperText:c.touched.nationalId&&c.errors.nationalId}),u.jsx(w,{name:"postalCode",label:"کد پستی",fullWidth:!0,inputProps:{inputMode:"numeric",pattern:"[0-9]*"},value:c.values.postalCode,onChange:c.handleChange,onBlur:c.handleBlur,error:c.touched.postalCode&&!!c.errors.postalCode,helperText:c.touched.postalCode&&c.errors.postalCode}),u.jsx(V,{type:"submit",variant:"contained",color:"primary",disabled:!g(),children:"ثبت اطلاعات"})]})})})},q0=({item:e,updateTable:r})=>{const a=X(),[n,x]=o.useState(!1),[t,s]=o.useState(null),[v]=o.useContext(nu),i=_=>{x(!0),s(_.currentTarget)},f=()=>{x(!1),s(null)};return u.jsxs(d,{children:[u.jsx(m,{variant:"contained",color:"primary",onClick:i,children:u.jsx(Wu,{})}),u.jsx(zu,{open:n,anchorEl:t,onClose:f,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},children:u.jsx("div",{style:{padding:2},children:u.jsxs(d,{container:!0,direction:"column",alignItems:"center",justifyContent:"center",gap:1,children:[u.jsx(Z,{title:"ویرایش اتحادیه",placement:"left-start",children:u.jsx(m,{color:"primary",onClick:()=>{f(),a(eu({right:!0,top:!1,content:u.jsx(e0,{item:e,updateTable:r}),title:"ویرایش اتحادیه "}))},children:u.jsx(Uu,{})})}),u.jsx(_u,{control:u.jsx(Yu,{size:"small",checked:e==null?void 0:e.active,onChange:()=>{a(u0({union_key:e==null?void 0:e.key,active:!(e!=null&&e.active)})).then(_=>{_.payload.error?v({vertical:"top",horizontal:"center",msg:_.payload.error,severity:"error"}):(r(),v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},color:"primary"}),label:e!=null&&e.active?"فعال":"غیرفعال",style:{justifyContent:"center",alignItems:"center",display:"flex"}}),u.jsx(Z,{title:"حذف",placement:"left-start",children:u.jsx(m,{"aria-label":"delete",color:"error",onClick:()=>{f(),a(pu({title:"آیا مطمئن هستید؟",content:u.jsxs(d,{container:!0,children:[u.jsx(V,{color:"error",variant:"contained",onClick:()=>{a(H0(e==null?void 0:e.key)).then(_=>{_.payload.error?v({vertical:"top",horizontal:"center",msg:_.payload.error,severity:"error"}):(r(),a(vu()),v({vertical:"top",horizontal:"center",msg:_.payload.data.result,severity:"success"}))})},children:"تایید"}),u.jsx(V,{onClick:()=>{a(vu())},children:"لغو"})]})}))},children:u.jsx(y6,{})})})]})})})]})},Y0=()=>{const e=X(),r=T=>{f(T.target.value)},[a,n]=o.useState([]),[x,t]=o.useState(0),[s,v]=o.useState(10),[i,f]=o.useState(""),[_,C]=o.useState(1),[N,E]=o.useState([]),l=async T=>{let F;e(z()),F=await D.get(`LiveStock/union/union-view/?search=filter&value=${i}&role=${O()}&page=${T}&page_size=${s}`),e(P()),n(F.data.results),t(F.data.count)},c=T=>{l(T),C(T)},g=T=>{v(T),C(1)},q=()=>{l(_!==0?_:1)};o.useEffect(()=>{const T=a==null?void 0:a.map((F,p)=>[_===1?p+1:p+s*(_-1)+1,F==null?void 0:F.name,F==null?void 0:F.user.fullname,F==null?void 0:F.user.provinceName,F==null?void 0:F.user.cityName,F==null?void 0:F.user.mobile,F==null?void 0:F.nationalId,u.jsx(q0,{updateTable:q,item:F},p)]);E(T)},[a]),o.useEffect(()=>{l(1)},[e,s]);const I=async T=>{T.preventDefault(),e(z());try{const F=await D.get(`LiveStock/union/union-view/?search=filter&value=${i}&role=${O()}&page=${_}&page_size=${s}`);n(F.data.results),t(F.data.count),e(P())}catch(F){console.error("Error fetching data:",F)}};return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(d,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[u.jsx(V,{variant:"contained",color:"primary",onClick:()=>{e(eu({right:!0,top:!1,content:u.jsx(e0,{updateTable:q}),title:"ایجاد اتحادیه "}))},children:"ایجاد اتحادیه"}),u.jsx(d,{children:u.jsxs("form",{onSubmit:I,children:[u.jsx(w,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:r}),u.jsx(V,{type:"submit",onClick:I,endIcon:u.jsx(yu,{}),children:"جستجو"})]})})]}),u.jsx(ou,{ignoreTextsLength:!0,data:N,columns:["ردیف","نام اتحادیه","کاربر","استان","شهر","موبایل","کد ملی","عملیات"],handlePageChange:c,totalRows:x,page:_,perPage:s,handlePerRowsChange:g,title:"اتحادیه ها"})]})},r0=Q("PROVINCE_JAHAD_SUBMIT_COOPERATIVE_SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.put("/LiveStock/cooperative/cooperative-views/0/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),G0=Q("PROVINCE_JAHAD_SUBMIT_COOPERATIVE_SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.post("/LiveStock/cooperative/cooperative-views/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),n0=({updateTable:e,item:r,getDashboardData:a})=>{var I,T,F,p,B,K,L,U;const[n,x]=o.useState([]),[t,s]=o.useState([]),[v,i]=o.useState(),[f,_]=o.useState(),[C,N]=o.useState(!0),[E]=o.useContext(nu),l=X(),c=$u().shape({name:G().required("این فیلد الزامی است"),first_name:G().required("این فیلد الزامی است"),last_name:G().required("این فیلد الزامی است"),address:G().required("این فیلد الزامی است"),nationalId:G().matches(/^\d+$/,"لطفا فقط عدد وارد کنید").length(10,"کد ملی باید ۱۰ رقم باشد").required("این فیلد الزامی است"),postalCode:G().matches(/^\d+$/,"لطفا فقط عدد وارد کنید").length(10,"کد پستی باید ۱۰ رقم باشد").required("این فیلد الزامی است"),mobile:G().matches(/^\d+$/,"لطفا فقط عدد وارد کنید").length(11,"شماره موبایل باید ۱۱ رقم باشد").required("این فیلد الزامی است"),account:gu().required("این فیلد اجباری است!").typeError("صرفا اعداد شماره شبا را وارد کنید!")});o.useEffect(()=>{var $;l(z()),($=l(j6()))==null||$.then(M=>{l(P()),x(M.payload.data)})},[]),o.useEffect(()=>{l(P()),v&&(l(z()),l(f6(v)).then($=>{s($.payload.data),N(!1),l(P())}))},[v]);const g=Bu({initialValues:{name:(r==null?void 0:r.name)||"",first_name:((I=r==null?void 0:r.user)==null?void 0:I.firstName)||"",last_name:((T=r==null?void 0:r.user)==null?void 0:T.lastName)||"",mobile:((F=r==null?void 0:r.user)==null?void 0:F.mobile)||"",address:((p=r==null?void 0:r.address)==null?void 0:p.address)||"",nationalId:(r==null?void 0:r.nationalId)||"",postalCode:((B=r==null?void 0:r.address)==null?void 0:B.postalCode)||"",account:((K=r==null?void 0:r.account)==null?void 0:K.replace(/ir/gi,""))??""},validationSchema:c,enableReinitialize:!0,onSubmit:$=>{var M,J;r?l(r0({cooperative_key:r==null?void 0:r.key,first_name:$.first_name,last_name:$.last_name,name:$.name,address:$.address,mobile:$.mobile,account:"IR"+$.account,national_id:$.nationalId,postal_code:$.postalCode,city:f||((J=(M=r==null?void 0:r.address)==null?void 0:M.city)==null?void 0:J.name)})).then(Y=>{Y.payload.error?E({vertical:"top",horizontal:"center",msg:Y.payload.error,severity:"error"}):(E({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),l(eu({right:!1,bottom:!1,content:null})),e(),a())}):l(G0({first_name:$.first_name,last_name:$.last_name,name:$.name,mobile:$.mobile,address:$.address,national_id:$.nationalId,postal_code:$.postalCode,account:"IR"+$.account,city:f})).then(Y=>{Y.payload.error?E({vertical:"top",horizontal:"center",msg:Y.payload.error,severity:"error"}):(E({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),l(eu({right:!1,bottom:!1,content:null})),e(),a())})}}),q=()=>r?g.isValid:g.isValid&&f;return u.jsx(au,{container:!0,direction:"column",gap:lu.SMALL,children:u.jsx("form",{onSubmit:g.handleSubmit,children:u.jsxs(au,{container:!0,direction:"column",gap:lu.TINY,children:[u.jsx(w,{name:"name",label:" نام تعاونی",fullWidth:!0,value:g.values.name,onChange:g.handleChange,onBlur:g.handleBlur,error:g.touched.name&&!!g.errors.name,helperText:g.touched.name&&g.errors.name}),u.jsx(Du,{disablePortal:!0,id:"province",options:n==null?void 0:n.map($=>({id:$.key,label:$.name})),onChange:($,M)=>{i(M.id)},renderInput:$=>u.jsx(w,{...$,label:"استان را انتخاب کنید*"})}),u.jsx(Du,{disabled:C,disablePortal:!0,id:"city",options:t==null?void 0:t.map($=>({id:$.key,label:$.name})),onChange:($,M)=>{_(M.label)},renderInput:$=>u.jsx(w,{...$,label:"شهر را انتخاب کنید*"})}),r&&!f&&u.jsxs(tu,{variant:"caption",color:"error",children:["شهر: ",(U=(L=r==null?void 0:r.address)==null?void 0:L.city)==null?void 0:U.name]}),u.jsx(w,{name:"first_name",label:"نام ",fullWidth:!0,value:g.values.first_name,onChange:g.handleChange,onBlur:g.handleBlur,error:g.touched.first_name&&!!g.errors.first_name,helperText:g.touched.first_name&&g.errors.first_name}),u.jsx(w,{name:"last_name",label:" نام خانوادگی",fullWidth:!0,value:g.values.last_name,onChange:g.handleChange,onBlur:g.handleBlur,error:g.touched.last_name&&!!g.errors.last_name,helperText:g.touched.last_name&&g.errors.last_name}),u.jsx(w,{name:"mobile",label:"تلفن",fullWidth:!0,value:g.values.mobile,onChange:g.handleChange,onBlur:g.handleBlur,error:g.touched.mobile&&!!g.errors.mobile,helperText:g.touched.mobile&&g.errors.mobile}),u.jsx(w,{name:"address",label:"آدرس ",fullWidth:!0,value:g.values.address,onChange:g.handleChange,onBlur:g.handleBlur,error:g.touched.address&&!!g.errors.address,helperText:g.touched.address&&g.errors.address}),u.jsx(w,{name:"nationalId",label:"کد ملی",inputProps:{inputMode:"numeric",pattern:"[0-9]*"},fullWidth:!0,value:g.values.nationalId,onChange:g.handleChange,onBlur:g.handleBlur,error:g.touched.nationalId&&!!g.errors.nationalId,helperText:g.touched.nationalId&&g.errors.nationalId}),u.jsx(w,{name:"postalCode",label:"کد پستی",fullWidth:!0,inputProps:{inputMode:"numeric",pattern:"[0-9]*"},value:g.values.postalCode,onChange:g.handleChange,onBlur:g.handleBlur,error:g.touched.postalCode&&!!g.errors.postalCode,helperText:g.touched.postalCode&&g.errors.postalCode}),u.jsx(w,{name:"account",label:"شماره شبا",fullWidth:!0,inputProps:{inputMode:"numeric",pattern:"[0-9]*"},value:g.values.account,onChange:g.handleChange,onBlur:g.handleBlur,error:g.touched.account&&!!g.errors.account,helperText:g.touched.account&&g.errors.account}),u.jsx(V,{type:"submit",variant:"contained",color:"primary",disabled:!q(),children:"ثبت اطلاعات"})]})})})},K0=({item:e,updateTable:r,getDashboardData:a})=>{const[n,x]=o.useState(null),t=X(),s=C=>{x(C.currentTarget)},[v]=o.useContext(nu),i=()=>{x(null)},f=!!n,_=f?"popover":void 0;return u.jsxs(d,{container:!0,children:[u.jsx(m,{"aria-describedby":_,variant:"contained",color:"primary",onClick:s,children:u.jsx(Wu,{})}),u.jsx(zu,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:_,open:f,anchorEl:n,onClose:i,children:u.jsxs("div",{style:{padding:"20px",display:"flex",flexDirection:"column"},children:[u.jsx(Z,{title:"ویرایش",placement:"left-start",children:u.jsx(m,{"aria-label":"delete",color:"primary",onClick:()=>{i(),t(eu({title:"ویرایش اطلاعات ",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(n0,{updateTable:r,getDashboardData:a,item:e})}))},children:u.jsx(Uu,{})})}),u.jsx(_u,{control:u.jsx(Yu,{size:"small",checked:e==null?void 0:e.active,onChange:()=>{t(r0({cooperative_key:e==null?void 0:e.key,active:!(e!=null&&e.active)})).then(C=>{C.payload.error?v({vertical:"top",horizontal:"center",msg:C.payload.error,severity:"error"}):(r(),v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},color:"primary"}),label:e!=null&&e.active?"فعال":"غیرفعال",style:{justifyContent:"center",alignItems:"center",display:"flex"}})]})})]})};var _6={},Z0=M6;Object.defineProperty(_6,"__esModule",{value:!0});var a0=_6.default=void 0,X0=Z0(K6()),Q0=u;a0=_6.default=(0,X0.default)((0,Q0.jsx)("path",{d:"M18 0H6C4.34 0 3 1.34 3 3v18c0 1.66 1.34 3 3 3h12c1.66 0 3-1.34 3-3V3c0-1.66-1.34-3-3-3m-4 22h-4v-1h4zm5.25-3H4.75V3h14.5z"}),"TabletAndroid");const m0=Q("PROVINCE_JAHAD_GET_COOPERATIVES_POS_INFO",async(e,{dispatch:r})=>{r(z());const{data:a,status:n}=await D.get(`/cooperative-pos/?cooperative_key=${e}`);return r(P()),{data:a,status:n}}),ue=({item:e})=>{const r=X(),[a,n]=o.useState([]);return o.useEffect(()=>{r(m0(e.key)).then(x=>{var s;const t=(s=x.payload.data)==null?void 0:s.map((v,i)=>[i+1,v==null?void 0:v.companyName,v==null?void 0:v.posId]);n(t)})},[]),u.jsx(d,{container:!0,xs:12,children:u.jsx(o6,{columns:["ردیف","نام شرکت","شناسه POS"],data:a})})},ee=()=>{const e=X(),r=F=>{_(F.target.value)},a=Nu(F=>F.userSlice.userProfile.key),[n,x]=o.useState([]),[t,s]=o.useState(0),[v,i]=o.useState(10),[f,_]=o.useState(""),[C,N]=o.useState(1),[E,l]=o.useState([]),c=async F=>{let p;e(z()),p=await D.get(`/LiveStock/cooperative/cooperative-views/?search=filter&value=${f}&role=${O()}&page=${F}&page_size=${v}`),e(P()),x(p.data.results),s(p.data.count)},g=F=>{c(F),N(F)},q=F=>{i(F),N(1)},I=()=>{c(C!==0?C:1)};o.useEffect(()=>{const F=n==null?void 0:n.map((p,B)=>{var K,L,U,$,M;return[C===1?B+1:B+v*(C-1)+1,p==null?void 0:p.name,p==null?void 0:p.user.fullname,(L=(K=p==null?void 0:p.address)==null?void 0:K.province)==null?void 0:L.name,($=(U=p==null?void 0:p.address)==null?void 0:U.city)==null?void 0:$.name,p==null?void 0:p.user.mobile,p==null?void 0:p.nationalId,(p==null?void 0:p.account)||"-",((M=p==null?void 0:p.user)==null?void 0:M.password)||"-",u.jsx(Z,{placement:"left",title:"لیست دستگاه POS",children:u.jsx(m,{"aria-label":"delete",variant:"outlined",color:"primary",onClick:()=>{e(pu({title:`لیست دستگاه‌های POS تعاونی ${p==null?void 0:p.name}`,content:u.jsx(ue,{item:p})}))},children:u.jsx(a0,{})})},B),u.jsx(K0,{item:p,updateTable:I},B)]});l(F)},[n]),o.useEffect(()=>{c(1)},[e,v]);const T=async F=>{F.preventDefault(),e(z());try{const p=await D.get(`/LiveStock/cooperative/cooperative-views/?search=filter&value=${f}&role=${O()}&page=${C}&page_size=${v}`);x(p.data.results),s(p.data.count),e(P())}catch(p){console.error("Error fetching data:",p)}};return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(d,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[u.jsx(V,{variant:"contained",onClick:()=>{e(eu({title:"ایجاد تعاونی",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(n0,{updateTable:I})}))},children:"ایجاد تعاونی"}),u.jsx(d,{children:u.jsxs("form",{onSubmit:T,children:[u.jsx(w,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:r}),u.jsx(V,{type:"submit",onClick:T,endIcon:u.jsx(yu,{}),children:"جستجو"})]})}),u.jsx(Z,{title:"خروجی اکسل",children:u.jsx("a",{href:`${D.defaults.baseURL}live-stock-cooperatives-excel/?role=${O()}&key=${a}`,rel:"noreferrer",children:u.jsx(V,{color:"success",children:u.jsx(fu,{size:32})})})})]}),u.jsx(ou,{data:E,columns:["ردیف","نام تعاونی","کاربر","استان","شهر","موبایل","کد ملی","شماره شبا","کلمه عبور","POS","عملیات"],handlePageChange:g,totalRows:t,page:C,perPage:v,handlePerRowsChange:q,title:"تعاونی ها "})]})},re=Q("PROVINCE_JAHAD_GET_HERD_INFO_DASHBOARD_SERVICE",async(e,{dispatch:r})=>{r(z());const{data:a,status:n}=await D.get("/LiveStock/live-stock/dashboard_live_stock/",{params:{role:O(),search:"filter",value:e.search,type:e.type}});return r(P()),{data:a,status:n}}),v6=Q("PROVINCE_JAHAD_EDIT_HERD_SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.put("/LiveStock/live-stock/live-stock-view/0/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),ne=Q("PROVINCE_JAHAD_SUBMIT_HERD_SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.post("/LiveStock/live-stock/live-stock-view/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),ae=Q("PROVINCE-JAHAD-DELETE-HERD-SERVICE",async(e,{dispatch:r})=>{var a,n;r(z());try{const{data:x,status:t}=await D.delete(`/LiveStock/live-stock/live-stock-view/0/?live_stock_key=${e.live_stock_key}`);return r(P()),{data:x,status:t}}catch(x){return r(P()),{error:((n=(a=x.response)==null?void 0:a.data)==null?void 0:n.result)||"خطا در بایگانی گله"}}}),te=Q("PROVINCE_JAHAD_GET_SINGLE_RANCHER",async(e,{dispatch:r})=>{r(z());const{data:a,status:n}=await D.get("LiveStock/rancher/rancher-view/",{params:{value:e.value,search:"filter",role:O()}});return r(P()),{data:a,status:n}}),F6=({item:e,updateTable:r,getDashboardData:a,rancherKey:n})=>{const[x]=o.useContext(nu),t=X(),[s,v]=o.useState(null),i=Bu({initialValues:{herd_code:(e==null?void 0:e.herdCode)||"",type:(e==null?void 0:e.type)||"",contractor_code:(e==null?void 0:e.contractorCode)||"",agent:(e==null?void 0:e.agent)||"",unique_identifier:(e==null?void 0:e.uniqueIdentifier)||"",gender:(e==null?void 0:e.gender)||"نر",userInfoCheck:null},validationSchema:$u({...e&&{herd_code:G().required("این فیلد اجباریست!"),contractor_code:G().required("این فیلد اجباریست!")},type:G().required("این فیلد اجباریست!"),agent:G().required("این فیلد اجباریست!"),unique_identifier:G().required("این فیلد اجباریست!"),gender:G().required("این فیلد اجباریست!")}),onSubmit:f=>{e?t(v6({live_stock_key:e==null?void 0:e.key,unique_identifier:f.unique_identifier,agent:f.agent,contractor_code:f.contractor_code,gender:f.gender,type:f.type,herd_code:f.herd_code})).then(_=>{_.payload.error?x({vertical:"top",horizontal:"center",msg:_.payload.error,severity:"error"}):(x({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),t(eu({right:!1,bottom:!1,content:null})),r(),a())}):t(ne({unique_identifier:f.unique_identifier,agent:f.agent,gender:f.gender,type:f.type,rancher_key:n||(s==null?void 0:s.key)})).then(_=>{_.payload.error?x({vertical:"top",horizontal:"center",msg:_.payload.error,severity:"error"}):(x({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),t(eu({right:!1,bottom:!1,content:null})),r(),a())})}});return u.jsx(u.Fragment,{children:!n&&!s?u.jsxs(d,{children:[u.jsx(tu,{children:"جستجو کاربر"}),u.jsxs(d,{mt:lu.SMALL,display:"flex",width:1,children:[u.jsx(w,{fullWidth:!0,id:"userInfoCheck",label:"شماره موبایل، کد گله یا کد ملی دامدار",variant:"outlined",value:i.values.userInfoCheck,error:i.touched.userInfoCheck?!!i.errors.userInfoCheck:null,onChange:i.handleChange,onBlur:i.handleBlur,helperText:i.touched.userInfoCheck&&i.errors.userInfoCheck?i.errors.userInfoCheck:null}),u.jsx(m,{disabled:!i.values.userInfoCheck,"aria-label":"delete",color:"primary",onClick:()=>{t(te({value:i.values.userInfoCheck})).then(f=>{f.error?x({vertical:"top",horizontal:"center",msg:"کاربر یافت نشد",severity:"error"}):v(f.payload.data)})},children:u.jsx(D0,{})})]}),u.jsx(c0,{children:"شماره موبایل، کد گله یا کد ملی دامدار را وارد کنید"})]}):u.jsxs(d,{container:!0,justifyContent:"center",alignItems:"center",direction:"column",gap:2,children:[s&&u.jsxs(d,{container:!0,p:2,direction:"column",gap:1,xs:12,style:{border:"1px solid #d9d9d9",borderRadius:"10px",padding:"20px",backgroundColor:"#f0f0f0"},children:[u.jsxs(d,{container:!0,gap:1,xs:12,children:[u.jsx(tu,{variant:"body",children:"نام دامدای:"}),u.jsx(tu,{variant:"body2",color:"primary",children:s==null?void 0:s.name})]}),u.jsxs(d,{container:!0,gap:1,xs:12,children:[u.jsx(tu,{variant:"body",children:"کد گله:"}),u.jsx(tu,{variant:"body2",color:"primary",children:s==null?void 0:s.herdCode})]}),u.jsxs(d,{container:!0,gap:1,xs:12,children:[u.jsx(tu,{variant:"body",children:"کد اپیدمیولوژیک:"}),u.jsx(tu,{variant:"body2",color:"primary",children:s==null?void 0:s.epidemiologicalCode})]}),u.jsxs(d,{container:!0,gap:1,xs:12,children:[u.jsx(tu,{variant:"body",children:"نام گله:"}),u.jsx(tu,{variant:"body2",color:"primary",children:s==null?void 0:s.herdName})]})]}),e&&u.jsx(w,{fullWidth:!0,id:"herd_code",name:"herd_code",label:"کد گله",value:i.values.herd_code,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.herd_code&&!!i.errors.herd_code,helperText:i.touched.herd_code&&i.errors.herd_code}),u.jsx(w,{fullWidth:!0,id:"type",name:"type",label:"نوع",value:i.values.type,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.type&&!!i.errors.type,helperText:i.touched.type&&i.errors.type}),e&&u.jsx(w,{fullWidth:!0,id:"contractor_code",name:"contractor_code",label:"کد پیمانکار",value:i.values.contractor_code,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.contractor_code&&!!i.errors.contractor_code,helperText:i.touched.contractor_code&&i.errors.contractor_code}),u.jsx(w,{fullWidth:!0,id:"agent",name:"agent",label:"مامور",value:i.values.agent,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.agent&&!!i.errors.agent,helperText:i.touched.agent&&i.errors.agent}),u.jsx(w,{fullWidth:!0,id:"unique_identifier",name:"unique_identifier",label:"شناسه یکتا دام",value:i.values.unique_identifier,onChange:i.handleChange,onBlur:i.handleBlur,error:i.touched.unique_identifier&&!!i.errors.unique_identifier,helperText:i.touched.unique_identifier&&i.errors.unique_identifier}),u.jsxs(qu,{component:"fieldset",children:[u.jsx(i0,{component:"legend",children:"جنسیت"}),u.jsxs(q6,{row:!0,id:"gender",name:"gender",value:i.values.gender,onChange:i.handleChange,children:[u.jsx(_u,{value:"نر",control:u.jsx(u6,{}),label:"نر"}),u.jsx(_u,{value:"ماده",control:u.jsx(u6,{}),label:"ماده"})]}),i.touched.gender&&i.errors.gender&&u.jsx("div",{style:{color:"red"},children:i.errors.gender})]}),u.jsx(V,{disabled:!i.isValid,type:"submit",variant:"contained",color:"primary",fullWidth:!0,onClick:i.handleSubmit,children:"ثبت"})]})})};var S6={},oe=M6;Object.defineProperty(S6,"__esModule",{value:!0});var t0=S6.default=void 0,le=oe(K6()),se=u;t0=S6.default=(0,le.default)((0,se.jsx)("path",{d:"m20.55 5.22-1.39-1.68C18.88 3.21 18.47 3 18 3H6c-.47 0-.88.21-1.15.55L3.46 5.22C3.17 5.57 3 6.01 3 6.5V19c0 1.1.89 2 2 2h14c1.1 0 2-.9 2-2V6.5c0-.49-.17-.93-.45-1.28M12 9.5l5.5 5.5H14v2h-4v-2H6.5zM5.12 5l.82-1h12l.93 1z"}),"Unarchive");const ce=({item:e,updateTable:r,getDashboardData:a,dataType:n})=>{const[x,t]=o.useState(null),s=X(),[v]=o.useContext(nu),i=c=>{t(c.currentTarget)},f=()=>{t(null)},_=!!x,C=_?"popover":void 0,N=()=>{s(ae({live_stock_key:e==null?void 0:e.key})).then(c=>{c.payload.error?v({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(r(),v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),s(vu()))}),f()},E=()=>{s(v6({live_stock_key:e==null?void 0:e.key,return_from_archive:!0})).then(c=>{c.payload.error?v({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(r(),s(vu()),v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))}),f()},l=c=>{f(),s(pu({title:"آیا مطمئن هستید؟",content:u.jsxs(d,{container:!0,spacing:2,children:[u.jsx(d,{item:!0,xs:12,container:!0,justifyContent:"center",alignItems:"center",children:u.jsx(tu,{variant:"body2",children:c==="archive"?"آیا می‌خواهید این گله را به بایگانی منتقل کنید؟":"آیا می‌خواهید این گله را از بایگانی خارج کنید؟"})}),u.jsx(d,{item:!0,xs:6,children:u.jsx(V,{fullWidth:!0,variant:"contained",color:"primary",onClick:()=>{c==="archive"?N():E()},children:"بله"})}),u.jsx(d,{item:!0,xs:6,children:u.jsx(V,{fullWidth:!0,variant:"outlined",onClick:()=>s(vu()),children:"خیر"})})]})}))};return u.jsxs(d,{container:!0,children:[u.jsx(m,{"aria-describedby":C,variant:"contained",color:"primary",onClick:i,children:u.jsx(Wu,{})}),u.jsx(zu,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:C,open:_,anchorEl:x,onClose:f,children:u.jsxs("div",{style:{padding:"20px",display:"flex",flexDirection:"column"},children:[u.jsx(Z,{title:"ویرایش",placement:"left-start",children:u.jsx(m,{"aria-label":"delete",color:"primary",onClick:()=>{f(),s(eu({title:"ویرایش اطلاعات",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(F6,{updateTable:r,getDashboardData:a,item:e})}))},children:u.jsx(Uu,{})})}),u.jsx(_u,{control:u.jsx(Yu,{size:"small",checked:e==null?void 0:e.active,onChange:()=>{s(v6({live_stock_key:e==null?void 0:e.key,active:!(e!=null&&e.active)})).then(c=>{c.payload.error?v({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(r(),v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},color:"primary"}),label:e!=null&&e.active?"فعال":"غیرفعال",style:{justifyContent:"center",alignItems:"center",display:"flex"}}),n==="archive"?u.jsx(Z,{title:"برگشت از بایگانی",placement:"left-start",children:u.jsx(m,{variant:"outlined",color:"primary",onClick:()=>l("unarchive"),style:{marginTop:"10px"},children:u.jsx(t0,{})})}):u.jsx(Z,{title:"انتقال به بایگانی",placement:"left-start",children:u.jsx(m,{variant:"outlined",color:"error",onClick:()=>l("archive"),style:{marginTop:"10px"},children:u.jsx(v0,{})})})]})})]})},ie=()=>{var $,M,J,Y,W,h,b,R,A;const e=X(),r=Nu(j=>j.userSlice.userProfile.key),[a,n]=o.useState([]),[x,t]=o.useState(0),[s,v]=o.useState(10),[i,f]=o.useState(""),[_,C]=o.useState(1),[N,E]=o.useState([]),[l,c]=o.useState([]),[g,q]=o.useState("0"),I=async j=>{let y;e(z()),y=await D.get(`/LiveStock/live-stock/live-stock-view/?search=filter&value=${i}&role=${O()}&page=${j}&page_size=${s}&type=${g==="0"?"pending":"archive"}`),e(P()),n(y.data.results),t(y.data.count)},T=j=>{f(j.target.value)},F=(j,y)=>{q(y)},p=j=>{I(j),C(j)},B=j=>{v(j),C(1)},K=()=>{I(_!==0?_:1)},L=()=>{e(re({search:i,type:g==="0"?"pending":"archive"})).then(j=>{c(j.payload.data)})};o.useEffect(()=>{const j=a==null?void 0:a.map((y,k)=>{var ru,cu,iu,Cu;return[_===1?k+1:k+s*(_-1)+1,((ru=y==null?void 0:y.rancher)==null?void 0:ru.fullname)||"-",(cu=y==null?void 0:y.rancher)==null?void 0:cu.nationalId,((iu=y==null?void 0:y.rancher)==null?void 0:iu.mobile)||"-",((Cu=y==null?void 0:y.rancher)==null?void 0:Cu.city)||"-",(y==null?void 0:y.nationalIdLivestockCode)||"-",(y==null?void 0:y.herdCode)||"-",(y==null?void 0:y.type)||"-",(y==null?void 0:y.birthDay)||"-",(y==null?void 0:y.gender)||"-",y0(y==null?void 0:y.age)||"-",(y==null?void 0:y.contractorCode)||"-",(y==null?void 0:y.uniqueIdentifier)||"-",(y==null?void 0:y.agent)||"-",(y==null?void 0:y.registeringUser)||"-",(y==null?void 0:y.registeringDate)||"-",u.jsx(ce,{dataType:g==="0"?"pending":"archive",item:y,getDashboardData:L,updateTable:K},k)]});E(j)},[a]),o.useEffect(()=>{I(1)},[e,s,g]),o.useEffect(()=>{L()},[]);const U=async j=>{j.preventDefault(),e(z());try{const y=await D.get(`/LiveStock/live-stock/live-stock-view/?search=filter&value=${i}&role=${O()}&page=1&page_size=${s}&type=${g==="0"?"pending":"archive"}`);n(y.data.results),t(y.data.count),L(),e(P())}catch(y){console.error("Error fetching data:",y)}};return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(d,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[u.jsx(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:u.jsxs(Y6,{value:g,onChange:F,children:[u.jsx(e6,{value:"0",label:"فعال"}),u.jsx(e6,{value:"1",label:"بایگانی شده"})]})}),u.jsx(V,{variant:"contained","aria-label":"delete",color:"primary",onClick:()=>{e(eu({title:"ایجاد گله",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(F6,{updateTable:K,getDashboardData:L})}))},children:"ایجاد گله"}),u.jsx(d,{children:u.jsxs("form",{onSubmit:U,children:[u.jsx(w,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:T}),u.jsx(V,{type:"submit",onClick:U,endIcon:u.jsx(yu,{}),children:"جستجو"})]})}),u.jsx(Z,{title:"خروجی اکسل",children:u.jsx("a",{href:`${D.defaults.baseURL}live-stock-herds-excel/?role=${O()}&key=${r}`,rel:"noreferrer",children:u.jsx(V,{color:"success",children:u.jsx(fu,{size:32})})})})]}),u.jsx(d,{container:!0,mt:2,mb:4,isDashboard:!0,children:u.jsx(ou,{noPagination:!0,isDashboard:!0,columns:["تعداد گله","تعداد گوسفندان","تعداد بزها ","تعداد گاوها","تعداد اسب ها ","تعداد شترها","تعداد دام سبک","تعداد دام سنگین","مجموع دام ها"],data:[[($=l==null?void 0:l.liveStocksCount)==null?void 0:$.toLocaleString(),(M=l==null?void 0:l.sheep)==null?void 0:M.toLocaleString(),(J=l==null?void 0:l.goat)==null?void 0:J.toLocaleString(),(Y=l==null?void 0:l.cow)==null?void 0:Y.toLocaleString(),(W=l==null?void 0:l.horse)==null?void 0:W.toLocaleString(),(h=l==null?void 0:l.camel)==null?void 0:h.toLocaleString(),(b=l==null?void 0:l.lightLivestock)==null?void 0:b.toLocaleString(),(R=l==null?void 0:l.heavyLivestock)==null?void 0:R.toLocaleString(),(A=Math.round((l==null?void 0:l.lightLivestock)+(l==null?void 0:l.heavyLivestock)))==null?void 0:A.toLocaleString()]],title:"خلاصه اطلاعات"})}),u.jsx(ou,{data:N,columns:["ردیف","دامدار","کد ملی دامدار","موبایل","شهرستان","کد ملی دام","کد گله","گونه","تاریخ تولد","جنسیت","سن","کد پیمانکار","شناسه یکتای واحد کشاورزی","مامور","کاربر ثبت کننده","تاریخ تکمیل فرم","عملیات"],handlePageChange:p,totalRows:x,page:_,perPage:s,handlePerRowsChange:B,title:"گله ها "})]})},J6=Q("PROVINCE_JAHAD_GET_RANCHERD_INFO_DASHBOARD_SERVICE",async(e,{dispatch:r})=>{r(z());const{data:a,status:n}=await D.get("/LiveStock/rancher/dashboard_rancher",{params:{role:O(),search:"filter",value:e.search}});return r(P()),{data:a,status:n}}),Ce=Q("PROVINCE_JAHAD_GET_PRODUCT_INFO",async(e,{dispatch:r})=>{r(z());const{data:a,status:n}=await D.get("LiveStock/rancher/get_detail_rancher/",{params:{herd_code:e.herd_code}});return r(P()),{data:a,status:n}}),he=({item:e})=>{const r=X(),[a,n]=o.useState();return o.useEffect(()=>{r(Ce({herd_code:e==null?void 0:e.herdCode})).then(x=>{n(x.payload.data)})},[]),u.jsx(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",children:u.jsx(o6,{columns:["تعداد دام سبک","تعداد دام سنگین","جمع کل گله","گاو","گوسفند","بز","شتر","اسب"],data:[[a==null?void 0:a.lightLivestock,a==null?void 0:a.heavyLivestock,Math.round((a==null?void 0:a.lightLivestock)+(a==null?void 0:a.heavyLivestock)).toLocaleString(),a==null?void 0:a.cow,a==null?void 0:a.sheep,a==null?void 0:a.goat,a==null?void 0:a.camel,a==null?void 0:a.horse]]})})},c6=Q("PROVINCE_JAHAD_RANCHER_ACTIVATION",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.put("LiveStock/rancher/rancher-view/0/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),de=Q("PROVINCE_JAHAD_SUBMIT_RANCHER",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.post("LiveStock/rancher/rancher-view/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),ge=$u({mobile:G().required("این فیلد اجباری است!").min(11,"شماره موبایل باید 11 رقم باشد").max(11,"شماره موبایل باید 11 رقم باشد").matches(/^09\d{9}$/,"شماره موبایل باید با 09 شروع شود و 11 رقم باشد"),first_name:G().required("این فیلد اجباریست!"),last_name:G().required("این فیلد اجباریست!"),national_id:G().required("این فیلد اجباریست!").matches(/^\d{10}$/,"کد ملی باید 10 رقم باشد!"),postal_code:G().required("این فیلد اجباریست!"),name:G().required("این فیلد اجباریست!"),epidemiological_code:G().required("این فیلد اجباریست!"),herd_code:G().required("این فیلد اجباریست!"),herd_name:G().required("این فیلد اجباریست!")}),o0=({item:e,updateTable:r})=>{var g,q;const[a,n]=o.useState([]),[x,t]=o.useState([]),[s,v]=o.useState(),[i,f]=o.useState(),[_,C]=o.useState(!0),[N]=o.useContext(nu),E=X(),l=Bu({initialValues:{mobile:(e==null?void 0:e.mobile)||"",first_name:((g=e==null?void 0:e.user)==null?void 0:g.firstName)||"",last_name:((q=e==null?void 0:e.user)==null?void 0:q.lastName)||"",national_id:(e==null?void 0:e.nationalId)||"",postal_code:(e==null?void 0:e.postalCode)||"",name:(e==null?void 0:e.name)||"",epidemiological_code:(e==null?void 0:e.epidemiologicalCode)||"",herd_code:(e==null?void 0:e.herdCode)||"",herd_name:(e==null?void 0:e.herdName)||""},validationSchema:ge,onSubmit:I=>{e?E(c6({key:e==null?void 0:e.key,city:i||(e==null?void 0:e.city),mobile:I.mobile,first_name:I.first_name,last_name:I.last_name,national_id:I.national_id,postal_code:I.postal_code,name:I.name,epidemiological_code:I.epidemiological_code,herd_code:I.herd_code,herd_name:I.herd_name})).then(T=>{T.payload.error?N({vertical:"top",horizontal:"center",msg:T.payload.error,severity:"error"}):(N({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),E(eu({right:!1,bottom:!1,content:null})),r())}):E(de({city:i,mobile:I.mobile,first_name:I.first_name,last_name:I.last_name,national_id:I.national_id,postal_code:I.postal_code,name:I.name,epidemiological_code:I.epidemiological_code,herd_code:I.herd_code,herd_name:I.herd_name})).then(T=>{T.payload.error?N({vertical:"top",horizontal:"center",msg:T.payload.error,severity:"error"}):(N({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),E(eu({right:!1,bottom:!1,content:null})),r())})}}),c=()=>e?l.isValid:l.isValid&&i;return o.useEffect(()=>{var I;E(z()),(I=E(j6()))==null||I.then(T=>{E(P()),n(T.payload.data)})},[]),o.useEffect(()=>{E(P()),s&&(E(z()),E(f6(s)).then(I=>{t(I.payload.data),C(!1),E(P())}))},[s]),u.jsx(au,{container:!0,direction:"column",gap:lu.SMALL,children:u.jsxs(au,{container:!0,direction:"column",gap:lu.TINY,children:[u.jsx(au,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"name",name:"name",label:"نام دامداری",value:l.values.name,onChange:l.handleChange,onBlur:l.handleBlur,error:l.touched.name&&!!l.errors.name,helperText:l.touched.name&&l.errors.name})}),u.jsx(au,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"herd_name",name:"herd_name",label:"نام گله",value:l.values.herd_name,onChange:l.handleChange,onBlur:l.handleBlur,error:l.touched.herd_name&&!!l.errors.herd_name,helperText:l.touched.herd_name&&l.errors.herd_name})}),u.jsx(au,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"first_name",name:"first_name",label:"نام",value:l.values.first_name,onChange:l.handleChange,onBlur:l.handleBlur,error:l.touched.first_name&&!!l.errors.first_name,helperText:l.touched.first_name&&l.errors.first_name})}),u.jsx(au,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"last_name",name:"last_name",label:"نام خانوادگی",value:l.values.last_name,onChange:l.handleChange,onBlur:l.handleBlur,error:l.touched.last_name&&!!l.errors.last_name,helperText:l.touched.last_name&&l.errors.last_name})}),u.jsx(au,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"mobile",name:"mobile",label:"موبایل",value:l.values.mobile,onChange:l.handleChange,onBlur:l.handleBlur,error:l.touched.mobile&&!!l.errors.mobile,helperText:l.touched.mobile&&l.errors.mobile})}),u.jsx(Du,{disablePortal:!0,id:"province",options:a==null?void 0:a.map(I=>({id:I.key,label:I.name})),onChange:(I,T)=>{v(T.id)},renderInput:I=>u.jsx(w,{...I,label:"استان را انتخاب کنید*"})}),u.jsx(Du,{disabled:_,disablePortal:!0,id:"city",options:x==null?void 0:x.map(I=>({id:I.key,label:I.name})),onChange:(I,T)=>{f(T.label)},renderInput:I=>u.jsx(w,{...I,label:"شهر را انتخاب کنید*"})}),e&&!i&&u.jsxs(tu,{variant:"caption",color:"error",children:["شهر: ",e==null?void 0:e.city]}),u.jsx(au,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"national_id",name:"national_id",label:"کد ملی",value:l.values.national_id,onChange:l.handleChange,onBlur:l.handleBlur,error:l.touched.national_id&&!!l.errors.national_id,helperText:l.touched.national_id&&l.errors.national_id})}),u.jsx(au,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"postal_code",name:"postal_code",label:"کد پستی",value:l.values.postal_code,onChange:l.handleChange,onBlur:l.handleBlur,error:l.touched.postal_code&&!!l.errors.postal_code,helperText:l.touched.postal_code&&l.errors.postal_code})}),u.jsx(au,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"epidemiological_code",name:"epidemiological_code",label:"کد اپیدمیولوژیک",value:l.values.epidemiological_code,onChange:l.handleChange,onBlur:l.handleBlur,error:l.touched.epidemiological_code&&!!l.errors.epidemiological_code,helperText:l.touched.epidemiological_code&&l.errors.epidemiological_code})}),u.jsx(au,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"herd_code",name:"herd_code",label:"کد گله",value:l.values.herd_code,onChange:l.handleChange,onBlur:l.handleBlur,error:l.touched.herd_code&&!!l.errors.herd_code,helperText:l.touched.herd_code&&l.errors.herd_code})}),u.jsx(au,{item:!0,xs:12,children:u.jsx(V,{disabled:!c(),type:"submit",variant:"contained",color:"primary",fullWidth:!0,onClick:l.handleSubmit,children:"ثبت"})})]})})},pe=$u({amount:gu().required("تعداد الزامی است").integer("تعداد باید یک عدد صحیح باشد")}),Ae=({updateTable:e,item:r,getDashboardData:a})=>{const n=X(),[x]=o.useContext(nu),t=Bu({initialValues:{amount:(r==null?void 0:r.dhiAmount)||""},validationSchema:pe,onSubmit:s=>{n(c6({key:r==null?void 0:r.key,dhi_amount:s.amount})).then(v=>{v.payload.error?x({vertical:"top",horizontal:"center",msg:v.payload.error,severity:"error"}):(x({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),n(vu()),a(),e())})}});return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",children:[u.jsx(tu,{variant:"body2",color:"error",children:"در صورت وارد کردن مقدار 0 دامدار از پروژه DHI خارج میشود."}),u.jsx(w,{fullWidth:!0,id:"amount",name:"amount",label:"تعداد دام DHI",variant:"outlined",margin:"normal",value:t.values.amount,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.amount&&!!t.errors.amount,helperText:t.touched.amount&&t.errors.amount}),u.jsx(V,{type:"submit",variant:"contained",color:"primary",fullWidth:!0,onClick:t.handleSubmit,children:"ثبت"})]})},xe=Q("PROVINCE-JAHAD-DELETE-RANCHER-SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.delete("/LiveStock/rancher/rancher-view/0/?rancher_key="+e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),ve=({item:e,updateTable:r,getDashboardData:a})=>{const n=X(),[x,t]=o.useState(!1),[s,v]=o.useState(null),[i]=o.useContext(nu),f=C=>{t(!0),v(C.currentTarget)},_=()=>{t(!1),v(null)};return u.jsxs(d,{children:[u.jsx(m,{variant:"contained",color:"primary",onClick:f,children:u.jsx(Wu,{})}),u.jsx(zu,{open:x,anchorEl:s,onClose:_,anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},children:u.jsx("div",{style:{padding:10},children:u.jsxs(d,{container:!0,direction:"column",alignItems:"center",justifyContent:"center",gap:1,children:[u.jsx(Z,{title:"جزِئیات گله",placement:"left-start",children:u.jsx(m,{color:"primary",size:"small",onClick:()=>{_(),n(pu({title:"جزئیات گله",content:u.jsx(he,{item:e})}))},children:u.jsx(a6,{})})}),u.jsx(Z,{title:"DHI",placement:"left-start",children:u.jsx(V,{variant:"outlined",size:"small","aria-label":"delete",onClick:()=>{_(),n(pu({title:"DHI",content:u.jsx(Ae,{item:e,updateTable:r,getDashboardData:a})}))},children:"DHI"})}),u.jsx(Z,{title:"ایجاد گله",placement:"left-start",children:u.jsx(m,{"aria-label":"delete",color:"primary",onClick:()=>{_(),n(eu({title:"ایجاد گله برای دامدار",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(F6,{updateTable:r,getDashboardData:a,rancherKey:e==null?void 0:e.key})}))},children:u.jsx(N0,{})})}),u.jsx(Z,{title:"ویرایش دامدار",placement:"left-start",children:u.jsx(m,{color:"primary",onClick:()=>{_(),n(eu({right:!0,top:!1,content:u.jsx(o0,{item:e,updateTable:r}),title:"ویرایش دامدار "}))},children:u.jsx(Uu,{})})}),u.jsx(_u,{control:u.jsx(Yu,{size:"small",checked:(e==null?void 0:e.type)==="industrial",onChange:()=>{n(c6({key:e==null?void 0:e.key,type:(e==null?void 0:e.type)==="rural"?"industrial":"rural"})).then(C=>{C.payload.error?i({vertical:"top",horizontal:"center",msg:C.payload.error,severity:"error"}):(r(),i({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},color:"primary"}),label:(e==null?void 0:e.type)==="rural"?"روستایی":"صنعتی",style:{justifyContent:"center",alignItems:"center",display:"flex"}}),u.jsx(Z,{title:"حذف",placement:"left-start",children:u.jsx(m,{"aria-label":"delete",color:"error",onClick:()=>{_(),n(pu({title:"آیا مطمئن هستید؟",content:u.jsxs(d,{container:!0,children:[u.jsx(V,{color:"error",variant:"contained",onClick:()=>{n(xe(e==null?void 0:e.key)).then(C=>{C.payload.error?i({vertical:"top",horizontal:"center",msg:C.payload.error,severity:"error"}):(r(),n(vu()),i({vertical:"top",horizontal:"center",msg:C.payload.data.result,severity:"success"}))})},children:"تایید"}),u.jsx(V,{onClick:()=>{n(vu())},children:"لغو"})]})}))},children:u.jsx(y6,{})})})]})})})]})},ye=()=>{var K,L,U,$,M,J,Y,W,h,b;const e=X(),r=R=>{_(R.target.value)},a=Nu(R=>R.userSlice.userProfile.key),[n,x]=o.useState([]),[t,s]=o.useState(0),[v,i]=o.useState(10),[f,_]=o.useState(""),[C,N]=o.useState(1),[E,l]=o.useState([]),[c,g]=o.useState([]),q=async R=>{let A;e(z()),A=await D.get(`/LiveStock/rancher/rancher-view/?search=filter&value=${f}&role=${O()}&page=${R}&page_size=${v}`),e(P()),x(A.data.results),s(A.data.count)},I=R=>{q(R),N(R)},T=R=>{i(R),N(1)},F=()=>{q(C!==0?C:1)},p=()=>{e(J6({search:f})).then(R=>{g(R.payload.data)})};o.useEffect(()=>{p()},[]),o.useEffect(()=>{const R=n==null?void 0:n.map((A,j)=>{var y;return[C===1?j+1:j+v*(C-1)+1,(A==null?void 0:A.type)==="rural"?"روستایی":"صنعتی",A==null?void 0:A.name,A==null?void 0:A.herdCode,A==null?void 0:A.epidemiologicalCode,A==null?void 0:A.postalCode,A==null?void 0:A.unitId,A==null?void 0:A.herdName,A==null?void 0:A.nationalId,A==null?void 0:A.mobile,(A==null?void 0:A.contractorCode)||"-",A==null?void 0:A.city,(A==null?void 0:A.registeringUser)||"-",(A==null?void 0:A.type)==="rural"?"-":(y=A==null?void 0:A.dhiAmount)==null?void 0:y.toLocaleString(),u.jsx(ve,{item:A,updateTable:F,getDashboardData:p},j)]});l(R)},[n]),o.useEffect(()=>{q(1)},[e,v]);const B=async R=>{R.preventDefault(),e(z());try{const A=await D.get(`/LiveStock/rancher/rancher-view/?search=filter&value=${f}&role=${O()}&page=${C}&page_size=${v}`);x(A.data.results),s(A.data.count),e(J6({search:f})).then(j=>{g(j.payload.data)}),e(P())}catch(A){console.error("Error fetching data:",A)}};return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(d,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[u.jsx(V,{variant:"contained",color:"primary",onClick:()=>{e(eu({right:!0,top:!1,content:u.jsx(o0,{updateTable:F}),title:"ایجاد دامدار"}))},children:"ایجاد دامدار"}),u.jsx(d,{children:u.jsxs("form",{onSubmit:B,children:[u.jsx(w,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:r}),u.jsx(V,{type:"submit",onClick:B,endIcon:u.jsx(yu,{}),children:"جستجو"})]})}),u.jsx(Z,{title:"خروجی اکسل",children:u.jsx("a",{href:`${D.defaults.baseURL}live-stock-ranchers-excel/?role=${O()}&key=${a}`,rel:"noreferrer",children:u.jsx(V,{color:"success",children:u.jsx(fu,{size:32})})})})]}),u.jsx(d,{container:!0,mt:2,mb:4,isDashboard:!0,children:u.jsx(ou,{noPagination:!0,isDashboard:!0,columns:["تعداد دامداران","تعداد گوسفندان","تعداد بزها ","تعداد گاوها","تعداد اسب ها ","تعداد شترها","تعداد دام سبک","تعداد دام سنگین","تعداد دام DHI","مجموع دام ها"],data:[[(K=c==null?void 0:c.rancherCount)==null?void 0:K.toLocaleString(),(L=c==null?void 0:c.sheep)==null?void 0:L.toLocaleString(),(U=c==null?void 0:c.goat)==null?void 0:U.toLocaleString(),($=c==null?void 0:c.cow)==null?void 0:$.toLocaleString(),(M=c==null?void 0:c.horse)==null?void 0:M.toLocaleString(),(J=c==null?void 0:c.camel)==null?void 0:J.toLocaleString(),(Y=c==null?void 0:c.lightLivestock)==null?void 0:Y.toLocaleString(),(W=c==null?void 0:c.heavyLivestock)==null?void 0:W.toLocaleString(),(h=c==null?void 0:c.dhiAmount)==null?void 0:h.toLocaleString(),(b=c==null?void 0:c.liveStocksCount)==null?void 0:b.toLocaleString()]],title:"خلاصه اطلاعات"})}),u.jsx(ou,{data:E,columns:["ردیف","مجوز فعالیت","نام دامداری","کد گله","کد اپیدمیولوژیک","کد پستی","شناسه یکتا","نام گله","کد ملی دامدار","موبایل","کد پیمانکار","شهرستان","کاربر ثبت کننده","تعداد دام DHI","جزئیات"],handlePageChange:I,totalRows:t,page:C,perPage:v,handlePerRowsChange:T,title:" دامداران "})]})},je=()=>u.jsx("div",{children:"این بخش در دست توسعه است"}),fe=({product:e})=>{const{pathname:r}=G6(),a=(e==null?void 0:e.key)==="bran"?"rgba(224, 224, 224, 0.5)":(e==null?void 0:e.key)==="barley"?"rgba(245, 194, 149, 0.5)":(e==null?void 0:e.key)==="soy"?"rgba(164, 239, 204, 0.5)":(e==null?void 0:e.key)==="corn"?"rgba(193, 239, 164, 0.5)":"rgba(132, 243, 233, 0.5)";return u.jsx(d,{container:!0,gap:lu.SMALL,p:lu.SMALL,direction:{xs:"column",md:"row"},justifyContent:"center",style:{placeContent:"baseline"},children:u.jsx(d,{container:!0,direction:"column",style:{width:"100%"},children:u.jsxs(d,{container:!0,gap:lu.SMALL,justifyContent:"center",children:[u.jsx(Zu,{active:h6,to:r===mu?h6:r===d6?Z6:X6,children:u.jsx(Xu,{style:{backgroundColor:a},icon:u.jsx(z0,{size:30,color:"#244CCC"}),title:`انبار و تخصیص ${e==null?void 0:e.label}`,description:`انبار و تخصیص ${e==null?void 0:e.label}`})}),(O()==="LiveStockProvinceJahad"||O()==="Union")&&u.jsx(Zu,{active:g6,to:r===mu?g6:r===d6?Q6:m6,children:u.jsx(Xu,{style:{backgroundColor:a},icon:u.jsx(W0,{size:30,color:"#244CCC"}),title:`مدیریت توزیع ${e==null?void 0:e.label}`,description:`مدیریت توزیع ${e==null?void 0:e.label}`})}),(O()==="LiveStockProvinceJahad"||O()==="Union")&&u.jsx(Zu,{active:r===mu?p6:A6,to:O()==="LiveStockProvinceJahad"?p6:A6,children:u.jsx(Xu,{style:{backgroundColor:a},icon:u.jsx(U0,{size:30,color:"#244CCC"}),title:`گزارش فروش ${e==null?void 0:e.label}`,description:`گزارش فروش ${e==null?void 0:e.label}`})}),O()==="LiveStockProvinceJahad"&&u.jsx(Zu,{active:x6,to:x6,children:u.jsx(Xu,{style:{backgroundColor:a},icon:u.jsx(J0,{size:30,color:"#244CCC"}),title:`سهم بندی ${e==null?void 0:e.label}`,description:`سهم بندی ${e==null?void 0:e.label}`})})]})})})},_e=Q("PROVINCE_JAHAD_GET_DISTRIBUTION_INFO",async(e,{dispatch:r})=>{r(z());const{data:a,status:n}=await D.get("LiveStock/jahad/dashboard-live-stock-allocation/",{params:e});return r(P()),{data:a,status:n}}),Fe=Q("PROVINCE_JAHAD_GET_INVENTORY_INFO",async(e,{dispatch:r})=>{r(z());const{data:a,status:n}=await D.get("LiveStock/jahad/live-stock-role-products/",{params:e});return r(P()),{data:a,status:n}}),Se=Q("SLAUGHTER_GET_GUILDS_FOR_ALLOCATE_SERVICE",async(e,{dispatch:r})=>{r(z());const{data:a,status:n}=await D.get("LiveStock/jahad/get_user_live_stock/",{params:e});return r(P()),{data:a,status:n}}),Ee=Q("PROVINCE_JAHAD_SUBMIT_ALLOCATION_SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.post("LiveStock/jahad/live-stock-allocation/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),be=Q("PROVINCE_JAHAD_EDIT_ALLOCATION_SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.put("/LiveStock/jahad/live-stock-allocation/0/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),ke=Q("PROVINCE_JAHAD_DELETE_ALLOCATION",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.delete("LiveStock/jahad/live-stock-allocation/0/?allocation_key="+e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),n6=({type:e,productKey:r,updateTable:a,getDashboardData:n,item:x,maxAllow:t})=>{const s=$u({allocationType:G().required("لطفا یک گزینه را انتخاب کنید"),weight:gu().required("این فیلد اجباریست!").positive("عدد مثبت وارد کنید!"),place:G().required("این فیلد اجباریست!"),description:G()}),[v,i]=o.useState([]),f=X(),[_]=o.useContext(nu),C=Bu({initialValues:{allocationType:e==="charge"?"LiveStockProvinceJahad":"Cooperative",buyer_key:null,weight:(x==null?void 0:x.weight)||"",place:(x==null?void 0:x.place)||"",description:(x==null?void 0:x.description)||""},validationSchema:s,onSubmit:E=>{if(x){let l={allocation_key:x==null?void 0:x.key,weight:E.weight,place:E.place,description:E.description};l=Object.fromEntries(Object.entries(l).filter(([c,g])=>g!==null)),f(be(l)).then(c=>{c.payload.error?_({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(_({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),f(vu()),a(),n())})}else{let l={allocator:O(),receiver:O()==="Cooperative"?"Cooperative":E.allocationType,product_key:r,buyer_key:E.buyer_key,weight:E.weight,place:E.place,description:E.description};if(l=Object.fromEntries(Object.entries(l).filter(([c,g])=>g!==null)),t&&E.weight>t){_({vertical:"top",horizontal:"center",msg:"مقدار وارد شده از سهیه دریافتی بیشتر است!",severity:"error"});return}f(Ee(l)).then(c=>{c.payload.error?_({vertical:"top",horizontal:"center",msg:c.payload.error,severity:"error"}):(_({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),f(vu()),a(),n())})}}});o.useEffect(()=>{e!=="charge"&&!x&&(C.setFieldValue("buyer_key",null),f(Se({type:C.values.allocationType})).then(E=>{i(E.payload.data)}))},[C.values.allocationType]),o.useEffect(()=>{C.validateForm()},[]);const N=()=>e==="charge"?C.isValid:x?C.values.weight&&C.values.place&&C.values.description:C.isValid&&C.values.buyer_key;return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[e!=="charge"&&!x&&O()==="LiveStockProvinceJahad"&&u.jsx(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",children:u.jsxs(qu,{component:"fieldset",children:[u.jsxs(q6,{row:!0,name:"allocationType",value:C.values.allocationType,onChange:C.handleChange,children:[u.jsx(_u,{value:"Cooperative",control:u.jsx(u6,{}),label:"تخصیص به تعاونی"}),u.jsx(_u,{value:"Union",control:u.jsx(u6,{}),label:"تخصیص به اتحادیه"})]}),C.touched.allocationType&&C.errors.allocationType&&u.jsx(tu,{color:"error",children:C.errors.allocationType})]})}),u.jsx(d,{item:!0,xs:12,children:u.jsx(Mu,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"weight",label:"وزن",variant:"outlined",InputLabelProps:{shrink:!0},value:C.values.weight,error:C.touched.weight?!!C.errors.weight:null,onChange:C.handleChange,onBlur:C.handleBlur,helperText:C.touched.weight&&C.errors.weight?C.errors.weight:null})}),e!=="charge"&&!x&&u.jsx(d,{xs:12,container:!0,children:u.jsx(Du,{fullWidth:!0,style:{minWidth:210},disablePortal:!0,id:"hatching",options:v?v.map(E=>({data:E,label:`${E==null?void 0:E.name}`})):[],onChange:(E,l)=>{var c;C.setFieldValue("buyer_key",(c=l==null?void 0:l.data)==null?void 0:c.key)},renderInput:E=>u.jsx(w,{fullWidth:!0,...E,label:"انتخاب تخصیص گیرنده"})})}),u.jsx(w,{id:"place",label:e==="charge"?"مبدا":"مکان دریافت ",variant:"outlined",sx:{width:"100%",height:"100%"},value:C.values.place,onChange:C.handleChange,onBlur:C.handleBlur,error:C.touched.place?!!C.errors.place:null,helperText:C.touched.place&&C.errors.place?C.errors.place:null}),u.jsx(w,{id:"description",label:"توضیحات",variant:"outlined",sx:{width:"100%",height:"100%"},value:C.values.description,onChange:C.handleChange,onBlur:C.handleBlur,error:C.touched.description?!!C.errors.description:null,helperText:C.touched.description&&C.errors.description?C.errors.description:null}),u.jsx(V,{disabled:!N(),type:"submit",variant:"contained",color:"primary",fullWidth:!0,onClick:C.handleSubmit,children:x?"ویرایش":"ثبت"})]})},l0=({item:e,updateTable:r,getDashboardData:a})=>{const[n,x]=o.useState(null),t=X(),s=C=>{x(C.currentTarget)},[v]=o.useContext(nu),i=()=>{x(null)},f=!!n,_=f?"popover":void 0;return u.jsxs(d,{container:!0,children:[u.jsx(m,{"aria-describedby":_,variant:"contained",color:"primary",onClick:s,children:u.jsx(Wu,{})}),u.jsx(zu,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:_,open:f,anchorEl:n,onClose:i,children:u.jsxs("div",{style:{padding:"20px",display:"flex",flexDirection:"column"},children:[u.jsx(Z,{title:"ویرایش",placement:"left-start",children:u.jsx(m,{"aria-label":"delete",color:"primary",onClick:()=>{i(),t(pu({title:"ویرایش",content:u.jsx(n6,{updateTable:r,getDashboardData:a,item:e})}))},children:u.jsx(Uu,{})})}),u.jsx(Z,{title:"حذف ",placement:"left-start",children:u.jsx(m,{"aria-label":"delete",color:"error",onClick:()=>{t(pu({title:"حذف تخصیص",content:u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",children:[u.jsx(tu,{variant:"body2",color:"red",children:"آیا از حذف تخصیص اطمینان دارید؟"}),u.jsxs(d,{container:!0,xs:12,mt:2,justifyContent:"center",alignItems:"center",spacing:2,children:[u.jsx(d,{item:!0,xs:6,children:u.jsx(V,{onClick:()=>{t(ke(e==null?void 0:e.key)).then(C=>{C.payload.error?v({vertical:"top",horizontal:"center",msg:C.payload.error,severity:"error"}):(v({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),r(),a(),t(vu()))})},variant:"contained",color:"error",fullWidth:!0,children:"تایید"})}),u.jsx(d,{item:!0,xs:6,children:u.jsx(V,{variant:"contained",color:"primary",fullWidth:!0,children:"رد"})})]})]})}))},children:u.jsx(y6,{})})})]})})]})},Ie=({inventoryData:e,getDashboardData:r,maxAllow:a,product:n})=>{const[,,x,t,s,v]=o.useContext(nu),i=Nu(h=>h.userSlice.userProfile.key),f=X();o.useEffect(()=>{const h=su(new Date).format("YYYY-MM-DD");t(h),v(h)},[]);const[_,C]=o.useState(""),[N,E]=o.useState(!1),l=h=>{C(h.target.value)},[c,g]=o.useState([]),[q,I]=o.useState(0),[T,F]=o.useState(10),[p,B]=o.useState(1),[K,L]=o.useState([]),U=async h=>{let b;f(z()),b=await D.get(`LiveStock/jahad/live-stock-allocation/?search=filter&value=${_}&role=${O()}${N?`&date1=${x}&date2=${s}`:""}&page=${h}&page_size=${T}&name=${n==null?void 0:n.key}`),f(P()),g(b.data.results),I(b.data.count)},$=h=>{U(h),B(h)},M=h=>{F(h),B(1)};o.useEffect(()=>{const h=c==null?void 0:c.map((b,R)=>{var ru,cu,iu,Cu,Au,xu,H,S,du;const A=(b==null?void 0:b.allocateFrom)==="LiveStockProvinceJahad"?(ru=b==null?void 0:b.jahad)==null?void 0:ru.name:(cu=b==null?void 0:b.union)==null?void 0:cu.name,j=U6(b==null?void 0:b.allocateFrom),y=(b==null?void 0:b.allocateTo)==="Union"?(iu=b==null?void 0:b.union)==null?void 0:iu.name:(Cu=b==null?void 0:b.cooperative)==null?void 0:Cu.name,k=U6(b==null?void 0:b.allocateTo);return[p===1?R+1:R+T*(p-1)+1,(Au=b==null?void 0:b.weight)==null?void 0:Au.toLocaleString(),`${j} (${A})`,`${k} (${y})`,(b==null?void 0:b.allocateFrom)==="LiveStockProvinceJahad"?(H=(xu=b==null?void 0:b.jahad)==null?void 0:xu.user)==null?void 0:H.fullname:(du=(S=b==null?void 0:b.union)==null?void 0:S.user)==null?void 0:du.fullname,t6(b==null?void 0:b.date),b==null?void 0:b.place,b==null?void 0:b.description,u.jsx(l0,{updateTable:Y,item:b,getDashboardData:r},R)]});L(h)},[c]),o.useEffect(()=>{U(1)},[f,x,s,T,N]);const J=async h=>{h.preventDefault(),f(z());try{const b=await D.get(`LiveStock/jahad/live-stock-allocation/?role=${O()}&search=filter&value=${_}${N?`&date1=${x}&date2=${s}`:""}&page=1&page_size=${T}&name=${n==null?void 0:n.key}`);g(b.data.results),I(b.data.count),f(P())}catch(b){console.error("Error fetching data:",b)}},Y=()=>{U(p!==0?p:1)},W=()=>O()==="LiveStockProvinceJahad"||O()==="Union"?["ردیف","وزن (کیلوگرم)","مبدا","مقصد","ثبت کننده","تاریخ ثبت","مکان دریافت","توضیحات","عملیات"]:["ردیف","وزن (کیلوگرم)","مبدا","مقصد","ثبت کننده","تاریخ ثبت","مکان دریافت","توضیحات"];return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(d,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[(O()==="LiveStockProvinceJahad"||O()==="Union")&&u.jsxs(V,{variant:"contained",onClick:()=>{f(pu({title:`تخصیص ${n==null?void 0:n.label}`,content:u.jsx(n6,{updateTable:Y,type:"allocate",productKey:e==null?void 0:e.key,getDashboardData:r})}))},children:["تخصیص ",n==null?void 0:n.label]}),u.jsxs(d,{container:!0,gap:1,style:{borderStyle:"solid",borderWidth:"1px",padding:"5px",borderRadius:"15px",borderColor:"gray",justifyContent:"left"},alignItems:"center",children:[u.jsx(Gu,{icon:u.jsx(l6,{}),checkedIcon:u.jsx(s6,{}),checked:N,onChange:()=>E(!N),color:"primary",size:"large"}),u.jsx(d,{children:u.jsx(Fu,{disabled:!N,label:"از تاریخ",id:"date",renderInput:h=>u.jsx(w,{size:"small",style:{width:"160px"},...h}),value:x,onChange:h=>{t(su(h).format("YYYY-MM-DD"))}})}),u.jsx(d,{children:u.jsx(Fu,{disabled:!N,label:"تا تاریخ",id:"date",renderInput:h=>u.jsx(w,{size:"small",style:{width:"160px"},...h}),value:s,onChange:h=>{v(su(h).format("YYYY-MM-DD"))}})})]}),u.jsx(d,{children:u.jsxs("form",{onSubmit:J,children:[u.jsx(w,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:l}),u.jsx(V,{type:"submit",onClick:J,endIcon:u.jsx(yu,{}),children:"جستجو"})]})}),u.jsx(Z,{title:"خروجی اکسل",placement:"left-start",children:u.jsx("a",{href:`${D.defaults.baseURL}LiveStock/jahad/allocation_live_stock_excel/?search=filter&value=${_}&role=${O()}&key=${i}&name=${n==null?void 0:n.key}`,rel:"noreferrer",children:u.jsxs(V,{color:"success",children:[u.jsx(fu,{size:32})," "]})})})]}),u.jsx(ou,{ignoreTextsLength:!0,data:K,columns:W(),handlePageChange:$,totalRows:q,page:p,perPage:T,handlePerRowsChange:M,title:`تخصیصات ${n==null?void 0:n.label}`})]})},Pe=({inventoryData:e,getDashboardData:r,product:a,maxAllow:n})=>{var b;const[,,x,t,s,v]=o.useContext(nu),i=Nu(R=>R.userSlice.userProfile.key),f=X();o.useEffect(()=>{const R=su(new Date).format("YYYY-MM-DD");t(R),v(R)},[]);const[_,C]=o.useState(""),[N,E]=o.useState(!1),l=R=>{C(R.target.value)},[c,g]=o.useState([]),[q,I]=o.useState(0),[T,F]=o.useState(10),[p,B]=o.useState(1),[K,L]=o.useState([]),U=async R=>{let A;f(z()),A=await D.get(`/LiveStock/jahad/live-stock-warehouse-charge-allocation/?search=filter&value=${_}&role=${O()}${N?`&date1=${x}&date2=${s}`:""}&page=${R}&page_size=${T}&name=${a==null?void 0:a.key}`),f(P()),g(A.data.results),I(A.data.count)},$=R=>{U(R),B(R)},M=R=>{F(R),B(1)},J=R=>{var A,j,y,k;return O()==="Cooperative"?{key:[],value:[]}:{key:"ثبت کننده",value:[((j=(A=R==null?void 0:R.jahad)==null?void 0:A.user)==null?void 0:j.fullname)||((k=(y=R==null?void 0:R.union)==null?void 0:y.user)==null?void 0:k.fullname)]}};o.useEffect(()=>{const R=c==null?void 0:c.map((A,j)=>{var y,k;return[p===1?j+1:j+T*(p-1)+1,(y=A==null?void 0:A.weight)==null?void 0:y.toLocaleString(),(k=J(A))==null?void 0:k.value,t6(A==null?void 0:A.date),A==null?void 0:A.place,A==null?void 0:A.description,u.jsx(l0,{updateTable:W,item:A,getDashboardData:r},j)]});L(R)},[c]),o.useEffect(()=>{U(1)},[f,x,s,T,N]);const Y=async R=>{R.preventDefault(),f(z());try{const A=await D.get(`LiveStock/jahad/live-stock-warehouse-charge-allocation/?role=${O()}&search=filter&value=${_}${N?`&date1=${x}&date2=${s}`:""}&page=1&page_size=${T}&name=${a==null?void 0:a.key}`);g(A.data.results),I(A.data.count),f(P())}catch(A){console.error("Error fetching data:",A)}},W=()=>{U(p!==0?p:1)},h=["ردیف","وزن (کیلوگرم)",(b=J())==null?void 0:b.key,"تاریخ ثبت","مبدا","توضیحات","عملیات"];return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(d,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[O()==="LiveStockProvinceJahad"&&u.jsxs(V,{variant:"contained",onClick:()=>{f(pu({title:`شارژ انبار ${a==null?void 0:a.label}`,content:u.jsx(n6,{updateTable:W,type:"charge",productKey:e==null?void 0:e.key,getDashboardData:r})}))},children:["شارژ انبار ",a==null?void 0:a.label]}),O()==="Cooperative"&&u.jsxs(V,{variant:"contained",onClick:()=>{f(pu({title:`ورود ${a==null?void 0:a.label} به انبار`,content:u.jsx(n6,{updateTable:W,type:"charge",productKey:e==null?void 0:e.key,getDashboardData:r,maxAllow:n})}))},children:["ورود ",a==null?void 0:a.label," به انبار"]}),u.jsxs(d,{container:!0,gap:1,style:{borderStyle:"solid",borderWidth:"1px",padding:"5px",borderRadius:"15px",borderColor:"gray",justifyContent:"left"},alignItems:"center",children:[u.jsx(Gu,{icon:u.jsx(l6,{}),checkedIcon:u.jsx(s6,{}),checked:N,onChange:()=>E(!N),color:"primary",size:"large"}),u.jsx(d,{children:u.jsx(Fu,{disabled:!N,label:"از تاریخ",id:"date",renderInput:R=>u.jsx(w,{size:"small",style:{width:"160px"},...R}),value:x,onChange:R=>{t(su(R).format("YYYY-MM-DD"))}})}),u.jsx(d,{children:u.jsx(Fu,{disabled:!N,label:"تا تاریخ",id:"date",renderInput:R=>u.jsx(w,{size:"small",style:{width:"160px"},...R}),value:s,onChange:R=>{v(su(R).format("YYYY-MM-DD"))}})})]}),u.jsx(d,{children:u.jsxs("form",{onSubmit:Y,children:[u.jsx(w,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:l}),u.jsx(V,{type:"submit",onClick:Y,endIcon:u.jsx(yu,{}),children:"جستجو"})]})}),u.jsx(Z,{title:"خروجی اکسل",children:u.jsx("a",{href:`${D.defaults.baseURL}LiveStock/jahad/warehouse_live_stock_excel/?search=filter&value=${_}&role=${O()}&key=${i}&name=${a==null?void 0:a.key}`,rel:"noreferrer",children:u.jsx(V,{color:"success",children:u.jsx(fu,{size:32})})})})]}),u.jsx(ou,{data:K,columns:O()==="LiveStockProvinceJahad"||O()==="Cooperative"?[...h]:h.slice(0,-1),handlePageChange:$,totalRows:q,page:p,perPage:T,handlePerRowsChange:M,title:`شارژ انبار ${a==null?void 0:a.label}`})]})},we=({product:e})=>{var _,C,N,E,l,c,g,q,I,T,F,p,B,K,L,U,$;const[r,a]=o.useState([]),[n,x]=o.useState([]),t=X(),s=()=>{t(_e({name:e==null?void 0:e.key,search:"filter",role:O()})).then(M=>{a(M.payload.data)}),t(Fe({name:e==null?void 0:e.key,search:"filter",role:O()})).then(M=>{x(M.payload.data)})};o.useEffect(()=>{s()},[t]);const[v,i]=o.useState(0),f=(M,J)=>{i(J)};return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsx(d,{container:!0,mt:2,mb:4,isDashboard:!0,children:u.jsx(ou,{noPagination:!0,isDashboard:!0,columns:O()==="LiveStockProvinceJahad"?["ورودی به انبار","تخصیص جهاد به اتحادیه","تخصیص جهاد به تعاونی ها","مجموع تخصیصات","مجموع تخصیص اتحادیه به تعاونی","مجموع تخصیص به تعاونی ها","توزیع به دامداران","مجموع توزیع به دامداران","مانده انبار جهاد استان","مانده انبار اتحادیه","مانده انبار تعاونی ها"]:O()==="Union"?["ورودی به انبار","تخصیص به تعاونی ها","مجموع تخصیص و توزیع","مانده انبار"]:["سهمیه دریافتی","مانده سهمیه دریافتی","ورودی به انبار","توزیع به دامداران","مانده انبار"],data:O()==="LiveStockProvinceJahad"?[[(_=r==null?void 0:r.totalWeight)==null?void 0:_.toLocaleString(),(C=r==null?void 0:r.jahadToUnion)==null?void 0:C.toLocaleString(),(N=r==null?void 0:r.jahatToCooperative)==null?void 0:N.toLocaleString(),(E=r==null?void 0:r.allocationCount)==null?void 0:E.toLocaleString(),(l=r==null?void 0:r.unionToCooperative)==null?void 0:l.toLocaleString(),(c=parseInt((r==null?void 0:r.unionToCooperative)+(r==null?void 0:r.jahatToCooperative)))==null?void 0:c.toLocaleString(),0,0,(g=r==null?void 0:r.totalRemainWeightJahad)==null?void 0:g.toLocaleString(),(q=r==null?void 0:r.totalRemainWeightUnion)==null?void 0:q.toLocaleString(),(I=r==null?void 0:r.totalRemainWeightCooperative)==null?void 0:I.toLocaleString()]]:O()==="Union"?[[(T=r==null?void 0:r.jahadToUnion)==null?void 0:T.toLocaleString(),(F=r==null?void 0:r.unionToCooperative)==null?void 0:F.toLocaleString(),(p=parseInt(0+(r==null?void 0:r.unionToCooperative)))==null?void 0:p.toLocaleString(),(B=r==null?void 0:r.totalRemainWeight)==null?void 0:B.toLocaleString()]]:[[(K=r==null?void 0:r.roleProductCooperativeReceiptWeight)==null?void 0:K.toLocaleString(),(L=parseInt((r==null?void 0:r.roleProductCooperativeReceiptWeight)-(r==null?void 0:r.totalWeight)))==null?void 0:L.toLocaleString(),(U=r==null?void 0:r.totalWeight)==null?void 0:U.toLocaleString(),0,($=r==null?void 0:r.totalRemainWeight)==null?void 0:$.toLocaleString()]],title:`اطلاعات انبار و تخصیصات ${e==null?void 0:e.label}`})}),u.jsx(d,{container:!0,justifyContent:"center",alignItems:"center",mb:lu.MEDIUM,mt:lu.SMALL,xs:12,children:u.jsxs(Y6,{scrollButtons:"auto",variant:"scrollable",allowScrollButtonsMobile:!0,value:v,onChange:f,children:[u.jsx(e6,{label:"انبار"}),u.jsx(e6,{label:"تخصیصات"})]})}),v===0&&u.jsx(Pe,{inventoryData:n,getDashboardData:s,product:e,maxAllow:r==null?void 0:r.roleProductCooperativeReceiptWeight}),v===1&&u.jsx(Ie,{inventoryData:n,getDashboardData:s,maxAllow:r==null?void 0:r.roleProductCooperativeReceiptWeight,product:e})]})},Te=Q("PROVINCE_JAHAD_GET_PRODUCT_INFO",async(e,{dispatch:r})=>{r(z());const{data:a,status:n}=await D.get("LiveStock/jahad/live-stock-product/",{params:{name:e.product}});return r(P()),{data:a,status:n}}),Le=Q("PROVINCE_JAHAD_UPDATE_PRODUCT_SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.put("LiveStock/jahad/live-stock-product/0/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),Re=({item:e,updateTable:r})=>{const a=X(),[n]=o.useContext(nu),x=$u({light_weight:gu().required("این فیلد اجباری است!"),heavy_weight:gu().required("این فیلد اجباری است!"),light_wight_industrial:gu().required("این فیلد اجباری است!"),heavy_wight_industrial:gu().required("این فیلد اجباری است!"),light_wight_dha:gu().required("این فیلد اجباری است!"),heavy_wight_dha:gu().required("این فیلد اجباری است!"),price:gu().required("این فیلد اجباری است!").positive("عدد مثبت وارد کنید!"),unionPrice:gu().required("این فیلد اجباری است!").positive("عدد مثبت وارد کنید!"),cooperativePrice:gu().required("این فیلد اجباری است!").positive("عدد مثبت وارد کنید!"),shippingPrice:gu().required("این فیلد اجباری است!").positive("عدد مثبت وارد کنید!")}),t=Bu({initialValues:{light_weight:e.lightWight||0,heavy_weight:e.heavyWight||0,light_wight_industrial:e.lightWightIndustrial||0,heavy_wight_industrial:e.heavyWightIndustrial||0,light_wight_dha:e.lightWightDha||0,heavy_wight_dha:e.heavyWightDha||0,price:e.price||0,unionPrice:e.unionPrice||0,cooperativePrice:e.cooperativePrice||0,shippingPrice:e.shippingPrice||0},validationSchema:x,onSubmit:s=>{a(Le({key:e==null?void 0:e.key,light_wight:s.light_weight,heavy_wight:s.heavy_weight,light_wight_industrial:s.light_wight_industrial,heavy_wight_industrial:s.heavy_wight_industrial,light_wight_dha:s.light_wight_dha,heavy_wight_dha:s.heavy_wight_dha,price:s.price,union_price:s.unionPrice,cooperative_price:s.cooperativePrice,shipping_price:s.shippingPrice})).then(v=>{v.payload.error?n({vertical:"top",horizontal:"center",msg:v.payload.error,severity:"error"}):(r(),n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),a(eu({right:!1,bottom:!1,content:null})))})}});return o.useEffect(()=>{t.validateForm()},[a]),u.jsxs(d,{container:!0,xs:12,alignItems:"center",justifyContent:"center",gap:1,children:[u.jsx(d,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"light_weight",name:"light_weight",label:"سهمیه دام سبک روستایی",value:t.values.light_weight,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.light_weight&&!!t.errors.light_weight,helperText:t.touched.light_weight&&t.errors.light_weight})}),u.jsx(d,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"heavy_weight",name:"heavy_weight",label:"سهمیه دام سنگین روستایی",value:t.values.heavy_weight,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.heavy_weight&&!!t.errors.heavy_weight,helperText:t.touched.heavy_weight&&t.errors.heavy_weight})}),u.jsx(d,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"light_wight_industrial",name:"light_wight_industrial",label:"سهمیه دام سبک صنعتی",value:t.values.light_wight_industrial,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.light_wight_industrial&&!!t.errors.light_wight_industrial,helperText:t.touched.light_wight_industrial&&t.errors.light_wight_industrial})}),u.jsx(d,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"heavy_wight_industrial",name:"heavy_wight_industrial",label:"سهمیه دام سنگین صنعتی",value:t.values.heavy_wight_industrial,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.heavy_wight_industrial&&!!t.errors.heavy_wight_industrial,helperText:t.touched.heavy_wight_industrial&&t.errors.heavy_wight_industrial})}),u.jsx(d,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"light_wight_dha",name:"light_wight_dha",label:"سهمیه دام سبک DHA",value:t.values.light_wight_dha,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.light_wight_dha&&!!t.errors.light_wight_dha,helperText:t.touched.light_wight_dha&&t.errors.light_wight_dha})}),u.jsx(d,{item:!0,xs:12,children:u.jsx(w,{fullWidth:!0,id:"heavy_wight_dha",name:"heavy_wight_dha",label:"سهمیه دام سنگین DHA",value:t.values.heavy_wight_dha,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.heavy_wight_dha&&!!t.errors.heavy_wight_dha,helperText:t.touched.heavy_wight_dha&&t.errors.heavy_wight_dha})}),u.jsx(d,{item:!0,xs:12,children:u.jsx(Mu,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"price",label:"قیمت هر کیلو (ریال)",variant:"outlined",value:t.values.price,error:t.touched.price?!!t.errors.price:null,onChange:t.handleChange,onBlur:t.handleBlur,helperText:t.touched.price&&t.errors.price?t.errors.price:null})}),u.jsx(d,{item:!0,xs:12,children:u.jsx(Mu,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"unionPrice",label:"کارمزد اتحادیه (ریال)",variant:"outlined",value:t.values.unionPrice,error:t.touched.unionPrice?!!t.errors.unionPrice:null,onChange:t.handleChange,onBlur:t.handleBlur,helperText:t.touched.unionPrice&&t.errors.unionPrice?t.errors.unionPrice:null})}),u.jsx(d,{item:!0,xs:12,children:u.jsx(Mu,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"cooperativePrice",label:"کارمزد تعاونی (ریال)",variant:"outlined",value:t.values.cooperativePrice,error:t.touched.cooperativePrice?!!t.errors.cooperativePrice:null,onChange:t.handleChange,onBlur:t.handleBlur,helperText:t.touched.cooperativePrice&&t.errors.cooperativePrice?t.errors.cooperativePrice:null})}),u.jsx(d,{item:!0,xs:12,children:u.jsx(Mu,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"shippingPrice",label:"هزینه حمل و نقل (ریال)",variant:"outlined",value:t.values.shippingPrice,error:t.touched.shippingPrice?!!t.errors.shippingPrice:null,onChange:t.handleChange,onBlur:t.handleBlur,helperText:t.touched.shippingPrice&&t.errors.shippingPrice?t.errors.shippingPrice:null})}),u.jsx(d,{item:!0,xs:12,children:u.jsx(V,{type:"submit",variant:"contained",fullWidth:!0,onClick:t.handleSubmit,children:"ثبت"})})]})},$e=({product:e})=>{var L,U,$,M,J,Y,W,h,b,R;const r=X(),a=A=>{l(A.target.value)},[n,x]=o.useState([]),t=()=>{r(Te({product:e==null?void 0:e.key})).then(A=>{x(A.payload.data)})};o.useEffect(()=>{O()==="LiveStockProvinceJahad"&&t()},[]);const[s]=o.useContext(nu),[v,i]=o.useState([]),[f,_]=o.useState(0),[C,N]=o.useState(10),[E,l]=o.useState(""),[c,g]=o.useState(1),[q,I]=o.useState([]),T=async A=>{let j;r(z()),j=await D.get(`/LiveStock/rancher/rancher-view/?search=filter&value=${E}&role=${O()}&page=${A}&page_size=${C}&name=${e==null?void 0:e.key}`),r(P()),i(j.data.results),_(j.data.count)},F=A=>{T(A),g(A)},p=A=>{N(A),g(1)},B=()=>{T(c!==0?c:1)};o.useEffect(()=>{const A=v==null?void 0:v.map((j,y)=>{var k;return[c===1?y+1:y+C*(c-1)+1,j==null?void 0:j.herdCode,j==null?void 0:j.epidemiologicalCode,j==null?void 0:j.postalCode,j==null?void 0:j.unitId,j==null?void 0:j.herdName,j==null?void 0:j.nationalId,(k=j==null?void 0:j.user)==null?void 0:k.fullname.replace(":"," "),j==null?void 0:j.mobile,(j==null?void 0:j.contractorCode)||"-",j==null?void 0:j.city,u.jsx(_u,{control:u.jsx(Yu,{checked:j==null?void 0:j.allowBuy,onChange:()=>{r(c6({key:j==null?void 0:j.key,allow_buy:!(j!=null&&j.allowBuy)})).then(ru=>{ru.payload.error?s({vertical:"top",horizontal:"center",msg:ru.payload.error,severity:"error"}):(B(),s({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}))})},color:"primary"}),label:j!=null&&j.allowBuy?"فعال":"غیرفعال",style:{justifyContent:"center",alignItems:"center",display:"flex"}},y)]});I(A)},[v]),o.useEffect(()=>{T(1)},[r,C]);const K=async A=>{A.preventDefault(),r(z());try{const j=await D.get(`/LiveStock/rancher/rancher-view/?search=filter&value=${E}&role=${O()}&page=${c}&page_size=${C}&name=${e==null?void 0:e.key}`);i(j.data.results),_(j.data.count),r(P())}catch(j){console.error("Error fetching data:",j)}};return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[O()==="LiveStockProvinceJahad"&&u.jsx(d,{container:!0,mt:2,mb:4,isDashboard:!0,children:u.jsx(ou,{noPagination:!0,isDashboard:!0,columns:["محصول","سهمیه دام سبک روستایی (کیلوگرم)","سهمیه دام سنگین روستایی (کیلوگرم)","سهمیه دام سبک صنعتی (کیلوگرم)","سهمیه دام سنگین صنعتی (کیلوگرم)","سهمیه دام سبک DHI (کیلوگرم)","سهمیه دام سنگین DHI (کیلوگرم)","قیمت سبوس (ریال)","کارمزد اتحادیه","کارمزد تعاونی","هزینه حمل و نقل","قیمت درب کارخانه (ریال)","قیمت درب تعاونی (ریال)","عملیات"],data:[[n==null?void 0:n.name,((L=n==null?void 0:n.lightWight)==null?void 0:L.toLocaleString())||"0",((U=n==null?void 0:n.heavyWight)==null?void 0:U.toLocaleString())||"0",(($=n==null?void 0:n.lightWightIndustrial)==null?void 0:$.toLocaleString())||"0",((M=n==null?void 0:n.heavyWightIndustrial)==null?void 0:M.toLocaleString())||"0",((J=n==null?void 0:n.lightWightDha)==null?void 0:J.toLocaleString())||"0",((Y=n==null?void 0:n.heavyWightDha)==null?void 0:Y.toLocaleString())||"0",((W=n==null?void 0:n.price)==null?void 0:W.toLocaleString())||"0",((h=n==null?void 0:n.unionPrice)==null?void 0:h.toLocaleString())||"0",((b=n==null?void 0:n.cooperativePrice)==null?void 0:b.toLocaleString())||"0",((R=n==null?void 0:n.shippingPrice)==null?void 0:R.toLocaleString())||"0",(((n==null?void 0:n.price)||0)+((n==null?void 0:n.unionPrice)||0)+((n==null?void 0:n.cooperativePrice)||0)).toLocaleString()||"0",(((n==null?void 0:n.price)||0)+((n==null?void 0:n.unionPrice)||0)+((n==null?void 0:n.cooperativePrice)||0)+((n==null?void 0:n.shippingPrice)||0)).toLocaleString()||"0",u.jsx(Z,{title:"ویرایش محصول",placement:"left",children:u.jsx(m,{color:"primary",size:"small",onClick:()=>{r(eu({title:"ویرایش محصول",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(Re,{item:n,updateTable:t})}))},children:u.jsx(a6,{})})},`edit-${(n==null?void 0:n.name)||"product"}`)]],title:`محدودیت های توزیع ${e==null?void 0:e.label}`})}),u.jsx(d,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:u.jsx(d,{children:u.jsxs("form",{onSubmit:K,children:[u.jsx(w,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:a}),u.jsx(V,{type:"submit",onClick:K,endIcon:u.jsx(yu,{}),children:"جستجو"})]})})}),u.jsx(ou,{data:q,columns:["ردیف","کد گله","کد اپیدمیولوژیک","کد پستی","شناسه یکتا","نام گله","کد ملی دامدار","نام دامدار","موبایل","کد پیمانکار","شهرستان","عملیات"],handlePageChange:F,totalRows:f,page:c,perPage:C,handlePerRowsChange:p,title:`مجوز دریافت ${e==null?void 0:e.label}`})]})},Be=Q("PROVINCE_JAHAD_SUBMIT_SHARE_SERVICE",async(e,{dispatch:r})=>{r(z());try{const{data:a,status:n}=await D.put("/LiveStock/jahad/cooperative-shares/0/",e);return r(P()),{data:a,status:n}}catch(a){return r(P()),{error:a.response.data.result}}}),Oe=({updateTable:e,item:r})=>{const[a]=o.useContext(nu),n=X(),x=$u().shape({price:G().required("این فیلد الزامی است"),shipping_price:G().required("این فیلد الزامی است"),union_price:G().required("این فیلد الزامی است"),cooperative_price:G().required("این فیلد الزامی است"),company_price:G().required("این فیلد الزامی است")}),t=Bu({initialValues:{price:(r==null?void 0:r.price)||"",shipping_price:(r==null?void 0:r.shippingPrice)||"",union_price:(r==null?void 0:r.unionPrice)||"",company_price:(r==null?void 0:r.companyPrice)||"",cooperative_price:(r==null?void 0:r.cooperativePrice)||""},validationSchema:x,enableReinitialize:!0,onSubmit:s=>{n(Be({share_key:r==null?void 0:r.key,shipping_price:s.shipping_price,union_price:s.union_price,company_price:s.company_price,price:s.price,cooperative_price:s.cooperative_price})).then(v=>{v.payload.error?a({vertical:"top",horizontal:"center",msg:v.payload.error,severity:"error"}):(a({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),n(eu({right:!1,bottom:!1,content:null})),e())})}});return u.jsx(au,{container:!0,direction:"column",gap:lu.SMALL,children:u.jsx("form",{onSubmit:t.handleSubmit,children:u.jsxs(au,{container:!0,direction:"column",gap:lu.TINY,children:[u.jsx(w,{name:"price",label:"قیمت پایه ",fullWidth:!0,value:t.values.price,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.price&&!!t.errors.price,helperText:t.touched.price&&t.errors.price}),u.jsx(w,{name:"shipping_price",label:"هزینه حمل و نقل",fullWidth:!0,value:t.values.shipping_price,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.shipping_price&&!!t.errors.shipping_price,helperText:t.touched.shipping_price&&t.errors.shipping_price}),u.jsx(w,{name:"union_price",label:"سهم اتحادیه",fullWidth:!0,value:t.values.union_price,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.union_price&&!!t.errors.union_price,helperText:t.touched.union_price&&t.errors.union_price}),u.jsx(w,{name:"cooperative_price",label:"سهم تعاونی",fullWidth:!0,value:t.values.cooperative_price,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.cooperative_price&&!!t.errors.cooperative_price,helperText:t.touched.cooperative_price&&t.errors.cooperative_price}),u.jsx(w,{name:"company_price",label:"سهم شرکت",fullWidth:!0,value:t.values.company_price,onChange:t.handleChange,onBlur:t.handleBlur,error:t.touched.company_price&&!!t.errors.company_price,helperText:t.touched.company_price&&t.errors.company_price}),u.jsx(V,{type:"submit",variant:"contained",color:"primary",children:"ثبت اطلاعات"})]})})})},De=({item:e,updateTable:r})=>{const[a,n]=o.useState(null),x=X(),t=f=>{n(f.currentTarget)},s=()=>{n(null)},v=!!a,i=v?"popover":void 0;return u.jsxs(d,{container:!0,children:[u.jsx(m,{"aria-describedby":i,variant:"contained",color:"primary",onClick:t,children:u.jsx(Wu,{})}),u.jsx(zu,{anchorOrigin:{vertical:"bottom",horizontal:"right"},transformOrigin:{vertical:"top",horizontal:"left"},id:i,open:v,anchorEl:a,onClose:s,children:u.jsx("div",{style:{padding:"20px",display:"flex",flexDirection:"column"},children:u.jsx(Z,{title:"ویرایش",placement:"left-start",children:u.jsx(m,{"aria-label":"delete",color:"primary",onClick:()=>{s(),x(eu({title:"ویرایش اطلاعات ",right:!(window.innerWidth<=600),bottom:window.innerWidth<=600,content:u.jsx(Oe,{item:e,updateTable:r})}))},children:u.jsx(Uu,{})})})})})]})},Ne=({product:e})=>{const r=X(),a=F=>{_(F.target.value)},[n,x]=o.useState([]),[t,s]=o.useState(0),[v,i]=o.useState(10),[f,_]=o.useState(""),[C,N]=o.useState(1),[E,l]=o.useState([]),c=async F=>{let p;r(z()),p=await D.get(`LiveStock/jahad/cooperative-shares/?search=filter&value=${f}&role=${O()}&page=${F}&page_size=${v}&name=${e==null?void 0:e.label}`),r(P()),x(p.data.results),s(p.data.count)},g=F=>{c(F),N(F)},q=F=>{i(F),N(1)},I=()=>{c(C!==0?C:1)};o.useEffect(()=>{const F=n==null?void 0:n.map((p,B)=>{var K,L,U,$,M,J,Y,W;return[C===1?B+1:B+v*(C-1)+1,`${(K=p==null?void 0:p.cooperative)==null?void 0:K.name} (${(U=(L=p==null?void 0:p.cooperative)==null?void 0:L.user)==null?void 0:U.fullname})`,($=p==null?void 0:p.price)==null?void 0:$.toLocaleString(),(M=p==null?void 0:p.unionPrice)==null?void 0:M.toLocaleString(),(J=p==null?void 0:p.cooperativePrice)==null?void 0:J.toLocaleString(),(Y=p==null?void 0:p.companyPrice)==null?void 0:Y.toLocaleString(),(W=p==null?void 0:p.shippingPrice)==null?void 0:W.toLocaleString(),u.jsx(De,{item:p,updateTable:I},B)]});l(F)},[n]),o.useEffect(()=>{c(1)},[r,v]);const T=async F=>{F.preventDefault(),r(z());try{const p=await D.get(`LiveStock/jahad/cooperative-shares/?role=${O()}&search=filter&value=${f}&page=1&page_size=${v}&name=${e==null?void 0:e.label}`);x(p.data.results),s(p.data.count),r(P())}catch(p){console.error("Error fetching data:",p)}};return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsx(d,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:u.jsx(d,{children:u.jsxs("form",{onSubmit:T,children:[u.jsx(w,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:a}),u.jsx(V,{type:"submit",onClick:T,endIcon:u.jsx(yu,{}),children:"جستجو"})]})})}),u.jsx(ou,{data:E,ignoreTextsLength:!0,columns:["ردیف","تعاونی","قیمت پایه","سهم اتحادیه","سهم تعاونی","سهم شرکت","هزینه حمل و نقل","عملیات"],handlePageChange:g,totalRows:t,page:C,perPage:v,handlePerRowsChange:q,title:`سهم بندی ${e==null?void 0:e.label}`})]})},ze=Q("PROVINCE_JAHAD_GET_TRANSACTION_INFO_DASHBOARD_SERVICE",async(e,{dispatch:r})=>{r(z());const{data:a,status:n}=await D.get("/live-stock-transactions-dashboard",{params:{...e}});return r(P()),{data:a,status:n}}),We=({product:e})=>{var y,k,ru,cu,iu,Cu,Au,xu;const[,,r,a,n,x]=o.useContext(nu),t=Nu(H=>H.userSlice.userProfile.key),[s,v]=o.useState([]),[i,f]=o.useState("all"),[_,C]=o.useState("bran"),N=H=>{f(H.target.value)},E=H=>{C(H.target.value)},l=X();o.useEffect(()=>{const H=su(new Date).format("YYYY-MM-DD");a(H),x(H)},[]);const c=H=>{K(H.target.value)},[g,q]=o.useState([]),[I,T]=o.useState(0),[F,p]=o.useState(10),[B,K]=o.useState(""),[L,U]=o.useState(1),[$,M]=o.useState([]),[J,Y]=o.useState(!1),W=()=>{l(ze({date1:J?r:"",date2:J?n:"",search:"filter",role:O(),value:B,name:_||(e==null?void 0:e.key),state:i})).then(H=>{v(H.payload.data)})},h=async H=>{let S;l(z()),S=await D.get(`live-stock-transactions/?search=filter&value=${B}&role=${O()}${J?`&date1=${r}&date2=${n}`:""}&page=${H}&page_size=${F}&state=${i}&name=${_}`),W(),l(P()),q(S.data.results),T(S.data.count)},b=H=>{h(H),U(H)},R=H=>{p(H),U(1)},A=H=>{if(H)return JSON.parse(H)};o.useEffect(()=>{const H=g==null?void 0:g.map((S,du)=>{var Su,Eu,bu,ku,Iu,Pu,wu,Tu,Lu,uu,Ru,Ju,Vu,Hu,E6,b6,k6,I6,P6,w6,T6,L6,R6,$6,B6,O6,D6;const Ou=(Su=S==null?void 0:S.products)==null?void 0:Su.map((hu,s0)=>{var N6,z6,W6;return[s0+1,hu==null?void 0:hu.name,(N6=hu==null?void 0:hu.curWeight)==null?void 0:N6.toLocaleString(),(z6=hu==null?void 0:hu.price)==null?void 0:z6.toLocaleString(),(W6=hu==null?void 0:hu.curPrice)==null?void 0:W6.toLocaleString()]});return[L===1?du+1:du+F*(L-1)+1,t6(S==null?void 0:S.date),(S==null?void 0:S.fullname)||"-",(S==null?void 0:S.natcode)||"-",(S==null?void 0:S.mobile)||"-",`${(bu=(Eu=S==null?void 0:S.pos)==null?void 0:Eu.cooperative)==null?void 0:bu.name} شهرستان ${(Pu=(Iu=(ku=S==null?void 0:S.pos)==null?void 0:ku.cooperative)==null?void 0:Iu.user)==null?void 0:Pu.cityName} (${(Lu=(Tu=(wu=S==null?void 0:S.pos)==null?void 0:wu.cooperative)==null?void 0:Tu.user)==null?void 0:Lu.fullname})`,(Ju=(Ru=(uu=S==null?void 0:S.pos)==null?void 0:uu.cooperative)==null?void 0:Ru.user)==null?void 0:Ju.mobile,S!=null&&S.paid?"پرداخت شده":`پرداخت نشده (${S==null?void 0:S.result})`,A(S==null?void 0:S.additional).isTaavoni?"تعاونی":"کارخانه",S!=null&&S.products?S==null?void 0:S.products.map(hu=>hu.name).join("-"):"-",((Hu=(Vu=A(S==null?void 0:S.additional))==null?void 0:Vu.ownerNatcode)==null?void 0:Hu.toLocaleString())||0,((b6=(E6=S==null?void 0:S.shares)==null?void 0:E6.curHeavy)==null?void 0:b6.toLocaleString())||0,((I6=(k6=S==null?void 0:S.shares)==null?void 0:k6.curLight)==null?void 0:I6.toLocaleString())||0,((w6=(P6=S==null?void 0:S.shares)==null?void 0:P6.curWeight)==null?void 0:w6.toLocaleString())||0,(T6=S==null?void 0:S.price)==null?void 0:T6.toLocaleString(),((R6=(L6=A(S==null?void 0:S.additional))==null?void 0:L6.cooperative_price)==null?void 0:R6.toLocaleString())||0,((B6=($6=S==null?void 0:S.shares)==null?void 0:$6.totalUnionPrice)==null?void 0:B6.toLocaleString())||0,((D6=(O6=S==null?void 0:S.shares)==null?void 0:O6.totalCompanyPrice)==null?void 0:D6.toLocaleString())||0,u.jsx(Z,{placement:"left",title:"مشاهده",children:u.jsx(m,{size:"small",color:"primary",onClick:()=>{l(pu({title:"جزئیات محصول",content:u.jsx(d,{container:!0,xs:12,justifyContent:"center",children:u.jsx(o6,{columns:["ردیف","محصول","وزن","فی","قیمت کل"],data:Ou})})}))},children:u.jsx(a6,{})},du)},du)]});M(H)},[g]),o.useEffect(()=>{h(1)},[l,r,n,F,i,J,_]);const j=async H=>{H.preventDefault(),l(z());try{const S=await D.get(`live-stock-transactions/?role=${O()}&search=filter&value=${B}${J?`&date1=${r}&date2=${n}`:""}&page=1&page_size=${F}&state=${i}&name=${_}`);q(S.data.results),T(S.data.count),W(),l(P())}catch(S){console.error("Error fetching data:",S)}};return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(d,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[u.jsx(d,{width:"200px",children:u.jsxs(qu,{size:"small",children:[u.jsx(i6,{id:"demo-simple-select-label",children:"انتخاب محصول"}),u.jsxs(C6,{labelId:"demo-simple-select-label",id:"demo-simple-select",value:_,label:"Age",onChange:E,children:[u.jsx(ju,{value:"bran",children:"سبوس"}),u.jsx(ju,{value:"barley",children:"جو"}),u.jsx(ju,{value:"soy",children:"سویا"}),u.jsx(ju,{value:"corn",children:"ذرت"})]})]})}),u.jsx(d,{width:"200px",children:u.jsxs(qu,{size:"small",children:[u.jsx(i6,{id:"demo-simple-select-label",children:"فیلتر تراکنش"}),u.jsxs(C6,{labelId:"demo-simple-select-label",id:"demo-simple-select",value:i,label:"Age",onChange:N,children:[u.jsx(ju,{value:"all",children:"همه"}),u.jsx(ju,{value:"paid",children:"تراکنش های موفق"}),u.jsx(ju,{value:"unpaid",children:"تراکنش های ناموفق"})]})]})}),u.jsxs(d,{container:!0,gap:1,style:{borderStyle:"solid",borderWidth:"1px",padding:"5px",borderRadius:"15px",borderColor:"gray",justifyContent:"left"},alignItems:"center",children:[u.jsx(Gu,{icon:u.jsx(l6,{}),checkedIcon:u.jsx(s6,{}),checked:J,onChange:()=>Y(!J),color:"primary",size:"large"}),u.jsx(d,{children:u.jsx(Fu,{disabled:!J,label:"از تاریخ",id:"date",renderInput:H=>u.jsx(w,{size:"small",style:{width:"160px"},...H}),value:r,onChange:H=>{a(su(H).format("YYYY-MM-DD"))}})}),u.jsx(d,{children:u.jsx(Fu,{disabled:!J,label:"تا تاریخ",id:"date",renderInput:H=>u.jsx(w,{size:"small",style:{width:"160px"},...H}),value:n,onChange:H=>{x(su(H).format("YYYY-MM-DD"))}})})]})," ",u.jsx(d,{children:u.jsxs("form",{onSubmit:j,children:[u.jsx(w,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:c}),u.jsx(V,{type:"submit",onClick:j,endIcon:u.jsx(yu,{}),children:"جستجو"})]})}),u.jsx(d,{children:u.jsx(Z,{title:"خروجی اکسل",children:u.jsx("a",{href:`${D.defaults.baseURL}LiveStock/jahad/live_stock_transaction_excel/?search=filter&value=${B}&role=${O()}&key=${t}&name=${_}${J?`&date1=${r}&date2=${n}`:""}`,rel:"noreferrer",children:u.jsx(V,{color:"success",children:u.jsx(fu,{size:32})})})})}),u.jsx(d,{container:!0,mt:2,mb:4,isDashboard:!0,children:u.jsx(ou,{noPagination:!0,isDashboard:!0,columns:["کل وزن فروش","تعداد تراکنش ها","مبلغ کل تراکنش ها","مجموع سهم تعاونی ها","مجموع سهم اتحادیه","مجموع سهم شرکت","مجموع دام سنگین","مجموع دام سبک"],data:[[(y=s==null?void 0:s.curWeight)==null?void 0:y.toLocaleString(),(k=s==null?void 0:s.lenTransaction)==null?void 0:k.toLocaleString(),(ru=s==null?void 0:s.price)==null?void 0:ru.toLocaleString(),(cu=s==null?void 0:s.totalCooperativePrice)==null?void 0:cu.toLocaleString(),(iu=s==null?void 0:s.totalUnionPrice)==null?void 0:iu.toLocaleString(),(Cu=s==null?void 0:s.totalCompanyPrice)==null?void 0:Cu.toLocaleString(),(Au=s==null?void 0:s.curHeavy)==null?void 0:Au.toLocaleString(),(xu=s==null?void 0:s.curLight)==null?void 0:xu.toLocaleString()]],title:"خلاصه اطلاعات"})})]}),u.jsx(ou,{ignoreTextsLength:!0,data:$,columns:["ردیف","تاریخ","خریدار","کد ملی خریدار","موبایل خریدار","فروشنده","تلفن فروشنده","وضعیت","محل تحویل","کالا","کد ملی فروشنده","دام سنگین","دام سبک","وزن (کیلوگرم)","مبلغ تراکنش","سهم تعاونی","سهم اتحادیه","سهم شرکت","جزئیات محصولات"],handlePageChange:b,totalRows:I,page:L,perPage:F,handlePerRowsChange:R,title:"تراکنش ها"})]})},Ue=({cooperative_key:e,product:r})=>{const[,,a,n,x,t]=o.useContext(nu),[s,v]=o.useState(!1),[i,f]=o.useState("all"),_=W=>{f(W.target.value)},C=X();o.useEffect(()=>{const W=su(new Date).format("YYYY-MM-DD");n(W),t(W)},[]);const N=W=>{F(W.target.value)},[E,l]=o.useState([]),[c,g]=o.useState(0),[q,I]=o.useState(10),[T,F]=o.useState(""),[p,B]=o.useState(1),[K,L]=o.useState([]),U=async W=>{let h;C(z()),h=await D.get(`live-stock-transactions/?search=filter&value=${T}${s?`&date1=${a}&date2=${x}`:""}&page=${W}&page_size=${q}&cooperative_key=${e}&state=${i}&name=${r==null?void 0:r.key}`),C(P()),l(h.data.results),g(h.data.count)},$=W=>{U(W),B(W)},M=W=>{I(W),B(1)},J=W=>{if(W)return JSON.parse(W)};o.useEffect(()=>{const W=E==null?void 0:E.map((h,b)=>{var A,j,y,k,ru,cu,iu,Cu,Au,xu,H,S,du,Ou,Su,Eu,bu,ku,Iu,Pu,wu,Tu,Lu;const R=(A=h==null?void 0:h.products)==null?void 0:A.map((uu,Ru)=>{var Ju,Vu,Hu;return[Ru+1,uu==null?void 0:uu.name,(Ju=uu==null?void 0:uu.curWeight)==null?void 0:Ju.toLocaleString(),(Vu=uu==null?void 0:uu.price)==null?void 0:Vu.toLocaleString(),(Hu=uu==null?void 0:uu.curPrice)==null?void 0:Hu.toLocaleString()]});return[p===1?b+1:b+q*(p-1)+1,t6(h==null?void 0:h.date),(h==null?void 0:h.fullname)||"-",(h==null?void 0:h.natcode)||"-",(h==null?void 0:h.mobile)||"-",`${(y=(j=h==null?void 0:h.pos)==null?void 0:j.cooperative)==null?void 0:y.name} شهرستان ${(cu=(ru=(k=h==null?void 0:h.pos)==null?void 0:k.cooperative)==null?void 0:ru.user)==null?void 0:cu.cityName} (${(Au=(Cu=(iu=h==null?void 0:h.pos)==null?void 0:iu.cooperative)==null?void 0:Cu.user)==null?void 0:Au.fullname})`,(S=(H=(xu=h==null?void 0:h.pos)==null?void 0:xu.cooperative)==null?void 0:H.user)==null?void 0:S.mobile,h!=null&&h.paid?"پرداخت شده":`پرداخت نشده (${h==null?void 0:h.result})`,J(h==null?void 0:h.additional).isTaavoni?"تعاونی":"کارخانه",h!=null&&h.products?h==null?void 0:h.products.map(uu=>uu.name).join("-"):"-",((Ou=(du=J(h==null?void 0:h.additional))==null?void 0:du.ownerNatcode)==null?void 0:Ou.toLocaleString())||0,((Eu=(Su=J(h==null?void 0:h.additional))==null?void 0:Su.cur_heavy)==null?void 0:Eu.toLocaleString())||0,((ku=(bu=J(h==null?void 0:h.additional))==null?void 0:bu.cur_light)==null?void 0:ku.toLocaleString())||0,h==null?void 0:h.products.reduce((uu,Ru)=>uu+(Ru==null?void 0:Ru.curWeight),0).toLocaleString(),(Iu=h==null?void 0:h.price)==null?void 0:Iu.toLocaleString(),((wu=(Pu=J(h==null?void 0:h.additional))==null?void 0:Pu.cooperative_price)==null?void 0:wu.toLocaleString())||0,((Lu=(Tu=J(h==null?void 0:h.additional))==null?void 0:Tu.union_price)==null?void 0:Lu.toLocaleString())||0,u.jsx(V,{size:"small",variant:"outlined",onClick:()=>{C(pu({title:"جزئیات محصول",content:u.jsx(d,{container:!0,xs:12,justifyContent:"center",children:u.jsx(o6,{columns:["ردیف","محصول","وزن","فی","قیمت کل"],data:R})})}))},children:"مشاهده"},b)]});L(W)},[E]),o.useEffect(()=>{U(1)},[C,a,x,q,s,i]);const Y=async W=>{W.preventDefault(),C(z());try{const h=await D.get(`live-stock-transactions/?search=filter&value=${T}${s?`&date1=${a}&date2=${x}`:""}&page=1&page_size=${q}&cooperative_key=${e}&state=${i}`);l(h.data.results),g(h.data.count),C(P())}catch(h){console.error("Error fetching data:",h)}};return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(d,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[u.jsx(d,{width:"200px",children:u.jsxs(qu,{size:"small",children:[u.jsx(i6,{id:"demo-simple-select-label",children:"فیلتر تراکنش"}),u.jsxs(C6,{labelId:"demo-simple-select-label",id:"demo-simple-select",value:i,label:"Age",onChange:_,children:[u.jsx(ju,{value:"all",children:"همه"}),u.jsx(ju,{value:"paid",children:"تراکنش های موفق"}),u.jsx(ju,{value:"unpaid",children:"تراکنش های ناموفق"})]})]})}),u.jsxs(d,{container:!0,style:{borderStyle:"solid",borderWidth:"1px",padding:"10px",borderRadius:"15px",borderColor:"gray",justifyContent:"left"},children:[u.jsx(d,{children:u.jsx(_u,{control:u.jsx(Gu,{checked:s,onChange:()=>v(!s),color:"primary"})})}),u.jsx(d,{children:u.jsx(Fu,{disabled:!s,label:"از تاریخ",id:"date",renderInput:W=>u.jsx(w,{size:"small",style:{width:"160px"},...W}),value:a,onChange:W=>{n(su(W).format("YYYY-MM-DD"))}})}),u.jsx(d,{children:u.jsx(Fu,{disabled:!s,label:"تا تاریخ",id:"date",renderInput:W=>u.jsx(w,{size:"small",style:{width:"160px"},...W}),value:x,onChange:W=>{t(su(W).format("YYYY-MM-DD"))}})})]}),u.jsx(d,{children:u.jsxs("form",{onSubmit:Y,children:[u.jsx(w,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:N}),u.jsx(V,{type:"submit",onClick:Y,endIcon:u.jsx(yu,{}),children:"جستجو"})]})}),u.jsx(Z,{title:"خروجی اکسل",children:u.jsx("a",{href:`${D.defaults.baseURL}`,rel:"noreferrer",children:u.jsx(V,{color:"success",children:u.jsx(fu,{size:32})})})})]}),u.jsx(ou,{ignoreTextsLength:!0,data:K,columns:["ردیف","تاریخ","خریدار","کد ملی خریدار","موبایل خریدار","فروشنده","تلفن فروشنده","وضعیت","محل تحویل","کالا","کد ملی فروشنده","دام سنگین","دام سبک","وزن (کیلوگرم)","مبلغ تراکنش","سهم تعاونی","سهم اتحادیه","جزئیات محصولات"],handlePageChange:$,totalRows:c,page:p,perPage:q,handlePerRowsChange:M,title:`تراکنش های ${r==null?void 0:r.label}`})]})},Je=Q("PROVINCE_JAHAD_GET_SELL_REPORT_INFO_DASHBOARD_SERVICE",async(e,{dispatch:r})=>{r(z());const{data:a,status:n}=await D.get("/cooperative-warehouse-dashboard",{params:{...e}});return r(P()),{data:a,status:n}}),Ve=({product:e})=>{var Y,W,h,b,R,A,j;const[,,r,a,n,x]=o.useContext(nu),[t,s]=o.useState(!1),v=Nu(y=>y.userSlice.userProfile.key),i=X();o.useEffect(()=>{const y=su(new Date).format("YYYY-MM-DD");a(y),x(y)},[]);const f=y=>{q(y.target.value)},[_,C]=o.useState([]),[N,E]=o.useState(0),[l,c]=o.useState(10),[g,q]=o.useState(""),[I,T]=o.useState(1),[F,p]=o.useState([]),[B,K]=o.useState([]),L=()=>{i(Je({date1:r,date2:n,search:"filter",role:O(),value:g,name:e==null?void 0:e.key})).then(y=>{K(y.payload.data)})},U=async y=>{let k;i(z()),k=await D.get(`cooperative-warehouse/?search=filter&value=${g}&role=${O()}${t?`&date1=${r}&date2=${n}`:""}&page=${y}&page_size=${l}&name=${e==null?void 0:e.key}`),i(P()),L(),C(k.data.results),E(k.data.count)},$=y=>{U(y),T(y)},M=y=>{c(y),T(1)};o.useEffect(()=>{const y=_==null?void 0:_.map((k,ru)=>{var cu,iu,Cu,Au,xu,H,S,du,Ou,Su,Eu,bu,ku,Iu,Pu,wu,Tu,Lu,uu;return[I===1?ru+1:ru+l*(I-1)+1,e==null?void 0:e.label,k==null?void 0:k.name,(cu=k==null?void 0:k.user)==null?void 0:cu.fullname,(iu=k==null?void 0:k.user)==null?void 0:iu.provinceName,(Cu=k==null?void 0:k.user)==null?void 0:Cu.cityName,(Au=k==null?void 0:k.user)==null?void 0:Au.mobile,(xu=k==null?void 0:k.user)==null?void 0:xu.nationalId,((S=(H=k==null?void 0:k.info)==null?void 0:H.totalReceiptWeight)==null?void 0:S.toLocaleString())||0,((Ou=(du=k==null?void 0:k.info)==null?void 0:du.totalWeight)==null?void 0:Ou.toLocaleString())||0,((Eu=(Su=k==null?void 0:k.info)==null?void 0:Su.totalAllocatedWeight)==null?void 0:Eu.toLocaleString())||0,((ku=(bu=k==null?void 0:k.info)==null?void 0:bu.totalRemainWeight)==null?void 0:ku.toLocaleString())||0,((Pu=(Iu=k==null?void 0:k.info)==null?void 0:Iu.transactions)==null?void 0:Pu.toLocaleString())||0,((Tu=(wu=k==null?void 0:k.info)==null?void 0:wu.totalTransactionsPrice)==null?void 0:Tu.toLocaleString())||0,((uu=(Lu=k==null?void 0:k.info)==null?void 0:Lu.totalTransactionsWeight)==null?void 0:uu.toLocaleString())||0,u.jsxs(d,{container:!0,gap:1,alignItems:"center",direction:"column",children:[u.jsx(Z,{title:"جزئیات",placement:"left",children:u.jsx(m,{color:"primary",onClick:()=>{i(eu({top:!0,title:"تراکنش ها",content:u.jsx(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",children:u.jsx(d,{container:!0,xs:10,justifyContent:"center",alignItems:"center",children:u.jsx(Ue,{cooperative_key:k==null?void 0:k.key,product:e})})})}))},children:u.jsx(a6,{})},ru)}),u.jsx(Z,{title:"خروجی اکسل",children:u.jsx("a",{href:`${D.defaults.baseURL}LiveStock/jahad/live_stock_transaction_excel/?search=filter&value=${g}&key=${v}&cooperative_key=${k==null?void 0:k.key}&name=${e==null?void 0:e.key}`,rel:"noreferrer",target:"_blank",children:u.jsx(V,{color:"success",children:u.jsx(fu,{size:24})})})})]},ru)]});p(y)},[_]),o.useEffect(()=>{U(1)},[i,r,n,l,t]);const J=async y=>{y.preventDefault(),i(z());try{const k=await D.get(`cooperative-warehouse/?role=${O()}&search=filter&value=${g}${t?`&date1=${r}&date2=${n}`:""}&page=1&page_size=${l}&name=${e==null?void 0:e.key}`);C(k.data.results),E(k.data.count),i(P()),L()}catch(k){console.error("Error fetching data:",k)}};return u.jsxs(d,{container:!0,xs:12,justifyContent:"center",alignItems:"center",gap:2,children:[u.jsxs(d,{container:!0,xs:12,justifyContent:"start",alignItems:"center",gap:2,children:[u.jsxs(d,{container:!0,gap:1,style:{borderStyle:"solid",borderWidth:"1px",padding:"5px",borderRadius:"15px",borderColor:"gray",justifyContent:"left"},alignItems:"center",children:[u.jsx(Gu,{icon:u.jsx(l6,{}),checkedIcon:u.jsx(s6,{}),checked:t,onChange:()=>s(!t),color:"primary",size:"large"}),u.jsx(d,{children:u.jsx(Fu,{disabled:!t,label:"از تاریخ",id:"date",renderInput:y=>u.jsx(w,{size:"small",style:{width:"160px"},...y}),value:r,onChange:y=>{a(su(y).format("YYYY-MM-DD"))}})}),u.jsx(d,{children:u.jsx(Fu,{disabled:!t,label:"تا تاریخ",id:"date",renderInput:y=>u.jsx(w,{size:"small",style:{width:"160px"},...y}),value:n,onChange:y=>{x(su(y).format("YYYY-MM-DD"))}})})]}),u.jsx(d,{children:u.jsxs("form",{onSubmit:J,children:[u.jsx(w,{id:"outlined-basic",size:"small",label:"جستجو",variant:"outlined",style:{width:250},onChange:f}),u.jsx(V,{type:"submit",onClick:J,endIcon:u.jsx(yu,{}),children:"جستجو"})]})}),u.jsx(Z,{title:"خروجی اکسل",children:u.jsx("a",{href:`${D.defaults.baseURL}LiveStock/jahad/cooperative_warehouse_excel/?search=filter&value=${g}&role=${O()}&key=${v}&name=${e==null?void 0:e.key}`,rel:"noreferrer",target:"_blank",children:u.jsx(V,{color:"success",children:u.jsx(fu,{size:32})})})}),u.jsx(Z,{title:"خروجی اکسل تراکنش مشکوک",children:u.jsx("a",{href:`${D.defaults.baseURL}LiveStock/jahad/rancher_management/?search=filter&value=${g}&role=${O()}&key=${v}&name=${e==null?void 0:e.key}`,rel:"noreferrer",target:"_blank",children:u.jsx(V,{color:"error",children:u.jsx(fu,{size:32})})})})]}),u.jsx(d,{container:!0,mt:2,mb:4,isDashboard:!0,gap:2,children:u.jsx(ou,{noPagination:!0,isDashboard:!0,columns:["محصول","تعداد کل تراکنش ها","وزن کل تراکنش ها","مبلغ کل تراکنش ها","کل وزن ورود به انبار","کل وزن دریافتی","کل وزن تخصیص داده شده","کل وزن باقی مانده"],data:[[e==null?void 0:e.label,(Y=B==null?void 0:B.transactions)==null?void 0:Y.toLocaleString(),(W=B==null?void 0:B.totalTransactionsWeight)==null?void 0:W.toLocaleString(),(h=B==null?void 0:B.totalTransactionsPrice)==null?void 0:h.toLocaleString(),(b=B==null?void 0:B.totalWeight)==null?void 0:b.toLocaleString(),(R=B==null?void 0:B.totalReceiptWeight)==null?void 0:R.toLocaleString(),(A=B==null?void 0:B.totalAllocatedWeight)==null?void 0:A.toLocaleString(),(j=B==null?void 0:B.totalRemainWeight)==null?void 0:j.toLocaleString()]],title:"خلاصه اطلاعات"})}),u.jsx(ou,{data:F,columns:["ردیف","محصول","نام تعاونی","کاربر","استان","شهر","موبایل","کد ملی","سهمیه دریافتی","وزن تحویلی","وزن فروش رفته","مانده انبار","تعداد تراکنش ها","جمع کل تراکنش ها","وزن کل تراکنش ها","جزئیات"],handlePageChange:$,totalRows:N,page:I,perPage:l,handlePerRowsChange:M,title:"گزارش فروش تعاونی ها"})]})},Qu={bran:{label:"سبوس",icon:u.jsx(x0,{fontSize:"small"})},barley:{label:"جو",icon:u.jsx(A0,{fontSize:"small"})},soy:{label:"سویا",icon:u.jsx(p0,{fontSize:"small"})},corn:{label:"ذرت",icon:u.jsx(g0,{fontSize:"small"})},sheep_concentrate:{label:"کنسانتره گوسفندی",icon:u.jsx(Ku,{fontSize:"small"})},high_cow_concentrate:{label:"کنسانتره گاو شیری پرتولید",icon:u.jsx(Ku,{fontSize:"small"})},medium_cow_concentrate:{label:"کنسانتره گاو شیری متوسط",icon:u.jsx(Ku,{fontSize:"small"})},fattening_calf_concentrate:{label:"کنسانتره گوساله پرواری",icon:u.jsx(Ku,{fontSize:"small"})}},V6="selectedProduct",He=j0(r6),Me=({onSelect:e})=>{const r=C0(),a=h0(r.breakpoints.down("sm")),[n,x]=o.useState("bran");o.useEffect(()=>{const s=localStorage.getItem(V6);if(s){const v=JSON.parse(s);v.key&&Qu[v.key]&&(x(v.key),e(v))}else e({key:"bran",label:Qu.bran.label})},[e]);const t=s=>{const v={key:s,label:Qu[s].label};x(s),localStorage.setItem(V6,JSON.stringify(v)),e(v)};return u.jsxs(r6,{sx:{mt:2},children:[u.jsx(tu,{variant:"h6",textAlign:"center",color:"primary",mb:1,children:"انتخاب محصول"}),u.jsx(r6,{sx:{display:"flex",flexWrap:a?"nowrap":"wrap",overflowX:a?"auto":"visible",gap:1,px:2,py:1,justifyContent:a?"flex-start":"center",scrollbarWidth:"none","&::-webkit-scrollbar":{display:"none"}},children:Object.entries(Qu).map(([s,{label:v,icon:i}])=>{const f=n===s;return u.jsx(He,{whileTap:{scale:.95},whileHover:{scale:1.05},transition:{duration:.15},children:u.jsxs(d0,{onClick:()=>t(s),sx:{borderRadius:"30px",border:`1px solid ${f?r.palette.primary.main:"#ddd"}`,backgroundColor:f?"#e3f2fd":"#fff",px:2,py:1,display:"flex",alignItems:"center",gap:1,whiteSpace:"nowrap",boxShadow:f?"0 2px 5px rgba(0,0,0,0.1)":"none",transition:"all 0.2s ease-in-out",minWidth:150,justifyContent:"center"},children:[i,u.jsx(tu,{fontSize:13,children:v})]})},s)})})]})},H6="selectedProduct",xr=()=>{const{pathname:e}=G6(),r=localStorage.getItem(H6);let a;try{a=r?JSON.parse(r):{key:"bran",label:"سبوس"}}catch{a={key:"bran",label:"سبوس"}}const[n,x]=o.useState(a);return o.useEffect(()=>{localStorage.setItem(H6,JSON.stringify(n))},[n]),u.jsx(r6,{display:"flex",justifyContent:"center",children:u.jsxs(d,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,my:lu.MEDIUM,children:[u.jsx(V0,{}),e===f0&&u.jsx(Y0,{}),(e===_0||e===F0)&&u.jsx(ee,{}),(e===S0||e===E0||e===b0)&&u.jsx(ye,{}),(e===k0||e===I0||e===P0)&&u.jsx(ie,{}),(e===w0||e===T0||e===L0)&&u.jsx(je,{}),(e===mu||e===d6||e===R0)&&u.jsxs(u.Fragment,{children:[u.jsx(Me,{onSelect:t=>x(t)}),u.jsx(fe,{product:n})]}),(e===h6||e===Z6||e===X6)&&u.jsx(we,{product:n}),(e===g6||e===Q6||e===m6)&&u.jsx($e,{product:n}),(e===$0||e===B0||e===O0)&&u.jsx(We,{product:n}),e===x6&&u.jsx(Ne,{product:n}),(e===A6||e===p6)&&u.jsx(Ve,{product:n})]})})};export{xr as default};