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