fix human language quick-create path creation

Create a real sub-category under Human Language and pass sub_category_id when creating the course so the new path renders immediately in the hierarchy panel.

Made-with: Cursor
This commit is contained in:
Yared Yemane 2026-04-14 05:23:44 -07:00
parent 24b5a0d7ee
commit 5206fb2e1a
2 changed files with 13 additions and 2 deletions

View File

@ -628,10 +628,20 @@ export function HumanLanguagePage() {
if (!effectiveCategoryId) { if (!effectiveCategoryId) {
throw new Error("Missing human language category id") throw new Error("Missing human language category id")
} }
const title = `${quickSubCategoryName.trim()} - ${quickCourseName.trim()}`
const createdSubCategory = await createCourseCategory({
name: quickSubCategoryName.trim(),
parent_id: effectiveCategoryId,
})
const subCategoryId = createdSubCategory.data?.data?.id
if (!subCategoryId) {
throw new Error("Failed to create subcategory")
}
await createCourse({ await createCourse({
category_id: effectiveCategoryId, category_id: effectiveCategoryId,
title, sub_category_id: Number(subCategoryId),
title: quickCourseName.trim(),
description: `${quickSubCategoryName.trim()} / ${quickCourseName.trim()}`, description: `${quickSubCategoryName.trim()} / ${quickCourseName.trim()}`,
}) })
toast.success("Subcategory/course path created") toast.success("Subcategory/course path created")

View File

@ -45,6 +45,7 @@ export interface GetCoursesResponse {
export interface CreateCourseRequest { export interface CreateCourseRequest {
category_id: number category_id: number
sub_category_id?: number | null
title: string title: string
description: string description: string
} }