import type { CourseView } from '../types'; import React, { useState } from 'react'; import { Loader2, Camera } from 'lucide-react'; import { base44 } from '@/api/base44Client'; import { Image } from '@/components/ui/image'; import { useTranslation } from 'react-i18next'; // Photo or video proof — capture/upload, then submit for AI evaluation. interface MediaChallengeProps { course: CourseView; onSubmit?: (...args: any[]) => void; submitting: boolean; } export default function MediaChallenge({ course, onSubmit, submitting }: MediaChallengeProps) { const { t } = useTranslation(); const type = course?.challenge?.type || 'photo'; const [mediaUrl, setMediaUrl] = useState(''); const [uploading, setUploading] = useState(false); const accept = type === 'video' ? 'video/*' : 'image/*'; const capture = type === 'photo' ? 'environment' : undefined; const handleFile = async (e) => { const file = e.target.files?.[0]; if (!file) return; setUploading(true); try { const { file_url } = await base44.integrations.Core.UploadFile({ file }); setMediaUrl(file_url); } catch { setMediaUrl(''); } finally { setUploading(false); } }; return (

{type === 'video' ? 'Record or upload a short video demonstrating the challenge.' : 'Take or upload a photo showing your work.'}

{mediaUrl ? (
{type === 'video' ? (
) : ( )}
{mediaUrl && ( )}
); }