'use client'; import React, { useEffect } from 'react'; import { formatLocalDate } from '../utils/date'; import { ProviderIcon } from '../utils/provider'; type ConnectedAccount = { name?: string; url?: string | null; handle?: string | null; observedAt?: string | null; }; const formatProviderName = (name?: string) => { const n = (name || '').trim(); if (!n) return ''; const lower = n.toLowerCase(); if (lower === 'so' || lower === 'stack_overflow') return 'Stack Overflow'; return n.charAt(0).toUpperCase() + n.slice(1); }; type ConnectedPlatformsProps = { accounts?: ConnectedAccount[] authenticity?: { label?: string; description?: string; oauth_connected?: string[]; mismatches?: Array<{ provider?: string; detail?: string }> } className?: string layoutVariant?: 'grid' | 'column' } const ConnectedPlatforms = ({ accounts, authenticity, className, layoutVariant = 'grid' }: ConnectedPlatformsProps) => { const list = Array.isArray(accounts) ? accounts : []; useEffect(() => { const flash = () => { const hash = typeof window !== 'undefined' ? window.location.hash : ''; if (!hash) return; const id = hash.startsWith('#') ? hash.slice(1) : hash; const el = document.getElementById(id) as HTMLElement | null; if (!el) return; const originalBg = el.style.backgroundColor; el.style.transition = 'background-color 300ms ease'; el.style.backgroundColor = 'rgba(2, 163, 137, 0.14)'; // Ensure visibility after tab switch try { el.scrollIntoView({ behavior: 'smooth', block: 'start' }); } catch {} setTimeout(() => { el.style.backgroundColor = originalBg || ''; }, 1200); }; flash(); window.addEventListener('hashchange', flash); return () => window.removeEventListener('hashchange', flash); }, []); if (list.length === 0) return null; const listClass = layoutVariant === 'column' ? 'flex flex-col gap-3' : 'grid grid-cols-1 sm:grid-cols-2 gap-3' return (