PageSourceSearch

https://extremebargains.uk/assets/DealCommentsManagement-B7quUnCy.js

js extremebargains.uk collected 2026-10-09 23:07:51 UTC 5,876 bytes, 1 lines download raw bytes

1import{a3 as q,F as B,ab as R,j as e,i as n,o as y,p as b,l,aa as i,C as j,ak as c,X as d,s as D,B as u,k as g}from"./index-Bj3g7Z6n.js";import{T as S,a as z,b as N,c as f}from"./tabs-xnuR-ZTi.js";import{A as E,a as H,b as L,c as Q,d as K,e as V,f as X,g as $,h as G}from"./alert-dialog-CCwV5umb.js";import{d as J,c as O}from"./useDealComments-C2Dt3AI1.js";import{M as A}from"./message-circle-CdwY76X3.js";import{T as U}from"./trash-2-C3_qP8oE.js";import{f as W}from"./formatDistanceToNow-CNKmwCGT.js";import"./normalizeDates-DzYoqby6.js";import"./en-US-ClfMaaVW.js";const le=()=>{const{data:t,isLoading:_}=J(),T=O(),{toast:v}=q(),M=B(),o=R({mutationFn:async({commentId:s,action:a})=>{if(a==="approve"){const{error:r}=await D.from("deal_comments").update({is_pending:!1,is_approved:!0}).eq("id",s);if(r)throw r}else{const{error:r}=await D.from("deal_comments").update({is_pending:!1,is_approved:!1}).eq("id",s);if(r)throw r}},onSuccess:(s,a)=>{M.invalidateQueries({queryKey:["all-deal-comments"]}),v({title:a.action==="approve"?"Comment approved":"Comment rejected",description:`The comment has been ${a.action}d successfully.`})},onError:()=>{v({title:"Action failed",description:"Failed to moderate comment. Please try again.",variant:"destructive"})}});if(_)return e.jsxs(n,{children:[e.jsx(y,{children:e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5"}),"Deal Comments Management"]})}),e.jsx(l,{children:e.jsx("div",{className:"space-y-4",children:[...Array(5)].map((s,a)=>e.jsx(n,{children:e.jsx(l,{className:"p-4",children:e.jsxs("div",{className:"flex justify-between items-start",children:[e.jsxs("div",{className:"space-y-2 flex-1",children:[e.jsx(i,{className:"h-4 w-48"}),e.jsx(i,{className:"h-3 w-32"}),e.jsx(i,{className:"h-16 w-full"})]}),e.jsx(i,{className:"h-6 w-16"})]})})},a))})})]});const k=async s=>{try{await T.mutateAsync(s)}catch{}},C=(s,a)=>{o.mutate({commentId:s,action:a})},F=s=>W(new Date(s),{addSuffix:!0}),P=s=>s.is_pending?e.jsxs(g,{variant:"secondary",className:"bg-yellow-100 text-yellow-800",children:[e.jsx(j,{className:"h-3 w-3 mr-1"}),"Pending"]}):s.is_approved?e.jsxs(g,{variant:"secondary",className:"bg-green-100 text-green-800",children:[e.jsx(c,{className:"h-3 w-3 mr-1"}),"Approved"]}):e.jsxs(g,{variant:"secondary",className:"bg-red-100 text-red-800",children:[e.jsx(d,{className:"h-3 w-3 mr-1"}),"Rejected"]}),m=(t==null?void 0:t.filter(s=>s.is_approved&&!s.is_pending))||[],x=(t==null?void 0:t.filter(s=>s.is_pending))||[],p=(t==null?void 0:t.filter(s=>!s.is_approved&&!s.is_pending))||[],h=s=>{var a,r,w;return e.jsx(n,{className:"mb-4",children:e.jsxs(l,{className:"p-4",children:[e.jsxs("div",{className:"flex justify-between items-start mb-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-sm",children:((a=s.profiles)==null?void 0:a.display_name)||((r=s.profiles)==null?void 0:r.username)||"Anonymous"}),P(s)]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Deal: ",(w=s.deals)==null?void 0:w.title," • ",F(s.created_at)]})]}),e.jsxs("div",{className:"flex space-x-2",children:[s.is_pending&&e.jsxs(e.Fragment,{children:[e.jsxs(u,{size:"sm",variant:"outline",onClick:()=>C(s.id,"approve"),disabled:o.isPending,className:"text-green-600 border-green-600 hover:bg-green-50",children:[e.jsx(c,{className:"h-4 w-4 mr-1"}),"Approve"]}),e.jsxs(u,{size:"sm",variant:"outline",onClick:()=>C(s.id,"reject"),disabled:o.isPending,className:"text-red-600 border-red-600 hover:bg-red-50",children:[e.jsx(d,{className:"h-4 w-4 mr-1"}),"Reject"]})]}),e.jsxs(E,{children:[e.jsx(H,{asChild:!0,children:e.jsx(u,{size:"sm",variant:"outline",className:"text-destructive border-destructive hover:bg-destructive/10",children:e.jsx(U,{className:"h-4 w-4"})})}),e.jsxs(L,{children:[e.jsxs(Q,{children:[e.jsx(K,{children:"Delete Comment"}),e.jsx(V,{children:"Are you sure you want to delete this comment? This action cannot be undone."})]}),e.jsxs(X,{children:[e.jsx($,{children:"Cancel"}),e.jsx(G,{onClick:()=>k(s.id),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Delete"})]})]})]})]})]}),e.jsx("p",{className:"text-sm whitespace-pre-wrap border-l-2 border-muted pl-3 ml-2",children:s.content})]})},s.id)};return e.jsxs(n,{children:[e.jsx(y,{children:e.jsxs(b,{className:"flex items-center gap-2",children:[e.jsx(A,{className:"h-5 w-5"}),"Deal Comments Management"]})}),e.jsx(l,{children:e.jsxs(S,{defaultValue:"pending",children:[e.jsxs(z,{className:"grid w-full grid-cols-3",children:[e.jsxs(N,{value:"pending",className:"flex items-center gap-2",children:[e.jsx(j,{className:"h-4 w-4"}),"Pending (",x.length,")"]}),e.jsxs(N,{value:"approved",className:"flex items-center gap-2",children:[e.jsx(c,{className:"h-4 w-4"}),"Approved (",m.length,")"]}),e.jsxs(N,{value:"rejected",className:"flex items-center gap-2",children:[e.jsx(d,{className:"h-4 w-4"}),"Rejected (",p.length,")"]})]}
1),e.jsx(f,{value:"pending",className:"space-y-4 mt-4",children:x.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(j,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"No pending comments to review"})]}):x.map(h)}),e.jsx(f,{value:"approved",className:"space-y-4 mt-4",children:m.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(c,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"No approved comments"})]}):m.map(h)}),e.jsx(f,{value:"rejected",className:"space-y-4 mt-4",children:p.length===0?e.jsxs("div",{className:"text-center py-8 text-muted-foreground",children:[e.jsx(d,{className:"h-12 w-12 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"No rejected comments"})]}):p.map(h)})]})})]})};export{le as DealCommentsManagement};

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.