Skip to content

Commit

Permalink
🦊 Sort categories in category filter (#463)
Browse files Browse the repository at this point in the history
  • Loading branch information
nezouse committed May 10, 2024
1 parent 2f8a16b commit 80660eb
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/components/ui/filterPanels/filters/categoryFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import { type Category } from "@/types/Category";
import { CategoryColor } from "@/types/CategoryColor";
import { cn } from "@/lib/cn";
import { sortObjectsByKey } from "@/lib/sort";
import { getCategoryIcon } from "@/components/ui/categories/getCategoryIcon";
import { getCategoryStyles } from "@/components/ui/categories/getCategoryStyles";
import {
Expand All @@ -28,13 +29,15 @@ export const CategoryFilter = ({
categories,
onCategoryChange,
}: CategoryFilterProps) => {
const sortedCategories = sortObjectsByKey(categories, ["name"], true);

return (
<Select onValueChange={onCategoryChange}>
<SelectTrigger className="w-[180px]">
<SelectValue placeholder="Category" />
</SelectTrigger>
<SelectContent>
{categories.map(({ id, name, color }) => (
{sortedCategories.map(({ id, name, color }) => (
<SelectItem key={id} value={id}>
<span
className={cn(
Expand Down

0 comments on commit 80660eb

Please sign in to comment.