diff --git a/package-lock.json b/package-lock.json index e244b31..294a93b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "@testing-library/jest-dom": "^6.4.5", "@testing-library/react": "^15.0.7", "@testing-library/user-event": "^14.5.2", + "axios": "^1.6.8", "react": "^18.3.1", "react-dom": "^18.3.1", "react-icons": "^5.2.1", @@ -4920,6 +4921,29 @@ "node": ">=4" } }, + "node_modules/axios": { + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", + "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", + "dependencies": { + "follow-redirects": "^1.15.6", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/axios/node_modules/form-data": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.0.tgz", + "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", + "dependencies": { + "asynckit": "^0.4.0", + "combined-stream": "^1.0.8", + "mime-types": "^2.1.12" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/axobject-query": { "version": "3.2.1", "resolved": "https://registry.npmjs.org/axobject-query/-/axobject-query-3.2.1.tgz", @@ -12612,6 +12636,11 @@ "node": ">= 0.10" } }, + "node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/psl": { "version": "1.9.0", "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz", diff --git a/package.json b/package.json index de9a35d..f7017aa 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "@testing-library/jest-dom": "^6.4.5", "@testing-library/react": "^15.0.7", "@testing-library/user-event": "^14.5.2", + "axios": "^1.6.8", "react": "^18.3.1", "react-dom": "^18.3.1", "react-icons": "^5.2.1", diff --git a/src/App.js b/src/App.js index af9353e..7013c99 100644 --- a/src/App.js +++ b/src/App.js @@ -6,7 +6,7 @@ import Navbar from "./Components/Navbar.js"; function App() { return ( <> -
+
diff --git a/src/Components/EventPlannerAi.js b/src/Components/EventPlannerAi.js index c0716d4..6886f37 100644 --- a/src/Components/EventPlannerAi.js +++ b/src/Components/EventPlannerAi.js @@ -1,101 +1,74 @@ import React, { useState } from "react"; +import { useParams } from "react-router-dom"; -const EventPlannerAi = () => { +const EventPlannerAi = ({ props }) => { const [budget, setBudget] = useState(""); const [timeToStay, setTimeToStay] = useState(""); - const [generatedAnswer, setGeneratedAnswer] = useState(""); + const { eventId } = useParams(); + console.log(eventId); - const handleSubmit = (e) => { + const handleSubmit = async (e) => { e.preventDefault(); - // Here you can perform any actions you want with the inputs - console.log("Budget:", budget); - console.log("Time to Stay:", timeToStay); - // Here you can generate the AI answer based on the inputs - const aiAnswer = generateAIAnswer(budget, timeToStay); - setGeneratedAnswer(aiAnswer); - }; + setLoading(true); + setError(""); + setGeneratedAnswer(""); - // Function to generate AI answer - const generateAIAnswer = (budget, timeToStay) => { - // You can implement your AI logic here - // For now, let's just return a dummy answer - return `AI Generated Answer: You have a budget of ${budget} and plan to stay for ${timeToStay}`; + useEffect(() => { + const fetchData = async () => { + try { + const response = await axios.post("http://localhost:8000/predict", { + budget, + timeToStay, + }); + setGeneratedAnswer(response.data.prediction); + } catch (error) { + setError("Something went wrong. Please try again later."); + } finally { + setLoading(false); + } + }; + fetchData(); + }, [budget, timeToStay]); }; return ( -
-
-
-

- Event Planner AI -

-
-
-
-
- - setBudget(e.target.value)} - /> -
-
- - setTimeToStay(e.target.value)} - /> -
+ <> +
+
+
+
+
+ {/* Your content here */}
-
- +
+ Event Image
- +
+
+
+
+
+

how are you all

+
{generatedAnswer && (

{generatedAnswer}

)}
-
+ ); }; diff --git a/src/Components/Footer.js b/src/Components/Footer.js index 9db3d6e..528068c 100644 --- a/src/Components/Footer.js +++ b/src/Components/Footer.js @@ -7,8 +7,8 @@ import { FaFacebookF } from "react-icons/fa"; const Footer = () => { return ( -
-
+ <> +

@@ -21,7 +21,7 @@ const Footer = () => {

-
+ ); }; diff --git a/src/index.js b/src/index.js index a00cddb..42b88b9 100644 --- a/src/index.js +++ b/src/index.js @@ -24,7 +24,7 @@ const appRouter = createBrowserRouter([ { path: "events/:eventId", - element: , + element: , }, ],