mirror of
https://github.com/9technologygroup/patchmon.net.git
synced 2025-11-10 00:45:39 +00:00
fix(frontend): use React Router navigation to open add host modal
Fixes page reload on add host button click.
This commit is contained in:
@@ -28,7 +28,7 @@ import {
|
|||||||
X,
|
X,
|
||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useCallback, useEffect, useRef, useState } from "react";
|
import { useCallback, useEffect, useRef, useState } from "react";
|
||||||
import { Link, useLocation } from "react-router-dom";
|
import { Link, useLocation, useNavigate } from "react-router-dom";
|
||||||
import { useAuth } from "../contexts/AuthContext";
|
import { useAuth } from "../contexts/AuthContext";
|
||||||
import { useUpdateNotification } from "../contexts/UpdateNotificationContext";
|
import { useUpdateNotification } from "../contexts/UpdateNotificationContext";
|
||||||
import { dashboardAPI, versionAPI } from "../utils/api";
|
import { dashboardAPI, versionAPI } from "../utils/api";
|
||||||
@@ -44,6 +44,7 @@ const Layout = ({ children }) => {
|
|||||||
const [_userMenuOpen, setUserMenuOpen] = useState(false);
|
const [_userMenuOpen, setUserMenuOpen] = useState(false);
|
||||||
const [githubStars, setGithubStars] = useState(null);
|
const [githubStars, setGithubStars] = useState(null);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
|
const navigate = useNavigate();
|
||||||
const {
|
const {
|
||||||
user,
|
user,
|
||||||
logout,
|
logout,
|
||||||
@@ -236,7 +237,7 @@ const Layout = ({ children }) => {
|
|||||||
|
|
||||||
const handleAddHost = () => {
|
const handleAddHost = () => {
|
||||||
// Navigate to hosts page with add modal parameter
|
// Navigate to hosts page with add modal parameter
|
||||||
window.location.href = "/hosts?action=add";
|
navigate("/hosts?action=add");
|
||||||
};
|
};
|
||||||
|
|
||||||
// Fetch GitHub stars count
|
// Fetch GitHub stars count
|
||||||
|
|||||||
Reference in New Issue
Block a user