From 39011afea7b3781fd13c8d9859b9421490175ac6 Mon Sep 17 00:00:00 2001 From: pepper Date: Mon, 18 Jan 2021 01:44:22 -0500 Subject: [PATCH] Changed error booking --- src/components/root/common/Forms/CPanelBooking.js | 6 +++--- src/components/root/common/Forms/ReportSingleMigration.js | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/components/root/common/Forms/CPanelBooking.js b/src/components/root/common/Forms/CPanelBooking.js index a0ff5b4..f0b7839 100644 --- a/src/components/root/common/Forms/CPanelBooking.js +++ b/src/components/root/common/Forms/CPanelBooking.js @@ -7,6 +7,7 @@ import * as Yup from "yup"; import { Input, Submit } from "formstrap"; import { callAPI } from "../../../actions/API"; import Msgbox from "../../../actions/Msgbox"; +import { buildErrorStringFromArray } from "../../../actions/Error"; // import FormikFieldDateTimePicker from "./FormikFieldDateTimePicker"; // Main form and POST Request to add migrations @@ -67,13 +68,12 @@ export const CPanelBooking = () => { callAPI .post("/", values) .then(function (response) { - console.log(response.data.id); + // console.log(response); // add function here setRespID(response.data.id) }) .catch(function (error) { - console.log(error); - setError(error) + setError(buildErrorStringFromArray(error.response.data)) }); setSubmitting(false); resetForm({ values: "" }); diff --git a/src/components/root/common/Forms/ReportSingleMigration.js b/src/components/root/common/Forms/ReportSingleMigration.js index 921b121..fe1d5fd 100644 --- a/src/components/root/common/Forms/ReportSingleMigration.js +++ b/src/components/root/common/Forms/ReportSingleMigration.js @@ -5,6 +5,7 @@ import { Formik, Form } from "formik"; import { Input, Submit } from "formstrap"; import { callAPI } from "../../../actions/API"; import Msgbox from "../../../actions/Msgbox"; +import { buildErrorStringFromArray } from "../../../actions/Error"; // Main form element for the UUID linking Migrations page, // Contians the PUT request to modify data from the API @@ -37,10 +38,10 @@ const ReportSingleMigration = ({ item }) => { .then(function (response) { console.log(JSON.stringify(response.values)); setRespID(response.data.ticket_id); + setError(0) }) .catch(function (error) { - console.log(error); - setError(error); + setError(buildErrorStringFromArray(error.response.data)); }); setSubmitting(false); };