fix: improve input checkbox input

Signed-off-by: Chloe <pinkcloudvnn@gmail.com>
This commit is contained in:
Chloe 2024-05-12 12:33:41 +07:00
parent 3d4dc9ec86
commit 80db45a522
No known key found for this signature in database
GPG Key ID: CFD53CE570D42DF5
2 changed files with 4 additions and 3 deletions

View File

@ -32,6 +32,8 @@ const Filters = ({ filters, defaultOpen = true }: { filters: Filter[]; defaultOp
router.replace(createUrl(pathname, newSearchParams), { scroll: false }); router.replace(createUrl(pathname, newSearchParams), { scroll: false });
}; };
if (filters.length === 0) return null;
return ( return (
<> <>
<SelectedList filters={filters} /> <SelectedList filters={filters} />
@ -62,12 +64,12 @@ const Filters = ({ filters, defaultOpen = true }: { filters: Filter[]; defaultOp
<input <input
id={valueId} id={valueId}
name={id} name={id}
checked={searchParams.getAll(id).includes(String(value))} defaultChecked={searchParams.getAll(id).includes(String(value))}
type="checkbox" type="checkbox"
value={String(value)} value={String(value)}
className="h-4 w-4 rounded border-gray-300 text-secondary focus:ring-secondary disabled:cursor-not-allowed disabled:opacity-50" className="h-4 w-4 rounded border-gray-300 text-secondary focus:ring-secondary disabled:cursor-not-allowed disabled:opacity-50"
disabled={count === 0} disabled={count === 0}
onChange={() => {}} key={searchParams.getAll(id).length}
/> />
<span>{`${label} (${count})`}</span> <span>{`${label} (${count})`}</span>
</label> </label>

View File

@ -181,7 +181,6 @@ const reshapeCollections = (collections: ShopifyCollection[]) => {
const reshapeFilters = (filters: ShopifyFilter[]): Filter[] => { const reshapeFilters = (filters: ShopifyFilter[]): Filter[] => {
const reshapedFilters = []; const reshapedFilters = [];
for (const filter of filters) { for (const filter of filters) {
const values = filter.values const values = filter.values
.map((valueItem) => { .map((valueItem) => {