PageSourceSearch

https://generative-storytelling.lovable.app/assets/AdminCarousels-DfvObYFT.js

js generative-storytelling.lovable.app collected 2026-10-03 03:27:56 UTC 7,266 bytes, 1 lines download raw bytes

1import{j as s,a as F}from"./query-w-1FDK4R.js";import{r as b}from"./vendor-BI5TZToo.js";import{d as I,e as O,f as z}from"./driveUtils-D6t0PL47.js";import{G as y,ap as K,I as P,a4 as R,ab as D,ac as G,an as M,F as $,D as B,ar as J,as as Q,K as o,J as v}from"./index-z0lIoSoV.js";import{T as H}from"./textarea-ep-i3Wn3.js";import{l as m}from"./Admin-CRCjTjiB.js";import"./ui-XCSPXWXn.js";import"./supabase-BZWkUGAr.js";import"./NoIndex-Cx3QDwB2.js";const U=[{value:"4:3",label:"كلاسيكي 4:3"},{value:"1:1",label:"مربع 1:1"},{value:"16:9",label:"أفقي 16:9"},{value:"9:16",label:"عمودي 9:16"},{value:"4:5",label:"عمودي 4:5"},{value:"21:9",label:"عريض 21:9"}],V=[{value:"cover",label:"تعبئة كاملة"},{value:"contain",label:"احتواء كامل"}],g=({tableName:a,queryKey:f,items:x,fields:j,showMediaType:_,showAspectRatio:w})=>{const N=F(),[p,n]=b.useState(null),[l,r]=b.useState({}),[d,c]=b.useState(!1),k=e=>{n(e.id),r({...e}),c(!1)},C=()=>{c(!0),n(null),r({media_type:"video"})},u=()=>N.invalidateQueries({queryKey:[f]}),A=async()=>{try{const e={...l};if(e.drive_url&&(e.embed_url=z(e.drive_url,e.media_type||"video")),d){delete e.id;const{error:t}=await o.from(a).insert(e);if(t)throw t}else{const{id:t,created_at:i,updated_at:L,...S}=e,{error:h}=await o.from(a).update(S).eq("id",p);if(h)throw h}v.success("تم الحفظ"),await m({action:d?"create":"update",entity_type:a,details:{title:e.title}}),n(null),c(!1),u()}catch(e){v.error(e?.message||"حدث خطأ")}},E=async e=>{if(!confirm("حذف؟"))return;const t=x.find(i=>i.id===e);await o.from(a).delete().eq("id",e),await m({action:"delete",entity_type:a,entity_id:e,details:{deleted_data:{title:t?.title}}}),v.success("تم الحذف"),u()},T=async(e,t)=>{await o.from(a).update({is_visible:!t}).eq("id",e),await m({action:t?"hide":"show",entity_type:a,entity_id:e}),u()},q=async(e,t)=>{await o.from(a).update({is_featured:!t}).eq("id",e),await m({action:t?"unfeature":"feature",entity_type:a,entity_id:e}),u()};return s.jsxs("div",{className:"space-y-3",children:[!p&&!d&&s.jsxs(y,{onClick:C,size:"sm",className:"btn-gold text-gray-900 gap-2",children:[s.jsx(K,{className:"w-4 h-4"})," إضافة جديد"]}),(d||p)&&s.jsxs("div",{className:"glass-card neon-border rounded-xl p-5 space-y-3",children:[s.jsx("h4",{className:"font-bold text-foreground",children:d?"إضافة جديد":"تعديل"}),_&&s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-muted-foreground mb-1 block",children:"نوع الوسائط"}),s.jsxs("select",{value:l.media_type||"video",onChange:e=>r(t=>({...t,media_type:e.target.value})),className:"w-full bg-muted/50 border border-input rounded-md px-3 py-2 text-sm text-foreground",children:[s.jsx("option",{value:"video",children:"فيديو"}),s.jsx("option",{value:"image",children:"صورة"})]})]}),w&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-muted-foreground mb-1 block",children:"المقاس المختار"}),s.jsx("div",{className:"grid grid-cols-3 gap-2",children:U.map(e=>s.jsxs("button",{type:"button",onClick:()=>r(t=>({...t,aspect_ratio:e.value})),className:`flex flex-col items-center gap-1 p-2 rounded-lg border text-xs transition-all ${(l.aspect_ratio||"4:3")===e.value?"border-primary bg-primary/10 text-primary":"border-border text-muted-foreground hover:border-primary/30"}`,children:[s.jsx("div",{className:"w-8 border border-current rounded-sm",style:{aspectRatio:e.value.replace(":","/"),maxHeight:"2rem"}}),s.jsx("span",{children:e.label})]},e.value))})]}),s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-muted-foreground mb-1 block",children:"طريقة العرض"}),s.jsx("select",{value:l.object_fit||"cover",onChange:e=>r(t=>({...t,object_fit:e.target.value})),className:"w-full bg-muted/50 border border-input rounded-md px-3 py-2 text-sm text-foreground",children:V.map(e=>s.jsx("option",{value:e.value,children:e.label},e.value))})]})]}),j.map(e=>s.jsxs("div",{children:[s.jsx("label",{className:"text-sm text-muted-foreground mb-1 block",children:e.label}),e.multiline?s.jsx(H,{value:l[e.key]||"",onChange:t=>r(i=>({...i,[e.key]:t.target.value})),className:"bg-muted/50 resize-none",rows:2}):s.jsx(P,{type:e.type||"text",value:l[e.key]||"",onChange:t=>r(i=>({...i,[e.key]:t.target.value})),className:"bg-muted/50",dir:e.key==="drive_url"?"ltr":void 0})]},e.key)),s.jsxs("div",{className:"flex gap-2",children:[s.jsxs(y,{onClick:A,size:"sm",className:"btn-gold text-gray-900 gap-1",children:[s.jsx(R,{className:"w-4 h-4"})," حفظ"]}),s.jsx(y,{onClick:()=>{n(null),c(!1)},size:"sm",variant:"outline",children:"إلغاء"})]})]}),s.jsxs("div",{className:"space-y-2",children:[x.map(e=>s.jsxs("div",{className:"glass-card rounded-xl p-4 flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"flex items-center gap-3 min-w-0 flex-1",children:[s.jsx("div",{className:"w-8 h-8 rounded-lg bg-primary/10 flex items-center justify-center flex-shrink-0",children:e.media_type==="video"?s.jsx(D,{className:"w-4 h-4 text-primary"}):s.jsx(G,{className:"w-4 h-4 text-primary"})}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("p",{className:"font-semibold text-foreground text-sm truncate",children:e.title}),s.jsx("p",{className:"text-muted-foreground text-xs truncate",dir:"ltr",children:e.drive_url})]})]}),s.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0",children:[s.jsx("button",{onClick:()=>q(e.id,e.is_featured),className:`text-xs p-1.5 rounded-lg border transition-all ${e.
1is_featured?"border-amber-400/30 text-amber-400 bg-amber-400/10":"border-border text-muted-foreground"}`,children:s.jsx(M,{className:"w-3.5 h-3.5"})}),s.jsx("button",{onClick:()=>T(e.id,e.is_visible),className:`text-xs p-1.5 rounded-lg border transition-all ${e.is_visible?"border-primary/30 text-primary bg-primary/10":"border-border text-muted-foreground"}`,children:e.is_visible?s.jsx($,{className:"w-3.5 h-3.5"}):s.jsx(B,{className:"w-3.5 h-3.5"})}),s.jsx("button",{onClick:()=>k(e),className:"text-muted-foreground hover:text-primary p-1.5",children:s.jsx(J,{className:"w-3.5 h-3.5"})}),s.jsx("button",{onClick:()=>E(e.id),className:"text-muted-foreground hover:text-destructive p-1.5",children:s.jsx(Q,{className:"w-3.5 h-3.5"})})]})]},e.id)),x.length===0&&s.jsx("p",{className:"text-muted-foreground text-sm text-center py-6",children:"لا توجد عناصر بعد"})]})]})},le=()=>{const{data:a=[]}=I();return s.jsx(g,{tableName:"course_previews",queryKey:"admin_course_previews",items:a,showMediaType:!1,fields:[{key:"title",label:"العنوان"},{key:"description",label:"الوصف (اختياري)",multiline:!0},{key:"drive_url",label:"رابط Google Drive"},{key:"sort_order",label:"الترتيب",type:"number"}]})},ie=()=>{const{data:a=[]}=O();return s.jsx("div",{className:"space-y-4",children:s.jsx(g,{tableName:"course_outcomes",queryKey:"admin_course_outcomes",items:a,showMediaType:!0,showAspectRatio:!0,fields:[{key:"title",label:"العنوان"},{key:"caption",label:"الوصف (اختياري)",multiline:!0},{key:"drive_url",label:"رابط Google Drive"},{key:"sort_order",label:"الترتيب",type:"number"}]})})};export{ie as AdminCourseOutcomes,le as AdminCoursePreviews};

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.