fix: add success modal on event-type update

pull/445/head
mihaic195 2021-08-13 12:48:20 +03:00
parent da98a1ff1d
commit 5193b723a4
No known key found for this signature in database
GPG Key ID: 18E6B791693DB416
1 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,7 @@ import { GetServerSideProps } from "next";
import Head from "next/head"; import Head from "next/head";
import Link from "next/link"; import Link from "next/link";
import { useRouter } from "next/router"; import { useRouter } from "next/router";
import Modal from "../../components/Modal";
import React, { useEffect, useRef, useState } from "react"; import React, { useEffect, useRef, useState } from "react";
import Select, { OptionBase } from "react-select"; import Select, { OptionBase } from "react-select";
import prisma from "@lib/prisma"; import prisma from "@lib/prisma";
@ -104,6 +105,7 @@ export default function EventTypePage({
availability, availability,
}: Props): JSX.Element { }: Props): JSX.Element {
const router = useRouter(); const router = useRouter();
const [successModalOpen, setSuccessModalOpen] = useState(false);
const inputOptions: OptionBase[] = [ const inputOptions: OptionBase[] = [
{ value: EventTypeCustomInputType.Text, label: "Text" }, { value: EventTypeCustomInputType.Text, label: "Text" },
@ -235,7 +237,7 @@ export default function EventTypePage({
}, },
}); });
router.push("/event-types"); setSuccessModalOpen(true);
} }
async function deleteEventTypeHandler(event) { async function deleteEventTypeHandler(event) {
@ -268,6 +270,10 @@ export default function EventTypePage({
setSelectedCustomInput(undefined); setSelectedCustomInput(undefined);
}; };
const closeSuccessModal = () => {
setSuccessModalOpen(false);
};
const updateLocations = (e) => { const updateLocations = (e) => {
e.preventDefault(); e.preventDefault();
@ -850,6 +856,12 @@ export default function EventTypePage({
</button> </button>
</div> </div>
</form> </form>
<Modal
heading="Event Type updated successfully"
description="Your event type has been updated successfully."
open={successModalOpen}
handleClose={closeSuccessModal}
/>
</div> </div>
</div> </div>
<div className="w-full sm:w-2/12 ml-2 px-4 mt-8 sm:mt-0 min-w-32"> <div className="w-full sm:w-2/12 ml-2 px-4 mt-8 sm:mt-0 min-w-32">