import React from 'react' export default function ProfileRecordList({ profileRecords, apiConfig, user = null, agent = null, onRecordDeleted = null }) { if (!profileRecords || profileRecords.length === 0) { return ( プロフィールがありません ) } const handleDelete = async (profile) => { if (!user || !agent || !profile.uri) return const confirmed = window.confirm('このプロフィールを削除しますか?') if (!confirmed) return try { const uriParts = profile.uri.split('/') await agent.api.com.atproto.repo.deleteRecord({ repo: uriParts[2], collection: uriParts[3], rkey: uriParts[4] }) if (onRecordDeleted) { onRecordDeleted() } } catch (error) { alert(`削除に失敗しました: ${error.message}`) } } const canDelete = (profile) => { if (!user || !agent || !profile.uri) return false // Check if the record is in the current user's repository const recordRepoDid = profile.uri.split('/')[2] return recordRepoDid === user.did } return ( {profileRecords.map((profile) => ( {profile.value.author?.avatar ? ( ) : ( {(profile.value.author?.displayName || profile.value.author?.handle || '?').charAt(0).toUpperCase()} )} {profile.value.author?.displayName || profile.value.author?.handle} {profile.value.profileType === 'admin' && ( Admin )} {canDelete(profile) && ( handleDelete(profile)} className="btn btn-danger btn-sm" title="Delete Profile" > delete )} {profile.value.text} ))} ) }
プロフィールがありません