Fix: show all training modules in course generator, not just unlinked ones
All 28 modules already have academy_course_id set, so the filter was hiding everything. Now shows all modules with a "Kurs vorhanden" badge for linked ones. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -40,17 +40,9 @@ export default function NewCoursePage() {
|
|||||||
setModulesLoading(true)
|
setModulesLoading(true)
|
||||||
try {
|
try {
|
||||||
const res = await getModules()
|
const res = await getModules()
|
||||||
// Filter out modules that already have an academy_course_id
|
setTrainingModules(res.modules || [])
|
||||||
const available = (res.modules || []).filter(m => !m.academy_course_id)
|
|
||||||
setTrainingModules(available)
|
|
||||||
} catch {
|
} catch {
|
||||||
// If loading fails, show all modules
|
setError('Training-Module konnten nicht geladen werden.')
|
||||||
try {
|
|
||||||
const res = await getModules()
|
|
||||||
setTrainingModules(res.modules || [])
|
|
||||||
} catch {
|
|
||||||
setError('Training-Module konnten nicht geladen werden.')
|
|
||||||
}
|
|
||||||
} finally {
|
} finally {
|
||||||
setModulesLoading(false)
|
setModulesLoading(false)
|
||||||
}
|
}
|
||||||
@@ -209,12 +201,13 @@ export default function NewCoursePage() {
|
|||||||
</div>
|
</div>
|
||||||
) : trainingModules.length === 0 ? (
|
) : trainingModules.length === 0 ? (
|
||||||
<div className="text-center py-8">
|
<div className="text-center py-8">
|
||||||
<p className="text-gray-500">Keine verfuegbaren Training-Module gefunden.</p>
|
<p className="text-gray-500">Keine Training-Module gefunden.</p>
|
||||||
<p className="text-sm text-gray-400 mt-1">Alle Module haben bereits einen Academy-Kurs oder es existieren noch keine Module.</p>
|
<p className="text-sm text-gray-400 mt-1">Bitte erstellen Sie zuerst Module unter Schulung > Module.</p>
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-2">Training-Modul auswählen *</label>
|
<label className="block text-sm font-medium text-gray-700 mb-2">Training-Modul auswaehlen *</label>
|
||||||
|
<p className="text-xs text-gray-400 mb-3">Module mit bestehendem Kurs werden beim Generieren uebersprungen oder neu verknuepft.</p>
|
||||||
<div className="grid gap-3 max-h-[400px] overflow-y-auto pr-2">
|
<div className="grid gap-3 max-h-[400px] overflow-y-auto pr-2">
|
||||||
{trainingModules.map((mod) => (
|
{trainingModules.map((mod) => (
|
||||||
<button
|
<button
|
||||||
@@ -231,9 +224,14 @@ export default function NewCoursePage() {
|
|||||||
<div className={`text-sm font-medium ${selectedModuleId === mod.id ? 'text-purple-700' : 'text-gray-700'}`}>
|
<div className={`text-sm font-medium ${selectedModuleId === mod.id ? 'text-purple-700' : 'text-gray-700'}`}>
|
||||||
{mod.title}
|
{mod.title}
|
||||||
</div>
|
</div>
|
||||||
<span className="text-xs px-2 py-1 rounded-full bg-gray-100 text-gray-600">
|
<div className="flex items-center gap-2">
|
||||||
{mod.regulation_area}
|
{mod.academy_course_id && (
|
||||||
</span>
|
<span className="text-xs px-2 py-0.5 rounded-full bg-green-100 text-green-700">Kurs vorhanden</span>
|
||||||
|
)}
|
||||||
|
<span className="text-xs px-2 py-1 rounded-full bg-gray-100 text-gray-600">
|
||||||
|
{mod.regulation_area}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{mod.description && (
|
{mod.description && (
|
||||||
<div className="text-xs text-gray-500 mt-1 line-clamp-2">{mod.description}</div>
|
<div className="text-xs text-gray-500 mt-1 line-clamp-2">{mod.description}</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user