Files
Rasadyar_FrontEnd/build/assets/ProvinceProducts-C9GkeL6h.js

2 lines
5.2 KiB
JavaScript

import{j as r,ak as t,B as f,b5 as h,T as v,b as F}from"./mui-vendor-CkIVaoQP.js";import{L as k,j as S,h as y,A as x,u as T,c as b,M as I,G as o,a$ as A,O as M,S as g}from"./index-N50kY0pn.js";import{r as p}from"./react-vendor-CmFgShSM.js";import{a as O,u as P,f as D}from"./redux-vendor-B7uoacJt.js";import{S as E}from"./SimpleTable-CB4BAAR3.js";import"./index-Cyn2oTqg.js";import"./Close-Cnq7tLoz.js";import"./Search-DJS_LN_I.js";import"./Delete-CiVJBR3T.js";const C=O("PROVINCE_SUBMUIT_PRODUCT_PRICE",async(n,{dispatch:e})=>{try{e(k());const{data:l,status:s}=await S.put("additional-products/0/",n);return e(y()),{data:l,status:s}}catch(l){return e(y()),{error:l.response.data.result}}}),B=({item:n})=>{const[e]=p.useContext(x),l=P(),s=T({initialValues:{price:""},validationSchema:b({price:I().required("این فیلد اجباری است!").typeError("لطفا فیلد را به درستی وارد کنید!")})});return p.useEffect(()=>{s.validateForm()},[]),r.jsxs(o,{container:!0,justifyContent:"center",gap:2,alignItems:"center",children:[r.jsx(o,{children:r.jsx(t,{fullWidth:!0,id:"price",label:"قیمت",value:s.values.price,error:s.touched.price?!!s.errors.price:null,onChange:s.handleChange,onBlur:s.handleBlur,helperText:s.touched.price&&s.errors.price?s.errors.price:null,autoComplete:"current-password",variant:"outlined"})}),r.jsx(o,{children:r.jsx(f,{disabled:!s.isValid,variant:"contained",onClick:()=>{l(C({product_key:n==null?void 0:n.key,selling_free_price:n==null?void 0:n.sellingFreePrice,selling_approved_price:n==null?void 0:n.sellingApprovedPrice,selling_more_than_inventory:n==null?void 0:n.sellingMoreThanInventory,selling_other_products:n==null?void 0:n.sellingOtherProducts,price:s.values.price})).then(_=>{_.error?e({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(e({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),l(A()))})},children:"ثبت"})})]})},$=()=>{const[n]=p.useContext(x),e=P();p.useEffect(()=>{e(A())},[]);const l=d=>{d.error?n({vertical:"top",horizontal:"center",msg:"مشکلی پیش آمده است!",severity:"error"}):(n({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"}),e(A()))},{provinceProductList:s}=D(d=>d.provinceSlice),[_,j]=p.useState([]);return p.useEffect(()=>{const d=s==null?void 0:s.map((u,a)=>[a+1,u==null?void 0:u.name,r.jsx(h,{checked:u==null?void 0:u.sellingApprovedPrice,onClick:()=>{e(C({product_key:u==null?void 0:u.key,selling_free_price:u==null?void 0:u.sellingFreePrice,selling_approved_price:(u==null?void 0:u.sellingApprovedPrice)!==!0,selling_more_than_inventory:u==null?void 0:u.sellingMoreThanInventory,selling_other_products:u==null?void 0:u.sellingOtherProducts,price:u==null?void 0:u.price})).then(c=>{l(c)})}},a),r.jsx(h,{checked:u==null?void 0:u.sellingFreePrice,onClick:()=>{e(C({product_key:u==null?void 0:u.key,selling_free_price:(u==null?void 0:u.sellingFreePrice)!==!0,selling_approved_price:u==null?void 0:u.sellingApprovedPrice,selling_more_than_inventory:u==null?void 0:u.sellingMoreThanInventory,selling_other_products:u==null?void 0:u.sellingOtherProducts,price:u==null?void 0:u.price})).then(c=>{l(c)})}},a),r.jsx(h,{checked:u==null?void 0:u.sellingMoreThanInventory,onClick:()=>{e(C({product_key:u==null?void 0:u.key,selling_free_price:u==null?void 0:u.sellingFreePrice,selling_approved_price:u==null?void 0:u.sellingApprovedPrice,selling_more_than_inventory:(u==null?void 0:u.sellingMoreThanInventory)!==!0,selling_other_products:u==null?void 0:u.sellingOtherProducts,price:u==null?void 0:u.price})).then(c=>{l(c)})}},a),r.jsx(h,{checked:u==null?void 0:u.sellingOtherProducts,onClick:()=>{e(C({product_key:u==null?void 0:u.key,selling_free_price:u==null?void 0:u.sellingFreePrice,selling_approved_price:u==null?void 0:u.sellingApprovedPrice,selling_more_than_inventory:u==null?void 0:u.sellingMoreThanInventory,selling_other_products:(u==null?void 0:u.sellingOtherProducts)!==!0,price:u==null?void 0:u.price})).then(c=>{l(c)})}},a),r.jsx("a",{href:u==null?void 0:u.image,alt:"دانلود تصویر محصول",children:r.jsx("img",{src:u==null?void 0:u.image,width:"50",height:"50",alt:"بدون بار",className:"images-file"})},"productPicture"),r.jsxs(o,{container:!0,justifyContent:"center",children:[r.jsx(v,{mr:2,children:u==null?void 0:u.price}),r.jsx(f,{disabled:!(u!=null&&u.sellingApprovedPrice),size:"small",variant:"contained",onClick:()=>{e(M({title:"ثبت قیمت",content:r.jsx(B,{item:u})}))},children:"ثبت"})]},a)]);j(d)},[s]),r.jsx(r.Fragment,{children:r.jsx(F,{display:"flex",justifyContent:"center",children:r.jsx(o,{container:!0,direction:"column",justifyContent:"center",xs:12,sm:12,md:10,lg:10,children:r.jsx(o,{container:!0,justifyContent:"space-between",gap:g.SMALL,mt:g.SMALL,children:r.jsxs(o,{width:"100%",children:[r.jsx(o,{mt:g.SMALL,mb:g.SMALL,children:r.jsx(v,{variant:"body1",children:"محصولات"})}),r.jsx(E,{data:_,columns:["ردیف","نام محصول","قیمت به قیمت دولتی","فروش به قیمت آزاد","فروش بیشتر از انبار","فروش سایر محصولات","تصویر","قیمت"]})]})})})})})};export{$ as default};