generated from NYCPlanning/ae-remix-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
clearing disctrict selections works, also FlyTo initial map view also…
… working
- Loading branch information
1 parent
437785e
commit 242cd88
Showing
4 changed files
with
61 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,10 @@ | ||
import { ClearFilterBtnProps, ClearFilterBtn } from "."; | ||
// import { ClearFilterBtnProps, ClearFilterBtn } from "."; | ||
|
||
export interface ClearFileringBtnProps | ||
extends Pick<ClearFilterBtnProps, "clearFiltering"> { | ||
path: string | null; | ||
} | ||
// export interface ClearFileringBtnProps | ||
// extends Pick<ClearFilterBtnProps, "onClear"> { | ||
// path: string | null; | ||
// } | ||
|
||
export function ClearFilteringBtn({path} :ClearFileringBtnProps) { | ||
return <ClearFilterBtn | ||
path={ | ||
null | ||
} | ||
} | ||
// export function ClearFilteringBtn({path} :ClearFileringBtnProps) { | ||
// return <ClearFilterBtn /> | ||
// } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,34 @@ | ||
import { useState } from "react"; | ||
import { Button } from "@nycplanning/streetscape"; | ||
import { useNavigate } from "@remix-run/react"; | ||
|
||
export interface ClearFilterBtnProps { | ||
clearFiltering: (path: string) => void; | ||
path: string | null; | ||
onClear: () => void; | ||
buttonLabel?: string; | ||
} | ||
|
||
export function ClearFilterBtn({ clearFiltering, path }: ClearFilterBtnProps) { | ||
export function ClearFilterBtn({ | ||
onClear, | ||
buttonLabel = "Reset Selections", | ||
}: ClearFilterBtnProps) { | ||
const [isClearing, setIsClearing] = useState(false); | ||
const navigate = useNavigate(); | ||
|
||
const handleClear = async () => { | ||
setIsClearing(true); | ||
try { | ||
await onClear(); | ||
navigate("/"); | ||
} catch (error) { | ||
console.error("Error clearing selections:", error); | ||
} finally { | ||
setIsClearing(false); | ||
} | ||
}; | ||
|
||
return ( | ||
<Button | ||
width="full" | ||
mt={4} | ||
onClick={path !== null ? () => clearFiltering(path) : () => undefined} | ||
> | ||
Clear Filtering | ||
<Button width="full" mt={4} onClick={handleClear} isDisabled={isClearing}> | ||
{buttonLabel} | ||
</Button> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters