Finished connection to API
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import React from 'react';
|
||||
import DashboardView from '../../Views/DashboardView'
|
||||
import API_DTO from '../../DTOs/api.dto';
|
||||
import ReportingRepository from '../../Repositories/ReportingRepository';
|
||||
import API_DTO from '../../DTOs/api.dto';
|
||||
import { RESPONSE_DTO } from '../../DTOs/response.dto';
|
||||
|
||||
export default class Dashboard extends React.Component<{
|
||||
history: any,
|
||||
location: any
|
||||
}, {
|
||||
dto: API_DTO,
|
||||
response: RESPONSE_DTO,
|
||||
ReportingRepository: ReportingRepository
|
||||
}> {
|
||||
constructor(props: any) {
|
||||
@@ -22,6 +24,7 @@ export default class Dashboard extends React.Component<{
|
||||
DTO.setSecondDate(localStorage.getItem("Second_Date") || "");
|
||||
this.state = {
|
||||
dto: DTO,
|
||||
response: new RESPONSE_DTO(),
|
||||
ReportingRepository: new ReportingRepository(DTO)
|
||||
}
|
||||
}
|
||||
@@ -37,6 +40,7 @@ export default class Dashboard extends React.Component<{
|
||||
DTO.setSecondDate(localStorage.getItem("Second_Date") || "");
|
||||
this.state = {
|
||||
dto: DTO,
|
||||
response: new RESPONSE_DTO(),
|
||||
ReportingRepository: new ReportingRepository(DTO)
|
||||
}
|
||||
} else {
|
||||
@@ -47,6 +51,8 @@ export default class Dashboard extends React.Component<{
|
||||
this.checkFirstDate = this.checkFirstDate.bind(this);
|
||||
this.checkSecondDate = this.checkSecondDate.bind(this);
|
||||
this.getItemsFromApi = this.getItemsFromApi.bind(this);
|
||||
this.getResponseDTO = this.getResponseDTO.bind(this);
|
||||
this.getItemsFromApi();
|
||||
}
|
||||
|
||||
checkFirstDate(_e: any) {
|
||||
@@ -59,7 +65,29 @@ export default class Dashboard extends React.Component<{
|
||||
|
||||
getItemsFromApi() {
|
||||
// TODO: Connect to ReportingRepository.
|
||||
console.log(this.state.ReportingRepository.Read(this.state.dto));
|
||||
this.state.ReportingRepository.Read(this.state.dto).then((res) => {
|
||||
const response = new RESPONSE_DTO();
|
||||
response.room_id = res.room_id;
|
||||
response.start_date = res.start_date;
|
||||
response.end_date = res.end_date;
|
||||
response.total_visitors_with_conversation_count = res.total_visitors_with_conversation_count;
|
||||
response.total_visitors_affected_by_chat_count = res.total_visitors_affected_by_chat_count;
|
||||
response.total_visitors_autosuggested_count = res.total_visitors_autosuggested_count;
|
||||
response.total_visitors_with_chat_count = res.total_visitors_with_chat_count;
|
||||
response.total_chats_from_autosuggest_count = res.total_chats_from_autosuggest_count;
|
||||
response.total_chats_from_user_count = res.total_chats_from_user_count;
|
||||
response.total_chats_from_visitor_count = res.total_chats_from_visitor_count;
|
||||
response.total_conversation_count = res.total_conversation_count;
|
||||
response.total_user_message_count = res.total_user_message_count;
|
||||
response.total_visitor_message_count = res.total_visitor_message_count;
|
||||
response.total_missed_chat_count = res.total_missed_chat_count;
|
||||
response.by_date = res.by_date;
|
||||
this.setState({response: response});
|
||||
});
|
||||
}
|
||||
|
||||
getResponseDTO() {
|
||||
return this.state.response;
|
||||
}
|
||||
|
||||
render () {
|
||||
@@ -67,6 +95,7 @@ export default class Dashboard extends React.Component<{
|
||||
checkFirstDate={this.checkFirstDate}
|
||||
checkSecondDate={this.checkSecondDate}
|
||||
getItemsFromApi={this.getItemsFromApi}
|
||||
getResponseDTO={this.getResponseDTO}
|
||||
/>)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user