2 lines
12 KiB
JavaScript
2 lines
12 KiB
JavaScript
|
|
import{j as t,T as x,an as W,B as w,d as S,aj as _,ay as L,az as E,aA as R,b as G}from"./mui-vendor-D_SVL-Dx.js";import{r as s,f as Y}from"./react-vendor-CmFgShSM.js";import{A as V,j as a,a0 as c,G as l,S as f,a3 as A,_ as P,mD as J,mE as X}from"./index-D80MdVQn.js";import{f as Z}from"./redux-vendor-CfkcHgWN.js";import{R as uu,a as T}from"./index.esm-C1-dCPnj.js";import{P as eu}from"./PageTable-B0hPU2Kw.js";import{a as tu}from"./ChainBarManagement-B5xS_M-_.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./ResponsiveTable-bUYl0qDM.js";import"./FilterAlt-DZsHj-WQ.js";import"./Settings-Cboitw62.js";import"./Tune-BBzxV8DK.js";import"./Delete-CIwpNviU.js";import"./CarPelak-BUqZflo3.js";import"./Pageview-CHY_bSEN.js";import"./AddCircleOutline-5cdNoXZy.js";const ru=()=>{const[o,F]=s.useState(0),[C,v]=s.useState(0),[z,p]=s.useState([]),[M,n]=s.useState(!1),[N,h]=s.useState(0),[g,k]=s.useState(10),[d,I]=s.useState(""),K=Z(u=>u.userSlice.userProfile.key),m=u=>{I(u.target.value)};s.useEffect(()=>{$(1)},[]);const[b]=s.useContext(V),y=u=>{let e="";return e=u.quantity-u.losses-u.leftOver,e},$=async(u,e)=>{n(!0);let r;e?r=await a.get(`poultry_hatching?search=filter&value=${e}&role=${c()}&page=${u}&page_size=${g}&chain=true`):o&&C?r=await a.get(`poultry_hatching?role=${c()}&age1=${o}&age2=${C}&page=${u}&page_size=${g}&chain=true`):r=await a.get(`poultry_hatching/?role=${c()}&page=${u}&page_size=${g}&chain=true`),p(r.data.results),h(r.data.count),n(!1)},D=u=>{$(u,d)},H=async(u,e)=>{n(!0);let r;d?r=await a.get(`poultry_hatching?search=filter&value=${d}&page=${e}&page_size=${u}&search=filter&value=${d}&chain=true`):o&&C?r=await a.get(`poultry_hatching?role=${c()}&age1=${o}&age2=${C}&page=${e}&page_size=${g}&chain=true`):r=await a.get(`poultry_hatching/?role=${c()}&page=${e}&page_size=${u}&chain=true`),p(r.data.results),h(r.data.count),k(u),n(!1)},j=async u=>{u.preventDefault(),n(!0);try{const e=await a.get(`poultry_hatching/?role=${c()}&search=filter&value=${d}&chain=true`);p(e.data.results),h(e.data.count)}catch(e){console.error("Error fetching data:",e)}finally{n(!1)}},B=async u=>{u.preventDefault(),F(null),v(null),n(!0);try{const e=await a.get(`poultry_hatching/?role=${c()}&chain=true&search=filter&value=`);p(e.data.results),h(e.data.count)}catch(e){console.error("Error fetching data:",e)}finally{n(!1)}},Q=async u=>{u.preventDefault(),n(!0);try{const e=await a.get(`poultry_hatching?role=${c()}&age1=${o}&age2=${C}&chain=true`);p(e.data.results),h(e.data.count)}catch(e){console.error("Error fetching data:",e)}finally{n(!1)}};let U=[{name:"ردیف",selector:(u,e)=>e+1,sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"30px"},{name:"شرکت زنجیره",selector:(u,e)=>{var r,i;return`${(r=u==null?void 0:u.chainCompany)==null?void 0:r.name} (${(i=u==null?void 0:u.chainCompany)==null?void 0:i.user.mobile})`},sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"وضعیت",selector:(u,e)=>t.jsx(x,{variant:"body2",color:u.violation?"error":"black",children:u.violation?"متخلف":"عادی"}),sortable:!1,wrap:!0,allowOverflow:!0,center:!0,width:"60px"},{name:"نام فارم",selector:u=>u.poultry.unitName,sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"90px"},{name:"مرغدار",selector:u=>`${u.poultry.userprofile.fullName} (${u.poultry.userprofile.mobile})`,sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"شهر/تعاونی",selector:u=>{var e,r,i;return`${(e=u==null?void 0:u.poultry)==null?void 0:e.address.city.name}/${(r=u==null?void 0:u.poultry)!=null&&r.cityOperator?(i=u==null?void 0:u.poultry)==null?void 0:i.cityOperator:"بدون تعاونی"}`},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"دامپزشک فارم",selector:u=>{var e,r,i;return(e=u==null?void 0:u.vetFarm)!=null&&e.vetFarmMobile?`${(r=u==null?void 0:u.vetFarm)==null?void 0:r.vetFarmFullName} (${(i=u==null?void 0:u.vetFarm)==null?void 0:i.vetFarmMobile})`:"-"},sortable:!0,wrap:!0,allowOverflow:!0,center:!0,width:"80px"},{name:"سالن",selector:u=>u.hall,sortable:!0,wrap:!0,allowOve
|