import{_ as N}from"./RoundedButton.f48696b9.js";import{_ as L}from"./FormTitle.508c8534.js";import{_ as S}from"./Spinner.d190d224.js";import{_ as T}from"./AvailableRouteCard.b93e6a03.js";import{_ as F}from"./BaseRouteCard.05b3b5e5.js";import{r as p,o as e,h as u,w as o,a as x,j as a,d as f,i as j,t as C,c as n,b as g,F as z,B as D,l as E,f as O,m as R,v as M,g as I}from"./entry.01d4b5f9.js";import{u as J}from"./dayjs.12728dc2.js";import{_ as P,a as G}from"./SectionWrapper.a3888927.js";const H={class:"flex justify-end gap-2"},K={class:"mb-2 flex"},Q=x("span",{class:"font-bold"},"Date souhaitée:  ",-1),W={key:0,class:"mb-5 flex justify-center"},X={key:0},Z={key:1},ee={key:1,class:"text-primary-lightest flex h-[5rem] items-center justify-center text-2xl font-bold uppercase"},te={key:2},se={__name:"AlertCard",props:{alert:{type:Object,required:!0,default:()=>({})}},emits:["update"],setup(l,{emit:B}){const h=l,{$api:i,$event:y,$toast:d}=E(),c=p(!1),_=J(),r=p(!1),k=s=>{y("booking.requested",s)},v=()=>{c.value=!0,i.call("delete",i.route("me.alerts.destroy",{alert:h.alert.id})).then(s=>{d.success("Alerte supprimé avec succès"),B("update")}).catch(s=>{s.response?d.error(s.response.data.message):d.error("Une erreur est survenue")}).finally(()=>{c.value=!1})};return(s,t)=>{const b=N,$=T,A=F;return e(),u(A,{route:l.alert},{main:o(()=>[x("div",H,[l.alert.archive?j("",!0):(e(),u(b,{key:0,design:1,size:s.sm,icon:"trash",onClick:v,loading:a(c)},{default:o(()=>[f(" Supprimer l'alerte ")]),_:1},8,["size","loading"]))])]),footer:o(()=>[x("div",K,[Q,f(" "+C(a(_)(l.alert.date).format("DD/MM/YYYY")),1)]),l.alert.matched_routes.length>0?(e(),n("div",W,[g(b,{design:4,size:s.sm,onClick:t[0]||(t[0]=m=>r.value=!a(r))},{default:o(()=>[a(r)?(e(),n("span",X," Cacher les trajets trouvés ")):(e(),n("span",Z," Voir les trajets trouvés ("+C(l.alert.matched_routes.length)+") ",1))]),_:1},8,["size"])])):(e(),n("div",ee," Aucune trajet trouvé pour le moment ")),a(r)?(e(),n("div",te,[(e(!0),n(z,null,D(l.alert.matched_routes,m=>(e(),u($,{class:"mb-5",route:m,onBook:w=>k(m)},null,8,["route","onBook"]))),256))])):j("",!0)]),_:1},8,["route"])}}},ae=x("div",{class:"mb-5"}," Les alertes sont automatiquement supprimées une fois la date souhaitée de départ dépassée. ",-1),oe={key:2,class:"text-primary-lightest flex h-[20rem] items-center justify-center text-4xl font-bold uppercase"},re={key:3,class:"flex flex-col gap-6"},pe={__name:"mes-alertes",emits:["store"],setup(l,{emit:B}){O();const{$api:h,$listen:i,$event:y,$toast:d}=E(),c=p([]),_=p(null),r=p(!1),k=()=>{y("open-create-alert")};R(()=>{s(),i("alert-created",t=>{s()}),i("booking.created",t=>{s()}),i("refresh-all",()=>{s()})});const v=M(()=>c.value.filter(t=>!t.archive));M(()=>c.value.filter(t=>t.archive));const s=async()=>{r.value=!0,_.value=null,h.call("get",h.route("me.alerts.index")).then(t=>{c.value=t}).catch(t=>{t.response&&(d.error(t.response.data.message),_.value=t.response.data.message)}).finally(()=>{r.value=!1})};return(t,b)=>{const $=N,A=L,m=I("Message"),w=S,V=se,U=G,Y=P;return e(),u(Y,{class:"bg-background-1 py-10"},{default:o(()=>[g(U,{"mobile-padding":"",class:"max-w-container relative z-10 rounded-2xl bg-white px-24 py-16"},{default:o(()=>[g(A,{number:""},{actions:o(()=>[g($,{design:"1",icon:"plus",class:"ml-5 w-[40rem]",onClick:k},{default:o(()=>[f(" AJOUTER UNE ALERTE ")]),_:1})]),default:o(()=>[f("Mes alertes en cours ")]),_:1}),ae,a(_)?(e(),u(m,{key:0,severity:"error"},{default:o(()=>[f(C(a(_)),1)]),_:1})):j("",!0),a(r)?(e(),u(w,{key:1,class:"mx-auto"})):!a(r)&&a(v).length===0?(e(),n("div",oe," Aucune alerte en cours ")):(e(),n("div",re,[(e(!0),n(z,null,D(a(v),q=>(e(),u(V,{alert:q,onUpdate:s},null,8,["alert"]))),256))]))]),_:1})]),_:1})}}};export{pe as default};
//# sourceMappingURL=mes-alertes.fcacb00a.js.map
