Skip to content

Commit

Permalink
fix(fe): add CommandList (#1663)
Browse files Browse the repository at this point in the history
  • Loading branch information
jihorobert authored May 6, 2024
1 parent 9fe4048 commit b6a990b
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 59 deletions.
49 changes: 26 additions & 23 deletions apps/frontend/app/admin/_components/GroupSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
Command,
CommandEmpty,
CommandGroup,
CommandItem
CommandItem,
CommandList
} from '@/components/ui/command'
import {
Popover,
Expand Down Expand Up @@ -56,28 +57,30 @@ export default function GroupSelect() {
</PopoverTrigger>
<PopoverContent className="mx-2 w-48 p-0 font-semibold">
<Command>
<CommandEmpty>No group found.</CommandEmpty>
<CommandGroup>
{groups.map((framework) => (
<CommandItem
key={framework.id}
value={framework.id}
className="text-slate-600"
onSelect={(currentValue) => {
setValue(currentValue === value ? '' : currentValue)
setOpen(false)
}}
>
<Check
className={cn(
'mr-2 h-4 w-4',
value === framework.id ? 'opacity-100' : 'opacity-0'
)}
/>
{framework.label}
</CommandItem>
))}
</CommandGroup>
<CommandList>
<CommandEmpty>No group found.</CommandEmpty>
<CommandGroup>
{groups.map((framework) => (
<CommandItem
key={framework.id}
value={framework.id}
className="text-slate-600"
onSelect={(currentValue) => {
setValue(currentValue === value ? '' : currentValue)
setOpen(false)
}}
>
<Check
className={cn(
'mr-2 h-4 w-4',
value === framework.id ? 'opacity-100' : 'opacity-0'
)}
/>
{framework.label}
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
Expand Down
29 changes: 16 additions & 13 deletions apps/frontend/components/CheckboxSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
Command,
CommandEmpty,
CommandGroup,
CommandItem
CommandItem,
CommandList
} from '@/components/ui/command'
import {
Popover,
Expand Down Expand Up @@ -91,18 +92,20 @@ export default function LanguageSelect<T extends string>({

<PopoverContent className="w-[115px] p-0" align="start">
<Command>
<CommandEmpty>No language found.</CommandEmpty>
<CommandGroup>
{options.map((option) => (
<CommandItem key={option} value={option} className="gap-x-2">
<Checkbox
checked={selectedValues.includes(option)}
onCheckedChange={() => handleCheckboxChange(option)}
></Checkbox>
{option}
</CommandItem>
))}
</CommandGroup>
<CommandList>
<CommandEmpty>No language found.</CommandEmpty>
<CommandGroup>
{options.map((option) => (
<CommandItem key={option} value={option} className="gap-x-2">
<Checkbox
checked={selectedValues.includes(option)}
onCheckedChange={() => handleCheckboxChange(option)}
></Checkbox>
{option}
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
Expand Down
49 changes: 26 additions & 23 deletions apps/frontend/components/DataTableLangFilter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ import {
Command,
CommandEmpty,
CommandGroup,
CommandItem
CommandItem,
CommandList
} from '@/components/ui/command'
import {
Popover,
Expand Down Expand Up @@ -73,28 +74,30 @@ export default function DataTableLangFilter<TData, TValue>({

<PopoverContent className="w-[115px] p-0" align="start">
<Command>
<CommandEmpty>No language found.</CommandEmpty>
<CommandGroup>
{options.map((option) => (
<CommandItem key={option} value={option} className="gap-x-2">
<Checkbox
checked={selectedValues.has(option)}
onCheckedChange={() => {
if (selectedValues.has(option)) {
selectedValues.delete(option)
} else {
selectedValues.add(option)
}
const filterValues = Array.from(selectedValues)
column?.setFilterValue(
filterValues.length ? filterValues : undefined
)
}}
/>
{option}
</CommandItem>
))}
</CommandGroup>
<CommandList>
<CommandEmpty>No language found.</CommandEmpty>
<CommandGroup>
{options.map((option) => (
<CommandItem key={option} value={option} className="gap-x-2">
<Checkbox
checked={selectedValues.has(option)}
onCheckedChange={() => {
if (selectedValues.has(option)) {
selectedValues.delete(option)
} else {
selectedValues.add(option)
}
const filterValues = Array.from(selectedValues)
column?.setFilterValue(
filterValues.length ? filterValues : undefined
)
}}
/>
{option}
</CommandItem>
))}
</CommandGroup>
</CommandList>
</Command>
</PopoverContent>
</Popover>
Expand Down

0 comments on commit b6a990b

Please sign in to comment.