import { Link } from 'react-router-dom' import { Component } from 'react' import { CityPresenter, CityPresenterFactory, CityPresenterVM } from '@grenoble-hands-on/web-adapters' type CityProps = { cityPresenterFactory: CityPresenterFactory, id: string } export class City extends Component { private cityPresenter: CityPresenter constructor(public props: CityProps) { super(props) this.cityPresenter = this.props.cityPresenterFactory.build(this.props.id) this.state = this.cityPresenter.vm } componentDidMount() { this.cityPresenter.fetchCity().then() this.cityPresenter.fetchWeather().then() this.cityPresenter.onVmUpdate((state: CityPresenterVM) => { this.setState({ ...state }) }) } render() { const vm = this.state return (

Cities weather

{vm.city?.name}

{vm.dailyWeather?.length ? (
{vm.dailyWeather.map((weather, i) => )}
Date Weather Max Min
{weather.day} {weather.weather}/ {weather.temperatureMax + ' ' + weather.unite + '°'} {weather.temperatureMin + ' ' + weather.unite + '°'}
) : null} {vm.hourlyWeather?.length ? (
{vm.hourlyWeather.map((weather, i) => )}
Time Weather Temperature
{weather.time} {weather.weather}/ {weather.temperature + ' ' + weather.unite + '°'}
) : null} {vm.loading ?
Loading...
: null}
Go back home
) } }