feat(frontend): updated to show toasts in create volume modal

pull/86/head
Samuel Rowe 3 years ago
parent 59dffcdd22
commit df6d694459

@ -9,8 +9,10 @@ import {
validationSchema validationSchema
} from "./form-utils"; } from "./form-utils";
import General from "./General"; import General from "./General";
import { CallbackFunction } from "../../../types"; import { CallbackFunction, IEditVolumeForm } from "../../../types";
import { classNames } from "../../../utils/styles"; import { classNames } from "../../../utils/styles";
import { toaster } from "../../../utils";
import { reportErrorsAndSubmit } from "../../../utils/forms";
interface ICreateVolumeModalProps { interface ICreateVolumeModalProps {
onHide: CallbackFunction; onHide: CallbackFunction;
@ -21,10 +23,12 @@ const CreateVolumeModal = (props: ICreateVolumeModalProps) => {
const { onHide, onAddEndpoint } = props; const { onHide, onAddEndpoint } = props;
const [openTab, setOpenTab] = useState("General"); const [openTab, setOpenTab] = useState("General");
const handleCreate = useCallback((values: any, formik: any) => { const handleCreate = useCallback((values: IEditVolumeForm, formik: any) => {
onAddEndpoint(getFinalValues(values)); onAddEndpoint(getFinalValues(values));
formik.resetForm(); formik.resetForm();
onHide(); onHide();
toaster(`Created "${values.entryName}" volume successfully`, "success");
}, []); }, []);
const initialValues = useMemo(() => getInitialValues(), []); const initialValues = useMemo(() => getInitialValues(), []);
@ -94,7 +98,7 @@ const CreateVolumeModal = (props: ICreateVolumeModalProps) => {
<button <button
className="btn-util" className="btn-util"
type="button" type="button"
onClick={formik.submitForm} onClick={reportErrorsAndSubmit(formik)}
> >
Add Add
</button> </button>

Loading…
Cancel
Save