PageSourceSearch

https://groupin-app.netlify.app/assets/FriendsList.js

js groupin-app.netlify.app collected 2026-10-03 11:57:34 UTC 5,133 bytes, 6 lines download raw bytes

1import{a as L,r as t,j as e,k as E,s as u}from"./index.js";import{u as P,I as G,F as U,b as q,P as R}from"./CreateGroupModal.js";import{A as B,U as D}from"./x.js";function T({onBack:v,shouldRefresh:$=!1,onRefreshed:z}){const{user:a}=L(),[l,y]=t.useState(a==null?void 0:a.id),{friends:d,isLoading:N,error:w,refreshFriends:c}=P(l),[_,C]=t.useState(!1),[k,i]=t.useState(!1),[M,S]=t.useState(!1),[g,m]=t.useState(null);if(t.useEffect(()=>{a!=null&&a.id&&a.id!==l&&(console.log("ユーザーIDを更新:",a.id),y(a.id))},[a,l]),t.useEffect(()=>{l?(console.log("友達リスト更新実行(マウント時)- ユーザーID:",l),c()):console.log("友達リスト更新をスキップ(マウント時)- ユーザーIDなし")},[c,l]),N)return e.jsx(E,{});if(w)return e.jsx("div",{className:"flex items-center justify-center p-8",children:e.jsx("div",{className:"text-red-500",children:"エラーが発生しました。再度お試しください。"})});const p=d.filter(s=>s.gender===(a==null?void 0:a.gender)),b=d.filter(s=>s.gender!==(a==null?void 0:a.gender)),j=async s=>{try{const r=s.id,{data:o,error:H}=await u.from("profiles").select("mbti, business_card_url").eq("id",r).single(),{data:I,error:J}=await u.from("user_sns_links").select("*").eq("user_id",r).order("display_order",{ascending:!0}),{data:x}=await u.from("user_hobbies").select(`
2          hobby_id,
3          hobby_tags (
4            name
5          )
6        `).eq("user_id",r),f=(x==null?void 0:x.flatMap(A=>{const n=A.hobby_tags;return Array.isArray(n)?n.map(h=>h==null?void 0:h.name).filter(Boolean):[n==null?void 0:n.name].filter(Boolean)}))||[];m({name:s.name,image:s.avatar_url||"",gender:s.gender,age:s.age_years??null,occupation:s.occupation||"",mbti:(o==null?void 0:o.mbti)||void 0,businessCardUrl:(o==null?void 0:o.business_card_url)||void 0,snsLinks:I||[],hobbies:f.length>0?f:void 0})}catch(r){console.error("プロフィール情報の取得に失敗しました:",r),m({name:s.name,image:s.avatar_url||"",gender:s.gender,age:s.age_years??null,occupation:s.occupation||""})}},F=()=>{i(!1),c()};return e.jsxs("div",{className:"bg-white",children:[e.jsx("div",{className:"bg-white border-b border-gray-200",children:e.jsxs("div",{className:"flex items-center space-x-3 px-4 h-14",children:[e.jsx("button",{onClick:v,className:"text-gray-700 hover:text-gray-900",children:e.jsx(B,{className:"w-6 h-6"})}),e.jsx("h2",{className:"text-xl font-bold",children:"友達リスト"}),e.jsx("div",{className:"flex-1"}),e.jsx("div",{className:"flex space-x-2",children:e.jsx("button",{onClick:()=>i(!0),className:"text-sm text-gray-600 hover:text-gray-800",title:"友達を追加",children:e.jsx(D,{className:"w-5 h-5"})})})]})}),e.jsx("div",{className:"px-4 pb-4",children:d.length===0?e.jsxs("div",{className:"text-center py-8 text-gray-500",children:[e.jsx("p",{children:"まだ友達がいません"}),e.jsx("div",{className:"flex space-x-3 mt-4 justify-center",children:e.jsx("button",{onClick:()=>i(!0),className:"bg-black text-white px-4 py-3 rounded-lg hover:bg-gray-800",children:"友達を追加"})})]}):e.jsxs("div",{className:"space-y-6",children:[p.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium mb-3",children:(a==null?void 0:a.gender)==="male"?"男性の友達":"女性の友達"}),e.jsx("div",{className:"space-y-2",children:p.map(s=>e.jsx("div",{onClick:()=>j(s),className:"flex items-center justify-between p-4 bg-white rounded-lg border border-gray-100 hover:bg-gray-50 cursor-pointer",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("img",{src:s.avatar_url||"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde",alt:s.name,className:`w-12 h-12 rounded-full object-cover border-2 ${s.gender==="male"?"border-blue-500":"border-pink-500"}`}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.name}),e.jsx("p",{className:"text-sm text-gray-500",children:s.occupation||"未設定"})]})]})},s.id))})]}),b.length>0&&e.jsxs("div",{children:[e.jsx("h3",{className:"text-lg font-medium mb-3",children:(a==null?void 0:a.gender)==="male"?"女性の友達":"男性の友達"}),e.jsx("div",{className:"space-y-2",children:b.map(s=>e.jsx("div",{onClick:()=>j(s),className:"flex items-center justify-between p-4 bg-white rounded-lg border border-gray-100 hover:bg-gray-50 cursor-pointer",children:e.jsxs("div",{className:"flex items-center space-x-3",children:[e.jsx("img",{src:s.avatar_url||"https://images.unsplash.com/photo-1535713875002-d1d0cf377fde",alt:s.name,className:`w-12 h-12 rounded-full object-cover border-2 ${s.gender==="male"?"border-blue-500":"border-pink-500"}`}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.name}),e.jsx("p",{className:"text-sm text-gray-500",children:s.occupation||"未設定"})]})]})},s.id))})]})]})}),_&&e.jsx(G,{onClose:()=>C(!1)}),k&&e.jsx(U,{onClose:F}),M&&e.jsx(q,{onClose:()=>S(!1),onCreateGroup:()=>{},friends:d.map((s,r)=>({id:r,name:s.name,image:s.avatar_url||"",gender:s.gender})),userGender:(a==null?void 0:a.gender)||"male"}),g&&e.jsx(R,{user:g,onClose:()=>m(null)})]})}export{T 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.