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,
    contributionAmount: member.contributionAmount,
    billingCadence: member.billingCadence,
    helcimCustomerId: member.helcimCustomerId,
    nextBillingDate: member.nextBillingDate,
    membershipLevel: `${member.circle}-${member.contributionAmount}`,
    // Profile fields
    pronouns: member.pronouns,
    timeZone: member.timeZone,
    avatar: member.avatar,
    studio: member.studio,
    bio: member.bio,
    location: member.location,
    socialLinks: member.socialLinks,
    craftTags: member.craftTags,
    board: member.board,
    showInDirectory: member.showInDirectory,
    notifications: member.notifications,
    createdAt: member.createdAt,
    onboarding: member.onboarding,
  };
});
