Compare commits

...

2 Commits

Author SHA1 Message Date
2d4442fe76 Fixed card links 2021-01-17 22:53:39 -05:00
7e23087bb5 Changed table pages into generic 2021-01-17 22:53:32 -05:00
5 changed files with 34 additions and 59 deletions

View File

@ -2,9 +2,8 @@ import React, { Component } from "react";
import { BrowserRouter as Router, Route, Switch } from "react-router-dom"; import { BrowserRouter as Router, Route, Switch } from "react-router-dom";
// Routes // Routes
import Upcoming from "./root/Pages/Upcoming";
import Migrations from "./root/Pages/Migrations"; import Migrations from "./root/Pages/Migrations";
import Historical from "./root/Pages/Historical"; import GenericList from "./root/Pages/GenericList";
import Reports from "./root/Pages/Reports"; import Reports from "./root/Pages/Reports";
import Book from "./root/Pages/Book"; import Book from "./root/Pages/Book";
import IDSingle from "./root/Pages/IDSingle"; import IDSingle from "./root/Pages/IDSingle";
@ -12,6 +11,7 @@ import IDSingle from "./root/Pages/IDSingle";
import Home from "./root/Home"; import Home from "./root/Home";
import Navigation from "./root/Navigation"; import Navigation from "./root/Navigation";
// Main app component, react-router comes from here, // Main app component, react-router comes from here,
// and links to all of the sub pages // and links to all of the sub pages
@ -24,11 +24,27 @@ class App extends Component {
<Switch> <Switch>
<Route exact path="/" component={Home} /> <Route exact path="/" component={Home} />
<Route exact path="/book" component={Book} /> <Route exact path="/book" component={Book} />
<Route exact path="/upcoming-migrations" component={Upcoming} />
<Route exact path="/migrations" component={Migrations} /> <Route exact path="/migrations" component={Migrations} />
<Route exact path="/reports" component={Reports} /> <Route exact path="/reports" component={Reports} />
<Route exact path="/historical-migrations" component={Historical} />
<Route path="/migrations/:migrationId" component={IDSingle} /> <Route path="/migrations/:migrationId" component={IDSingle} />
<Route exact path="/upcoming-migrations" render={(props) => (
<GenericList {...props} APILINK="/pending/" />
)} />
<Route exact path="/missed" render={(props) => (
<GenericList {...props} APILINK="/missed/" />
)} />
<Route exact path="/completed" render={(props) => (
<GenericList {...props} APILINK="/completed/" />
)} />
<Route exact path="/pending-terminations" render={(props) => (
<GenericList {...props} APILINK="/pendingterm/" />
)} />
<Route exact path="/all-terminations" render={(props) => (
<GenericList {...props} APILINK="/waitingterm/" />
)} />
<Route exact path="/historical-migrations" render={(props) => (
<GenericList {...props} APILINK="/all/" />
)} />
</Switch> </Switch>
</div> </div>
</Router> </Router>

View File

@ -44,7 +44,7 @@ class Cards extends Component {
{this.waitingMig()} {this.waitingMig()}
</div> </div>
<div className="card-action"> <div className="card-action">
<a href="/upcoming-migrations">waiting</a> <a href="/pending-terminations">waiting</a>
</div> </div>
</div> </div>
</div> </div>
@ -56,7 +56,7 @@ class Cards extends Component {
{this.completedMig()} {this.completedMig()}
</div> </div>
<div className="card-action"> <div className="card-action">
<a href="/historical-migrations">complete</a> <a href="/completed">complete</a>
</div> </div>
</div> </div>
</div> </div>
@ -67,7 +67,7 @@ class Cards extends Component {
{this.missedMig()} {this.missedMig()}
</div> </div>
<div className="card-action"> <div className="card-action">
<a href="/historical-migrations">missed</a> <a href="/missed">missed</a>
</div> </div>
</div> </div>
</div> </div>

View File

@ -3,13 +3,13 @@ import CompTable from "../common/Tables/CompTable";
import { callAPI } from "../../actions/API" import { callAPI } from "../../actions/API"
import Error from "../../actions/Error"; import Error from "../../actions/Error";
// Upcoming parent page, // Missing parent page,
// Most of the good stuff is happening in UpcomingSingle, which does the // Most of the good stuff is happening in UpcomingSingle, which does the
// main rendering of the table, // main rendering of the table,
// may want to eventually do the API call here, to re-use the table // may want to eventually do the API call here, to re-use the table
// instead of duplicating it. // instead of duplicating it.
class Upcoming extends Component { class GenericList extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
@ -18,8 +18,9 @@ class Upcoming extends Component {
} }
renderItems() { renderItems() {
console.log(this.props.APILINK)
if (!this.state.error) { if (!this.state.error) {
return <CompTable data={callAPI('/pending/')} />; return <CompTable data={callAPI(this.props.APILINK)} />;
} else { } else {
console.log("error"); console.log("error");
return <Error />; return <Error />;
@ -43,4 +44,4 @@ class Upcoming extends Component {
} }
} }
export default Upcoming; export default GenericList;

View File

@ -1,47 +0,0 @@
import React, { Component } from "react";
import { callAPI } from "../../actions/API";
import CompTable from "../common/Tables/CompTable";
import Error from "../../actions/Error";
// Parent page for the /historical-migrations page,
// is referenced in the react route, and calls the main table using
// HIstoricalSingle,
// All migrations are called, and can be searched
// It actuall does error reporting, using `renderItems`
class Historical extends Component {
constructor(props) {
super(props);
this.state = {
error: false,
};
}
renderItems() {
if (!this.state.error) {
return <CompTable data={callAPI('/all/')} />;
} else {
console.log("error");
return <Error />;
}
}
render() {
return (
<div className="row">
<div className="divider"></div>
<div className="section">
<div className="col s12"></div>
</div>
<div className="divider"></div>
<div className="section">
<div className="col s12">{this.renderItems()}</div>
</div>
<div className="divider"></div>
</div>
);
}
}
export default Historical;

View File

@ -1,4 +1,6 @@
import React, { Component } from "react"; import React, { Component } from "react";
import { Link } from "react-router-dom";
// This page was should hold a way to generate reports/lists of // This page was should hold a way to generate reports/lists of
// Migrations in varied statuses. // Migrations in varied statuses.
@ -7,7 +9,10 @@ export default class Reports extends Component {
render() { render() {
return ( return (
<div> <div>
<h1>Reports</h1> <Link to="/missed">Missed migrations</Link><p />
<Link to="/pending-terminations">Upcoming Terminations</Link><p />
<Link to="/all-terminations">All waiting terminations</Link><p />
<Link to="/completed">Completed Migrations</Link><p />
</div> </div>
); );
} }