PageSourceSearch

https://mpchurch.base44.app/assets/AdminFamilyHubs-BQbJ51Kh.js

js mpchurch.base44.app collected 2026-10-03 03:07:27 UTC 11,941 bytes, 1 lines download raw bytes

1import{r as n,j as e,X as U,o as y,a9 as R,b as p,K as H,a5 as z,U as K,P as M,M as V,bi as O,J as X,n as Y,T as $}from"./index-DShK1gGc.js";import{F as J}from"./FamilyHubMemberPicker-D1b1XQky.js";import{C as G}from"./chevron-up-CXQi2Gsx.js";function I({hub:o,allUsers:m,onClose:u,onSaved:f}){const[i,N]=n.useState({owner_name:o.owner_name||"",owner_email:o.owner_email||"",owner_phone:o.owner_phone||"",owner_address:o.owner_address||"",owner_birthday:o.owner_birthday||""}),[c,g]=n.useState(()=>{try{return JSON.parse(o.members_json||"[]")}catch{return[]}}),[b,w]=n.useState(!1),d=(t,x)=>N(j=>({...j,[t]:x})),A=async t=>{t.preventDefault(),w(!0);const x=await p.entities.FamilyHub.update(o.id,{...i,members_json:JSON.stringify(c)});w(!1),f(x)};return e.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",onClick:u,children:e.jsxs("form",{onSubmit:A,onClick:t=>t.stopPropagation(),className:"bg-white rounded-2xl p-6 w-full max-w-lg max-h-[85vh] overflow-y-auto space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"font-semibold text-[#1A1A1A]",children:"Manage Family Hub"}),e.jsx("button",{type:"button",onClick:u,children:e.jsx(U,{className:"w-5 h-5 text-[#1A1A1A]/40"})})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-1",children:"Owner Name *"}),e.jsx("input",{required:!0,value:i.owner_name,onChange:t=>d("owner_name",t.target.value),className:"w-full px-3 py-2 rounded-xl border border-[#EAE4DD] text-sm outline-none focus:border-[#e71d32]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-1",children:"Owner Email *"}),e.jsx("input",{required:!0,type:"email",value:i.owner_email,onChange:t=>d("owner_email",t.target.value),className:"w-full px-3 py-2 rounded-xl border border-[#EAE4DD] text-sm outline-none focus:border-[#e71d32]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-1",children:"Phone"}),e.jsx("input",{value:i.owner_phone,onChange:t=>d("owner_phone",t.target.value.replace(/\D/g,"")),placeholder:"(650) 555-0000",className:"w-full px-3 py-2 rounded-xl border border-[#EAE4DD] text-sm outline-none focus:border-[#e71d32]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-1",children:"Birthday"}),e.jsx("input",{type:"date",value:i.owner_birthday,onChange:t=>d("owner_birthday",t.target.value),className:"w-full px-3 py-2 rounded-xl border border-[#EAE4DD] text-sm outline-none focus:border-[#e71d32]"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-1",children:"Address"}),e.jsx("input",{value:i.owner_address,onChange:t=>d("owner_address",t.target.value),placeholder:"123 Main St, South San Francisco, CA",className:"w-full px-3 py-2 rounded-xl border border-[#EAE4DD] text-sm outline-none focus:border-[#e71d32]"})]})]}),e.jsx("div",{className:"pt-3 border-t border-[#EAE4DD]",children:e.jsx(J,{members:c,onChange:g,allUsers:m,excludeEmail:i.owner_email})}),e.jsxs("button",{type:"submit",disabled:b,className:"w-full flex items-center justify-center gap-2 py-2.5 bg-[#1A1A1A] text-white rounded-xl text-sm font-semibold hover:bg-[#e71d32] transition-all",children:[b?e.jsx(y,{className:"w-4 h-4 animate-spin"}):e.jsx(R,{className:"w-4 h-4"})," Save Changes"]})]})})}const P={owner_name:"",owner_email:"",owner_phone:"",owner_address:"",owner_birthday:""};function ee(){const[o,m]=n.useState([]),[u,f]=n.useState([]),[i,N]=n.useState(!0),[c,g]=n.useState(""),[b,w]=n.useState(null),[d,A]=n.useState(!1),[t,x]=n.useState(P),[j,_]=n.useState([]),[E,D]=n.useState(!1),[C,v]=n.useState(null);n.useEffect(()=>{Promise.all([p.entities.FamilyHub.list("-created_date",200),p.entities.User.list()]).then(([s,a])=>{m(s),f(a),N(!1)})},[]);const h=(s,a)=>x(r=>({...r,[s]:a})),L=async s=>{window.confirm("Delete this Family Hub?")&&(await p.entities.FamilyHub.delete(s),m(
1a=>a.filter(r=>r.id!==s)))},q=async s=>{s.preventDefault(),D(!0);const a=await p.entities.FamilyHub.create({...t,owner_user_id:"manual",members_json:JSON.stringify(j)});m(r=>[a,...r]),x(P),_([]),A(!1),D(!1)},S=o.filter(s=>{var a,r;return!c||((a=s.owner_name)==null?void 0:a.toLowerCase().includes(c.toLowerCase()))||((r=s.owner_email)==null?void 0:r.toLowerCase().includes(c.toLowerCase()))}),T=s=>{try{return JSON.parse(s||"[]")}catch{return[]}};return e.jsxs("div",{className:"p-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-[#1A1A1A]",children:"Family Hubs"}),e.jsx("p",{className:"text-[#1A1A1A]/40 text-sm mt-1",children:"View, manage, and create Family Hubs."})]}),e.jsxs("button",{onClick:()=>A(s=>!s),className:"flex items-center gap-2 px-5 py-2.5 bg-[#1A1A1A] hover:bg-[#e71d32] text-white rounded-xl text-sm font-medium transition-all",children:[d?e.jsx(U,{className:"w-4 h-4"}):e.jsx(H,{className:"w-4 h-4"}),d?"Cancel":"Create Hub"]})]}),d&&e.jsxs("form",{onSubmit:q,className:"bg-white rounded-2xl border border-[#EAE4DD] p-6 mb-6 space-y-4",children:[e.jsx("h3",{className:"text-sm font-semibold text-[#1A1A1A]/50 uppercase tracking-widest",children:"New Family Hub"}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-1.5",children:"Owner Name *"}),e.jsx("input",{required:!0,value:t.owner_name,onChange:s=>h("owner_name",s.target.value),className:"w-full px-3 py-2 rounded-xl border border-[#EAE4DD] text-sm outline-none focus:border-[#e71d32]",placeholder:"John Smith"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-1.5",children:"Owner Email *"}),e.jsx("input",{required:!0,type:"email",value:t.owner_email,onChange:s=>h("owner_email",s.target.value),className:"w-full px-3 py-2 rounded-xl border border-[#EAE4DD] text-sm outline-none focus:border-[#e71d32]"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-1.5",children:"Phone"}),e.jsx("input",{value:t.owner_phone,onChange:s=>h("owner_phone",s.target.value.replace(/\D/g,"")),className:"w-full px-3 py-2 rounded-xl border border-[#EAE4DD] text-sm outline-none focus:border-[#e71d32]",placeholder:"(650) 555-0000"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-1.5",children:"Birthday"}),e.jsx("input",{type:"date",value:t.owner_birthday,onChange:s=>h("owner_birthday",s.target.value),className:"w-full px-3 py-2 rounded-xl border border-[#EAE4DD] text-sm outline-none focus:border-[#e71d32]"})]}),e.jsxs("div",{className:"sm:col-span-2",children:[e.jsx("label",{className:"block text-xs font-medium text-[#1A1A1A]/50 mb-1.5",children:"Address"}),e.jsx("input",{value:t.owner_address,onChange:s=>h("owner_address",s.target.value),className:"w-full px-3 py-2 rounded-xl border border-[#EAE4DD] text-sm outline-none focus:border-[#e71d32]",placeholder:"123 Main St, South San Francisco, CA"})]})]}),e.jsx("div",{className:"pt-3 border-t border-[#EAE4DD]",children:e.jsx(J,{members:j,onChange:_,allUsers:u,excludeEmail:t.owner_email})}),e.jsxs("button",{type:"submit",disabled:E,className:"flex items-center gap-2 px-5 py-2 bg-[#1A1A1A] text-white rounded-xl text-sm font-medium hover:bg-[#e71d32] transition-all",children:[E?e.jsx(y,{className:"w-4 h-4 animate-spin"}):e.jsx(H,{className:"w-4 h-4"})," Create Hub"]})]}),e.jsxs("div",{className:"relative mb-4 max-w-sm",children:[e.jsx(z,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[#1A1A1A]/30"}),e.jsx("input",{value:c,onChange:s=>g(s.target.value),placeholder:"Search by name or email…",className:"w-full pl-9 pr-4 py-2.5 rounded-xl border border-[#EAE4DD] text-sm outline-none focus:border-[#e71d32]"})]}),i?e.jsx("div",{className:"flex justify-center py-20",children:e.jsx(y,{className:"w-7 h-7 text-[#e71d32] animate-spin"})}):S.length===0?e.jsxs("div",{className:"text-center py-16 text-[#1A1A1A]/30 bg-white rounded-2xl border border-[#
1EAE4DD]",children:[e.jsx(K,{className:"w-8 h-8 mx-auto mb-2 opacity-30"}),e.jsx("p",{className:"text-sm",children:c?"No hubs match your search.":"No family hubs yet."})]}):e.jsx("div",{className:"space-y-3",children:S.map(s=>{var k,F;const a=T(s.members_json),r=b===s.id;return e.jsxs("div",{className:"bg-white rounded-2xl border border-[#EAE4DD] overflow-hidden",children:[e.jsxs("div",{className:"flex items-center justify-between p-5 flex-wrap gap-3",children:[e.jsxs("div",{className:"flex items-center gap-4 flex-wrap",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-[#e71d32]/20 flex items-center justify-center text-[#e71d32] font-bold flex-shrink-0",children:((F=(k=s.owner_name)==null?void 0:k.charAt(0))==null?void 0:F.toUpperCase())||"?"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold text-[#1A1A1A] text-sm",children:s.owner_name||"Unknown"}),e.jsxs("div",{className:"flex flex-wrap gap-x-3 gap-y-0.5 text-[#1A1A1A]/40 text-xs mt-0.5",children:[e.jsx("span",{children:s.owner_email}),s.owner_phone&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(M,{className:"w-3 h-3"}),s.owner_phone]}),s.owner_address&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(V,{className:"w-3 h-3"}),s.owner_address]}),s.owner_birthday&&e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(O,{className:"w-3 h-3"}),s.owner_birthday]})]})]}),e.jsxs("span",{className:"ml-1 px-2.5 py-0.5 rounded-full bg-[#e71d32]/10 text-[#e71d32] text-xs font-medium",children:[a.length," member",a.length!==1?"s":""]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{onClick:()=>v(s),className:"flex items-center gap-1.5 px-3 py-1.5 border border-[#EAE4DD] hover:border-[#e71d32] text-[#1A1A1A]/60 hover:text-[#e71d32] rounded-xl text-xs font-medium transition-all",children:[e.jsx(X,{className:"w-3.5 h-3.5"})," Manage"]}),a.length>0&&e.jsx("button",{onClick:()=>w(r?null:s.id),className:"p-2 text-[#1A1A1A]/30 hover:text-[#1A1A1A] transition-colors",children:r?e.jsx(G,{className:"w-4 h-4"}):e.jsx(Y,{className:"w-4 h-4"})}),e.jsx("button",{onClick:()=>L(s.id),className:"p-2 text-[#1A1A1A]/20 hover:text-red-500 transition-colors",children:e.jsx($,{className:"w-4 h-4"})})]})]}),r&&a.length>0&&e.jsxs("div",{className:"border-t border-[#EAE4DD] px-5 py-4 bg-[#F9F8F6]",children:[e.jsx("p",{className:"text-xs font-semibold text-[#1A1A1A]/40 uppercase tracking-widest mb-3",children:"Members"}),e.jsx("div",{className:"space-y-2",children:a.map((l,B)=>e.jsxs("div",{className:"flex items-center gap-3 text-sm flex-wrap",children:[e.jsx("span",{className:"px-2 py-0.5 rounded-full text-xs font-medium bg-white border border-[#EAE4DD] text-[#1A1A1A]/50",children:l.relationship||"Member"}),e.jsx("span",{className:"text-[#1A1A1A]/70",children:l.name||l.email}),e.jsx("span",{className:"text-[#1A1A1A]/30 text-xs",children:l.email}),l.phone&&e.jsxs("span",{className:"text-[#1A1A1A]/30 text-xs flex items-center gap-1",children:[e.jsx(M,{className:"w-3 h-3"}),l.phone]}),l.birthday&&e.jsxs("span",{className:"text-[#1A1A1A]/30 text-xs flex items-center gap-1",children:[e.jsx(O,{className:"w-3 h-3"}),l.birthday]}),e.jsx("span",{className:`ml-auto text-xs px-2 py-0.5 rounded-full ${l.status==="active"||l.status==="accepted"?"bg-green-50 text-green-600":l.status==="declined"?"bg-red-50 text-red-500":"bg-amber-50 text-amber-600"}`,children:l.status||"pending"})]},B))})]})]},s.id)})}),C&&e.jsx(I,{hub:C,allUsers:u,onClose:()=>v(null),onSaved:s=>{m(a=>a.map(r=>r.id===s.id?s:r)),v(null)}})]})}export{ee 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.