diff --git a/frontend/src/components/Links/Popup/Popup.jsx b/frontend/src/components/Links/Popup/Popup.jsx index 6951b762..a774a681 100644 --- a/frontend/src/components/Links/Popup/Popup.jsx +++ b/frontend/src/components/Links/Popup/Popup.jsx @@ -20,12 +20,9 @@ const Popup = () => { const handleClosePopup = async () => { setIsPopupOpen(false); - setLinks( - links.filter( - (it) => it.title !== itemToDelete.title && it.id !== itemToDelete.id - ) - ); - setDeletedLinks((prev) => [...prev, itemToDelete]); + setLinks(links.filter((it) => it.id !== itemToDelete.id)); + typeof itemToDelete.id === "number" && + setDeletedLinks((prev) => [...prev, itemToDelete]); setItemToDelete(null); }; diff --git a/frontend/src/components/Links/Settings/Settings.jsx b/frontend/src/components/Links/Settings/Settings.jsx index fa9babcf..c9177f73 100644 --- a/frontend/src/components/Links/Settings/Settings.jsx +++ b/frontend/src/components/Links/Settings/Settings.jsx @@ -2,7 +2,7 @@ import CloseOutlinedIcon from "@mui/icons-material/CloseOutlined"; import { useContext, useEffect, useRef, useState } from "react"; import { HelperLinkContext } from "../../../services/linksProvider"; import Switch from "../../Switch/Switch"; -import s from "./Settings.module.scss"; +import style from "./Settings.module.scss"; const defaultState = { title: "", @@ -38,7 +38,10 @@ const Settings = () => { }; setState(newState); } else { - setState({ ...defaultState, id: Math.floor(Date.now() * Math.random()) }); + setState({ + ...defaultState, + id: `${Date.now()}-${Math.random().toString(36).substring(2, 11)}`, + }); } window.addEventListener("mousedown", handleMouseDown); @@ -78,84 +81,84 @@ const Settings = () => { setLinkToEdit(null); toggleSettings(e); } else { - setLinks((prev) => [...prev, { ...info, id: +info.id }]); + setLinks((prev) => [...prev, { ...info, id: info.id }]); toggleSettings(e); } }; return (