@local-civics/mgmt-ui 0.1.234 → 0.1.235

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -3324,7 +3324,19 @@ const Pathway = (props) => {
3324
3324
  const numberOfStudents = props.students.length;
3325
3325
  const numberOfBadgesEarned = numberOfStudents > 0 ? props.students.filter((u) => u.isComplete).length : 0;
3326
3326
  const criteria = props.criteria || {};
3327
- const criteriaCategories = (props.categories || []).filter((c) => criteria[c.categoryId] !== void 0);
3327
+ const parentById = new Map((props.allCategories || []).map((c) => [c.categoryId, c.parentCategoryId]));
3328
+ const depthOf = (id) => {
3329
+ let depth = 0;
3330
+ let current = id;
3331
+ const seen = /* @__PURE__ */ new Set();
3332
+ while (parentById.get(current) && !seen.has(current)) {
3333
+ seen.add(current);
3334
+ current = parentById.get(current);
3335
+ depth++;
3336
+ }
3337
+ return depth;
3338
+ };
3339
+ const criteriaCategories = (props.categories || []).filter((c) => criteria[c.categoryId] !== void 0).sort((a, b) => depthOf(a.categoryId) - depthOf(b.categoryId));
3328
3340
  const rootCategoryIds = new Set(
3329
3341
  (props.allCategories || []).filter((c) => !c.parentCategoryId).map((c) => c.categoryId)
3330
3342
  );