'use client'; import React, { useEffect, useState } from 'react'; import Link from 'next/link'; import { onAuthStateChanged, User } from 'firebase/auth'; import { firebaseAuth } from '../../lib/firebase-client'; import { AppCloudData } from '../../components/app-cloud-data'; import { SessionManager } from '../../components/session-manager'; import { FirebaseLink } from '../../components/firebase-link'; import { SignOutButton } from '../../components/sign-out-button'; export default function AccountPage() { const [user, setUser] = useState(null); const [authChecked, setAuthChecked] = useState(false); const [syncTrigger, setSyncTrigger] = useState(0); const [isSyncing, setIsSyncing] = useState(false); const [lastSynced, setLastSynced] = useState(null); const [metrics, setMetrics] = useState({ totalMiles: 12480, rideCount: 184, peakLean: 56.4 }); useEffect(() => { const unsubscribe = onAuthStateChanged(firebaseAuth, (currentUser) => { setUser(currentUser); setAuthChecked(true); }); return () => unsubscribe(); }, []); function handleQuickSync() { setIsSyncing(true); setSyncTrigger((prev) => prev + 1); } const initials = user?.displayName ? user.displayName.split(' ').map((n) => n[0]).join('').slice(0, 2).toUpperCase() : (user?.email ? user.email.slice(0, 2).toUpperCase() : 'MS'); return (
{/* BEGIN: HeroIdentitySection */}
{/* Top aesthetic accent line (Red Area Fixed) */}
{/* Rider Info */}
{/* Rider Avatar / Helmet Node */}
{initials}
{/* Titles & Metadata */}
Rider Portal // Telemetry Cockpit

{user ? `Welcome back, ${user.displayName || user.email?.split('@')[0] || 'Rider'}.` : 'Rider Account & Cloud Telemetry'}

{user?.email || 'Guest Session (Not Signed In)'} • {user ? 'Pro Telemetry Tier' : 'Guest Tier'} • Status: {user ? 'Active Rider' : 'Signed Out'}
{/* Quick Action Buttons (Green Area Fixed) */}
{user ? ( <> groups Group Rides Hub
) : ( <> Sign In Register )}
{/* END: HeroIdentitySection */} {/* BEGIN: TelemetryKpiGrid */}
{/* Metric 1: Distance */}
Total Distance Logged Cloud Aggregate
{metrics.totalMiles.toLocaleString()} miles
All-time telemetry aggregate
{/* Metric 2: Sessions */}
Recorded Sessions 100% Cloud Synced
{metrics.rideCount} rides
Canyons, Circuits & Commutes
{/* Metric 3: Lean Angle Peak */}
Peak Lean Angle Lateral Roll
{metrics.peakLean > 0 ? `${metrics.peakLean}°` : '--'} lateral roll
6-Axis IMU Verified
{/* Metric 4: Hardware Link */}
Hardware Telemetry
Not connected
OBD-II / CAN telemetry unavailable
{/* END: TelemetryKpiGrid */} {/* Live App Cloud Data (Vehicle Garage, Telemetry Hardware & Recent Rides from Firestore) */} { setIsSyncing(syncing); if (!syncing) { setLastSynced(new Date().toLocaleTimeString([], { hour: '2-digit', minute: '2-digit' })); } }} onMetricsLoaded={(m) => setMetrics(m)} /> {/* BEGIN: PlanAndClusterSection */}
{/* Left 7 cols: Plan & Hardware Dongle */}
Subscription billing

Not connected Web billing unavailable

No active plan data
{/* Inclusions Pills */}
Entitlements & Features
Phone-based ride recording OBD-II / ECU telemetry unavailable Cloud sync status shown below Emergency dispatch is not provided
{/* Linked Hardware Details */}
Motorcycle hardware Not available
Device status No device linked
groups Group Rides Hub shield Founder Portal
{/* Right 5 cols: Connected Apps & Cluster Sync */}
App Connections & Sync All Synced
{/* Sync List */}
{/* Google App Account */}
G
Google Account bponders12@gmail.com
Connected
{/* MotorSignal Mobile App */}
iOS Mobile App iPhone 16 Pro • v4.1.0
14m ago
{/* Comms / Cardo */}
Helmet Comms Link Cardo Packtalk Edge
Paired
Apple Watch Companion: Active (HRM Sync)
{/* END: PlanAndClusterSection */} {/* BEGIN: SecurityAndSessionsGrid */}
{/* Sessions (7 cols) */}

Active Device Sessions

Authenticated tokens accessing MotorSignal account telemetry

{/* Security & SOS Preferences (5 cols) */}

Account & Security

Account-link status and security settings

{/* Google App Link */}
Mobile App Account Link {user ? 'CONNECTED' : 'NOT LINKED'}
{/* 2FA State */}
Two-Factor Authentication (2FA) Hardware TOTP Authenticator
ENABLED
{/* Leaderboard Privacy */}
Telemetry Privacy Mode Public Leaderboard (Club Trophies)
Telemetry Data Retention: 100% Retained Security Logs
{/* END: SecurityAndSessionsGrid */}
); }