2 lines
13 KiB
JavaScript
2 lines
13 KiB
JavaScript
|
|
import{j as u,an as B,ac as N,B as v,I as uu,b3 as eu,d as Z,T as R,b as ru}from"./mui-vendor-D_SVL-Dx.js";import{j as V,A as G,u as K,c as Q,b as D,v as J,G as l,S as g,$ as ou,L as H,h as j,b3 as nu,W as M,a0 as Y,ad as tu,O as iu,b4 as lu,C as au,p as m}from"./index-D80MdVQn.js";import{r as C}from"./react-vendor-CmFgShSM.js";import{a as X,u as T}from"./redux-vendor-CfkcHgWN.js";import{N as O}from"./NumberFormatCustom-BXcOcGV4.js";import{C as su}from"./CustomCard-Cq1zECRb.js";import{R as cu}from"./ResponsiveTable-bUYl0qDM.js";import{d as Cu}from"./Tune-BBzxV8DK.js";import"./FilterAlt-DZsHj-WQ.js";import"./styled-components.browser.esm-gS9mh05b.js";const du=X("PROVINCE_NEW_PRICING",async i=>{const{data:r,status:e}=await V.post("pricing/",i);return{data:r,status:e}}),hu=()=>{const[i]=C.useContext(G),r=T(),e=K({initialValues:{date:J(Date()).format("YYYY-MM-DD hh:mm:ss"),price:"",floorprice:"",ceilingprice:""},validationSchema:Q({price:D().required("این فیلد اجباری است!").typeError("لطفا عدد وارد کنید!")})});return C.useEffect(()=>{e.validateForm()},[]),u.jsxs(l,{container:!0,gap:g.SMALL,direction:"column",height:"100%",justifyContent:"space-between",children:[u.jsx(l,{children:u.jsx(ou,{fullWidth:!0,label:"تاریخ",id:"date",renderInput:a=>u.jsx(B,{...a}),value:e.values.date,error:e.touched.date?!!e.errors.date:null,onChange:a=>{e.setFieldValue("date",J(a).format("YYYY-MM-DD hh:mm:ss"))},onBlur:e.handleBlur,helperText:e.touched.date&&e.errors.date?e.errors.date:null})}),u.jsx(l,{children:u.jsx(O,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"price",label:"قیمت هر کیلو مرغ زنده",variant:"outlined",InputLabelProps:{shrink:!0},InputProps:{endAdornment:u.jsx(N,{position:"start",children:"ریال"})},value:e.values.price,error:e.touched.price?!!e.errors.price:null,onChange:e.handleChange,onBlur:e.handleBlur,helperText:e.touched.price&&e.errors.price?e.errors.price:null})}),u.jsx(l,{children:u.jsx(O,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"floorprice",label:"قیمت کف",variant:"outlined",InputLabelProps:{shrink:!0},InputProps:{endAdornment:u.jsx(N,{position:"start",children:"ریال"})},value:e.values.floorprice,error:e.touched.floorprice?!!e.errors.floorprice:null,onChange:e.handleChange,onBlur:e.handleBlur,helperText:e.touched.floorprice&&e.errors.floorprice?e.errors.floorprice:null})}),u.jsx(l,{children:u.jsx(O,{allowLeadingZeros:!0,thousandSeparator:",",fullWidth:!0,id:"ceilingprice",label:"قیمت سقف",variant:"outlined",InputLabelProps:{shrink:!0},InputProps:{endAdornment:u.jsx(N,{position:"start",children:"ریال"})},value:e.values.ceilingprice,error:e.touched.ceilingprice?!!e.errors.ceilingprice:null,onChange:e.handleChange,onBlur:e.handleBlur,helperText:e.touched.ceilingprice&&e.errors.ceilingprice?e.errors.ceilingprice:null})}),u.jsx(l,{children:u.jsx(v,{fullWidth:!0,variant:"contained",component:"label",disabled:!e.isValid,size:"large",onClick:()=>{e.values.floorprice>e.values.ceilingprice?i({vertical:"top",horizontal:"center",msg:"قیمت گذاری غیر استاندارد است!",severity:"error"}):(r(H()),r(du({date:e.values.date,live_chicken_price:e.values.price,floor_price:e.values.floorprice?e.values.floorprice:0,ceiling_price:e.values.ceilingprice?e.values.ceilingprice:0})).then(a=>{a.error?(r(j()),i({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"})):r(nu()).then(c=>{r(j()),i({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),r(M({right:!1,bottom:!1,content:null}))})}))},children:"ثبت درخواست"})})]})},$=X("PROVINCE_PRICE_EDIT_SERVICE",async(i,{dispatch:r})=>{var e,a;try{r(H());const{data:c,status:d}=await V.put(`chicken-commission-prices/${i.id}/`,{kill_house_price:i.kill_house_price,wholesaler_price:i.wholesaler_price,retailer_price:i.retailer_price});return r(j()),{data:c,status:d}}catch(c){return r(j()),{error:((a=(e=c==null?void 0:c.response)==null?void 0:e.data)==null?void 0:a.result)||"خط
|