@local-civics/hub-ui 0.1.174 → 0.1.175

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.d.ts CHANGED
@@ -1035,6 +1035,7 @@ type PathwayCardProps = {
1035
1035
  target?: number;
1036
1036
  displayTags?: string[];
1037
1037
  criteria?: PathwayCriteria;
1038
+ categoryNames?: Record<string, string>;
1038
1039
  points?: Record<string, number>;
1039
1040
  onClose?: () => void;
1040
1041
  onSubmit?: () => void;
package/dist/index.js CHANGED
@@ -5599,30 +5599,35 @@ const PathwayCard = (props) => {
5599
5599
  const completedCount = badges.filter((b) => b.completedAt).length;
5600
5600
  const target = props.target || badges.length;
5601
5601
  const categoryTargets = (_a = props.criteria) != null ? _a : {};
5602
+ const categoryIds = Object.keys(categoryTargets);
5602
5603
  const points = (_b = props.points) != null ? _b : {};
5603
- const allCategories = Array.from(
5604
- new Set(badges.flatMap((b) => b.categories || []))
5605
- );
5606
5604
  const [filters, setFilters] = React__namespace.useState(
5607
5605
  () => {
5608
5606
  const obj = {};
5609
- allCategories.forEach((cat) => {
5610
- obj[cat] = { label: cat, isActive: false };
5607
+ categoryIds.forEach((id) => {
5608
+ obj[id] = {
5609
+ id,
5610
+ isActive: false
5611
+ };
5611
5612
  });
5612
5613
  return obj;
5613
5614
  }
5614
5615
  );
5615
- const toggleFilter = (label) => {
5616
- setFilters((prev) => __spreadProps$1(__spreadValues$2({}, prev), {
5617
- [label]: __spreadProps$1(__spreadValues$2({}, prev[label]), {
5618
- isActive: !prev[label].isActive
5619
- })
5620
- }));
5616
+ const toggleFilter = (id) => {
5617
+ setFilters((prev) => {
5618
+ if (!prev[id])
5619
+ return prev;
5620
+ return __spreadProps$1(__spreadValues$2({}, prev), {
5621
+ [id]: __spreadProps$1(__spreadValues$2({}, prev[id]), {
5622
+ isActive: !prev[id].isActive
5623
+ })
5624
+ });
5625
+ });
5621
5626
  };
5622
5627
  const activeFilters = Object.values(filters).filter((f) => f.isActive);
5623
5628
  const filteredBadges = activeFilters.length === 0 ? badges : badges.filter(
5624
5629
  (b) => activeFilters.some(
5625
- (f) => (b.categories || []).includes(f.label)
5630
+ (f) => (b.categories || []).includes(f.id)
5626
5631
  )
5627
5632
  );
5628
5633
  const filterClassName = "inline-block px-4 py-2 bg-gray-600 text-white rounded-full cursor-pointer text-sm";
@@ -5640,17 +5645,18 @@ const PathwayCard = (props) => {
5640
5645
  points,
5641
5646
  height: "sm"
5642
5647
  }
5643
- ), /* @__PURE__ */ React__namespace.createElement("div", { className: "flex flex-wrap gap-2 mt-3" }, allCategories.map((cat, i) => {
5644
- var _a2;
5645
- const isActive = (_a2 = filters[cat]) == null ? void 0 : _a2.isActive;
5648
+ ), /* @__PURE__ */ React__namespace.createElement("div", { className: "flex flex-wrap gap-2 mt-3" }, categoryIds.map((id) => {
5649
+ var _a2, _b2, _c2;
5650
+ const isActive = (_a2 = filters[id]) == null ? void 0 : _a2.isActive;
5651
+ const label = (_c2 = (_b2 = props.categoryNames) == null ? void 0 : _b2[id]) != null ? _c2 : id;
5646
5652
  return /* @__PURE__ */ React__namespace.createElement(
5647
5653
  "div",
5648
5654
  {
5649
- key: i,
5650
- onClick: () => toggleFilter(cat),
5655
+ key: id,
5656
+ onClick: () => toggleFilter(id),
5651
5657
  className: isActive ? `${filterClassName} bg-gray-700` : "inline-block px-4 py-2 rounded-full hover:bg-gray-200 cursor-pointer text-sm"
5652
5658
  },
5653
- cat
5659
+ label
5654
5660
  );
5655
5661
  })), /* @__PURE__ */ React__namespace.createElement("div", { className: "mt-2 grid grid-cols-1 gap-y-2 max-h-[18rem] overflow-y-auto" }, filteredBadges.map((b) => {
5656
5662
  const buttonText = b.completedAt ? "Completed" : b.startedAt ? "Continue" : "Start";