2024-05-05 20:55:51 +00:00
|
|
|
'use client'
|
2024-05-04 21:04:30 +00:00
|
|
|
import LocationSearch from '@/components/LocationSearch';
|
|
|
|
import WeatherNow from '../components/WeatherNow'
|
2024-05-09 21:40:14 +00:00
|
|
|
import { createContext, useState } from 'react';
|
|
|
|
import { defaultGeoLocation } from './defaultState';
|
|
|
|
import { LocationContextType, coordType } from '@/types/types';
|
2024-05-10 23:21:34 +00:00
|
|
|
import { LocationContext } from '@/context/LocationContext';
|
2024-05-05 07:51:29 +00:00
|
|
|
|
2024-05-04 07:39:10 +00:00
|
|
|
export default function Home() {
|
2024-05-09 21:40:14 +00:00
|
|
|
const [geoLocation, setGeoLocation] = useState<coordType>(defaultGeoLocation);
|
|
|
|
|
|
|
|
// Create an object that will be passed to the context provider
|
|
|
|
const contextValue: LocationContextType = {
|
|
|
|
geoLocation,
|
|
|
|
setGeoLocation
|
|
|
|
};
|
|
|
|
|
2024-05-04 07:39:10 +00:00
|
|
|
return (
|
2024-05-10 17:23:02 +00:00
|
|
|
<main>
|
2024-05-10 22:45:03 +00:00
|
|
|
<div className='mx-auto max-w-3xl text-center'>
|
2024-05-09 21:40:14 +00:00
|
|
|
<LocationContext.Provider value={contextValue}>
|
|
|
|
<LocationSearch />
|
|
|
|
<WeatherNow />
|
|
|
|
</LocationContext.Provider>
|
2024-05-04 21:04:30 +00:00
|
|
|
</div>
|
2024-05-03 14:48:24 +00:00
|
|
|
</main>
|
|
|
|
);
|
2024-05-04 13:40:23 +00:00
|
|
|
}
|