feat: pre-populate generator with problem samples on open

This commit is contained in:
2026-05-19 04:22:23 -06:00
parent 06738f6e29
commit 874a6fbe90
2 changed files with 11 additions and 3 deletions

View File

@@ -13,6 +13,7 @@ interface FileEntry {
interface Props {
answers: { language: LANGUAGE; code: string }[]
samples?: { input: string; output: string }[]
}
const props = defineProps<Props>()
@@ -23,9 +24,15 @@ const emit = defineEmits<{
const message = useMessage()
let nextId = 0
const files = ref<FileEntry[]>(
Array.from({ length: 5 }, () => ({ id: nextId++, in: "", out: "", error: false })),
)
function makeInitialFiles(): FileEntry[] {
if (props.samples?.length) {
return props.samples.map((s) => ({ id: nextId++, in: s.input, out: s.output, error: false }))
}
return Array.from({ length: 5 }, () => ({ id: nextId++, in: "", out: "", error: false }))
}
const files = ref<FileEntry[]>(makeInitialFiles())
const selectedLanguage = ref<LANGUAGE>("Python3")