import{u as N,q as V,c as v,a as t,t as o,e as U,d as _,F as B,r as $,f as T,g as i,h as d,v as D,i as M,l as f,k as A,o as p}from"./BKiFavna.js";import{u as E}from"./BZ7f31ti.js";import{u as S}from"./DKzHUNYh.js";import{_ as I}from"./DlAUqK2U.js";const j={class:"page-head"},q={class:"page-hdr"},F={class:"table-wrap"},L={class:"ad-table"},O={class:"actions"},P=["onClick"],h=["onClick"],z={class:"modal"},G={class:"modal-header"},H={style:{margin:"0"}},J={class:"form-group"},K={class:"form-group"},Q={class:"form-group"},R={class:"form-row"},W={class:"form-group"},X={class:"form-group"},Y={class:"form-group"},Z={class:"ck"},tt={class:"modal-actions"},et=["disabled"],st={__name:"breaking",setup(lt){const{lang:k}=N(),{api:r}=E(),m=S(),b=f([]),a=f(!1),u=f(!1),l=A({id:null,text_bn:"",text_en:"",link:"",priority:0,start_date:"",end_date:"",is_active:!0}),c=async()=>{try{const n=await r.get("/admin/breaking-news");b.value=n.data.items}catch{}},g=()=>{Object.assign(l,{id:null,text_bn:"",text_en:"",link:"",priority:0,start_date:"",end_date:"",is_active:!0}),a.value=!0},y=n=>{Object.assign(l,n),l.is_active=!!n.is_active,a.value=!0},w=async()=>{u.value=!0;const n={...l,is_active:l.is_active?1:0};try{l.id?await r.put(`/admin/breaking-news/${l.id}`,n):await r.post("/admin/breaking-news",n),a.value=!1,c(),m.success(l.id?"Updated!":"Created!")}catch(e){m.error(e.message)}finally{u.value=!1}},x=async n=>{confirm("Delete?")&&(await r.del(`/admin/breaking-news/${n.id}`),c(),m.success("Deleted"))};return V(c),(n,e)=>(p(),v("div",null,[t("div",j,[t("h1",q,o(U(k)==="bn"?"ব্রেকিং নিউজ":"Breaking News"),1),t("button",{onClick:g,class:"btn-primary"},[...e[10]||(e[10]=[t("i",{class:"fas fa-plus"},null,-1),_(" New",-1)])])]),t("div",F,[t("table",L,[e[13]||(e[13]=t("thead",null,[t("tr",null,[t("th",null,"ID"),t("th",null,"Text (BN)"),t("th",null,"Priority"),t("th",null,"Active"),t("th",null,"Actions")])],-1)),t("tbody",null,[(p(!0),v(B,null,$(b.value,s=>(p(),v("tr",{key:s.id},[t("td",null,o(s.id),1),t("td",null,o(s.text_bn),1),t("td",null,o(s.priority),1),t("td",null,o(s.is_active?"✓":"×"),1),t("td",O,[t("button",{onClick:C=>y(s),class:"btn-icon"},[...e[11]||(e[11]=[t("i",{class:"fas fa-edit"},null,-1)])],8,P),t("button",{onClick:C=>x(s),class:"btn-icon danger"},[...e[12]||(e[12]=[t("i",{class:"fas fa-trash"},null,-1)])],8,h)])]))),128))])])]),a.value?(p(),v("div",{key:0,class:"modal-backdrop",onClick:e[9]||(e[9]=T(s=>a.value=!1,["self"]))},[t("div",z,[t("div",G,[t("h3",H,o(l.id?"Edit":"New")+" Breaking News",1),t("button",{class:"modal-close",onClick:e[0]||(e[0]=s=>a.value=!1),title:"Close"},"×")]),t("div",J,[e[14]||(e[14]=t("label",null,"Text (BN) *",-1)),i(t("textarea",{"onUpdate:modelValue":e[1]||(e[1]=s=>l.text_bn=s),rows:"2",required:""},null,512),[[d,l.text_bn]])]),t("div",K,[e[15]||(e[15]=t("label",null,"Text (EN)",-1)),i(t("textarea",{"onUpdate:modelValue":e[2]||(e[2]=s=>l.text_en=s),rows:"2"},null,512),[[d,l.text_en]])]),t("div",Q,[e[16]||(e[16]=t("label",null,"Link (optional)",-1)),i(t("input",{"onUpdate:modelValue":e[3]||(e[3]=s=>l.link=s)},null,512),[[d,l.link]])]),t("div",R,[t("div",W,[e[17]||(e[17]=t("label",null,"Priority",-1)),i(t("input",{type:"number","onUpdate:modelValue":e[4]||(e[4]=s=>l.priority=s)},null,512),[[d,l.priority,void 0,{number:!0}]])]),t("div",X,[e[18]||(e[18]=t("label",null,"Start",-1)),i(t("input",{type:"datetime-local","onUpdate:modelValue":e[5]||(e[5]=s=>l.start_date=s)},null,512),[[d,l.start_date]])])]),t("div",Y,[e[19]||(e[19]=t("label",null,"End",-1)),i(t("input",{type:"datetime-local","onUpdate:modelValue":e[6]||(e[6]=s=>l.end_date=s)},null,512),[[d,l.end_date]])]),t("label",Z,[i(t("input",{type:"checkbox","onUpdate:modelValue":e[7]||(e[7]=s=>l.is_active=s)},null,512),[[D,l.is_active]]),e[20]||(e[20]=_(" Active",-1))]),t("div",tt,[t("button",{onClick:e[8]||(e[8]=s=>a.value=!1),class:"btn-secondary"},"Cancel"),t("button",{onClick:w,disabled:u.value,class:"btn-primary"},o(u.value?"Saving...":"Save"),9,et)])])])):M("",!0)]))}},dt=I(st,[["__scopeId","data-v-074b6df1"]]);export{dt as default};
