'use client'; import { useEffect } from 'react'; import { Box, FormControl, RadioGroup, FormControlLabel, Radio, Typography, } from '@mui/material'; import { Schedule } from '@mui/icons-material'; import { useAuth } from '@/lib/auth/AuthContext'; import { useTranslation } from '@/hooks/useTranslation'; interface TimeFormatSelectorProps { value: '12h' | '24h'; onChange: (timeFormat: '12h' | '24h') => void; } export function TimeFormatSelector({ value, onChange }: TimeFormatSelectorProps) { const { user } = useAuth(); const { t } = useTranslation('settings'); // Initialize with user's time format on mount useEffect(() => { if (user?.preferences?.timeFormat && !value) { onChange(user.preferences.timeFormat); } }, [user?.preferences?.timeFormat]); const currentTime = new Date(); const preview12h = currentTime.toLocaleTimeString('en-US', { hour: 'numeric', minute: '2-digit', hour12: true, }); const preview24h = currentTime.toLocaleTimeString('en-US', { hour: '2-digit', minute: '2-digit', hour12: false, }); return ( Time Format onChange(e.target.value as '12h' | '24h')} > } label={ 12-hour format Example: {preview12h} } /> } label={ 24-hour format Example: {preview24h} } /> ); }