import { requireAuth } from "../../utils/auth.js";

export default defineEventHandler(async (event) => {
  const member = await requireAuth(event);

  return {
    _id: member._id,
    id: member._id,
    email: member.email,
    name: member.name,
    status: member.status,
    role: member.role || 'member',
    circle: member.circle,
    contributionTier: member.contributionTier,
    membershipLevel: `${member.circle}-${member.contributionTier}`,
    // Profile fields
    pronouns: member.pronouns,
    timeZone: member.timeZone,
    avatar: member.avatar,
    studio: member.studio,
    bio: member.bio,
    location: member.location,
    socialLinks: member.socialLinks,
    offering: member.offering,
    lookingFor: member.lookingFor,
    showInDirectory: member.showInDirectory,
    notifications: member.notifications,
    privacy: member.privacy,
    // Peer support
    peerSupport: member.peerSupport,
    // Timestamps
    createdAt: member.createdAt,
  };
});
