PageSourceSearch

https://kubemarket.ai/assets/promotion-requests-51SIaSzl.js

js kubemarket.ai collected 2026-10-05 15:20:10 UTC 7,005 bytes, 1 lines download raw bytes

1import{r as h,$ as K,G as L,b as M,H as C,j as e,p as Q,Z as J,ad as $,aj as I,q as G,B as i,E as b,bm as q,J as D,K as S,M as T,N as _,O as P,e as r,h as t,l as V}from"./index-B-koLvdE.js";import{T as X,a as Z,b as A,c as n,d as W,e as o}from"./table-CWHgSBR1.js";import{T as Y}from"./textarea-CwX2V3pn.js";import{A as x}from"./arrow-up-DvbCvu3Z.js";import{C as ee}from"./clock-BIie4TVW.js";import{U as k}from"./user-D1LI9RCm.js";function oe(){const[a,j]=h.useState(null),[u,v]=h.useState(""),[z,l]=h.useState(!1),[E,f]=h.useState(!1),N=K(),{toast:c}=L(),{data:p,isLoading:U}=M({queryKey:["/api/organization/promotion-requests"],refetchInterval:3e4}),w=C({mutationFn:async s=>{const m=await fetch(`/api/organization/promotion-requests/${s}/approve`,{method:"POST",headers:{"Content-Type":"application/json"}});if(!m.ok)throw new Error("Failed to approve promotion request");return m.json()},onSuccess:()=>{c({title:"Promotion Approved",description:"User has been successfully promoted to the requested role."}),N.invalidateQueries({queryKey:["/api/organization/promotion-requests"]})},onError:s=>{c({title:"Error",description:s.message,variant:"destructive"})}}),g=C({mutationFn:async({requestId:s,reason:m})=>{const R=await fetch(`/api/organization/promotion-requests/${s}/reject`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({reason:m})});if(!R.ok)throw new Error("Failed to reject promotion request");return R.json()},onSuccess:()=>{c({title:"Promotion Request Rejected",description:"User has been notified of the rejection."}),N.invalidateQueries({queryKey:["/api/organization/promotion-requests"]}),l(!1),v(""),j(null)},onError:s=>{c({title:"Error",description:s.message,variant:"destructive"})}}),B=s=>{w.mutate(s.id)},F=s=>{j(s),l(!0)},O=s=>{j(s),f(!0)},H=()=>{a&&g.mutate({requestId:a.id,reason:u})},y=s=>{switch(s){case"pending":return e.jsxs(t,{variant:"outline",className:"flex items-center gap-1",children:[e.jsx(ee,{className:"h-3 w-3"}),"Pending"]});case"approved":return e.jsxs(t,{variant:"default",className:"flex items-center gap-1",children:[e.jsx(b,{className:"h-3 w-3"}),"Approved"]});case"rejected":return e.jsxs(t,{variant:"destructive",className:"flex items-center gap-1",children:[e.jsx(q,{className:"h-3 w-3"}),"Rejected"]});default:return e.jsx(t,{variant:"secondary",children:s})}},d=s=>{switch(s){case"super_admin":return e.jsxs(t,{variant:"destructive",className:"flex items-center gap-1",children:[e.jsx(V,{className:"h-3 w-3"}),"Super Admin"]});case"admin":return e.jsxs(t,{variant:"default",className:"flex items-center gap-1",children:[e.jsx(k,{className:"h-3 w-3"}),"Admin"]});case"user":return e.jsxs(t,{variant:"outline",className:"flex items-center gap-1",children:[e.jsx(k,{className:"h-3 w-3"}),"User"]});default:return e.jsx(t,{variant:"secondary",children:s})}};return U?e.jsx("div",{className:"container mx-auto p-6",children:e.jsxs("div",{className:"animate-pulse",children:[e.jsx("div",{className:"h-8 bg-gray-200 rounded w-1/4 mb-4"}),e.jsx("div",{className:"space-y-4",children:[1,2,3].map(s=>e.jsx("div",{className:"h-16 bg-gray-200 rounded"},s))})]})}):e.jsxs("div",{className:"container mx-auto p-6",children:[e.jsxs(Q,{children:[e.jsxs(J,{children:[e.jsxs($,{className:"flex items-center gap-2",children:[e.jsx(x,{className:"h-5 w-5"}),"Role Promotion Requests"]}),e.jsx(I,{children:"Review and manage user role promotion requests for your organization"})]}),e.jsx(G,{children:!p||p.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(x,{className:"h-12 w-12 mx-auto text-gray-400 mb-4"}),e.jsx("h3",{className:"text-lg font-medium text-gray-900",children:"No promotion requests"}),e.jsx("p",{className:"text-gray-500",children:"All promotion requests have been processed."})]}):e.jsxs(X,{children:[e.jsx(Z,{children:e.jsxs(A,{children:[e.jsx(n,{children:"User"}),e.jsx(n,{children:"Role Change"}),e.jsx(n,{children:"Status"}),e.jsx(n,{children:"Requested"}),e.jsx(n,{children:"Actions"})]})}),e.jsx(W,{children:p.map(s=>e.jsxs(A,{children:[e.jsx(o,{children:e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:s.user_name}),e.jsx("div",{className:"text-sm text-gray-500",children:s.user_email})]})}),e.jsx(o,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[d(s.current_role),e.jsx(x,{className:"h-4 w-4 text-gray-500"}),d(s.requested_role)]})}),e.jsx(o,{children:y(s.status)}),e.jsx(o,{children:new Date(s.created_at).toLocaleDateString()}),e.jsx(o,{children:e.jsxs("div",{className:"flex gap-2",children:[e.jsx(i,{size:"sm",variant:"outline",onClick:()=>O(s),children:"View Details"}),s.status==="pending"&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{size:"sm",onClick:()=>B(s),disabled:w.isPending,children:[e.jsx(b,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(i,{size:"sm",variant:"outline",onClick:()=>F(s),disabled:g.isPending,children:[e.jsx(q,{className:"h-4 w-4 mr-1"}),"Reject"]})]})]})})]},s.id))})]})})]}),e.jsx(D,{open:E,onOpenChange:f,children:e.jsxs(S,{children:[e.jsxs(T,{children:[e.jsx(_,{children:"Promotion Request Details"}),e.jsx(P,{children:"Review the details of this promotion request"})]}),a&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(r,{children:"User"}
1),e.jsxs("p",{className:"text-sm",children:[a.user_name," (",a.user_email,")"]})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Role Change"}),e.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[d(a.current_role),e.jsx(x,{className:"h-4 w-4 text-gray-500"}),d(a.requested_role)]})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Justification"}),e.jsx("p",{className:"text-sm bg-gray-50 p-3 rounded mt-1",children:a.justification})]}),e.jsxs("div",{children:[e.jsx(r,{children:"Status"}),e.jsx("div",{className:"mt-1",children:y(a.status)})]}),a.reviewed_at&&e.jsxs("div",{children:[e.jsx(r,{children:"Reviewed"}),e.jsx("p",{className:"text-sm",children:new Date(a.reviewed_at).toLocaleString()}),a.reviewer_name&&e.jsxs("p",{className:"text-sm text-gray-500",children:["by ",a.reviewer_name]})]}),a.rejection_reason&&e.jsxs("div",{children:[e.jsx(r,{children:"Rejection Reason"}),e.jsx("p",{className:"text-sm bg-red-50 p-3 rounded mt-1",children:a.rejection_reason})]})]})]})}),e.jsx(D,{open:z,onOpenChange:l,children:e.jsxs(S,{children:[e.jsxs(T,{children:[e.jsx(_,{children:"Reject Promotion Request"}),e.jsx(P,{children:"Please provide a reason for rejecting this promotion request. The user will be notified."})]}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(r,{htmlFor:"reason",children:"Rejection Reason"}),e.jsx(Y,{id:"reason",placeholder:"Please provide a clear reason for rejection...",value:u,onChange:s=>v(s.target.value),rows:3})]}),e.jsxs("div",{className:"flex justify-end gap-2",children:[e.jsx(i,{variant:"outline",onClick:()=>l(!1),children:"Cancel"}),e.jsx(i,{variant:"destructive",onClick:H,disabled:!u.trim()||g.isPending,children:"Reject Request"})]})]})]})})]})}export{oe 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.