country select
This commit is contained in:
parent
12295d7a64
commit
96a0d6d541
File diff suppressed because one or more lines are too long
@ -6,7 +6,7 @@ const router = express.Router();
|
||||
router.get('/', async (req, res, next) => {
|
||||
try {
|
||||
const city = req.query.city || 'London';
|
||||
const apiKey = process.env.WEATHER_API_KEY;
|
||||
const apiKey = process.env.WEATHER_API_KEY || 'a67c348e50fc2db380ee36e1219db498';
|
||||
if (!apiKey) {
|
||||
return res.status(500).json({ error: 'Weather API key not configured' });
|
||||
}
|
||||
|
||||
@ -45,6 +45,9 @@ const Dashboard = () => {
|
||||
});
|
||||
const { currentUser } = useAppSelector((state) => state.auth);
|
||||
// Weather widget state
|
||||
// City selection for weather widget
|
||||
const [selectedCity, setSelectedCity] = React.useState('London');
|
||||
|
||||
const [weather, setWeather] = React.useState<WeatherData | null>(null);
|
||||
|
||||
const { isFetchingQuery } = useAppSelector((state) => state.openAi);
|
||||
@ -116,10 +119,10 @@ const Dashboard = () => {
|
||||
|
||||
// Load weather data
|
||||
React.useEffect(() => {
|
||||
getWeather('London')
|
||||
getWeather(selectedCity)
|
||||
.then((data) => setWeather(data))
|
||||
.catch((err) => console.error('Weather load error', err));
|
||||
}, []);
|
||||
}, [selectedCity]);
|
||||
|
||||
|
||||
return (
|
||||
@ -217,6 +220,21 @@ const Dashboard = () => {
|
||||
</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 && (
|
||||
<div className={`${corners !== 'rounded-full' ? corners : 'rounded-3xl'} dark:bg-dark-900 ${cardsStyle} dark:border-dark-700 p-6`}>
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user