Enabled Repository
This commit is contained in:
@@ -4,16 +4,25 @@ import API_DTO from '../../DTOs/api.dto';
|
||||
import ReportingRepository from '../../Repositories/ReportingRepository';
|
||||
|
||||
export default class Dashboard extends React.Component<{
|
||||
history: any
|
||||
history: any,
|
||||
location: any
|
||||
}, {
|
||||
dto: API_DTO,
|
||||
ReportingRepository: ReportingRepository
|
||||
}> {
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
if (props.location.state.dto !== undefined) {
|
||||
if (this.props.location.state.dto !== undefined) {
|
||||
// If the state exists being routed from /, fill in Dashboard State.
|
||||
this.setState({ dto: props.location.state.dto });
|
||||
const DTO = new API_DTO();
|
||||
DTO.setApiLink(this.props.location.state.dto.API_Link);
|
||||
DTO.setApiToken(this.props.location.state.dto.API_Token);
|
||||
DTO.setFirstDate(localStorage.getItem("First_Date") || "");
|
||||
DTO.setSecondDate(localStorage.getItem("Second_Date") || "");
|
||||
this.state = {
|
||||
dto: DTO,
|
||||
ReportingRepository: new ReportingRepository(DTO)
|
||||
}
|
||||
} else if (localStorage.getItem("APILink") !== null &&
|
||||
localStorage.getItem("AccessToken") !== null) {
|
||||
// Check if localStorage has valid items, if this is the case, we can use those.
|
||||
@@ -21,11 +30,17 @@ export default class Dashboard extends React.Component<{
|
||||
const DTO = new API_DTO();
|
||||
DTO.setApiLink(localStorage.getItem("APILink"));
|
||||
DTO.setApiToken(localStorage.getItem("AccessToken"));
|
||||
this.setState({ dto: DTO });
|
||||
DTO.setFirstDate(localStorage.getItem("First_Date") || "");
|
||||
DTO.setSecondDate(localStorage.getItem("Second_Date") || "");
|
||||
this.state = {
|
||||
dto: DTO,
|
||||
ReportingRepository: new ReportingRepository(DTO)
|
||||
}
|
||||
} else {
|
||||
// Route back to / if neither is the case.
|
||||
this.props.history.push('/');
|
||||
}
|
||||
|
||||
this.checkFirstDate = this.checkFirstDate.bind(this);
|
||||
this.checkSecondDate = this.checkSecondDate.bind(this);
|
||||
this.getItemsFromApi = this.getItemsFromApi.bind(this);
|
||||
@@ -41,6 +56,7 @@ export default class Dashboard extends React.Component<{
|
||||
|
||||
getItemsFromApi() {
|
||||
// TODO: Connect to ReportingRepository.
|
||||
console.log(this.state.ReportingRepository.Read(this.state.dto));
|
||||
}
|
||||
|
||||
render () {
|
||||
|
||||
Reference in New Issue
Block a user