import { GitForkIcon, Loader2Icon } from 'lucide-react'; import { Modal } from '../Modal'; import type { AICourseDocument } from '../../queries/ai-course'; import { useMutation } from '@tanstack/react-query'; import { queryClient } from '../../stores/query-client'; import { httpPost } from '../../lib/query-http'; import { useToast } from '../../hooks/use-toast'; import { useState } from 'react'; type ForkAICourseParams = { aiCourseSlug: string; }; type ForkAICourseBody = {}; type ForkAICourseQuery = {}; type ForkAICourseResponse = AICourseDocument; type ForkCourseConfirmationProps = { onClose: () => void; courseSlug: string; }; export function ForkCourseConfirmation(props: ForkCourseConfirmationProps) { const { onClose, courseSlug } = props; const toast = useToast(); const [isPending, setIsPending] = useState(false); const { mutate: forkCourse } = useMutation( { mutationFn: async () => { setIsPending(true); return httpPost( `${import.meta.env.PUBLIC_API_URL}/v1-fork-ai-course/${courseSlug}`, {}, ); }, onSuccess(data) { window.location.href = `/ai/${data.slug}`; }, onError(error) { toast.error(error?.message || 'Failed to fork course'); setIsPending(false); }, }, queryClient, ); return ( {} : onClose}>

Fork Course

Forking this course will create a new course with the same content.

); }