import { useState } from 'react'; import { addAppToSection } from '../services/api'; import '../style/AddAppModal.css'; import { IoIosAddCircleOutline } from "react-icons/io"; function AddAppModal({ onAdded }) { const [open, setOpen] = useState(false); const [section, setSection] = useState(''); const [name, setName] = useState(''); const [icon, setIcon] = useState(''); const [description, setDescription] = useState(''); const [url, setUrl] = useState(''); const handleSubmit = async (e) => { e.preventDefault(); try { await addAppToSection({ section, app: { name, icon, description, url } }); setOpen(false); setSection(''); setName(''); setIcon(''); setDescription(''); setUrl(''); if (onAdded) onAdded(); } catch (err) { alert('Failed to add app'); } }; return ( <> setOpen(true)} /> {open && (
setOpen(false)}>
e.stopPropagation()}>

Add New App

setSection(e.target.value)} required /> setName(e.target.value)} required /> setIcon(e.target.value)} /> setDescription(e.target.value)} /> setUrl(e.target.value)} required />
)} ); } export default AddAppModal;