diff --git a/README.md b/README.md index 941dcea..d661a86 100644 --- a/README.md +++ b/README.md @@ -3,4 +3,5 @@ FA23: p-reset ### People Sumi Vora Vivien Song -Haram Yoon \ No newline at end of file +Haram Yoon +Mohamed Hamouda \ No newline at end of file diff --git a/client/.env b/client/.env new file mode 100644 index 0000000..19d3d35 --- /dev/null +++ b/client/.env @@ -0,0 +1,6 @@ +GOOGLE_CLIENT_ID = 757306875568-76c8a3tmj1hhousioaa6a2587rq2tjir.apps.googleusercontent.com +GOOGLE_CLIENT_SECRET = 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 + +NEXTAUTH_URL = http://localhost:3000 + +JWT_SECRET = c085ce0c5c21a4d774591a20b981013e diff --git a/client/components/add_event.js b/client/components/add_event.js new file mode 100644 index 0000000..d234168 --- /dev/null +++ b/client/components/add_event.js @@ -0,0 +1,70 @@ +// add_event.jsx + +import React, { useState } from "react"; + +function AddEvent() { + const [title, setTitle] = useState(""); + const [description, setDescription] = useState(""); + const [startDate, setStartDate] = useState(""); + const [endDate, setEndDate] = useState(""); + + const fullStartDate = `${startDate}:00`; + const fullEndDate = `${endDate}:00`; + + const handleSubmit = async () => { + const eventBody = { + summary: title, + description: description, + start: { dateTime: fullStartDate, timeZone: "America/Los_Angeles" }, // Adjust timeZone as needed + end: { dateTime: fullEndDate, timeZone: "America/Los_Angeles" } + }; + + try { + console.log(eventBody); + const response = await fetch("http://localhost:8080/add_event", { + method: "POST", + headers: { + "Content-Type": "application/json" + }, + body: JSON.stringify(eventBody), + credentials: 'include' + }); + + if (response.ok) { + alert("Event added successfully!"); + window.location.href = "http://localhost:3000"; // Redirect to homepage + } else { + alert("Failed to add event. Please try again."); + } + } catch (error) { + console.error("Error adding event:", error); + } + }; + + return ( +
+ +

Add Event

+
+

+ setTitle(e.target.value)} /> +
+
+

+