FanClub Profile & Member Card
Relevant source files
The following files were used as context for generating this wiki page:
The FanClub Profile & Member Card system provides Lou Gehrig Fan Club members with tools to manage their identity and view digital keepsakes. This module allows authenticated users to update personal details, manage email communication preferences, and access a digital membership card featuring unique front and back designs.
This system is a core part of the authenticated FanClub area (/fanclub/**), which is restricted to users with a valid session. Authentication state is primarily managed client-side via localStorage, using the key lgfc_member_email to represent the login state.
Sources: context.md:19-22, src/app/fanclub/page.tsx:24
Architecture and Authentication
The FanClub routes utilize the useMemberSession hook to enforce authentication. If a user is not authenticated, they are redirected to the homepage (/). The profile and member card pages are client-side rendered components that interact with Cloudflare Pages Functions (API routes) to fetch and persist data.
The following diagram illustrates the authentication check and data flow for accessing the profile:
Member Profile Management
The profile management interface allows members to update their naming information and communication preferences. The system differentiates between "Full Name" (used for internal records) and "Screen Name" (used for public interactions like chat).
Data Structures
The profile data is handled using a specific Profile type:
| Field | Type | Description |
|---|---|---|
email | string | Unique identifier, read-only in the profile UI. |
first_name | string | Member's given name. |
last_name | string | Member's surname. |
screen_name | string | Public alias used within the club. |
email_opt_in | boolean | Preference for receiving update emails. |
Sources: src/app/fanclub/myprofile/page.tsx:7-13, src/app/auth/AuthClient.tsx:12-17
Profile Update Flow
The UI tracks "dirty" state by comparing the current local state against the savedProfile fetched from the API. The "Save" button is only enabled when changes are detected.
Digital Membership Card
The Member Card is a digital keepsake accessible via /fanclub/membercard. It serves as a visual representation of membership and provides content managed via a D1 database backend.
Components and Display
The membership card page displays two distinct images representing the front and back of the card.
| Aspect | Implementation Details |
|---|---|
| Front Image | /membercard-front.png |
| Back Image | /membercard-back.png |
| Dynamic Content | Fetched from /api/content/membercard |
| Data Schema | Includes title, body_md, and updated_at |
Sources: src/app/fanclub/membercard/page.tsx:9-14, src/app/fanclub/membercard/page.tsx:68-87
Content Retrieval
The page attempts to fetch custom Markdown content for the membership card. If the API call fails or no content is configured, it falls back to a default description: "Your membership card is a digital keepsake. Save the front and back card images below for personal use and sharing."
Sources: src/app/fanclub/membercard/page.tsx:32-40, src/app/fanclub/membercard/page.tsx:61-64
Integration with Join Process
The initial creation of the profile occurs during the "Join" flow. The AuthClient handles the transition from a new registration to an authenticated session.
Sources: src/app/auth/AuthClient.tsx:50-84
The splitName utility is used to parse a single "Full Name" input field into first_name and last_name components for the database:
- A single word is treated as the
first_name. - Multiple words result in the first word being
first_nameand all subsequent words being joined as thelast_name.
Sources: src/app/auth/AuthClient.tsx:9-14
Summary
The FanClub Profile & Member Card module provides the essential interface for member identity management. By combining read-only identifiers (email) with editable attributes (screen name, opt-in status) and visual assets (member card images), the system creates a personalized experience for Lou Gehrig Fan Club members while maintaining strict access control through client-side session validation.