diff --git a/frontend/src/Components/CreatePetModal.tsx b/frontend/src/Components/CreatePetModal.tsx index 970e0912..3117746b 100644 --- a/frontend/src/Components/CreatePetModal.tsx +++ b/frontend/src/Components/CreatePetModal.tsx @@ -1,11 +1,195 @@ -import { SetStateAction, useState } from 'react'; -import Popup from 'reactjs-popup'; -import 'reactjs-popup/dist/index.css'; -import profile_land from '../Misc/8-bit-dog-nobg.png'; -import profile_air from '../Misc/duck_8bit.png'; -import profile_water from '../Misc/fish_8bit.png' +import { SetStateAction, useState } from "react"; +import Popup from "reactjs-popup"; +import "reactjs-popup/dist/index.css"; +import profile_land from "../Misc/8-bit-dog-nobg.png"; +import profile_air from "../Misc/duck_8bit.png"; +import profile_water from "../Misc/frog.png"; const CreatePetModal = () => { + const [open, setOpen] = useState(false); + const [petName, setPetName] = useState(""); + const [petType, setPetType] = useState("Land"); + + const handleClose = () => { + setPetName(""); + setPetType("Land"); + setOpen(false); + }; + + const handleInputPetName = (e: { + target: { value: SetStateAction }; + }) => { + setPetName(e.target.value); + }; + + const handleInputPetType = (e: { + target: { value: SetStateAction }; + }) => { + setPetType(e.target.value); + }; + + const handleSubmit = (e: { preventDefault: () => void }) => { + e.preventDefault(); // Prevent form from reloading the page + if (petName.trim() === "" || petType === "") { + return; + } + // TODO: Save the device ID or perform any action with the input value + console.log("Pet Name:", petName, " Pet Type:", petType); + setOpen(false); // Close the popup after submission + }; + + return ( + <> +
+ +
+ +
+ + +
+
+

+ Enter your Pet Name below and choose it's Type: +

+
+ + {petType === "Land" && ( +
+ +
+ )} + + {petType == "Air" && ( +
+ profile picture +
+ )} + + {petType == "Water" && ( +
+ profile picture +
+ )} + +
+ @ + + +
ok
+
+ +
+ + + + + + + + +
+ + +
+
+
+ + ); const [open, setOpen] = useState(false); const [petName, setPetName] = useState(""); const [petType, setPetType] = useState("Land"); @@ -111,6 +295,7 @@ const CreatePetModal = () => { ); + }; export default CreatePetModal; diff --git a/frontend/src/Components/PetPage.tsx b/frontend/src/Components/PetPage.tsx index 087b8560..4a38a4e4 100644 --- a/frontend/src/Components/PetPage.tsx +++ b/frontend/src/Components/PetPage.tsx @@ -1,5 +1,5 @@ import { useEffect, useState } from "react"; -import petImage from "../assets/pet_frog.png"; +import petImage from "../Misc/frog.png"; import CreatePetModal from "./CreatePetModal"; import { Device, useDeviceApi } from "../lib/api/useDeviceApi"; import { Pet, usePetApi } from "../lib/api/usePetApi"; @@ -26,7 +26,7 @@ const PetPage = () => { const pet = await petApi.getPetById(defaultDevice.petId); setPet(pet); } - } + }; fetchData(); }, [deviceApi, petApi]); diff --git a/frontend/src/Misc/frog.png b/frontend/src/Misc/frog.png new file mode 100644 index 00000000..8f85866f Binary files /dev/null and b/frontend/src/Misc/frog.png differ