updated links id page

This commit is contained in:
daniel31x13
2023-12-07 00:33:05 -05:00
parent 4b1017f45b
commit ce5b1f444a
6 changed files with 77 additions and 82 deletions
@@ -11,6 +11,7 @@ import Link from "next/link";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faLink, faTrashCan } from "@fortawesome/free-solid-svg-icons";
import Modal from "../Modal";
import { useRouter } from "next/router";
type Props = {
onClose: Function;
@@ -24,6 +25,8 @@ export default function DeleteLinkModal({ onClose, activeLink }: Props) {
const { removeLink } = useLinkStore();
const [submitLoader, setSubmitLoader] = useState(false);
const router = useRouter();
useEffect(() => {
setLink(activeLink);
}, []);
@@ -37,6 +40,10 @@ export default function DeleteLinkModal({ onClose, activeLink }: Props) {
response.ok && toast.success(`Link Deleted.`);
if (router.pathname.startsWith("/links/[id]")) {
router.push("/dashboard");
}
onClose();
};