import { Form } from "react-router"; import { useEffect, useState } from "react"; import { Button } from "~/components/ui/button"; import { Input } from "~/components/ui/input"; import { Label } from "~/components/ui/label"; import { TimezoneSelect, TIMEZONE_OPTIONS } from "~/components/league/TimezoneSelect"; import { AvatarEditor } from "~/components/ui/AvatarEditor"; import type { User } from "~/models/user"; const VALID_TIMEZONES = new Set( TIMEZONE_OPTIONS.flatMap((g) => g.zones.map((z) => z.value)) ); type Props = { user: User; isInActiveDraft: boolean; success?: boolean; error?: string; }; export function ProfileSection({ user, isInActiveDraft, success, error }: Props) { const [timezone, setTimezone] = useState(user.timezone ?? ""); useEffect(() => { if (!user.timezone) { try { const detected = Intl.DateTimeFormat().resolvedOptions().timeZone; if (detected && VALID_TIMEZONES.has(detected)) { setTimezone(detected); } } catch { // Intl not available } } }, [user.timezone]); return (

Profile

Your username, avatar, and timezone.

{success && (

Profile updated successfully.

)} {error &&

{error}

}

{user.email}

{isInActiveDraft ? (

Timezone cannot be changed while you are in an active draft.

) : (

Used for overnight pick protection. We pre-filled your browser's detected timezone.

)}
); }