import Button from "../ui/Button/Button";
import { useContext } from "react";
import { AuthContext, AuthContextType } from "../../contexts/Auth/AuthContext";
import { APP_CONFIG } from "../../config/appConfig";

export default function ExportCalendarBtn() {

    const { user } = useContext(AuthContext) as AuthContextType;
    const calendarUrl = `${import.meta.env.VITE_API_URL}/api/export/ics/${user?.id}`;

    return <Button
        variant="default"
        onClick={() => {
            window.open(
                `${APP_CONFIG.newCalendarURL}${calendarUrl}`
            );
        }}
    >
        Exporter le calendrier
    </Button>
}