import fetchWrapper from "../fetchWrapper";
import getXSRFToken from "../getXSRF";

interface CreateTaskParams {
    eventId: number;
    name: string;
    description: string;
    start: string;
    end: string;
    location: string;
    maxParticipants: number;
}

export default async function createTask({
    eventId,
    name,
    description,
    start,
    end,
    location,
    maxParticipants,
}: CreateTaskParams): Promise<any> {
    const csrfToken = await getXSRFToken();

    return fetchWrapper(
        "/api/events/task",
        {
            event_id: eventId,
            name,
            description,
            start,
            end,
            location,
            max_participants: maxParticipants,
        },
        "POST",
        {"X-XSRF-TOKEN": csrfToken}
    );
}
