Skip to content

Commit

Permalink
Update index.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
saithsab877 authored Aug 13, 2024
1 parent 242662c commit 5144551
Showing 1 changed file with 19 additions and 8 deletions.
27 changes: 19 additions & 8 deletions src/components/App/SideBar/FilterSearch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@ type Props = {
anchorEl: HTMLElement | null
}

const defaultValues = {
selectedTypes: [] as string[],
hops: 1,
sourceNodes: 10,
maxResults: 30,
}

export const FilterSearch = ({ showAllSchemas, setShowAllSchemas, schemaAll, anchorEl }: Props) => {
const handleSchemaTypeClick = (type: string) => {
setSelectedTypes((prevSelectedTypes) =>
Expand All @@ -26,16 +33,20 @@ export const FilterSearch = ({ showAllSchemas, setShowAllSchemas, schemaAll, anc
}

const { setFilters } = useDataStore((s) => s)
const [selectedTypes, setSelectedTypes] = useState<string[]>([])
const [hops, setHops] = useState(1)
const [sourceNodes, setSourceNodes] = useState<number>(10)
const [maxResults, setMaxResults] = useState<number>(30)
const [selectedTypes, setSelectedTypes] = useState<string[]>(defaultValues.selectedTypes)
const [hops, setHops] = useState(defaultValues.hops)
const [sourceNodes, setSourceNodes] = useState<number>(defaultValues.sourceNodes)
const [maxResults, setMaxResults] = useState<number>(defaultValues.maxResults)

const resetToDefaultValues = () => {
setSelectedTypes(defaultValues.selectedTypes)
setHops(defaultValues.hops)
setSourceNodes(defaultValues.sourceNodes)
setMaxResults(defaultValues.maxResults)
}

const handleClear = async () => {
setSelectedTypes([])
setHops(1)
setSourceNodes(10)
setMaxResults(30)
resetToDefaultValues()
}

const handleViewMoreClick = () => {
Expand Down

0 comments on commit 5144551

Please sign in to comment.