2 lines
2.0 KiB
JavaScript
2 lines
2.0 KiB
JavaScript
import{J as a}from"./index-02897754.js";async function h(t){return a.post("/admin/push/broadcast",t)}async function q(t,e,s){return h({title:t,body:e,url:s,mode:"all"})}async function I(t,e,s,n){return h({title:t,body:e,url:n,mode:"selected",userIds:s})}async function F(t){var r;const e=await a.get("/admin/push/logs",{params:{page:t.page,limit:t.limit,search:t.search}}),s=t.page||1,n=t.limit||20,i=(s-1)*n;return{rows:(e.data||[]).map((o,l)=>({...o,index:i+l})),total:e.total??((r=e.data)==null?void 0:r.length)??0,query:{...t,total:e.total??0,page:s,limit:n}}}async function N(t){return(await a.get(`/admin/push/logs/${t}`)).data}async function S(){return a.get("/admin/push/stats")}function P(t){return t===!0||t==="true"||t===1||t==="1"?!0:t===!1||t==="false"||t===0||t==="0"?!1:null}function x(t){const e=[...t||[]],s=e.findIndex(o=>o.field==="has_push");if(s<0)return{filters:e,hasPush:null,pushFilter:null};const n=e.splice(s,1)[0],i=P(n.value);if(i===null)return{filters:e,hasPush:null,pushFilter:null};let r=i;return n.op==="not"&&(r=!i),{filters:e,hasPush:r,pushFilter:n}}function p(t){const e={...t};return delete e.includeIn,delete e.excludeIn,delete e.withPushSubscription,e}function w(t,e,s){var c,d,f;const n=((c=t.query)==null?void 0:c.page)??e.page??1,i=((d=t.query)==null?void 0:d.limit)??e.limit??20,r=((f=t.query)==null?void 0:f.total)??0,o=(n-1)*i,l=(Array.isArray(t.rows)?t.rows:[]).map((m,y)=>({...m,index:o+y})),u=[...e.filters||[]];s&&u.push({...s,hidden:!1,type:s.type||"select"});const g=p({...e,page:n,limit:i,total:r,filters:u});return{rows:l,total:r,query:g}}async function A(t){const e=p({...t,filters:[...t.filters||[]]});!e.sort&&!e.order&&(e.order="-created_at");const{filters:s,hasPush:n,pushFilter:i}=x(e.filters),r={...e,filters:s??[]},o=await a.post("/admin/push/members/table",{page:e.page||1,limit:e.limit||20,search:e.search||void 0,filters:s,order:e.order,sort:e.sort,hasPush:n??void 0});return w({rows:o.rows??[],query:{page:o.page,limit:o.limit,total:o.total}},r,i)}export{S as a,q as b,F as c,N as d,A as g,I as s};
|