diff --git a/src/pages/content-management/HumanLanguagePage.tsx b/src/pages/content-management/HumanLanguagePage.tsx index d6e2ec9..04a71a2 100644 --- a/src/pages/content-management/HumanLanguagePage.tsx +++ b/src/pages/content-management/HumanLanguagePage.tsx @@ -628,10 +628,20 @@ export function HumanLanguagePage() { if (!effectiveCategoryId) { 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({ category_id: effectiveCategoryId, - title, + sub_category_id: Number(subCategoryId), + title: quickCourseName.trim(), description: `${quickSubCategoryName.trim()} / ${quickCourseName.trim()}`, }) toast.success("Subcategory/course path created") diff --git a/src/types/course.types.ts b/src/types/course.types.ts index 4e08ba1..cb33048 100644 --- a/src/types/course.types.ts +++ b/src/types/course.types.ts @@ -45,6 +45,7 @@ export interface GetCoursesResponse { export interface CreateCourseRequest { category_id: number + sub_category_id?: number | null title: string description: string }