PageSourceSearch

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

js doghealthy.netlify.app collected 2026-10-03 10:41:02 UTC 4,726 bytes, 1 lines download raw bytes

1import{f as T,u as U,r as n,h as I,L as K,C as L,w as N,o as d,a as t,c as r,i as h,b as q,m as E,P as O,s as A,v as R,j as a,d as g,n as j,t as m,F as H,k as z,e as G}from"#entry";import{a as J,_ as Q}from"./CJQauOmt.js";import{_ as W}from"./BRsHvoYg.js";import{u as X}from"./Dy9pVEbO.js";import"./DKLWY9DJ.js";const Y={class:"mb-4 flex flex-wrap gap-3 items-end"},Z={class:"flex-1 min-w-[200px]"},ee={class:"flex items-center gap-2 text-sm text-slate-700 pb-2"},te=["disabled"],se={key:0,class:"mb-4 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg px-3 py-2"},ae={key:1,class:"text-slate-600 py-8"},oe={key:2,class:"bg-white rounded-xl border border-slate-200 shadow-sm overflow-x-auto"},le={class:"min-w-full text-sm"},ne={class:"px-4 py-3"},de={class:"font-medium text-slate-900"},ie={class:"text-slate-500"},re={class:"px-4 py-3"},ue={class:"px-4 py-3"},ce={key:0,class:"text-slate-400"},me={class:"px-4 py-3 text-right whitespace-nowrap"},pe=["disabled","onClick"],_e={key:0},ye=T({__name:"index",setup(fe){X({title:"Admin dogs — DogHealthy",path:"/admin/dogs",index:!1});const y=U(),f=n(""),x=n(!0),l=n(1),w=n(0),p=n(!0),u=n(""),c=n([]),k=n({}),b=n(""),P=o=>k.value[o]||o.slice(0,8),C=()=>{l.value!==1?l.value=1:v()},v=async()=>{p.value=!0,u.value="";try{const{from:o,to:e}=J(l.value);let i=y.from("doghealthy_dogs").select("id, user_id, name, breed, is_active, nfc_tag_enabled",{count:"exact"}).order("created_at",{ascending:!1}).range(o,e);const _=f.value.trim();_&&(i=i.or(`name.ilike.%${_}%,breed.ilike.%${_}%`)),x.value&&(i=i.eq("is_active",!0));const{data:D,error:s,count:B}=await i;if(s)throw s;c.value=D||[],w.value=B||0;const V=[...new Set(c.value.map(S=>S.user_id).filter(Boolean))];if(V.length){const{data:S}=await y.from("doghealthy_users").select("id, email, full_name").in("id",V),F={};for(const $ of S||[])F[$.id]=$.full_name||$.email;k.value=F}else k.value={}}catch(o){u.value=o?.message||"Failed to load dogs",c.value=[],w.value=0}finally{p.value=!1}},M=async o=>{if(confirm(`Delete dog “${o.name}” and related records? This cannot be undone.`)){b.value=o.id,u.value="";try{const{error:e}=await y.from("doghealthy_dogs").delete().eq("id",o.id);if(e)throw e;c.value.length<=1&&l.value>1?l.value-=1:await v()}catch(e){u.value=e?.message||"Failed to delete dog"}finally{b.value=""}}};return I(v),K(l,v),(o,e)=>{const i=G,_=Q,D=W;return d(),L(D,{title:"Dogs",subtitle:"Browse, edit or delete any dog profile."},{default:N(()=>[t("div",Y,[t("div",Z,[e[3]||(e[3]=t("label",{class:"block text-xs font-medium text-slate-600 mb-1"},"Search",-1)),E(t("input",{"onUpdate:modelValue":e[0]||(e[0]=s=>A(f)?f.value=s:null),type:"search",placeholder:"Dog name or breed…",class:"w-full px-3 py-2 border border-slate-300 rounded-lg text-sm",onKeyup:O(C,["enter"])},null,544),[[R,a(f)]])]),t("label",ee,[E(t("input",{"onUpdate:modelValue":e[1]||(e[1]=s=>A(x)?x.value=s:null),type:"checkbox",class:"rounded border-slate-300",onChange:C},null,544),[[j,a(x)]]),e[4]||(e[4]=g(" Active only ",-1))]),t("button",{type:"button",class:"px-4 py-2 bg-slate-900 text-white rounded-lg text-sm font-semibold",disabled:a(p),onClick:C}," Search ",8,te)]),a(u)?(d(),r("div",se,m(a(u)),1)):h("",!0),a(p)?(d(),r("div",ae,"Loading dogs…")):(d(),r("div",oe,[t("table",le,[e[7]||(e[7]=t("thead",{class:"bg-slate-50 text-left text-slate-600"},[t("tr",null,[t("th",{class:"px-4 py-3 font-medium"},"Dog"),t("th",{class:"px-4 py-3 font-medium"},"Owner"),t("th",{class:"px-4 py-3 font-medium"},"Status"),t("th",{class:"px-4 py-3 font-medium text-right"},"Actions")])],-1)),t("tbody",null,[(d(!0),r(H,null,z(a(c),s=>(d(),r("tr",{key:s.id,class:"border-t border-slate-100 hover:bg-slate-50"},[t("td",ne,[t("div",de,m(s.name),1),t("div",ie,m(s.breed||"—"),1)]),t("td",re,[s.user_id?(d(),L(i,{key:0,to:`/admin/users/${s.user_id}`,class:"text-blue-700 hover:underline"},{default:N(()=>[g(m(P(s.user_id)),1)]),_:2},1032,["to"])):h("",!0)]),t("td",ue,[g(m(s.is_active?"Active":"Inactive")+" ",1),s.nfc_tag_enabled?(d(),r("span",ce," · NFC")):h("",!0)]),t("td",me,[q(i,{to:`/admin/dogs/${s.id}`,class:"text-blue-700 font-medium hover:underline"},{default:N(()=>[...e[5]||(e[5]=[g(" Edit ",-1)])]),_:1},8,["to"]),t("button",{type:"button",class:"ml-3 text-red-700 font-medium hover:underline disabled:opacity-50",disabled:a(b)===s.id,onClick:B=>M(s)},m(a(b)===s.id?"Deleting…":"Delete"),9,pe)])]))),128)),a(c).length===0?(d(),r("tr",_e,[...e[6]||(e[6]=[t("td",{colspan:"4",class:"px-4 py-8 text-center text-slate-500"},"No dogs found.",-1)])])):h("",!0)])])])),q(_,{page:a(l),"onUpdate:page":e[2]||(e[2]=s=>A(l)?l.value=s:null),total:a(w),disabled:a(p)},null,8,["page","total","disabled"])]),_:1})}}});
1export{ye 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.