Files
Rasadyar_FrontEnd/build/assets/SendMassage-CpDMN-RW.js

2 lines
47 KiB
JavaScript
Raw Normal View History

2026-01-19 15:55:00 +03:30
import{j as u,T as b,ak as N,d as Y,B as T,bf as te,ai as O,aX as M,bg as re,a3 as F,ag as Q,av as Z,aw as uu,ax as m,ah as ne,aj as Su,I as K,b0 as Au,b5 as Wu,am as se,an as ae,b4 as Ru,ap as bu,aq as Fu,b as vu,s as $u,ar as oe,a9 as le}from"./mui-vendor-CkIVaoQP.js";import{L as S,j as E,h as v,A as U,V as mu,c as tu,M as q,cs as ie,u as ru,G as h,S as P,ct as ce,C as eu,b as au,O as J,X as _,N as Xu,p as Ce,cu as de,cv as he,cw as pe,cx as Tu,cy as Pu,cz as cu,cA as Ou,cB as Nu,cC as Cu,cD as xe,cE as ge,cF as Iu,cG as wu,cH as ku,cI as du,cJ as Mu,cK as Du,cL as hu,cM as pu,cN as Bu,cO as xu,cP as Uu,cQ as gu,cR as zu,cS as Vu}from"./index-Vwb3Bce5.js";import{L as X}from"./LinkItem-Cp7DiDkz.js";import{r as C,f as ve,k as H}from"./react-vendor-CmFgShSM.js";import{S as Lu}from"./SelectCheck-CAe89SYT.js";import{a as R,u as z,f as Ae}from"./redux-vendor-B7uoacJt.js";import{d as me}from"./Add-C-nZhvlM.js";import{d as je}from"./Refresh-D98x_8Pm.js";import{a as Ee,R as Hu}from"./index.esm-Bu7XMDZU.js";import{A as fe}from"./AdvancedTable-B0ObjV8k.js";import{e as Gu,f as lu,g as _e,h as ye}from"./index.esm-BY9chGNa.js";import{B as Se}from"./BackButton-CX1bfrW9.js";import{a as Re}from"./get-announcement-BMpjiNsX.js";import{g as be}from"./getRoleList-BYQaJKdj.js";import{P as Yu}from"./PageTable-CMByDrOd.js";import{d as ju}from"./Tune-DzkdDfJZ.js";import{d as Fe}from"./PublishedWithChanges-BErs-ATv.js";import{d as Ku}from"./Edit-CwJaslma.js";import{d as Ju}from"./Delete-DHYHiC8G.js";import{R as Te}from"./ResponsiveTable-DugzNG82.js";import"./iconBase-BEJYyZsk.js";import"./index-CgNdnt2v.js";import"./Close-8pFLGZ5w.js";import"./Search-CLlOaERQ.js";import"./styled-components.browser.esm-gS9mh05b.js";import"./FilterAlt-CTDmPS36.js";const Pe=["Admin","CityOperator","Poultry","ProvinceOperator","ProvinceFinancial","KillHouse","KillHouseVet","VetFarm","Driver","ProvinceInspector","VetSupervisor","Jahad","ProvincialGovernment"],Oe=R("PROVINCE_GET_USERS_BY_ROLES_SERVICE",async(e,{dispatch:t})=>{try{t(S());const{data:r,status:s}=await E.get("diageram",{params:e});return t(v()),{data:r,status:s}}catch(r){return t(v()),{error:r.response.data}}}),Ne=R("PROVINCE_SEND_SMS_SERVICE",async(e,{dispatch:t})=>{try{t(S());const{data:r,status:s}=await E.post("sms/",e);return t(v()),{data:r,status:s}}catch(r){return t(v()),{error:r.response.data}}});function Ie(){const e=z(),[t]=C.useContext(U),[r,s]=C.useState([]),[i,n]=C.useState([]),[a,x]=C.useState([]);C.useEffect(()=>{if(r.length){const g=r.map(k=>({label:k.fullname,value:k.key}));n(g)}},[r]);const[d]=C.useState(Pe.map((g,k)=>({label:mu(g),value:g}))),l=tu().shape({selectedRoles:ie().required("لطفا نقش را انتخاب کنید"),inputText:q().required("لطفا متن پیامک را وارد کنید")}),o=ru({initialValues:{selectedRoles:[],inputText:""},validationSchema:l,onSubmit:()=>{e(Ne({user:a,message:o.values.inputText,role:o.values.selectedRoles})).then(g=>{g.payload.status===200&&t({vertical:"top",horizontal:"center",msg:"عملیات با موفقیت انجام شد.",severity:"success"})})}});C.useEffect(()=>{o.validateForm()},[]);const y=g=>{const k=/[آ-ی]/.test(g);let I=0;return k?I=A(g)*980:I=A(g)*1320,o.values.selectedRoles.length?a.length>0?I*a.length+" ریال":I*i.length+" ریال":"نامشخص (پیامک برای کل کاربران ارسال میشود) "},A=g=>{const k=[160,146,153,153],I=[70,64,67,67],L=/[آ-ی]/.test(g)?I:k;let W=g.length,G=0;for(;W>0;){const j=L[G]||L[L.length-1];if(W>=j)W-=j,G++;else{G++;break}}return G};return C.useEffect(()=>{o.values.selectedRoles.length&&e(Oe({role:o.values.selectedRoles.join(",")})).then(g=>s(g.payload.data))},[o.values.selectedRoles]),u.jsxs(h,{container:!0,mx:P.SMALL,justifyContent:"space-between",children:[u.jsx(h,{item:!0,xs:12,sm:12,md:4,lg:3,direction:"column",alignItems:"start",gap:P.SMALL,children:u.jsx(h,{children:u.jsxs("form",{style:{display:"flex",alignItems:"start",flexDirection:"column",gap:P.LARGE},onSubmit:o.handleSubmit,children:[u.jsxs(h,{children:[u.jsx(Lu,{name:"selectedOption",label:"انتخ