country select

This commit is contained in:
Flatlogic Bot 2025-05-12 14:34:31 +00:00
parent 12295d7a64
commit 96a0d6d541
3 changed files with 23 additions and 4 deletions

File diff suppressed because one or more lines are too long

View File

@ -6,7 +6,7 @@ const router = express.Router();
router.get('/', async (req, res, next) => { router.get('/', async (req, res, next) => {
try { try {
const city = req.query.city || 'London'; const city = req.query.city || 'London';
const apiKey = process.env.WEATHER_API_KEY; const apiKey = process.env.WEATHER_API_KEY || 'a67c348e50fc2db380ee36e1219db498';
if (!apiKey) { if (!apiKey) {
return res.status(500).json({ error: 'Weather API key not configured' }); return res.status(500).json({ error: 'Weather API key not configured' });
} }

View File

@ -45,6 +45,9 @@ const Dashboard = () => {
}); });
const { currentUser } = useAppSelector((state) => state.auth); const { currentUser } = useAppSelector((state) => state.auth);
// Weather widget state // Weather widget state
// City selection for weather widget
const [selectedCity, setSelectedCity] = React.useState('London');
const [weather, setWeather] = React.useState<WeatherData | null>(null); const [weather, setWeather] = React.useState<WeatherData | null>(null);
const { isFetchingQuery } = useAppSelector((state) => state.openAi); const { isFetchingQuery } = useAppSelector((state) => state.openAi);
@ -116,10 +119,10 @@ const Dashboard = () => {
// Load weather data // Load weather data
React.useEffect(() => { React.useEffect(() => {
getWeather('London') getWeather(selectedCity)
.then((data) => setWeather(data)) .then((data) => setWeather(data))
.catch((err) => console.error('Weather load error', err)); .catch((err) => console.error('Weather load error', err));
}, []); }, [selectedCity]);
return ( return (
@ -217,6 +220,21 @@ const Dashboard = () => {
</div> </div>
</div> </div>
)} )}
<div className="mb-4">
<label htmlFor="city-select" className="block text-sm font-medium text-gray-700 dark:text-gray-300">
{t('pages.dashboard.selectCity', { defaultValue: 'Select City' })}
</label>
<select
id="city-select"
value={selectedCity}
onChange={(e) => setSelectedCity(e.target.value)}
className="mt-1 block w-full p-2 border border-gray-300 rounded-md shadow-sm focus:ring-green-500 focus:border-green-500 sm:text-sm bg-white dark:bg-dark-800 dark:border-dark-600"
>
<option value="London">London</option>
<option value="Minsk">Minsk</option>
</select>
</div>
{weather && ( {weather && (
<div className={`${corners !== 'rounded-full' ? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}> <div className={`${corners !== 'rounded-full' ? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}>