Skip to content

Commit

Permalink
chore: eslint behavior fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
karl-cardenas-coding committed Jul 16, 2024
1 parent d0ff3fb commit 3823181
Showing 1 changed file with 43 additions and 24 deletions.
67 changes: 43 additions & 24 deletions src/components/Technologies/PacksFilters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,73 @@ import CustomLabel from "./CategorySelector/CustomLabel";
import FilterSelect from "./CategorySelector/FilterSelect";
import "./packsFilters.antd.css";
import { packTypeNames, cloudProviderTypes } from "../../constants/packs";

interface PackFiltersProps {
categories: string[];
registries: any[];
setSelectedSearchFilters: (...args: any[]) => void;
selectedFilters: any;
registries: registry[];
setSelectedSearchFilters: (filters: SelectedFilters) => void;
selectedFilters: SelectedFilters;
}

interface registry {
uid: string;
name: string;
}

interface sources {
label: string;
value: string;
}

const sourceList: any[] = [
interface SelectedFilters {
category: string[];
registries: string[];
cloudTypes: string[];
source: string[];
}

const sourceList: sources[] = [
{
label: "All",
value: "all"
value: "all",
},
{
label: "Verified",
value: "verified"
value: "verified",
},
{
label: "Community",
value: "community",
},
];

export default function PacksFilters({ categories, registries, setSelectedSearchFilters, selectedFilters }: PackFiltersProps) {


export default function PacksFilters({
categories,
registries,
setSelectedSearchFilters,
selectedFilters,
}: PackFiltersProps) {
return (
<div className={styles.wrapper}>
<div className={styles.filterItems}>
<CustomLabel label="Type" />
<FilterSelect
selectMode="multiple"
options={categories.map((category) => {
options={categories.map((category: string) => {
return { value: category, label: packTypeNames[category] };
})}
onChange={(items) => setSelectedSearchFilters({ category: items })}
onChange={(items) => setSelectedSearchFilters({ ...selectedFilters, category: items as string[] })}
value={selectedFilters.category}
/>
</div>
<div className={styles.filterItems}>
<CustomLabel label="Registry" />
<FilterSelect
selectMode="multiple"
options={Array.from(registries).map((registry) => {
options={registries.map((registry) => {
return { value: registry.uid, label: registry.name };
})}
onChange={(items) => setSelectedSearchFilters({ registries: items })}
onChange={(items) => setSelectedSearchFilters({ ...selectedFilters, registries: items as string[] })}
value={selectedFilters.registries}
/>
</div>
Expand All @@ -60,11 +81,10 @@ export default function PacksFilters({ categories, registries, setSelectedSearch
return { value: provider.name, label: provider.displayName };
})}
onChange={(item) => {
if (item) {
setSelectedSearchFilters({ cloudTypes: [item] })
} else {
setSelectedSearchFilters({ cloudTypes: [] })
}
setSelectedSearchFilters({
...selectedFilters,
cloudTypes: item ? [item as string] : [],
});
}}
value={selectedFilters.cloudTypes.length ? selectedFilters.cloudTypes[0] : undefined}
/>
Expand All @@ -74,15 +94,14 @@ export default function PacksFilters({ categories, registries, setSelectedSearch
<FilterSelect
options={sourceList}
onChange={(item) => {
if (item) {
setSelectedSearchFilters({ source: [item] })
} else {
setSelectedSearchFilters({ source: [] })
}
setSelectedSearchFilters({
...selectedFilters,
source: item ? [item as string] : [],
});
}}
value={selectedFilters.source.length ? selectedFilters.source[0] : undefined}
/>
</div>
</div >
</div>
);
}

0 comments on commit 3823181

Please sign in to comment.