diff --git a/src/App.js b/src/App.js index 099cfe4..b715392 100644 --- a/src/App.js +++ b/src/App.js @@ -1,28 +1,31 @@ import "./App.css"; +import Education from "./Education"; function App() { return (

Resume Builder

+

Experience

Experience Placeholder

-

+
+
-

Education

-

Education Placeholder

- -

+ +
+

Skills

Skill Placeholder

-

+
-

+ +
); diff --git a/src/Education.js b/src/Education.js new file mode 100644 index 0000000..a9ffca4 --- /dev/null +++ b/src/Education.js @@ -0,0 +1,67 @@ +import React, { useState } from "react"; + +function Education() { + const [formData, setFormData] = useState({ + course: "", + school: "", + start_date: "", + end_date: "", + grade: "", + logo: "" + }); + + const [responseId, setResponseId] = useState(null); + const [error, setError] = useState(""); + + // Updates form state when typing + function handleChange(e) { + setFormData({ + ...formData, + [e.target.name]: e.target.value + }); + } + + // Sends POST request to backend + async function handleSubmit(e) { + e.preventDefault(); + setError(""); // Reset error + + try { + const res = await fetch("http://localhost:5000/resume/education", { + method: "POST", + headers: { "Content-Type": "application/json" }, + body: JSON.stringify(formData) + }); + + if (!res.ok) throw new Error("Failed to submit education"); + + const data = await res.json(); + setResponseId(data.id); + } catch (err) { + setError(err.message); + } + } + + return ( +
+

Add Education

+
+ + + + + + +

+ +
+ + {responseId !== null && ( +

Education added! ID: {responseId}

+ )} + {error &&

{error}

} +
+ ); +} + +export default Education;