This commit is contained in:
Ben Mitchinson 2025-10-09 22:51:54 -07:00
parent 79b31ac634
commit df9dcca62e
1 changed files with 24 additions and 17 deletions

View File

@ -35,23 +35,30 @@ const LocationSelector = (props: Props) => {
const [popoverOpen, setPopoverOpen] = useState<boolean>(false); const [popoverOpen, setPopoverOpen] = useState<boolean>(false);
useEffect(() => { useEffect(() => {
if (props.location) {
setState((state) => ({ setState((state) => ({
...state, ...state,
placeholder: props.location.placeholder || "", placeholder: props.location?.placeholder || "",
position: new LatLng(props.location.latitude, props.location.longitude), position: new LatLng(props.location?.latitude || 0, props.location?.longitude || 0),
latInput: String(props.location.latitude), latInput: String(props.location?.latitude) || "",
lngInput: String(props.location.longitude), lngInput: String(props.location?.longitude) || "",
})); }));
} else { // if (props.location) {
setState((state) => ({ // setState((state) => ({
...state, // ...state,
placeholder: "", // placeholder: props.location.placeholder || "",
position: undefined, // position: new LatLng(props.location.latitude, props.location.longitude),
latInput: "", // latInput: String(props.location.latitude),
lngInput: "", // lngInput: String(props.location.longitude),
})); // }));
} // } else {
// setState((state) => ({
// ...state,
// placeholder: "",
// position: undefined,
// latInput: "",
// lngInput: "",
// }));
// }
}, [props.location]); }, [props.location]);
useEffect(() => { useEffect(() => {