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 = () => ( ...@@ -28,7 +28,9 @@ const DebugCreate = () => (
"X-CSRFToken": GetCSRFToken() "X-CSRFToken": GetCSRFToken()
}, },
body: JSON.stringify(values) body: JSON.stringify(values)
}).then(response => console.log(response)); })
.then(response => console.log(response))
.then(setSubmitting(false));
}} }}
render={({ isSubmitting }) => ( render={({ isSubmitting }) => (
<Form> <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 AuthButton from "./AuthButton";
import DebugRead from "./DebugRead"; import DebugRead from "./DebugRead";
import DebugCreate from "./DebugCreate"; import DebugCreate from "./DebugCreate";
import DebugDelete from "./DebugDelete";
export { AuthButton, DebugRead, DebugCreate }; export { AuthButton, DebugRead, DebugCreate, DebugDelete };
import React from "react"; import React from "react";
import { PageTemplate, DebugRead, DebugCreate } from "Components"; import { PageTemplate, DebugRead, DebugCreate, DebugDelete } from "Components";
class DebugCRUD extends React.Component { class DebugCRUD extends React.Component {
constructor(props) { constructor(props) {
...@@ -21,6 +21,7 @@ class DebugCRUD extends React.Component { ...@@ -21,6 +21,7 @@ class DebugCRUD extends React.Component {
<h3>Update</h3> <h3>Update</h3>
<h3>Delete</h3> <h3>Delete</h3>
<DebugDelete />
</div> </div>
</PageTemplate> </PageTemplate>
); );
......
import { AuthButton, DebugRead, DebugCreate } from "./Molecules"; import { AuthButton, DebugRead, DebugCreate, DebugDelete } from "./Molecules";
import { NavBar } from "./Organisms"; import { NavBar } from "./Organisms";
import { HomePage, AboutPage, DhaynesPage, DebugCRUD } from "./Pages"; import { HomePage, AboutPage, DhaynesPage, DebugCRUD } from "./Pages";
import { PageTemplate } from "./Templates"; import { PageTemplate } from "./Templates";
...@@ -8,6 +8,7 @@ export { ...@@ -8,6 +8,7 @@ export {
AuthButton, AuthButton,
DebugRead, DebugRead,
DebugCreate, DebugCreate,
DebugDelete,
//Organisms //Organisms
NavBar, NavBar,
//Pages //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