From 76ca036e2a50fddd1eb6b8ebf06338bf1866b053 Mon Sep 17 00:00:00 2001 From: dvirlabs Date: Wed, 4 Jun 2025 04:13:17 +0300 Subject: [PATCH] Add drop down to sections --- frontend/src/components/AddAppModal.jsx | 47 +++++++++++++++++++++---- frontend/src/style/AddAppModal.css | 25 +++++++++++++ 2 files changed, 65 insertions(+), 7 deletions(-) diff --git a/frontend/src/components/AddAppModal.jsx b/frontend/src/components/AddAppModal.jsx index 0608d0a..c37ee16 100644 --- a/frontend/src/components/AddAppModal.jsx +++ b/frontend/src/components/AddAppModal.jsx @@ -1,5 +1,5 @@ -import { useState } from 'react'; -import { addAppToSection } from '../services/api'; +import { useEffect, useState } from 'react'; +import { addAppToSection, fetchSections } from '../services/api'; import '../style/AddAppModal.css'; import { IoIosAdd } from "react-icons/io"; @@ -7,11 +7,16 @@ function AddAppModal({ onAdded }) { const [open, setOpen] = useState(false); const [section, setSection] = useState(''); + const [customSection, setCustomSection] = useState(false); const [name, setName] = useState(''); const [icon, setIcon] = useState(''); const [description, setDescription] = useState(''); const [url, setUrl] = useState(''); + const [sections, setSections] = useState([]); + useEffect(() => { + fetchSections().then(data => setSections(data.sections || [])); + }, []); const handleSubmit = async (e) => { e.preventDefault(); @@ -23,6 +28,7 @@ function AddAppModal({ onAdded }) { setIcon(''); setDescription(''); setUrl(''); + setCustomSection(false); if (onAdded) onAdded(); } catch (err) { alert('Failed to add app'); @@ -31,17 +37,44 @@ function AddAppModal({ onAdded }) { return ( <> - setOpen(true)} - /> + setOpen(true)} /> {open && (
setOpen(false)}>
e.stopPropagation()}>

Add New App

- setSection(e.target.value)} required /> + + + {customSection && ( + setSection(e.target.value)} + required + /> + )} + setName(e.target.value)} required /> setIcon(e.target.value)} /> setDescription(e.target.value)} /> diff --git a/frontend/src/style/AddAppModal.css b/frontend/src/style/AddAppModal.css index b1bb0e3..70db2f4 100644 --- a/frontend/src/style/AddAppModal.css +++ b/frontend/src/style/AddAppModal.css @@ -60,6 +60,31 @@ animation: fadeInUp 0.3s ease-out; } +.modal select { + width: 95%; + height: 40px; + padding: 0.6rem; + margin-bottom: 1rem; + background-color: #1f1f1f; + border: 1px solid #2c2c2c; + color: #fff; + border-radius: 8px; + transition: border 0.3s; + font-family: inherit; + font-size: 1rem; +} + +.modal select:focus { + border: 1px solid #00f0ff; + outline: none; + box-shadow: 0 0 6px #00f0ff40; +} + +.modal option { + background-color: #1f1f1f; + color: #fff; +} + .modal h2 { color: #fff; font-size: 1.8rem;