Compare commits

..

No commits in common. "48a314ae8413062a795248a29a492d6d6e4051be" and "d386caadabd914cdade0f47431569cc7c63d523a" have entirely different histories.

6 changed files with 17 additions and 45 deletions

View File

@ -2,7 +2,7 @@ import React from "react";
// Generic error // Generic error
export const Error = () => ( const Error = () => (
<div> <div>
<div className="card-panel blue-grey darken-1"> <div className="card-panel blue-grey darken-1">
<div className="card-content white-text"> <div className="card-content white-text">
@ -16,13 +16,4 @@ export const Error = () => (
</div> </div>
); );
export function buildErrorStringFromArray(error) { export default Error;
let errors = []
for (let key in error) {
errors.push(key + ": " + error[key])
// console.log(key + ": " + error[key])
}
return errors
}
// export default Error;

View File

@ -1,5 +1,4 @@
import React from "react"; import React from "react";
import { UList } from "../root/common/Functionality/UnorderedList";
// // Generic Msgbox // // Generic Msgbox
function Msgbox(props) { function Msgbox(props) {
@ -8,11 +7,9 @@ function Msgbox(props) {
<div className="card-content white-link"> <div className="card-content white-link">
<center> <center>
<span className="card-title"> <span className="card-title">
{ props.error ? <span className="white-text"> { "Unable to update: " } <UList className="white-text" listItems={props.error}></UList> </span> { props.error ? <span> { "Unable to update: " + props.error } </span> : null }
: props.msg ? <span className="white-text">{ "Updated migration details for: " + props.msg }</span> { props.msg ? <span className="white-text">{ "Updated migration details for: " + props.msg }</span> : null }
: props.linkid ? <a href={ process.env.REACT_APP_SITE_URL + "migrations/" + props.linkid } { props.linkid ? <a href={ process.env.REACT_APP_SITE_URL + "migrations/" + props.linkid } className="white-link">{process.env.REACT_APP_SITE_URL + "migrations/" + props.linkid }</a> : null }
className="white-link">{process.env.REACT_APP_SITE_URL + "migrations/" + props.linkid }</a>
: null}
</span> </span>
</center> </center>
</div> </div>

View File

@ -1,7 +1,7 @@
import React, { Component } from "react"; import React, { Component } from "react";
import CompTable from "../common/Tables/CompTable"; 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";
// Missing 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

View File

@ -7,7 +7,6 @@ import * as Yup from "yup";
import { Input, Submit } from "formstrap"; import { Input, Submit } from "formstrap";
import { callAPI } from "../../../actions/API"; import { callAPI } from "../../../actions/API";
import Msgbox from "../../../actions/Msgbox"; import Msgbox from "../../../actions/Msgbox";
import { buildErrorStringFromArray } from "../../../actions/Error";
// import FormikFieldDateTimePicker from "./FormikFieldDateTimePicker"; // import FormikFieldDateTimePicker from "./FormikFieldDateTimePicker";
// Main form and POST Request to add migrations // Main form and POST Request to add migrations
@ -37,22 +36,16 @@ const InputValidation = Yup.object().shape({
username: Yup.string().min(2, "Too Short!").required("Required"), username: Yup.string().min(2, "Too Short!").required("Required"),
original_server: Yup.string() original_server: Yup.string()
.matches( .matches(
/^((([1-9]?\d|1\d\d|2[0-5][0-5]|2[0-4]\d)\.){3}([1-9]?\d|1\d\d|2[0-5][0-5]|2[0-4]\d))|(((https?):\/\/)?(www.)?[a-z0-9]+(\.[a-z]{2,}){1,3}(#?\/?[a-zA-Z0-9#]+)*\/?(\?[a-zA-Z0-9-_]+=[a-zA-Z0-9-%]+&?)?)$/, /^(([1-9]?\d|1\d\d|2[0-5][0-5]|2[0-4]\d)\.){3}([1-9]?\d|1\d\d|2[0-5][0-5]|2[0-4]\d)$/,
"Please enter a valid IPv4 Address or domain" "Please enter a valid IPv4 Address"
) )
.required("Please enter a valid IPv4 or domain"), .required("Please enter a valid IP"),
new_server: Yup.string() new_server: Yup.string()
.matches( .matches(
/^((([1-9]?\d|1\d\d|2[0-5][0-5]|2[0-4]\d)\.){3}([1-9]?\d|1\d\d|2[0-5][0-5]|2[0-4]\d))|(((https?):\/\/)?(www.)?[a-z0-9]+(\.[a-z]{2,}){1,3}(#?\/?[a-zA-Z0-9#]+)*\/?(\?[a-zA-Z0-9-_]+=[a-zA-Z0-9-%]+&?)?)$/, /^(([1-9]?\d|1\d\d|2[0-5][0-5]|2[0-4]\d)\.){3}([1-9]?\d|1\d\d|2[0-5][0-5]|2[0-4]\d)$/,
"Please enter a valid IPv4 Address or domain" "Please enter a valid IPv4 Address"
) )
.required("Please enter a valid IPv4 or domain"), .required("Please enter a valid IP"),
agent_booked: Yup.string().min(2, "Too short!").required("Requried"),
booked_time: Yup.string().required("Requried"),
ticket_id: Yup.string().required("Requried"),
brand: Yup.string().required("Requried"),
migration_type: Yup.string().required("Requried"),
booked_date: Yup.date().required("Required")
}); });
export const CPanelBooking = () => { export const CPanelBooking = () => {
@ -68,12 +61,13 @@ export const CPanelBooking = () => {
callAPI callAPI
.post("/", values) .post("/", values)
.then(function (response) { .then(function (response) {
// console.log(response); console.log(response.data.id);
// add function here // add function here
setRespID(response.data.id) setRespID(response.data.id)
}) })
.catch(function (error) { .catch(function (error) {
setError(buildErrorStringFromArray(error.response.data)) console.log(error);
setError(error)
}); });
setSubmitting(false); setSubmitting(false);
resetForm({ values: "" }); resetForm({ values: "" });

View File

@ -5,7 +5,6 @@ import { Formik, Form } from "formik";
import { Input, Submit } from "formstrap"; import { Input, Submit } from "formstrap";
import { callAPI } from "../../../actions/API"; import { callAPI } from "../../../actions/API";
import Msgbox from "../../../actions/Msgbox"; import Msgbox from "../../../actions/Msgbox";
import { buildErrorStringFromArray } from "../../../actions/Error";
// Main form element for the UUID linking Migrations page, // Main form element for the UUID linking Migrations page,
// Contians the PUT request to modify data from the API // Contians the PUT request to modify data from the API
@ -38,10 +37,10 @@ const ReportSingleMigration = ({ item }) => {
.then(function (response) { .then(function (response) {
console.log(JSON.stringify(response.values)); console.log(JSON.stringify(response.values));
setRespID(response.data.ticket_id); setRespID(response.data.ticket_id);
setError(0)
}) })
.catch(function (error) { .catch(function (error) {
setError(buildErrorStringFromArray(error.response.data)); console.log(error);
setError(error);
}); });
setSubmitting(false); setSubmitting(false);
}; };

View File

@ -1,9 +0,0 @@
import React from "react";
export function UList(props){
return (<div>
<ul>
{props.listItems.map((item) => (<li className="white-text">{item}</li>))}
</ul>
</div>)
}