Create eventDetail context

This commit is contained in:
T'JAMPENS QUENTIN p2406187 committed 2026-01-27 16:09:59 +01:00
1 parent 6c51e70817
commit 93f9001eb5
3 files changed
+34 -7

No files matched your search

+3
View File
@@ -0,0 +1,3 @@
import { createContext } from "react";
export const EventDetailContext = createContext(null);
@@ -0,0 +1,21 @@
import {useState} from 'react';
import { EventDetailContext } from "./eventDetail.js"
import getEventById from "../../utils/events/getEventById.js";
export function EventDetailProvider({ children }) {
const [tasks, setTasks] = useState([]);
const [eventInfo, setEventInfo] = useState([]);
const updateEventInfo = async (id) => {
const e = await getEventById(id);
setEventInfo(e);
setTasks(e.tasks)
}
return (
<EventDetailContext.Provider value={{ tasks, eventInfo, updateEventInfo }}>
{children}
</EventDetailContext.Provider>
);
}