diff --git a/app/(tabs)/actions/index.tsx b/app/(tabs)/actions/index.tsx index 710cd3bf3..dd7cfa53d 100644 --- a/app/(tabs)/actions/index.tsx +++ b/app/(tabs)/actions/index.tsx @@ -5,11 +5,12 @@ import ActionForm from '@/components/ActionForm/ActionForm' import AddressAutocomplete from '@/components/AddressAutoComplete/AddressAutocomplete' import Select from '@/components/base/Select/Select' import Text from '@/components/base/Text' -import BoundarySuspenseWrapper from '@/components/BoundarySuspenseWrapper' +import BoundarySuspenseWrapper, { DefaultErrorFallback } from '@/components/BoundarySuspenseWrapper' import Button from '@/components/Button' import GradientButton from '@/components/Buttons/GradientButton' import { ActionCard, ActionVoxCardProps, SubscribeButton } from '@/components/Cards' import EmptyState from '@/components/EmptyStates/EmptyEvent/EmptyEvent' +import PageLayout from '@/components/layouts/PageLayout/PageLayout' import MapboxGl from '@/components/Mapbox/Mapbox' import MobileWallLayout from '@/components/MobileWallLayout/MobileWallLayout' import ModalOrPageBase from '@/components/ModalOrPageBase/ModalOrPageBase' @@ -22,8 +23,9 @@ import { useSession } from '@/ctx/SessionProvider' import { Action, ActionStatus, ActionType, isFullAction, RestAction, RestActionAuthor, RestActionParticipant } from '@/data/restObjects/RestActions' import { QUERY_KEY_PAGINATED_ACTIONS, useAction, usePaginatedActions } from '@/hooks/useActions/useActions' import { useLazyRef } from '@/hooks/useLazyRef' -import { QUERY_KEY_LOCATION, useLocation, useLocationPermission } from '@/hooks/useLocation' +import { LocationPermissionError, QUERY_KEY_LOCATION, useLocation, useLocationPermission } from '@/hooks/useLocation' import MapButton from '@/screens/doorToDoor/DoorToDoorMapButton' +import LocationAuthorization from '@/screens/doorToDoor/LocationAuthorization' import { useOnFocus } from '@/utils/useOnFocus.hook' import { CameraStop } from '@rnmapbox/maps' import { OnPressEvent } from '@rnmapbox/maps/src/types/OnPressEvent' @@ -75,7 +77,18 @@ export default function ActionsScreen() { } return ( - + { + if (props.error instanceof LocationPermissionError) { + return props.resetErrorBoundary()} /> + } + return ( + + + + ) + }} + > ) diff --git a/src/components/BoundarySuspenseWrapper.tsx b/src/components/BoundarySuspenseWrapper.tsx index 51fdf55da..2b6cb3a13 100644 --- a/src/components/BoundarySuspenseWrapper.tsx +++ b/src/components/BoundarySuspenseWrapper.tsx @@ -1,5 +1,4 @@ import { Suspense } from 'react' -import { err } from 'react-native-svg' import Button from '@/components/Button' import PageLayout from '@/components/layouts/PageLayout/PageLayout' import { QueryErrorResetBoundary } from '@tanstack/react-query' @@ -15,7 +14,7 @@ type BoundarySuspenseWrapperProps = { errorChildren?: (err: FallbackProps) => React.ReactNode } -const DefaultErrorFallback = ({ resetErrorBoundary }: FallbackProps) => ( +export const DefaultErrorFallback = ({ resetErrorBoundary }: FallbackProps) => ( <> @@ -34,9 +33,15 @@ const BoundarySuspenseWrapper = (props: BoundarySuspenseWrapperProps) => ( {({ reset }) => ( ( - {props.errorChildren ? props.errorChildren(EBprops) : } - )} + fallbackRender={(EBprops) => + props.errorChildren ? ( + props.errorChildren(EBprops) + ) : ( + + + + ) + } > ({ { setOpen(false) + if (search) Keyboard.dismiss() onBlur?.() }} style={{ padding: 5 }} diff --git a/src/hooks/useLocation.tsx b/src/hooks/useLocation.tsx index d378c2589..e92cbab8c 100644 --- a/src/hooks/useLocation.tsx +++ b/src/hooks/useLocation.tsx @@ -1,7 +1,7 @@ import { useSuspenseQuery } from '@tanstack/react-query' import * as Geolocation from 'expo-location' -class LocationPermissionError extends Error { +export class LocationPermissionError extends Error { constructor() { super('Location permission denied') this.name = 'LocationPermissionError'