diff --git a/ui/actions/demo-actions.ts b/ui/actions/demo-actions.ts index 1627900..a65797f 100644 --- a/ui/actions/demo-actions.ts +++ b/ui/actions/demo-actions.ts @@ -33,7 +33,7 @@ export const DemoActionCreators = { getRentIndexError: new ActionCreator<'GET_RENTINDEX_ERROR', AxiosError>('GET_RENTINDEX_ERROR'), getRentCalculateStart: new ActionCreator<'GET_RENTCALCULATE_START', undefined>('GET_RENTCALCULATE_START'), - getRentCalculateDone: new ActionCreator<'GET_RENTCALCULATE_DONE', RentResult>('GET_RENTCALCULATE_DONE'), + getRentCalculateDone: new ActionCreator<'GET_RENTCALCULATE_DONE', RentResult[]>('GET_RENTCALCULATE_DONE'), getRentCalculateError: new ActionCreator<'GET_RENTCALCULATE_ERROR', AxiosError>('GET_RENTCALCULATE_ERROR'), }; diff --git a/ui/components/rent-index-query.tsx b/ui/components/rent-index-query.tsx index 8f1b09a..e152d13 100644 --- a/ui/components/rent-index-query.tsx +++ b/ui/components/rent-index-query.tsx @@ -1,9 +1,9 @@ import * as React from "react"; -import { Form, Col, FormGroup, Label, Input, Row, Button, Card, CardBody, CardTitle, ListGroupItem, ListGroup, Alert } from "reactstrap"; +import { Form, Col, FormGroup, Label, Input, Row, Button, Card, CardBody, CardTitle, ListGroupItem, ListGroup, Alert, Table } from "reactstrap"; import { State } from "../reducers/state"; import { BoundActions, actionBinder } from "../actions/bindable"; import { connect } from "react-redux"; -import { RentIndexListItem, QuestionCatalog, Question, QuestionCatalogRequest, Address } from "../models/rentindex"; +import { RentIndexListItem, QuestionCatalog, Question, QuestionCatalogRequest, Address, RentResult } from "../models/rentindex"; import { bind } from "decko"; import { isBoolean, isString } from "util"; @@ -46,6 +46,11 @@ export class RentIndexImpl extends React.Component) { const city = this.props.rentIndexList.filter(i => i.name === event.target.value); @@ -155,7 +160,7 @@ export class RentIndexImpl extends React.Component) => void { return (event: React.ChangeEvent) => { - const o = { + this.setState({ rentIndexRequest: { ...this.state.rentIndexRequest, ...{ @@ -165,8 +170,7 @@ export class RentIndexImpl extends React.Component + +

Result

+ + + + + + + + + + + + + + + +
MinAvgMax
{result.rentIndex.min}{result.rentIndex.avg}{result.rentIndex.max}
+ + + ) + } + render() { if (this.props.loading)

Loading

return ( @@ -219,64 +252,65 @@ export class RentIndexImpl extends React.Component
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- -

Question Catalog

- { - this.props.rentIndex && this.props.rentIndex.questionCatalogs.map(this.renderQuestionCatalog) - || Select city and year first. - } - - - -
+ {this.state.city && this.state.selectedYear && this.props.rentIndex &&
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ +

Question Catalog

+ { + this.props.rentIndex && this.props.rentIndex.questionCatalogs.map(this.renderQuestionCatalog) + || Select city and year first. + } +
+ + {this.renderResult(this.props.result)} + + + + +
+
+ }
- {this.props.result && - -

Result

- {JSON.stringify(this.props.result)} - -
} ) } diff --git a/ui/models/rentindex.ts b/ui/models/rentindex.ts index 6f62b84..58d0a80 100644 --- a/ui/models/rentindex.ts +++ b/ui/models/rentindex.ts @@ -66,7 +66,7 @@ export interface QuestionCatalogRequest { } export interface RentResult { - rentIndex: { + rentIndex?: { min: number max: number avg: number diff --git a/ui/reducers/state.ts b/ui/reducers/state.ts index c311f26..6039ffe 100644 --- a/ui/reducers/state.ts +++ b/ui/reducers/state.ts @@ -19,7 +19,7 @@ export interface DemoState { export interface RentIndexState { rentIndexList: RentIndexList rentIndex: RentIndex | null - result: RentResult | null + result: RentResult[] | null loading: boolean error: AxiosError | null } diff --git a/ui/router.ts b/ui/router.ts index 580deea..d3214a3 100644 --- a/ui/router.ts +++ b/ui/router.ts @@ -1,7 +1,7 @@ import { State } from "./reducers/state"; import { Router, Routes } from "./helper/routing"; import { NavigationPage, NavigationActionCreators } from "./actions/navigation"; -import { checkToken, registerToken, openXLStoreApp, getRentIndexList } from "./actions/demo"; +import { checkToken, registerToken, openXLStoreApp } from "./actions/demo"; import { Promise } from "es6-promise"; import * as cookie from "cookie"; @@ -60,7 +60,6 @@ const routes: Routes = { "/demo/rentindex": { name: NavigationPage.RentIndex, action: (dispatch) => { - getRentIndexList(dispatch)(); dispatch(NavigationActionCreators.navigateTo.create({ name: NavigationPage.RentIndex, params: {} })) return Promise.resolve(undefined) },