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 || 0, props.location?.longitude || 0),
position: new LatLng(props.location.latitude, props.location.longitude), latInput: String(props.location?.latitude) || "",
latInput: String(props.location.latitude), lngInput: String(props.location?.longitude) || "",
lngInput: String(props.location.longitude), }));
})); // if (props.location) {
} else { // setState((state) => ({
setState((state) => ({ // ...state,
...state, // placeholder: props.location.placeholder || "",
placeholder: "", // position: new LatLng(props.location.latitude, props.location.longitude),
position: undefined, // latInput: String(props.location.latitude),
latInput: "", // lngInput: String(props.location.longitude),
lngInput: "", // }));
})); // } else {
} // setState((state) => ({
// ...state,
// placeholder: "",
// position: undefined,
// latInput: "",
// lngInput: "",
// }));
// }
}, [props.location]); }, [props.location]);
useEffect(() => { useEffect(() => {