Commit b74653e6 authored by David Haynes's avatar David Haynes 🙆

Abstracted DebugRead into it's own component

- added refresh button to allow for.. just that
parent 45271a66
Pipeline #3569 passed with stage
in 1 minute and 2 seconds
import React from "react";
import { GetAllGoLinks } from "../../Utils";
import { Button } from "reactstrap";
class DebugRead extends React.Component {
constructor(props) {
super(props);
this.state = {
GoLinks: [],
error: null
};
// This binding is necessary to make `this` work in the callback
this.refreshGoLinks = this.refreshGoLinks.bind(this);
}
async refreshGoLinks() {
GetAllGoLinks()
.then(data =>
this.setState({
GoLinks: data
})
)
.catch(reason => this.setState({ error: reason }));
}
async componentDidMount() {
this.refreshGoLinks();
}
render() {
return (
<div>
<Button onClick={this.refreshGoLinks} color="primary">
Refresh
</Button>{" "}
{this.state.GoLinks.map(golink => (
<li key={golink.short}>
<a href={`/${golink.short}`}> /{golink.short}</a> |{" "}
{golink.destination}
</li>
))}
</div>
);
}
}
export default DebugRead;
import AuthButton from "./AuthButton";
import DebugRead from "./DebugRead";
export { AuthButton };
export { AuthButton, DebugRead };
import React from "react";
import { Formik, Field, Form, ErrorMessage } from "formik";
import * as Yup from "yup";
import { PageTemplate } from "Components";
import { GetAllGoLinks } from "../../Utils";
import { PageTemplate, DebugRead } from "Components";
const SignupSchema = Yup.object().shape({
password: Yup.string()
......@@ -16,17 +15,7 @@ const SignupSchema = Yup.object().shape({
class DebugCRUD extends React.Component {
constructor(props) {
super(props);
this.state = { AllGoLinks: [], error: null };
}
async componentDidMount() {
GetAllGoLinks()
.then(data =>
this.setState({
AllGoLinks: data
})
)
.catch(reason => this.setState({ error: reason }));
this.state = {};
}
render() {
......@@ -59,13 +48,7 @@ class DebugCRUD extends React.Component {
/>
<h3>Read</h3>
{this.state.AllGoLinks.map(golink => (
<li key={golink.short}>
<a href={`/${golink.short}`}> /{golink.short}</a> |{" "}
{golink.destination}
</li>
))}
<DebugRead />
<h3>Update</h3>
<Formik
......
import { AuthButton } from "./Molecules";
import { AuthButton, DebugRead } from "./Molecules";
import { NavBar } from "./Organisms";
import { HomePage, AboutPage, DhaynesPage, DebugCRUD } from "./Pages";
import { PageTemplate } from "./Templates";
......@@ -6,6 +6,7 @@ import { PageTemplate } from "./Templates";
export {
//Molecules
AuthButton,
DebugRead,
//Organisms
NavBar,
//Pages
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment