Use event Context
This commit is contained in:
@@ -1,13 +1,15 @@
|
||||
import styles from "./createEventBtn.module.css"
|
||||
import { useState } from "react";
|
||||
import { useState, useContext } from "react";
|
||||
import Modal from "../ui/modal/modal.jsx";
|
||||
import Button from "../ui/button/button.jsx";
|
||||
import TextInput from "../ui/input/input.jsx";
|
||||
import createEvent from "../../utils/events/createEvent.js"
|
||||
import { EventContext } from "../../contexts/events/EventContext.js";
|
||||
|
||||
|
||||
export default function CreateEventBtn() {
|
||||
|
||||
const { addEvent } = useContext(EventContext);
|
||||
|
||||
const [isOpen, setIsOpen] = useState(false);
|
||||
const [name, setName] = useState("");
|
||||
const [description, setDescription] = useState("");
|
||||
@@ -17,8 +19,7 @@ export default function CreateEventBtn() {
|
||||
const handleCreateEvent = async () => {
|
||||
|
||||
if(name !== "" || description !== "" || start !== "" || end !== "") {
|
||||
await createEvent(name, description, start, end);
|
||||
console.log(start);
|
||||
await addEvent(name, description, start, end);
|
||||
}
|
||||
setIsOpen(false);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user