Added state to booking page for msgbox
This commit is contained in:
parent
eb82d0873b
commit
a44dd8df10
@ -1,4 +1,4 @@
|
|||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import "bootstrap/dist/css/bootstrap.min.css";
|
import "bootstrap/dist/css/bootstrap.min.css";
|
||||||
import moment from "moment";
|
import moment from "moment";
|
||||||
import { Col, FormGroup, Row, Container, Label } from "reactstrap";
|
import { Col, FormGroup, Row, Container, Label } from "reactstrap";
|
||||||
@ -6,6 +6,7 @@ import { Formik, Form, Field } from "formik";
|
|||||||
import * as Yup from "yup";
|
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 FormikFieldDateTimePicker from "./FormikFieldDateTimePicker";
|
// import FormikFieldDateTimePicker from "./FormikFieldDateTimePicker";
|
||||||
|
|
||||||
// Main form and POST Request to add migrations
|
// Main form and POST Request to add migrations
|
||||||
@ -23,6 +24,8 @@ const timezoneList = {
|
|||||||
};
|
};
|
||||||
const timezone = timezoneList.melbourne;
|
const timezone = timezoneList.melbourne;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const InputValidation = Yup.object().shape({
|
const InputValidation = Yup.object().shape({
|
||||||
domain: Yup.string()
|
domain: Yup.string()
|
||||||
.matches(
|
.matches(
|
||||||
@ -46,6 +49,9 @@ const InputValidation = Yup.object().shape({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export const CPanelBooking = () => {
|
export const CPanelBooking = () => {
|
||||||
|
const [respID, setRespID] = useState(0)
|
||||||
|
const [error, setError] = useState(0)
|
||||||
|
|
||||||
const initialValues = {
|
const initialValues = {
|
||||||
submit_time: moment().format("YYYY-MM-DD"),
|
submit_time: moment().format("YYYY-MM-DD"),
|
||||||
dateTime: "2019-03-11T12:00:00.000Z",
|
dateTime: "2019-03-11T12:00:00.000Z",
|
||||||
@ -57,9 +63,11 @@ export const CPanelBooking = () => {
|
|||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
console.log(response.data.id);
|
console.log(response.data.id);
|
||||||
// add function here
|
// add function here
|
||||||
|
setRespID(response.data.id)
|
||||||
})
|
})
|
||||||
.catch(function (error) {
|
.catch(function (error) {
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
setError(error)
|
||||||
});
|
});
|
||||||
setSubmitting(false);
|
setSubmitting(false);
|
||||||
resetForm({ values: "" });
|
resetForm({ values: "" });
|
||||||
@ -227,6 +235,8 @@ export const CPanelBooking = () => {
|
|||||||
</FormGroup>
|
</FormGroup>
|
||||||
<Submit withSpinner>Submit</Submit>
|
<Submit withSpinner>Submit</Submit>
|
||||||
</Container>
|
</Container>
|
||||||
|
{ respID ? <Msgbox linkid={respID}></Msgbox> : null }
|
||||||
|
{ error ? <Msgbox error={error}></Msgbox> : null }
|
||||||
</Form>
|
</Form>
|
||||||
)}
|
)}
|
||||||
</Formik>
|
</Formik>
|
||||||
|
|||||||
Reference in New Issue
Block a user