refactor: simplify Check component rendering in CategoryCombobox for improved readability and maintainability

This commit is contained in:
Julien Froidefond
2025-12-08 07:51:30 +01:00
parent b2c8237bea
commit 3e119813cd

View File

@@ -206,12 +206,9 @@ export function CategoryCombobox({
<CommandItem value="__none__" onSelect={() => handleSelect(null)}>
<X className="h-4 w-4 text-muted-foreground" />
<span className="text-muted-foreground">Aucune catégorie</span>
<Check
className={cn(
"ml-auto h-4 w-4",
value === null ? "opacity-100" : "opacity-0",
)}
/>
{value === null && (
<Check className="ml-auto h-4 w-4" />
)}
</CommandItem>
</CommandGroup>
<CommandGroup>
@@ -227,12 +224,9 @@ export function CategoryCombobox({
size={16}
/>
<span className="font-medium">{parent.name}</span>
<Check
className={cn(
"ml-auto h-4 w-4",
value === parent.id ? "opacity-100" : "opacity-0",
)}
/>
{value === parent.id && (
<Check className="ml-auto h-4 w-4" />
)}
</CommandItem>
{childrenByParent[parent.id]?.map((child) => (
<CommandItem
@@ -247,12 +241,9 @@ export function CategoryCombobox({
size={16}
/>
<span>{child.name}</span>
<Check
className={cn(
"ml-auto h-4 w-4",
value === child.id ? "opacity-100" : "opacity-0",
)}
/>
{value === child.id && (
<Check className="ml-auto h-4 w-4" />
)}
</CommandItem>
))}
</div>