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

Add DebugDelete

parent c84a05ae
Pipeline #3586 passed with stage
in 1 minute and 11 seconds
......@@ -28,7 +28,9 @@ const DebugCreate = () => (
"X-CSRFToken": GetCSRFToken()
},
body: JSON.stringify(values)
}).then(response => console.log(response));
})
.then(response => console.log(response))
.then(setSubmitting(false));
}}
render={({ isSubmitting }) => (
<Form>
......
import React from "react";
import * as Yup from "yup";
import { GetCSRFToken } from "../../Utils";
import { Formik, Field, Form, ErrorMessage } from "formik";
const DebugDeleteYup = Yup.object().shape({
short: Yup.string()
.required("Required")
.max(20, "Too Long!")
});
const DebugDelete = () => (
<div>
<Formik
initialValues={{ short: "" }}
validationSchema={DebugDeleteYup}
onSubmit={(values, { setSubmitting }) => {
const deleteURL = "/api/golinks/" + values.short;
fetch(deleteURL, {
method: "delete",
headers: {
"Content-Type": "application/json",
"X-CSRFToken": GetCSRFToken()
}
})
.then(response => console.log(response))
.then(setSubmitting(false));
}}
render={({ isSubmitting }) => (
<Form>
{"Short: "}
<Field name="short" />
<ErrorMessage name="short" />
<button type="submit" disabled={isSubmitting}>
Submit
</button>
</Form>
)}
/>
</div>
);
export default DebugDelete;
import AuthButton from "./AuthButton";
import DebugRead from "./DebugRead";
import DebugCreate from "./DebugCreate";
import DebugDelete from "./DebugDelete";
export { AuthButton, DebugRead, DebugCreate };
export { AuthButton, DebugRead, DebugCreate, DebugDelete };
import React from "react";
import { PageTemplate, DebugRead, DebugCreate } from "Components";
import { PageTemplate, DebugRead, DebugCreate, DebugDelete } from "Components";
class DebugCRUD extends React.Component {
constructor(props) {
......@@ -21,6 +21,7 @@ class DebugCRUD extends React.Component {
<h3>Update</h3>
<h3>Delete</h3>
<DebugDelete />
</div>
</PageTemplate>
);
......
import { AuthButton, DebugRead, DebugCreate } from "./Molecules";
import { AuthButton, DebugRead, DebugCreate, DebugDelete } from "./Molecules";
import { NavBar } from "./Organisms";
import { HomePage, AboutPage, DhaynesPage, DebugCRUD } from "./Pages";
import { PageTemplate } from "./Templates";
......@@ -8,6 +8,7 @@ export {
AuthButton,
DebugRead,
DebugCreate,
DebugDelete,
//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