Category Master — Sub-Category Form (Level 1)

By Engineering Team•October 9, 2026•3 min read

Sub-category add/edit drawer form, showing the parent-root chip and variant attribute cards

What the admin sees

CategorySubcatsLeafPage.tsx, rendered inside the drawer when a Level 1 node is being added or edited. The form has:

  • A read-only “PARENT ROOT” chip showing the currently-selected root’s name — never editable here, since it’s set automatically from the tree selection.
  • Name and Slug — same free-text/auto-slug behavior as the root form.
  • Display Order — a numeric field.
  • Variant Attributes — a repeatable list of attribute cards. Each card has a Name field and a Type dropdown (select or swatch):
    • select type shows a chip-based “Standard Values” list (type + Enter to add, same pattern as the root form’s Spec Template field).
    • swatch type shows a repeatable name + hex input pair with a live color-dot preview, building up a list of named swatch values.

What the admin does here

Submitting validates: Name required, Slug required, at least one Variant Attribute present, each attribute’s Name required, and each attribute must have at least one value (standard value for select, swatch value for swatch). On success it calls onAdd/onUpdate with nodeLevel: 1, parentId set to the selected root’s ID, mainDisplayCategory: true (always, for this level), and specTemplate: [] — sub-categories never carry a spec template, that’s root-only.

In edit mode, useCategorySubcatsLeafController pre-fills name, slug, displayOrder, and reconstructs each VariantAttributeForm card from the fetched variantAttributes array (via fromApiVariantAttr) — including correctly routing each attribute’s stored values back into either the select-chip list or the swatch-value list depending on its type.