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