PageSourceSearch

https://premiumecom1.lovable.app/assets/admin.users-CJBBJ3LZ.js

js premiumecom1.lovable.app collected 2026-10-03 03:40:16 UTC 4,941 bytes, 1 lines download raw bytes

1import{c as d,as as w,at as C,au as L,an as R,r as x,d as k,j as e,X as E,B as F,t}from"./index-DSXTHp_n.js";import{u}from"./useMutation-DCnUjsax.js";import{I as q}from"./input-CVVKrf1r.js";import{B as _}from"./badge-WDZ8vjSY.js";import{S as B,a as O,b as Q,c as I,d as K}from"./select-mZ6Ie5tF.js";import{S as P}from"./shield-check-Dfn0WxTN.js";import"./index-P72ZlWpd.js";import"./index-BAU_c2OA.js";import"./chevron-down-Bte0CX8p.js";import"./check-B_ORuh6A.js";const U=["admin","manager","customer"],h={admin:"অ্যাডমিন",manager:"ম্যানেজার",customer:"কাস্টমার"},V={admin:"bg-red-100 text-red-700 border-red-200",manager:"bg-blue-100 text-blue-700 border-blue-200",customer:"bg-muted text-muted-foreground"};function W(){const p=d(w),j=d(C),g=d(L),l=R(),[o,b]=x.useState(""),[f,N]=x.useState({}),{data:v=[],isLoading:c}=k({queryKey:["admin-users"],queryFn:()=>p()}),i=u({mutationFn:s=>j({data:s}),onSuccess:()=>{t.success("রোল দেওয়া হয়েছে"),l.invalidateQueries({queryKey:["admin-users"]})},onError:s=>t.error(s.message??"ব্যর্থ")}),y=u({mutationFn:s=>g({data:s}),onSuccess:()=>{t.success("রোল সরানো হয়েছে"),l.invalidateQueries({queryKey:["admin-users"]})},onError:s=>t.error(s.message??"ব্যর্থ")}),m=v.filter(s=>{const r=o.trim().toLowerCase();return r?(s.full_name??"").toLowerCase().includes(r)||(s.email??"").toLowerCase().includes(r)||(s.phone??"").toLowerCase().includes(r):!0});return e.jsxs("div",{className:"p-4 md:p-6 space-y-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"grid h-10 w-10 place-items-center rounded-xl bg-primary/10 text-primary",children:e.jsx(P,{className:"h-5 w-5"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl md:text-2xl font-extrabold",children:"ইউজার রোল ম্যানেজমেন্ট"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"ইউজারদের অ্যাডমিন / ম্যানেজার / কাস্টমার রোল দিন বা সরান"})]})]}),e.jsx("div",{className:"rounded-2xl border border-border bg-card p-4 shadow-sm",children:e.jsx(q,{placeholder:"নাম, ইমেইল বা ফোন দিয়ে সার্চ করুন…",value:o,onChange:s=>b(s.target.value),className:"max-w-md"})}),e.jsx("div",{className:"rounded-2xl border border-border bg-card shadow-sm overflow-hidden",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-muted/50 text-left",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-3 font-semibold",children:"ইউজার"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"কন্টাক্ট"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"বর্তমান রোল"}),e.jsx("th",{className:"px-4 py-3 font-semibold",children:"নতুন রোল দিন"})]})}),e.jsxs("tbody",{children:[c&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-10 text-center text-muted-foreground",children:"লোড হচ্ছে…"})}),!c&&m.length===0&&e.jsx("tr",{children:e.jsx("td",{colSpan:4,className:"px-4 py-10 text-center text-muted-foreground",children:"কোনো ইউজার পাওয়া যায়নি"})}),m.map(s=>{const r=f[s.id]??"manager",n=a=>s.roles.includes(a);return e.jsxs("tr",{className:"border-t border-border align-top",children:[e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{className:"font-semibold",children:s.full_name??"—"}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono",children:[s.id.slice(0,8),"…"]})]}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx("div",{children:s.email||"—"}),e.jsx("div",{className:"text-xs text-muted-foreground",children:s.phone||""})]}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[s.roles.length===0&&e.jsx("span",{className:"text-xs text-muted-foreground",children:"কোনো রোল নেই"}),s.roles.map(a=>e.jsxs(_,{variant:"outline",className:`gap-1 ${V[a]}`,children:[h[a]??a,e.jsx("button",{onClick:()=>y.mutate({user_id:s.id,role:a}),className:"ml-1 hover:opacity-70","aria-label":"remove",children:e.jsx(E,{className:"h-3 w-3"})})]},a))]})}),e.jsx("td",{className:"px-4 py-3",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs(B,{value:r,onValueChange:a=>N(S=>({...S,[s.id]:a})),children:[e.jsx(O,{className:"w-36",children:e.jsx(Q,{})}),e.jsx(I,{children:U.map(a=>e.jsxs(K,{value:a,disabled:n(a),children:[h[a],n(a)?" ✓":""]},a))})]}),e.jsx(F,{size:"sm",disabled:n(r)||i.isPending,onClick:()=>i.mutate({user_id:s.id,role:r}),children:"যোগ করুন"})]})})]},s.id)})]})]})})})]})}export{W as component};

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.