local-weather/types/types.ts

221 lines
4.3 KiB
TypeScript
Raw Normal View History

export interface Forecast {
coord: {
lon: number;
lat: number;
};
weather: Array<{
id: number;
main: string;
description: string;
icon: string;
}>;
base: string;
main: {
temp: number;
feels_like: number;
temp_min: number;
temp_max: number;
pressure: number;
humidity: number;
};
visibility: number;
wind: {
speed: number;
deg: number;
};
clouds: {
all: number;
};
dt: number;
sys: {
type: number;
id: number;
country: string;
sunrise: number;
sunset: number;
};
timezone: number;
id: number;
name: string;
cod: number;
}
export interface HourlyForecast {
latitude: number;
longitude: number;
generationtime_ms: number;
utc_offset_seconds: number;
timezone: string;
timezone_abbreviation: string;
elevation: number;
current_units: CurrentUnits;
current: CurrentWeather;
hourly_units: HourlyUnits;
hourly: HourlyWeather;
daily_units: DailyUnits;
daily: DailyWeather;
}
interface CurrentUnits {
time: string;
interval: string;
temperature_2m: string;
apparent_temperature: string;
is_day: string;
precipitation: string;
rain: string;
showers: string;
snowfall: string;
weather_code: string;
cloud_cover: string;
wind_speed_10m: string;
wind_direction_10m: string;
}
interface CurrentWeather {
time: string;
interval: number;
temperature_2m: number;
apparent_temperature: number;
is_day: number;
precipitation: number;
rain: number;
showers: number;
snowfall: number;
weather_code: number;
cloud_cover: number;
wind_speed_10m: number;
wind_direction_10m: number;
}
interface HourlyUnits {
time: string;
temperature_2m: string;
apparent_temperature: string;
precipitation_probability: string;
precipitation: string;
weather_code: string;
wind_speed_10m: string;
is_day: string;
}
export interface HourlyWeather {
time: string[];
temperature_2m: number[];
apparent_temperature: number[];
precipitation_probability: number[];
precipitation: number[];
weather_code: number[];
wind_speed_10m: number[];
is_day: number[];
}
interface DailyUnits {
time: string;
weather_code: string;
temperature_2m_max: string;
temperature_2m_min: string;
apparent_temperature_max: string;
apparent_temperature_min: string;
sunrise: string;
sunset: string;
daylight_duration: string;
sunshine_duration: string;
uv_index_max: string;
precipitation_sum: string;
precipitation_hours: string;
wind_speed_10m_max: string;
}
interface DailyWeather {
time: string[];
weather_code: number[];
temperature_2m_max: number[];
temperature_2m_min: number[];
apparent_temperature_max: number[];
apparent_temperature_min: number[];
sunrise: string[];
sunset: string[];
daylight_duration: number[];
sunshine_duration: number[];
uv_index_max: number[];
precipitation_sum: number[];
precipitation_hours: number[];
wind_speed_10m_max: number[];
}
2024-05-05 20:55:51 +00:00
export interface LocationType {
2024-05-05 20:55:51 +00:00
results: {
address_components: {
long_name: string;
short_name: string;
2024-05-05 20:55:51 +00:00
types: string[];
}[];
formatted_address: string;
geometry: {
bounds: {
northeast: {
lat: number;
lng: number;
};
southwest: {
lat: number;
lng: number;
};
};
location: {
lat: number;
lng: number;
};
location_type: string;
viewport: {
northeast: {
lat: number;
lng: number;
};
southwest: {
lat: number;
lng: number;
};
};
};
place_id: string;
types: string[];
2024-05-05 20:55:51 +00:00
}[];
status: string;
}
2024-05-05 20:55:51 +00:00
export interface coordType {
name: string;
geo: {
lat: number;
lng: number;}
}
export type EffectCallback = () => void | (() => void | undefined);
export interface TempInfo {
temp: number;
feels_like: number;
temp_min: number;
temp_max: number;
pressure: number;
humidity: number;
}
export interface LocationContextType {
geoLocation: coordType;
setGeoLocation: React.Dispatch<React.SetStateAction<coordType>>;
}
export interface WeatherContextType {
weather: HourlyForecast;
setWeather: React.Dispatch<React.SetStateAction<HourlyForecast>>;
}
export interface HourlyCardPropType {
2024-05-10 17:23:02 +00:00
temperature: number;
weatherCode: number;
time: string;
}