Replace router URL instead of reloading
This commit is contained in:
parent
b2c848d666
commit
687ab5ad3e
1 changed files with 4 additions and 2 deletions
|
@ -3,7 +3,7 @@ import Link from 'next/link';
|
||||||
import prisma from '../../lib/prisma';
|
import prisma from '../../lib/prisma';
|
||||||
import Modal from '../../components/Modal';
|
import Modal from '../../components/Modal';
|
||||||
import Shell from '../../components/Shell';
|
import Shell from '../../components/Shell';
|
||||||
import Router from 'next/router';
|
import { useRouter } from 'next/router';
|
||||||
import { useRef } from 'react';
|
import { useRef } from 'react';
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useSession, getSession } from 'next-auth/client';
|
import { useSession, getSession } from 'next-auth/client';
|
||||||
|
@ -11,6 +11,7 @@ import { PlusIcon, ClockIcon } from '@heroicons/react/outline';
|
||||||
|
|
||||||
export default function Availability(props) {
|
export default function Availability(props) {
|
||||||
const [ session, loading ] = useSession();
|
const [ session, loading ] = useSession();
|
||||||
|
const router = useRouter();
|
||||||
const [showAddModal, setShowAddModal] = useState(false);
|
const [showAddModal, setShowAddModal] = useState(false);
|
||||||
const [successModalOpen, setSuccessModalOpen] = useState(false);
|
const [successModalOpen, setSuccessModalOpen] = useState(false);
|
||||||
const [showChangeTimesModal, setShowChangeTimesModal] = useState(false);
|
const [showChangeTimesModal, setShowChangeTimesModal] = useState(false);
|
||||||
|
@ -71,7 +72,8 @@ export default function Availability(props) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (enteredTitle && enteredLength) {
|
if (enteredTitle && enteredLength) {
|
||||||
Router.reload();
|
router.replace(router.asPath);
|
||||||
|
toggleAddModal();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue