Convert CreateEventBtn to Typescript
This commit is contained in:
+9
-9
@@ -4,19 +4,19 @@ import Modal from "../../../ui/Modal/Modal";
|
|||||||
import Button from "../../../ui/Button/Button";
|
import Button from "../../../ui/Button/Button";
|
||||||
import TextInput from "../../../ui/Input/Input";
|
import TextInput from "../../../ui/Input/Input";
|
||||||
import { EventContext } from "../../../../contexts/Events/EventContext.js";
|
import { EventContext } from "../../../../contexts/Events/EventContext.js";
|
||||||
import {AuthContext} from "../../../../contexts/Auth/AuthContext.ts";
|
import { AuthContext } from "../../../../contexts/Auth/AuthContext";
|
||||||
|
|
||||||
|
|
||||||
export default function CreateEventBtn() {
|
export default function CreateEventBtn() {
|
||||||
|
|
||||||
const { addEvent } = useContext(EventContext);
|
const { addEvent } = useContext(EventContext)!;
|
||||||
const { user } = useContext(AuthContext);
|
const { user } = useContext(AuthContext)!;
|
||||||
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState<boolean>(false);
|
||||||
const [name, setName] = useState("");
|
const [name, setName] = useState<string>("");
|
||||||
const [description, setDescription] = useState("");
|
const [description, setDescription] = useState<string>("");
|
||||||
const [start, setStart] = useState("");
|
const [start, setStart] = useState<string>("");
|
||||||
const [end, setEnd] = useState("");
|
const [end, setEnd] = useState<string>("");
|
||||||
|
|
||||||
const handleCreateEvent = async () => {
|
const handleCreateEvent = async () => {
|
||||||
|
|
||||||
@@ -62,4 +62,4 @@ export default function CreateEventBtn() {
|
|||||||
</section>
|
</section>
|
||||||
</Modal>
|
</Modal>
|
||||||
</>
|
</>
|
||||||
}
|
}
|
||||||
@@ -17,6 +17,7 @@ export type EventGroup = {
|
|||||||
export type EventContextType = {
|
export type EventContextType = {
|
||||||
events: EventGroup[];
|
events: EventGroup[];
|
||||||
updateEvent: () => void;
|
updateEvent: () => void;
|
||||||
|
addEvent: (name: string, description: string, start: string, end: string) => Promise<void>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export const EventContext = createContext<EventContextType | null>(null);
|
export const EventContext = createContext<EventContextType | null>(null);
|
||||||
Reference in New Issue
Block a user