1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[1908],{59491:(e,s,i)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/_admin",function(){return i(96537)}])},96537:(e,s,i)=>{"use strict";i.r(s),i.d(s,{__N_SSP:()=>y,default:()=>S});var a=i(37876),l=i(14232),t=i(77328),n=i.n(t),r=i(48230),o=i.n(r),d=i(75656),c=i(92306),m=i(61875),u=i(19512),h=i(27910),x=i(30338),p=i(33115),g=i(87868),v=i(71950),j=i(60577),b=i(11444),f=i(11613);function N(){let{config:e,ready:s}=(0,j.r)(),[i,t]=(0,l.useState)(""),[n,r]=(0,l.useState)(""),[o,d]=(0,l.useState)(""),[c,m]=(0,l.useState)(null),x=s&&e.flags.useNewNotifications,p=o.trim()?parseInt(o.trim(),10):void 0,g=null!=p&&!Number.isNaN(p)&&p>0,v=o.trim().length>0&&!g;async function N(e,s){let i=JSON.stringify({message:s,workflowId:e});confirm("Send message to everyone?")&&(await fetch("/api/admin/notification/broadcast_to_all",{method:"post",headers:{"Content-Type":"application/json"},body:i}).then(async e=>{e.status>=400?alert("Failed: "+await e.text()):console.log("Good - status is",await e.text())}).catch(e=>{alert("Failed: "+e.message),(0,f.UG)("Failed to send: "+e.message)}),r(""))}async function _(){let e=i.trim(),s=n.trim();if(!e||!s)return void alert("Title and message are required");if(v)return void alert("User ID must be a positive number");if(confirm(g?`Send in-app notification to user ${p} only?`:`No user ID provided â this will send to all ${c??"eligible"} users. Continue?`))try{let i=await (0,b.OD)(e,s,g?p:void 0);(0,f.VX)(g?`Sent to user ${p}`:`Sent to ${i} users`),t(""),r(""),d("")}catch(s){let e=s instanceof Error?s.message:"Failed to send";alert("Failed: "+e),(0,f.UG)("Failed to send: "+e)}}return((0,l.useEffect)(()=>{if(!x)return;let e=!1;return(0,b.O8)().then(s=>{e||m(s)}).catch(s=>{e||console.error("Failed to load broadcast recipient count",s)}),()=>{e=!0}},[x]),s)?x?(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(h.A,{label:"Title",value:i,onChange:e=>t(e.target.value),fullWidth:!0,size:"small",className:"mb-3"}),(0,a.jsx)(h.A,{label:"User ID (optional)",value:o,onChange:e=>d(e.target.value),fullWidth:!0,size:"small",className:"mb-3",placeholder:"Leave blank to send to all eligible users",error:v,helperText:v?"Enter a positive user ID, or leave blank for everyone":"Leave blank to broadcast to all eligible users"}),(0,a.jsx)("textarea",{value:n,rows:8,cols:60,className:"w-full rounded border border-neutral-700 bg-neutral-900 p-3 text-white",onChange:e=>r(e.target.value)}),(0,a.jsxs)("div",{className:"mt-2 text-sm text-neutral-300",children:["Recipients:"," ",g?`1 user (ID ${p})`:null==c?"loading...":`${c} users (all eligible)`]}),(0,a.jsxs)("div",{className:"mt-4 flex flex-row gap-3",children:[(0,a.jsx)(u.A,{variant:"contained",onClick:()=>void _(),children:"Send in-app"}),(0,a.jsx)(u.A,{variant:"outlined",disabled:!0,title:"Email broadcast could be dangerous",children:"Send email (disabled)"})]}),(0,a.jsx)("div",{className:"mt-2 text-xs text-amber-300",children:"Email broadcast is disabled in v1 because it could be dangerous."})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)("textarea",{value:n,rows:8,cols:60,onChange:e=>r(e.target.value)}),(0,a.jsx)("div",{className:"bg-black",children:n}),(0,a.jsx)(u.A,{onClick:()=>N("send-all-web-users-a-note",n),children:"Send"})]}):null}var _=i(8961),y=!0;function S(e){let[s,i]=(0,l.useState)(),[t,r]=(0,l.useState)(),[j,b]=(0,l.useState)(),[y,S]=(0,l.useState)(""),[w,C]=(0,l.useState)(""),{data:E}=(0,d.Ay)("/api/admin/admin_manage",(0,c.we)()),{isTaskLoading:I,runAdminTask:A,runConfirmedTask:D}=(0,_.hN)();if(!(0,p.B)())return(0,a.jsx)(x.G,{});async function k(){await A("give_commission_discount","Give Commission Discount","/api/admin/give_commission_discount",{confirm:"Apply commission discount with the entered user, seller, and commission IDs?",body:{userId:t,sellerId:s,commissionTypeId:j}})}async function F(){console.log("Submitting...");try{let e=await fetch("/api/beta",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:y,user_type:{},noEmail:!0})}).then(e=>e.json()).catch(e=>{console.log("FAILED.. parse response",e)});e.ok?(console.log("RESP_OK",e),(0,f.VX)("Submitted ok.")):(0,f.UG)("Failed to submit, please ensure you have entered your email.")}catch(e){console.log("FAILED"),(0,f.UG)("Failed to submit, please ensure you have entered your email correctly.")}}return(0,a.jsxs)(g.A,{...e,children:[(0,a.jsx)(n(),{children:(0,a.jsx)("title",{children:"Admin"})}),(0,a.jsxs)("div",{className:"flex flex-col gap-10 pb-8",children:[(0,a.jsxs)(_.hR,{title:"Discounts / Coupons",children:[(0,a.jsx)("div",{className:"flex justify-end",children:(0,a.jsx)(o(),{href:"/_admin/discount",children:(0,a.jsx)(u.A,{size:"small",variant:"outlined",children:"Create new Discount / Sale"})})}),(0,a.jsx)(_.IE,{className:"overflow-x-auto p-0",children:(0,a.jsxs)("div",{className:"min-w-[640px]",children:[(0,a.jsxs)("div",{className:"grid grid-cols-12 gap-2 px-3 py-2 text-xs uppercase text-neutral-400 bg-neutral-900 border-b border-neutral-700",children:[(0,a.jsx)("div",{className:"col-span-2",children:"Name"}),(0,a.jsx)("div",{className:"col-span-2",children:"Code"}),(0,a.jsx)("div",{className:"col-span-1",children:"Discount"}
1),(0,a.jsx)("div",{className:"col-span-2",children:"Min spend"}),(0,a.jsx)("div",{className:"col-span-4",children:"Description"}),(0,a.jsx)("div",{className:"col-span-1 text-right",children:"Edit"})]}),E?.discounts?.length?E.discounts.map(e=>(0,a.jsxs)("div",{className:"grid grid-cols-12 gap-2 px-3 py-2 text-xs border-b border-neutral-800 last:border-b-0",children:[(0,a.jsx)("div",{className:"col-span-2",children:e.name}),(0,a.jsxs)("div",{className:"col-span-2",children:[e.code_prefix,"-",e.code]}),(0,a.jsxs)("div",{className:"col-span-1",children:[e.percentage_off,"%"]}),(0,a.jsx)("div",{className:"col-span-2",children:e.minimum_spend}),(0,a.jsx)("div",{className:"col-span-4 text-neutral-400",children:e.description}),(0,a.jsx)("div",{className:"col-span-1 text-right",children:(0,a.jsx)(m.WJ,{href:`/_admin/discount/?id=${e.id}`,children:"Edit"})})]},e.id)):(0,a.jsx)("p",{className:"px-3 py-4 text-sm text-neutral-500",children:"No discounts configured."})]})})]}),(0,a.jsx)(_.hR,{title:"Commission Discounts",description:"Apply a commission discount to a specific user and seller.",children:(0,a.jsxs)(_.IE,{children:[(0,a.jsxs)("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-3 mb-4",children:[(0,a.jsx)(h.A,{label:"User ID",size:"small",value:t??"",onChange:e=>r(e.target.value),fullWidth:!0}),(0,a.jsx)(h.A,{label:"Seller ID",size:"small",value:s??"",onChange:e=>i(e.target.value),fullWidth:!0}),(0,a.jsx)(h.A,{label:"Commission ID",size:"small",value:j??"",onChange:e=>b(e.target.value),fullWidth:!0})]}),(0,a.jsx)(_.DR,{loading:I("give_commission_discount"),onClick:k,variant:"contained",children:"Apply commission discount"})]})}),(0,a.jsx)(_.hR,{title:"Communications",description:"Invites, test emails, and user messaging.",children:(0,a.jsxs)("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[(0,a.jsxs)(_.IE,{title:"Beta invite",description:"Submit a beta invite without sending email.",children:[(0,a.jsx)(h.A,{name:"email",className:"w-full",label:"Email (required)",value:y,onChange:e=>S(e.target.value),size:"small",fullWidth:!0}),(0,a.jsx)("div",{className:"mt-3",children:(0,a.jsx)(u.A,{variant:"contained",size:"small",onClick:()=>{confirm("Submit this invite with the entered email?")&&F()},children:"Submit invite"})})]}),(0,a.jsx)(_.IE,{title:"Test email",description:"Trigger the admin test email endpoint.",children:(0,a.jsx)(_.DR,{loading:I("send_email"),onClick:()=>D("send_email","Send Email","/api/admin/send_email","Send the admin test email?"),variant:"contained",children:"Send test email"})}),(0,a.jsxs)(_.IE,{title:"QR code",description:"Generate a QR code from any text value.",className:"lg:col-span-2",children:[(0,a.jsx)(h.A,{name:"qrValue",className:"w-full",label:"QR value",value:w,onChange:e=>C(e.target.value),size:"small",fullWidth:!0}),(0,a.jsx)("div",{className:"mt-4 flex justify-center",children:(0,a.jsx)(v.X,{value:w,size:280})})]}),(0,a.jsx)(_.IE,{title:"Send message",description:"Send a notification message to users.",className:"lg:col-span-2",children:(0,a.jsx)(N,{...e})})]})})]})]})}}},e=>{e.O(0,[5712,2103,636,6593,8792],()=>e(e.s=59491)),_N_E=e.O()}]);
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.