From c6571b6f84e99afb5c405303036af6db6716fffa Mon Sep 17 00:00:00 2001 From: mseng10 Date: Tue, 11 Jun 2024 22:04:59 -0500 Subject: [PATCH] MISC: Rearrange forms --- client/react/src/forms/{ => create}/NewGenusForm.js | 12 +----------- client/react/src/forms/{ => create}/NewLightForm.js | 0 client/react/src/forms/{ => create}/NewPlantForm.js | 0 client/react/src/forms/{ => create}/NewSystemForm.js | 0 client/react/src/forms/{ => create}/NewTypeForm.js | 0 .../src/forms/{ => update}/FertilizePlantsForm.js | 0 .../react/src/forms/{ => update}/KillPlantsForm.js | 0 .../react/src/forms/{ => update}/RepotPlantsForm.js | 0 .../react/src/forms/{ => update}/UpdatePlantForm.js | 0 .../react/src/forms/{ => update}/WaterPlantsForm.js | 0 client/react/src/pages/Home.js | 10 +++++----- client/react/src/pages/Plants.js | 10 +++++----- 12 files changed, 11 insertions(+), 21 deletions(-) rename client/react/src/forms/{ => create}/NewGenusForm.js (90%) rename client/react/src/forms/{ => create}/NewLightForm.js (100%) rename client/react/src/forms/{ => create}/NewPlantForm.js (100%) rename client/react/src/forms/{ => create}/NewSystemForm.js (100%) rename client/react/src/forms/{ => create}/NewTypeForm.js (100%) rename client/react/src/forms/{ => update}/FertilizePlantsForm.js (100%) rename client/react/src/forms/{ => update}/KillPlantsForm.js (100%) rename client/react/src/forms/{ => update}/RepotPlantsForm.js (100%) rename client/react/src/forms/{ => update}/UpdatePlantForm.js (100%) rename client/react/src/forms/{ => update}/WaterPlantsForm.js (100%) diff --git a/client/react/src/forms/NewGenusForm.js b/client/react/src/forms/create/NewGenusForm.js similarity index 90% rename from client/react/src/forms/NewGenusForm.js rename to client/react/src/forms/create/NewGenusForm.js index f335dc8..face57c 100644 --- a/client/react/src/forms/NewGenusForm.js +++ b/client/react/src/forms/create/NewGenusForm.js @@ -9,21 +9,11 @@ import CloseSharpIcon from '@mui/icons-material/CloseSharp'; import FingerprintSharpIcon from '@mui/icons-material/FingerprintSharp'; -const NewGenusForm = ({ isOpen, onRequestClose }) => { +const NewGenusForm = ({ isOpen, onRequestClose, allGenus }) => { const [name, setName] = useState(''); const [watering, setWatering] = useState(0); - const [allGenus, setAllGenus] = useState([]); const [submitted, setSubmitted] = useState(false); // Initialize submitted state - useEffect(() => { - if (isOpen) { - fetch('http://127.0.0.1:5000/genus') - .then((response) => response.json()) - .then((data) => setAllGenus(data)) - .catch((error) => console.error('Error fetching genus data:', error)); - } - }, []); - useEffect(() => { if (submitted) { const requestOptions = { diff --git a/client/react/src/forms/NewLightForm.js b/client/react/src/forms/create/NewLightForm.js similarity index 100% rename from client/react/src/forms/NewLightForm.js rename to client/react/src/forms/create/NewLightForm.js diff --git a/client/react/src/forms/NewPlantForm.js b/client/react/src/forms/create/NewPlantForm.js similarity index 100% rename from client/react/src/forms/NewPlantForm.js rename to client/react/src/forms/create/NewPlantForm.js diff --git a/client/react/src/forms/NewSystemForm.js b/client/react/src/forms/create/NewSystemForm.js similarity index 100% rename from client/react/src/forms/NewSystemForm.js rename to client/react/src/forms/create/NewSystemForm.js diff --git a/client/react/src/forms/NewTypeForm.js b/client/react/src/forms/create/NewTypeForm.js similarity index 100% rename from client/react/src/forms/NewTypeForm.js rename to client/react/src/forms/create/NewTypeForm.js diff --git a/client/react/src/forms/FertilizePlantsForm.js b/client/react/src/forms/update/FertilizePlantsForm.js similarity index 100% rename from client/react/src/forms/FertilizePlantsForm.js rename to client/react/src/forms/update/FertilizePlantsForm.js diff --git a/client/react/src/forms/KillPlantsForm.js b/client/react/src/forms/update/KillPlantsForm.js similarity index 100% rename from client/react/src/forms/KillPlantsForm.js rename to client/react/src/forms/update/KillPlantsForm.js diff --git a/client/react/src/forms/RepotPlantsForm.js b/client/react/src/forms/update/RepotPlantsForm.js similarity index 100% rename from client/react/src/forms/RepotPlantsForm.js rename to client/react/src/forms/update/RepotPlantsForm.js diff --git a/client/react/src/forms/UpdatePlantForm.js b/client/react/src/forms/update/UpdatePlantForm.js similarity index 100% rename from client/react/src/forms/UpdatePlantForm.js rename to client/react/src/forms/update/UpdatePlantForm.js diff --git a/client/react/src/forms/WaterPlantsForm.js b/client/react/src/forms/update/WaterPlantsForm.js similarity index 100% rename from client/react/src/forms/WaterPlantsForm.js rename to client/react/src/forms/update/WaterPlantsForm.js diff --git a/client/react/src/pages/Home.js b/client/react/src/pages/Home.js index bbdb20f..feed261 100644 --- a/client/react/src/pages/Home.js +++ b/client/react/src/pages/Home.js @@ -3,9 +3,9 @@ import GrassOutlinedIcon from '@mui/icons-material/GrassOutlined'; import System from './System' import ButtonGroup from '@mui/material/ButtonGroup'; import AddSharpIcon from '@mui/icons-material/AddSharp'; -import NewPlantForm from '../forms/NewPlantForm'; -import NewGenusForm from '../forms/NewGenusForm'; -import NewSystemForm from '../forms/NewSystemForm'; +import NewPlantForm from '../forms/create/NewPlantForm'; +import NewGenusForm from '../forms/create/NewGenusForm'; +import NewSystemForm from '../forms/create/NewSystemForm'; import FingerprintSharpIcon from '@mui/icons-material/FingerprintSharp'; import PointOfSaleIcon from '@mui/icons-material/PointOfSale'; import React, { useState, useEffect } from 'react'; @@ -15,8 +15,8 @@ import Box from '@mui/material/Box'; import CloseSharpIcon from '@mui/icons-material/CloseSharp'; import VisibilitySharpIcon from '@mui/icons-material/VisibilitySharp'; import ReportGmailerrorredSharpIcon from '@mui/icons-material/ReportGmailerrorredSharp'; -import NewLightForm from '../forms/NewLightForm'; -import NewTypeForm from '../forms/NewTypeForm'; +import NewLightForm from '../forms/create/NewLightForm'; +import NewTypeForm from '../forms/create/NewTypeForm'; import TungstenSharpIcon from '@mui/icons-material/TungstenSharp'; import Modal from '@mui/material/Modal'; import CallSplitSharpIcon from '@mui/icons-material/CallSplitSharp'; diff --git a/client/react/src/pages/Plants.js b/client/react/src/pages/Plants.js index 6443d96..c9d9239 100644 --- a/client/react/src/pages/Plants.js +++ b/client/react/src/pages/Plants.js @@ -1,15 +1,15 @@ // Plants.js import React, { useState, useEffect } from 'react'; -import UpdatePlantForm from '../forms/UpdatePlantForm'; -import WaterPlantsForm from '../forms/WaterPlantsForm'; -import FertilizePlantsForm from '../forms/FertilizePlantsForm'; -import RepotPlantsForm from '../forms/RepotPlantsForm'; +import UpdatePlantForm from '../forms/update/UpdatePlantForm'; +import WaterPlantsForm from '../forms/update/WaterPlantsForm'; +import FertilizePlantsForm from '../forms/update/FertilizePlantsForm'; +import RepotPlantsForm from '../forms/update/RepotPlantsForm'; import IconButton from '@mui/material/IconButton'; import DeleteOutlineSharpIcon from '@mui/icons-material/DeleteOutlineSharp'; import WaterDropOutlinedIcon from '@mui/icons-material/WaterDropOutlined'; import LunchDiningIcon from '@mui/icons-material/LunchDining'; import EditSharpIcon from '@mui/icons-material/EditSharp'; -import KillPlantsForm from '../forms/KillPlantsForm'; +import KillPlantsForm from '../forms/update/KillPlantsForm'; import ParkSharpIcon from '@mui/icons-material/ParkSharp'; import { DataGrid,GridToolbarContainer, GridToolbarColumnsButton,