PageSourceSearch

https://mahmoudmasri.com/assets/AdminReviews-CPfumL1c.js

js mahmoudmasri.com collected 2026-09-30 08:26:42 UTC 8,722 bytes, 1 lines download raw bytes

1import{r as n,j as t}from"./ui-BgAZunKE.js";import{bg as M,bh as $,bi as G,ah as U,I as w,D as S,aw as k,C as J,aa as O,ak as C,G as r,am as q,aG as H,F as K,ar as P,a8 as Q,as as V,J as d}from"./index-CD3Ytjl1.js";import{l as N}from"./Admin-BN5giwe6.js";import{T as W}from"./textarea-RhjPNQvr.js";import"./supabase-Cv5z-ElN.js";import"./query-DfKp04n6.js";import"./vendor-BPxC6GVa.js";import"./NoIndex-Bqgc44cQ.js";const X={pending:{label:"بانتظار المراجعة",cls:"border-amber-400/40 text-amber-400 bg-amber-400/10",icon:J},approved:{label:"منشور",cls:"border-primary/40 text-primary bg-primary/10",icon:k},hidden:{label:"مخفي",cls:"border-muted-foreground/40 text-muted-foreground bg-muted/30",icon:S}},ne=()=>{const{data:l=[],isLoading:A}=M(),y=$(),E=G(),[x,z]=n.useState(""),[p,D]=n.useState("all"),[h,T]=n.useState(0),[f,I]=n.useState("newest"),[g,j]=n.useState(null),[o,b]=n.useState({}),_=n.useMemo(()=>{let e=[...l];switch(x&&(e=e.filter(a=>a.full_name.toLowerCase().includes(x.toLowerCase()))),p!=="all"&&(e=e.filter(a=>a.status===p)),h>0&&(e=e.filter(a=>a.rating===h)),f){case"oldest":return e.sort((a,s)=>new Date(a.created_at).getTime()-new Date(s.created_at).getTime());case"highest":return e.sort((a,s)=>s.rating-a.rating);default:return e.sort((a,s)=>new Date(s.created_at).getTime()-new Date(a.created_at).getTime())}},[l,x,p,h,f]),c=n.useMemo(()=>({total:l.length,pending:l.filter(e=>e.status==="pending").length,approved:l.filter(e=>e.status==="approved").length,hidden:l.filter(e=>e.status==="hidden").length,featured:l.filter(e=>e.is_featured).length}),[l]),m=async(e,a)=>{try{const s=l.find(u=>u.id===e);await y.mutateAsync({id:e,...a}),await N({action:"update",entity_type:"review",entity_id:e,details:{changes:a,reviewer:s?.full_name}}),d.success("تم التحديث")}catch{d.error("حدث خطأ")}},R=async e=>{if(confirm("هل تريد حذف هذا التقييم نهائياً؟"))try{const a=l.find(u=>u.id===e),s=a?{full_name:a.full_name,rating:a.rating,comment:a.comment,status:a.status}:{};await E.mutateAsync(e),await N({action:"delete",entity_type:"review",entity_id:e,details:{deleted_data:s}}),d.success("تم الحذف")}catch{d.error("حدث خطأ")}},F=async()=>{if(g)try{await y.mutateAsync({id:g,full_name:o.full_name,comment:o.comment}),await N({action:"edit",entity_type:"review",entity_id:g,details:{updated_fields:{full_name:o.full_name}}}),d.success("تم الحفظ"),j(null)}catch{d.error("حدث خطأ")}},L=async e=>{await m(e,{profile_image_url:null})};return A?t.jsx("p",{className:"text-muted-foreground",children:"جاري التحميل..."}):t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{className:"grid grid-cols-2 md:grid-cols-5 gap-3",children:[{label:"الكل",value:c.total,color:"text-foreground"},{label:"بانتظار",value:c.pending,color:"text-amber-400"},{label:"منشور",value:c.approved,color:"text-primary"},{label:"مخفي",value:c.hidden,color:"text-muted-foreground"},{label:"مميز",value:c.featured,color:"text-amber-400"}].map(e=>t.jsxs("div",{className:"glass-card rounded-xl p-3 text-center",children:[t.jsx("p",{className:`text-2xl font-black ${e.color}`,children:e.value}),t.jsx("p",{className:"text-xs text-muted-foreground",children:e.label})]},e.label))}),t.jsxs("div",{className:"flex flex-wrap gap-3 items-center",children:[t.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[t.jsx(U,{className:"absolute right-3 top-1/2 -translate-y-1/2 w-4 h-4 text-muted-foreground"}),t.jsx(w,{value:x,onChange:e=>z(e.target.value),placeholder:"بحث بالاسم...",className:"bg-muted/50 pr-9"})]}),t.jsxs("select",{value:p,onChange:e=>D(e.target.value),className:"bg-muted/50 border border-input rounded-md px-3 py-2 text-sm text-foreground",children:[t.jsx("option",{value:"all",children:"كل الحالات"}),t.jsx("option",{value:"pending",children:"بانتظار المراجعة"}),t.jsx("option",{value:"approved",children:"منشور"}),t.jsx("option",{value:"hidden",children:"مخفي"})]}),t.jsxs("select",{value:h,onChange:e=>T(Number(e.target.value)),className:"bg-muted/50 border border-input rounded-md px-3 py-2 text-sm text-foreground",children:[t.jsx("option",{value:0,children:"كل التقييمات"}),[5,4,3,2,1].map(e=>t.jsxs("option",{value:e,children:[e," نجوم"]},e))]}),t.jsxs("select",{value:f,onChange:e=>I(e.target.value),className:"bg-muted/50 border border-input rounded-md px-3 py-2 text-sm text-foreground",children:[t.jsx("option",{value:"newest",children:"الأحدث"}),t.jsx("option",{value:"oldest",children:"الأقدم"}),t.jsx("option",{value:"highest",children:"الأعلى تقييماً"})]})]}),_.length===0?t.jsx("p",{className:"text-center text-muted-foreground py-8",children:"لا توجد نتائج"}):t.jsx("div",{className:"space-y-3",children:_.map(e=>{const a=g===e.id,s=X[e.status],u=s.icon,B=new Date(e.created_at).toLocaleDateString("ar-EG",{year:"numeric",month:"short",day:"numeric"});return t.jsxs("div",{className:"glass-card rounded-xl p-4 space-y-3",children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-center gap-3",children:[e.profile_image_url?t.jsx("img",{src:e.profile_image_url,alt:"",className:"w-10 h-10 rounded-full object-cover border border-border"}):t.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/15 flex items-center justify-center text-primary font-bold text-sm",children:e.full_name.charAt(0)}),t.jsxs("div",{children:[a?t.jsx(w,{value:o.full_name||"",onChange:i=>b(v=>({...v,full_name:i.target.value})),className:"bg-muted/50 h-8 text-sm"}):t.jsx("p",{className:"font-bold text-foreground text-sm",children:e.full_name}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("div",{className:"flex gap-0.5",children:[1,2,3,4,5].map(i=>t.jsx(O,{className:`w-3 h-3 ${i<=e.rating?"fill-amber-400 text-amber-400":"text-muted-foreground
1/30"}`},i))}),t.jsx("span",{className:"text-xs text-muted-foreground",children:B})]})]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[t.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] px-2 py-0.5 rounded-full border ${s.cls}`,children:[t.jsx(u,{className:"w-3 h-3"})," ",s.label]}),e.is_featured&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] px-2 py-0.5 rounded-full border border-amber-400/30 text-amber-400 bg-amber-400/10",children:[t.jsx(C,{className:"w-3 h-3"})," مميز"]})]})]}),a?t.jsx(W,{value:o.comment||"",onChange:i=>b(v=>({...v,comment:i.target.value})),className:"bg-muted/50 resize-none text-sm",rows:3}):t.jsxs("p",{className:"text-foreground/80 text-sm leading-relaxed",children:['"',e.comment,'"']}),t.jsx("div",{className:"flex items-center gap-2 flex-wrap pt-1 border-t border-border",children:a?t.jsxs(t.Fragment,{children:[t.jsxs(r,{size:"sm",onClick:F,className:"btn-gold text-gray-900 gap-1 h-7 text-xs",children:[t.jsx(q,{className:"w-3 h-3"})," حفظ"]}),t.jsxs(r,{size:"sm",variant:"outline",onClick:()=>j(null),className:"h-7 text-xs gap-1",children:[t.jsx(H,{className:"w-3 h-3"})," إلغاء"]})]}):t.jsxs(t.Fragment,{children:[e.status==="pending"&&t.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(e.id,{status:"approved"}),className:"h-7 text-xs gap-1 text-primary border-primary/30 hover:bg-primary/10",children:[t.jsx(k,{className:"w-3 h-3"})," قبول"]}),e.status==="approved"&&t.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(e.id,{status:"hidden"}),className:"h-7 text-xs gap-1",children:[t.jsx(S,{className:"w-3 h-3"})," إخفاء"]}),e.status==="hidden"&&t.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(e.id,{status:"approved"}),className:"h-7 text-xs gap-1 text-primary",children:[t.jsx(K,{className:"w-3 h-3"})," نشر"]}),t.jsxs(r,{size:"sm",variant:"outline",onClick:()=>m(e.id,{is_featured:!e.is_featured}),className:`h-7 text-xs gap-1 ${e.is_featured?"text-amber-400 border-amber-400/30":""}`,children:[t.jsx(C,{className:"w-3 h-3"})," ",e.is_featured?"إلغاء التمييز":"تمييز"]}),t.jsxs(r,{size:"sm",variant:"outline",onClick:()=>{j(e.id),b({full_name:e.full_name,comment:e.comment})},className:"h-7 text-xs gap-1",children:[t.jsx(P,{className:"w-3 h-3"})," تعديل"]}),e.profile_image_url&&t.jsxs(r,{size:"sm",variant:"outline",onClick:()=>L(e.id),className:"h-7 text-xs gap-1",children:[t.jsx(Q,{className:"w-3 h-3"})," حذف الصورة"]}),t.jsxs(r,{size:"sm",variant:"outline",onClick:()=>R(e.id),className:"h-7 text-xs gap-1 text-destructive border-destructive/30 hover:bg-destructive/10 mr-auto",children:[t.jsx(V,{className:"w-3 h-3"})," حذف"]})]})})]},e.id)})})]})};export{ne 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.