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 (
Your username, avatar, and timezone.
Profile updated successfully.
)} {error &&{error}
}