refactor: simplify Check component rendering in CategoryCombobox for improved readability and maintainability
This commit is contained in:
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user