From 2678a7edddd6487d0eb131914b9c6f0733b3da56 Mon Sep 17 00:00:00 2001 From: Sarah Oberbichler <66369271+soberbichler@users.noreply.github.com> Date: Fri, 25 Oct 2024 14:19:45 +0200 Subject: [PATCH] Delete Glossary.jsx --- Glossary.jsx | 113 --------------------------------------------------- 1 file changed, 113 deletions(-) delete mode 100644 Glossary.jsx diff --git a/Glossary.jsx b/Glossary.jsx deleted file mode 100644 index 2af83a6..0000000 --- a/Glossary.jsx +++ /dev/null @@ -1,113 +0,0 @@ -import React, { useState, useEffect } from 'react'; - -const Glossary = () => { - const [glossary, setGlossary] = useState(() => { - const saved = localStorage.getItem('glossary'); - return saved ? JSON.parse(saved) : []; - }); - - const [term, setTerm] = useState(''); - const [definition, setDefinition] = useState(''); - const [search, setSearch] = useState(''); - - useEffect(() => { - localStorage.setItem('glossary', JSON.stringify(glossary)); - }, [glossary]); - - const handleSubmit = (e) => { - e.preventDefault(); - if (term.trim() && definition.trim()) { - setGlossary([...glossary, { - id: Date.now(), - term: term.trim(), - definition: definition.trim() - }]); - setTerm(''); - setDefinition(''); - } - }; - - const handleDelete = (id) => { - if (window.confirm('Delete this term?')) { - setGlossary(glossary.filter(item => item.id !== id)); - } - }; - - const filteredTerms = glossary - .filter(item => - item.term.toLowerCase().includes(search.toLowerCase()) || - item.definition.toLowerCase().includes(search.toLowerCase()) - ) - .sort((a, b) => a.term.localeCompare(b.term)); - - return ( -
No terms found.
- ) : ( - filteredTerms.map(item => ( -