PageSourceSearch

https://doghealthy.netlify.app/_nuxt/wIA14oRp.js

js doghealthy.netlify.app collected 2026-10-03 10:40:42 UTC 11,753 bytes, 1 lines download raw bytes

1import{f as W,u as X,g as Z,O as ee,r as l,q as u,h as te,c as a,a as e,i as x,m as C,n as se,y as _,t as d,I as M,A as re,F as oe,k as ae,o as i,l as ie,G as m}from"#entry";import{u as ne}from"./Dy9pVEbO.js";import"./DKLWY9DJ.js";const de={class:"container mx-auto px-4 py-8 max-w-4xl"},le={class:"mb-8"},ce={class:"mt-6 bg-white rounded-lg shadow-sm border border-muted p-6"},ue={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},me={class:"flex items-center justify-between"},pe={class:"relative inline-flex items-center cursor-pointer"},fe={class:"flex items-center justify-between"},ge={key:0,class:"mt-4 p-3 bg-gray-50 rounded-lg"},be={class:"text-sm text-secondary"},ve=["disabled"],he={class:"flex justify-between items-center mb-6"},ye={class:"flex gap-4"},xe={class:"flex gap-2"},_e={class:"grid grid-cols-1 md:grid-cols-4 gap-4 mb-8"},ke={class:"bg-white rounded-lg shadow-sm border border-muted p-4"},we={class:"flex items-center"},Ce={class:"ml-3"},Re={class:"text-2xl font-bold text-dark"},Se={class:"bg-white rounded-lg shadow-sm border border-muted p-4"},Ne={class:"flex items-center"},Ae={class:"ml-3"},Ee={class:"text-2xl font-bold text-dark"},Me={class:"bg-white rounded-lg shadow-sm border border-muted p-4"},qe={class:"flex items-center"},De={class:"ml-3"},Be={class:"text-2xl font-bold text-dark"},Ie={class:"bg-white rounded-lg shadow-sm border border-muted p-4"},Pe={class:"flex items-center"},Le={class:"ml-3"},Ue={class:"text-2xl font-bold text-dark"},Ve={key:0,class:"text-center py-12"},je={key:1,class:"text-center py-12"},Fe={key:2,class:"space-y-4"},$e=["onClick"],Ge={class:"flex items-start gap-4"},Te={class:"flex-shrink-0"},ze={class:"flex-1 min-w-0"},Oe={class:"flex items-start justify-between"},He={class:"font-semibold text-dark mb-1"},Ke={class:"text-secondary mb-2"},Ye={class:"text-sm text-secondary"},Je={class:"flex items-center gap-2"},Qe={key:0,class:"w-3 h-3 bg-primary rounded-full"},We=["onClick"],Xe={key:3,class:"mt-8 text-center"},Ze=["disabled"],et={key:0},tt={key:1},R=20,it=W({__name:"notifications",setup(st){ne({title:"Notifications & Reminders",description:"Manage DogHealthy vaccination, medication and appointment reminders for your UK dogs.",path:"/notifications",index:!1}
1);const p=X(),c=Z(),{getReminderSettings:q,setRemindersEnabled:D,requestNotificationPermission:B,checkAllReminders:I}=ee(),o=l([]),k=l(!0),b=l(!1),v=l(""),h=l(""),w=l(1),S=l(!0),n=l(q()),y=l(!1),N=u(()=>o.value.filter(s=>!s.is_read).length),P=u(()=>o.value.filter(s=>s.type==="appointment").length),L=u(()=>o.value.filter(s=>s.type==="message").length),A=u(()=>{let s=o.value;return v.value&&(s=s.filter(t=>t.type===v.value)),h.value==="unread"?s=s.filter(t=>!t.is_read):h.value==="read"&&(s=s.filter(t=>t.is_read)),s}),U=u(()=>{switch(n.value.notificationsPermission){case"granted":return"Enabled";case"denied":return"Blocked";case"default":default:return"Request Permission"}}),V=u(()=>{switch(n.value.notificationsPermission){case"granted":return"bg-green-100 text-green-700 hover:bg-green-200";case"denied":return"bg-red-100 text-red-700 hover:bg-red-200";case"default":default:return"bg-primary text-dark hover:bg-accent"}}),j=()=>{D(n.value.enabled)},F=async()=>{await B()?n.value.notificationsPermission="granted":n.value.notificationsPermission="denied"},$=async()=>{y.value=!0;try{const s=await I();n.value.lastCheck=new Date().toISOString(),s.appointments+s.medications+s.vaccinations>0?alert(`Found ${s.appointments+s.medications+s.vaccinations} reminders! Check your notifications.`):alert("No new reminders found."),await f()}catch(s){console.error("Error checking reminders:",s),alert("Error checking reminders. Please try again.")}finally{y.value=!1}},G=s=>new Date(s).toLocaleDateString("en-GB",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"}),T=s=>{switch(s){case"appointment":return"bi-calendar2-event";case"medication":return"bi-capsule";case"message":return"bi-chat-dots";case"upgrade":return"bi-star";case"nfc_order":return"bi-upc-scan";case"nfc_dogs":return"bi-heart";default:return"bi-bell"}},z=s=>{switch(s){case"appointment":return"bg-primary";case"medication":return"bg-accent";case"message":return"bg-secondary";case"upgrade":return"bg-primary";case"nfc_order":return"bg-slate-800";case"nfc_dogs":return"bg-amber-600";default:return"bg-muted"}},O=s=>new Date(s).toLocaleDateString("en-GB",{year:"numeric",month:"long",day:"numeric",hour:"2-digit",minute:"2-digit"}),f=async(s=!1)=>{if(c.userId)try{s?b.value=!0:(k.value=!0,w.value=1);const t=(w.value-1)*R,r=t+R-1,{data:g,error:E}=await p.from("doghealthy_notifications").select("*").eq("user_id",c.userId).order("created_at",{ascending:!1}).range(t,r);if(E)throw E;s?o.value=[...o.value,...g||[]]:o.value=g||[],S.value=(g||[]).length===R}catch(t){console.error("Error fetching notifications:",t)}finally{k.value=!1,b.value=!1}},H=async()=>{w.value++,await f(!0)},K=async()=>{if(c.userId)try{const{error:s}=await p.from("doghealthy_notifications").update({is_read:!0}).eq("user_id",c.userId).eq("is_read",!1);if(s)throw s;o.value.forEach(t=>t.is_read=!0)}catch(s){console.error("Error marking notifications as read:",s)}},Y=async()=>{if(confirm("Are you sure you want to delete all read notifications?")&&c.userId)try{const{error:s}=await p.from("doghealthy_notifications").delete().eq("user_id",c.userId).eq("is_read",!0);if(s)throw s;o.value=o.value.filter(t=>!t.is_read)}catch(s){console.error("Error deleting read notifications:",s)}},J=async s=>{if(confirm("Are you sure you want to delete this notification?"))try{const{error:t}=await p.from("doghealthy_notifications").delete().eq("id",s);if(t)throw t;o.value=o.value.filter(r=>r.id!==s)}catch(t){console.error("Error deleting notification:",t)}},Q=async s=>{if(!s.is_read)try{await p.from("doghealthy_notifications").update({is_read:!0}).eq("id",s.id),s.is_read=!0}catch(t){console.error("Error marking notification as read:",t)}switch(s.type){case"appointment":await m(`/dogs/${s.reference_id}/appointments`);break;case"medication":await m(`/dogs/${s.reference_id}/medications`);break;case"message":await m("/inbox");break;case"upgrade":await m("/classifieds/my-listings");break;case"nfc_order":await m("/admin/nfc-orders");break;case"nfc_dogs":await m("/admin/dogs");break}};return te(()=>{f()}),(s,t)=>(i(),a("div",de,[e("div",le,[t[7]||(t[7]=e("h1",{class:"text-4xl font-bold text-dark mb-4"},"Notifications",-1)),t[8]||(t[8]=e("p",{class:"text-secondary text-lg"},"Stay updated with your dog's health and messages",-1)),e("div",ce,[t[6]||(t[6]=e("h2",{class:"text-xl font-semibold text-dark mb-4"},"Reminder Settings",-1)),e("div",ue,[e("div",me,[t[4]||(t[4]=e("div",null,[e("h3",{class:"font-medium text-dark"},"Enable Reminders"),e("p",{class:"text-sm text-secondary"},"Get notifications for appointments, medications, and vaccinations")],-1)),e("label",pe,[C(e("input",{"onUpdate:modelValue":t[0]||(t[0]=r=>n.value.enabled=r),onChange:j,type:"checkbox",class:"sr-only peer"},null,544),[[se,n.value.enabled]]),t[3]||(t[3]=e("div",{class:"w-11 h-6 bg-gray-200 peer-focus:outline-none peer-focus:ring-4 peer-focus:ring-primary/20 rounded-full peer peer-checked:after:translate-x-full peer-checked:after:border-white after:content-[''] after:absolute after:top-[2px] after:left-[2px] after:bg-white after:border-gray-300 after:border after:rounded-full after:h-5 after:w-5 after:transition-all peer-checked:bg-primary"},null,-1))])]),e("div",fe,[t[5]||(t[5]=e("div",null,[e("h3",{class:"font-medium text-dark"},"Browser Notifications"),e("p",{class:"text-sm text-secondary"},"Show desktop notifications when reminders are due")],-1)),e("button",{onClick:F,class:_([V.value,"px-4 py-2 rounded-lg font-medium transition-colors"])},d(U.value),3)])]),n.value.lastCheck?(i(),a("div",ge,[e("p",be," Last reminder check: "+d(G(n.value.lastCheck)),1),e("button",{onClick:$,disabled:y.value,class:"mt-2 text-sm text-primary hover:text-accent font-medium disabled:opacity-50"},d(y.value?"Checking...":"Check Reminders Now"),9,ve)])):x("",!0)])]),e("div",he,[e("div",ye,[C(e("select",{"onUpdate:modelValue":t[1]||(t[1]=r=>v.value=r),onChange:f,class:"border border-muted rounded-lg px-3 py-2 focus:ring-2 focus:ring-primary focus:border-primary"}
1,[...t[9]||(t[9]=[re('<option value="">All Types</option><option value="appointment">Appointments</option><option value="medication">Medications</option><option value="message">Messages</option><option value="upgrade">Upgrades</option>',5)])],544),[[M,v.value]]),C(e("select",{"onUpdate:modelValue":t[2]||(t[2]=r=>h.value=r),onChange:f,class:"border border-muted rounded-lg px-3 py-2 focus:ring-2 focus:ring-primary focus:border-primary"},[...t[10]||(t[10]=[e("option",{value:""},"All Status",-1),e("option",{value:"unread"},"Unread",-1),e("option",{value:"read"},"Read",-1)])],544),[[M,h.value]])]),e("div",xe,[N.value>0?(i(),a("button",{key:0,onClick:K,class:"bg-secondary hover:bg-dark text-white px-4 py-2 rounded-lg font-semibold transition-colors"}," Mark All Read ")):x("",!0),e("button",{onClick:Y,class:"bg-red-100 hover:bg-red-200 text-red-600 px-4 py-2 rounded-lg font-semibold transition-colors"}," Delete Read ")])]),e("div",_e,[e("div",ke,[e("div",we,[t[12]||(t[12]=e("div",{class:"p-2 bg-primary rounded-lg"},[e("i",{class:"bi bi-bell text-dark"})],-1)),e("div",Ce,[e("p",Re,d(o.value.length),1),t[11]||(t[11]=e("p",{class:"text-secondary text-sm"},"Total",-1))])])]),e("div",Se,[e("div",Ne,[t[14]||(t[14]=e("div",{class:"p-2 bg-accent rounded-lg"},[e("i",{class:"bi bi-envelope"})],-1)),e("div",Ae,[e("p",Ee,d(N.value),1),t[13]||(t[13]=e("p",{class:"text-secondary text-sm"},"Unread",-1))])])]),e("div",Me,[e("div",qe,[t[16]||(t[16]=e("div",{class:"p-2 bg-secondary rounded-lg"},[e("i",{class:"bi bi-calendar2-event text-white"})],-1)),e("div",De,[e("p",Be,d(P.value),1),t[15]||(t[15]=e("p",{class:"text-secondary text-sm"},"Appointments",-1))])])]),e("div",Ie,[e("div",Pe,[t[18]||(t[18]=e("div",{class:"p-2 bg-dark rounded-lg"},[e("i",{class:"bi bi-chat-dots text-white"})],-1)),e("div",Le,[e("p",Ue,d(L.value),1),t[17]||(t[17]=e("p",{class:"text-secondary text-sm"},"Messages",-1))])])])]),k.value?(i(),a("div",Ve,[...t[19]||(t[19]=[e("div",{class:"animate-spin rounded-full h-12 w-12 border-b-2 border-primary mx-auto"},null,-1),e("p",{class:"text-secondary mt-4"},"Loading notifications...",-1)])])):A.value.length===0?(i(),a("div",je,[...t[20]||(t[20]=[e("div",{class:"text-6xl mb-4"},"🔔",-1),e("h3",{class:"text-xl font-semibold text-dark mb-2"},"No notifications",-1),e("p",{class:"text-secondary"},"You're all caught up! Check back later for updates.",-1)])])):(i(),a("div",Fe,[(i(!0),a(oe,null,ae(A.value,r=>(i(),a("div",{key:r.id,class:_(["bg-white rounded-lg shadow-sm border border-muted p-6 hover:shadow-md transition-shadow cursor-pointer",{"bg-primary bg-opacity-5 border-primary":!r.is_read}]),onClick:g=>Q(r)},[e("div",Ge,[e("div",Te,[e("div",{class:_(["w-12 h-12 rounded-full flex items-center justify-center text-white",z(r.type)])},[e("i",{class:_([T(r.type),"text-lg"])},null,2)],2)]),e("div",ze,[e("div",Oe,[e("div",null,[e("h3",He,d(r.title),1),e("p",Ke,d(r.message),1),e("p",Ye,d(O(r.created_at)),1)]),e("div",Je,[r.is_read?x("",!0):(i(),a("div",Qe)),e("button",{onClick:ie(g=>J(r.id),["stop"]),class:"text-secondary hover:text-red-600 transition-colors"},[...t[21]||(t[21]=[e("i",{class:"bi bi-trash"},null,-1)])],8,We)])])])])],10,$e))),128))])),S.value?(i(),a("div",Xe,[e("button",{onClick:H,disabled:b.value,class:"bg-primary hover:bg-accent text-dark px-6 py-3 rounded-lg font-semibold transition-colors disabled:bg-muted disabled:cursor-not-allowed"},[b.value?(i(),a("span",et,"Loading...")):(i(),a("span",tt,"Load More"))],8,Ze)])):x("",!0)]))}});export{it 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.