import { notifyApiError } from "../../../../lib/apiErrors" import { useRef, useState, type ChangeEvent } from "react"; import { Link } from "react-router-dom"; import { Upload, ArrowRight, Loader2 } from "lucide-react"; import { Button } from "../../../../components/ui/button"; import { Card } from "../../../../components/ui/card"; import { Input } from "../../../../components/ui/input"; import { RichTextEditor } from "../../../../components/ui/rich-text-editor"; import { toast } from "sonner"; import { uploadImageFile } from "../../../../api/files.api"; import { hasRichTextContent } from "../../../../lib/richText"; interface ScenarioStepProps { formData: any; setFormData: (data: any) => void; nextStep: () => void; cancelHref: string; } export function ScenarioStep({ formData, setFormData, nextStep, cancelHref, }: ScenarioStepProps) { const fileRef = useRef(null); const [uploadingBanner, setUploadingBanner] = useState(false); const onBannerFile = async (event: ChangeEvent) => { const file = event.target.files?.[0]; event.target.value = ""; if (!file) return; setUploadingBanner(true); try { const res = await uploadImageFile(file); const url = res.data?.data?.url?.trim(); if (!url) throw new Error("Missing URL"); setFormData({ ...formData, storyImageUrl: url }); toast.success("Story image uploaded"); } catch (e) { notifyApiError(e, "Could not upload image"); } finally { setUploadingBanner(false); } }; const canContinue = Boolean(formData.title?.trim()) && hasRichTextContent(formData.description); return (

Practice details

Story fields and question set options used when saving the practice.

setFormData({ ...formData, storyImageUrl: e.target.value }) } placeholder="Image URL" className="h-10 rounded-lg border-grayScale-200 font-mono text-xs" />
setFormData({ ...formData, title: e.target.value }) } />
setFormData({ ...formData, description })} placeholder="Describe the scenario…" maxLength={2000} editorClassName="min-h-[160px]" />
setFormData({ ...formData, tips })} placeholder="Learner-facing tips (quick_tips)" maxLength={1000} editorClassName="min-h-[80px]" />
); }