PageSourceSearch

https://extremebargains.uk/assets/BoostUsersManagement-caEnqSEx.js

js extremebargains.uk collected 2026-10-09 23:08:39 UTC 5,244 bytes, 4 lines download raw bytes

1import{a3 as L,F as K,r as l,P as I,ab as v,j as e,i as b,o as N,p as C,l as S,I as _,B as w,s as c}from"./index-Bj3g7Z6n.js";import{L as d}from"./label-ZAJAkNWx.js";import{T as $}from"./textarea-DpDzU_cc.js";import{T as M,a as R,b as T,c as m,d as V,e as u}from"./table-DSDqORNl.js";import{U as z}from"./users-CwEKp0xP.js";import{U as A}from"./upload-3X4ftL-M.js";import{T as W}from"./trash-2-C3_qP8oE.js";function se(){const{toast:n}=L(),x=K(),[p,B]=l.useState(""),[h,U]=l.useState(""),[j,E]=l.useState(""),[g,D]=l.useState(""),{data:i,isLoading:k}=I({queryKey:["boost-users"],queryFn:async()=>{const{data:s,error:a}=await c.from("profiles").select("id, username, display_name, created_at, user_id").eq("account_type","boost").order("created_at",{ascending:!1});if(a)throw a;s!=null&&s.map(t=>t.user_id);const o=[];for(const t of s||[])o.push({id:t.id,username:t.username||"",display_name:t.display_name||"",email:`boost_${t.username}@system.local`,created_at:t.created_at||""});return o}}),y=v({mutationFn:async()=>{const{data:s,error:a}=await c.functions.invoke("setup-boost-users",{body:{users:[{email:h,username:j,display_name:g}]}});if(a)throw a;return s},onSuccess:()=>{x.invalidateQueries({queryKey:["boost-users"]}),U(""),E(""),D(""),n({title:"Success",description:"Boost user created successfully"})},onError:s=>{n({title:"Error",description:s.message||"Failed to create user",variant:"destructive"})}}),f=v({mutationFn:async()=>{const a=p.split(`
2`).filter(r=>r.trim()).map(r=>{const[F,H,P]=r.split(",").map(Q=>Q.trim());return{email:F,username:H,display_name:P}}).filter(r=>r.email&&r.username&&r.display_name);if(a.length===0)throw new Error("No valid users found in input");const{data:o,error:t}=await c.functions.invoke("setup-boost-users",{body:{users:a}});if(t)throw t;return o},onSuccess:s=>{var a;x.invalidateQueries({queryKey:["boost-users"]}),B(""),n({title:"Success",description:`Created ${((a=s==null?void 0:s.results)==null?void 0:a.length)||0} boost users`})},onError:s=>{n({title:"Error",description:s.message||"Failed to create users",variant:"destructive"})}}),q=v({mutationFn:async s=>{const{error:a}=await c.from("profiles").delete().eq("id",s);if(a)throw a},onSuccess:()=>{x.invalidateQueries({queryKey:["boost-users"]}),n({title:"Success",description:"Boost user deleted"})},onError:s=>{n({title:"Error",description:s.message||"Failed to delete user",variant:"destructive"})}});return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(b,{children:[e.jsx(N,{children:e.jsxs(C,{className:"flex items-center gap-2",children:[e.jsx(z,{className:"h-5 w-5"}),"Create Single Boost User"]})}),e.jsxs(S,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Email"}),e.jsx(_,{type:"email",placeholder:"[email protected]",value:h,onChange:s=>U(s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Username"}),e.jsx(_,{placeholder:"DealHunter247",value:j,onChange:s=>E(s.target.value)})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Display Name"}),e.jsx(_,{placeholder:"Deal Hunter 247",value:g,onChange:s=>D(s.target.value)})]})]}),e.jsx(w,{onClick:()=>y.mutate(),disabled:!h||!j||!g||y.isPending,children:y.isPending?"Creating...":"Create Boost User"})]})]}),e.jsxs(b,{children:[e.jsx(N,{children:e.jsxs(C,{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5"}),"Bulk Import Boost Users"]})}),e.jsxs(S,{className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"CSV Data (email, username, display_name)"}),e.jsx($,{placeholder:`[email protected],DealHunter247,Deal Hunter 247
3[email protected],BargainQueen,Bargain Queen
4[email protected],SaverPro,Saver Pro`,value:p,onChange:s=>B(s.target.value),rows:8,className:"font-mono text-sm"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Enter one user per line in CSV format: email,username,display_name"})]}),e.jsx(w,{onClick:()=>f.mutate(),disabled:!p.trim()||f.isPending,children:f.isPending?"Creating...":"Create Bulk Users"})]})]}),e.jsxs(b,{children:[e.jsx(N,{children:e.jsxs(C,{children:["Existing Boost Users (",(i==null?void 0:i.length)||0,")"]})}),e.jsx(S,{children:k?e.jsx("div",{className:"text-center py-8",children:"Loading boost users..."}):i&&i.length>0?e.jsxs(M,{children:[e.jsx(R,{children:e.jsxs(T,{children:[e.jsx(m,{children:"Username"}),e.jsx(m,{children:"Display Name"}),e.jsx(m,{children:"Created"}),e.jsx(m,{className:"text-right",children:"Actions"})]})}),e.jsx(V,{children:i.map(s=>e.jsxs(T,{children:[e.jsx(u,{className:"font-mono text-sm",children:s.username}),e.jsx(u,{children:s.display_name}),e.jsx(u,{className:"text-sm text-muted-foreground",children:new Date(s.created_at).toLocaleDateString()}),e.jsx(u,{className:"text-right",children:e.jsx(w,{variant:"ghost",size:"sm",onClick:()=>{confirm(`Delete boost user ${s.username}?`)&&q.mutate(s.id)},children:e.jsx(W,{className:"h-4 w-4 text-destructive"})})})]},s.id))})]}):e.jsx("div",{className:"text-center py-8 text-muted-foreground",children:"No boost users found. Create some above."})})]})]})}export{se as BoostUsersManagement};

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.