From 5206fb2e1a0529675783db9d4ca1e6832a948ee4 Mon Sep 17 00:00:00 2001 From: Yared Yemane Date: Tue, 14 Apr 2026 05:23:44 -0700 Subject: [PATCH] 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 --- src/pages/content-management/HumanLanguagePage.tsx | 14 ++++++++++++-- src/types/course.types.ts | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) 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 }