PageSourceSearch

https://rsdmrkt.com/assets/GlobalPricingRulePage-D2TzkXjl.js

js rsdmrkt.com collected 2026-09-25 04:10:35 UTC 6,539 bytes, 1 lines download raw bytes

1import{e as B,b as z,c as $,r as g,j as e,L as f}from"./emotion-element-f0de968e.browser.esm-DAcAn3jx.js";import{S as L}from"./SkipNext-BP6HZFXB.js";import{P as A,b as E}from"./ItemNotFound-ryDCeKGA.js";import{u as G,s as M,q as N,t as O}from"./api-KZNW2Ket.js";import{h as U}from"./moment-BLMuvzoS.js";import{B as a,T as c}from"./Box-CdsPgKjk.js";import{C as _,B as u,u as q}from"./Button-KVxmVPcQ.js";import{C as J}from"./Card-QqbP_w_-.js";import{T as H}from"./TextField-BKbREhBK.js";import{I as P}from"./Favorite-V6xGmSVP.js";import"./Snackbar-BLmOveHA.js";import"./index-DkVogYJF.js";import"./imageUtils-Bv75Hoxq.js";import"./useId-BOtalUON.js";import"./getThemeProps-B4ZF914Q.js";import"./LocationOn-DM2UKiY4.js";import"./Price-CnfREIyP.js";import"./appPaths-B9EFiJhW.js";import"./Divider-DJxQQ4t0.js";import"./IconButton-C4bln0zo.js";import"./Edit-DQtX7EYK.js";import"./DialogTitle-BztL3sGR.js";import"./Tooltip-BamK8vw1.js";import"./FormControlLabel-gDZUzoP6.js";import"./Checkbox-BQKglEA7.js";import"./DefaultButton-EB8kJvev.js";import"./Chip-BmmJUiHy.js";import"./LocalizationProvider-DSrdV9YK.js";import"./useThemeProps-DVgs-USV.js";import"./Drawer-D9kGXRYg.js";import"./index.esm-CUxG0IsZ.js";const We=({edit:o})=>{var b,j,C,y,w;const l=B(),r=G(M);let{storeId:n}=z();n||(n=(b=r==null?void 0:r.role)==null?void 0:b.store);const s=(j=$().state)==null?void 0:j.rule,t=!!(o&&s),[m,d]=g.useState(t?(C=s.rule)==null?void 0:C.ruleType:"markup"),[x,R]=g.useState(t?(y=s.rule)==null?void 0:y.operator:"flat"),[p,S]=g.useState(t?(w=s.rule)==null?void 0:w.amount:0),[I,{isLoading:W}]=N(),[v,{isLoading:V}]=O(),D=()=>{const h={store:n,name:"Global Pricing Rule",global:!0,priority:0,startDate:U().toISOString(),rule:{ruleType:m,operator:x,amount:p}};I({rule:h,storeId:n}).unwrap().then(T=>{l(`/admin/pricing/${n}`)})},F=()=>{const h={_id:s._id,rule:{ruleType:m,operator:x,amount:p}};v({rule:h}).unwrap().then(T=>{l(`/admin/pricing/${n}`)})};return o&&!s?e.jsxs(a,{sx:{p:4},children:[e.jsx(c,{variant:"h5",sx:{mb:2},children:"Pricing rule not available"}),e.jsx(c,{sx:{mb:2},children:"Open the global rule from the pricing list to edit it — this page can’t be reloaded or bookmarked directly."}),e.jsx(f,{to:`/admin/pricing/${n}`,children:"Back to pricing rules"})]}):e.jsxs(a,{sx:{p:4},children:[e.jsxs(a,{sx:{display:"flex"},children:[e.jsx(f,{to:`/admin/dashboard/${n}`,style:{WebkitTextDecoration:"none",textDecoration:"none"},children:e.jsx(c,{color:"text.secondary",sx:{fontWeight:600,"&:hover":{textDecoration:"underline"}},children:"Admin"})}),"/",e.jsx(f,{to:`/admin/pricing/${n}`,style:{WebkitTextDecoration:"none",textDecoration:"none"},children:e.jsx(c,{color:"text.secondary",sx:{fontWeight:600,"&:hover":{textDecoration:"underline"}},children:"Pricing"})}),"/",e.jsx(c,{color:"text.secondary",sx:{fontWeight:600},children:"Global Rule"})]}),e.jsxs(c,{variant:"h2",sx:{mt:2,mb:2,fontSize:"14px",fontWeight:700,fontFamily:"Plus Jakarta Sans"},color:"text.primary",children:[o?"Edit":"New"," Global Pricing Rule"]}),e.jsx(Q,{ruleType:m,setRuleType:d,operator:x,setOperator:R,amount:p,setAmount:S}),e.jsx(a,{sx:{mt:4},children:W?e.jsx(_,{color:"warning"}):e.jsxs(a,{sx:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:1},children:[e.jsxs(u,{variant:"outlined",color:"warning",size:"small",sx:K,onClick:()=>{o&&s?F():D()},disabled:x==="set"&&(p===""||parseFloat(p)===0),children:["Accept and Finalize ",e.jsx(L,{})]}),x==="set"&&(p===""||parseFloat(p)===0)&&e.jsx(c,{color:"error",sx:{fontSize:"12px",ml:1},children:"Can't set price to $0.00"})]})})]})},k=({theme:o,thisType:l,currentType:r})=>{const n=l===r?o.palette.warning.main:o.palette.background.parchment,i=l===r?"white":o.palette.text.secondary,s=l===r?o.palette.warning.dark:o.palette.background.default;return{backgroundColor:n,color:i,fontWeight:700,borderRadius:"0px",textTransform:"none","&:hover":{backgroundColor:s,color:i}}},K={borderRadius:"14px",textTransform:"none",fontSize:"14px",fontWeight:700,p:"3px 10px",display:"flex",alignItems:"center",gap:1},Q=({ruleType:o,setRuleType:l,operator:r,setOperator:n,amount:i,setAmount:s})=>{const t=q(),m=d=>{(d===""||/^\d*\.?\d{0,2}$/.test(d))&&s(d)};return e.jsxs(J,{sx:{display:"flex",flexDirection:"column",alignItems:"center",maxWidth:"400px"},children:[e.jsx(a,{sx:{backgroundColor:"#383838",p:"5px 10px",width:"100%"},children:e.jsx(c,{sx:{fontFamily:"Oswald",fontSize:"20px",fontWeight:500,color:"white"},children:"Change price by"})}),e.jsxs(a,{sx:{backgroundColor:t.palette.background.parchment,width:"100%",height:"100%"},children:[e.jsxs(a,{sx:{display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center"},children:[e.jsx(u,{sx:{borderRadius:0,textTransform:"none",fontWeight:700,width:"100%",color:o==="markup"?"white":t.palette.text.secondary,backgroundColor:o==="markup"&&r!=="set"?t.palette.success.main:t.palette.background.parchment,"&:hover":{backgroundColor:o==="markup"?t.palette.success.dark:t.palette.background.default}},disabled:r==="set",onClick:()=>l("markup"),children:"Increase"}),e.jsx(u,{sx:{borderRadius:0,textTransform:"none",fontWeight:700,width:"100%",color:o==="markdown"?"white":t.palette.text.secondary,backgroundColor:o==="markdown"&&r!=="set"?t.palette.error.main:t.palette.background.parchment,"&:hover":{backgroundColor:o==="markdown"?t.palette.error.dark:t.palette.background.default}},disabled:r==="set",onClick:()=>l("markdown"),children:"Decrease"})]}),e.jsxs(a,{children:[e.jsx(u,{sx:k({theme:t,thisType:"flat",currentType:r}),onClick:()=>{n("flat"),(i===""||parseFloat(i)===0)&&s(0)},children:"Flat Rate"}),e.jsx(u,{sx:k({theme:t,thisType:"percent",currentType:r}),onClick:()=>{n("percent"),(i===""||parseFloat(i)===0)&&s(0)},children:"Percentage"}),e.jsx(u,{sx:k({theme:t,thisType:"set",currentType:r}),onClick:()=>{n("set"),(i===""||parseFloat(i)===0)&&s(10)},children:"Set price to specific amount"})]}),e.jsx(a,{sx:{p:2,display:"flex",flexDirection:"row",alignItems:"center",justifyContent:"center"},children:e.jsx(H,{size:"small",placeholder:"Enter amount",InputProps:r==="percent"?{endAdornment:e.jsx(P,{position:"end",children:e.jsx(A,{})})}:{startAdornment:e.jsx(P,{position:"start",children:e.jsx(E,{})})},sx:{width:"100%","& .MuiOutlinedInput-root":{fontSize:"16px",fontWeight:500,backgroundColor:t.palette.background.paper}},value:i,onChange:d=>m(d.target.value),error:r==="set"&&(i===""||parseFloat(i)===0),helperText:r==="set"&&(i===""||parseFloat(i)===0)?"Can't set price to $0.00":""})})]})]})};export{We as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.