From a67f5f28f9bad98e362ab9b9633209d54b0e5fca Mon Sep 17 00:00:00 2001 From: ErikSin <67773827+ErikSin@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:12:06 -0700 Subject: [PATCH 01/12] chore: created screen --- .../YourTeam/UnableToCancelInvite.tsx | 72 +++++++++++++++++++ 1 file changed, 72 insertions(+) create mode 100644 src/frontend/screens/Settings/ProjectSettings/YourTeam/UnableToCancelInvite.tsx diff --git a/src/frontend/screens/Settings/ProjectSettings/YourTeam/UnableToCancelInvite.tsx b/src/frontend/screens/Settings/ProjectSettings/YourTeam/UnableToCancelInvite.tsx new file mode 100644 index 000000000..a9462a386 --- /dev/null +++ b/src/frontend/screens/Settings/ProjectSettings/YourTeam/UnableToCancelInvite.tsx @@ -0,0 +1,72 @@ +import * as React from 'react'; +import {StyleSheet, View} from 'react-native'; +import {Button} from '../../../../sharedComponents/Button'; +import ErrorIcon from '../../../../images/Error.svg'; +import {defineMessages, useIntl} from 'react-intl'; +import {Text} from '../../../../sharedComponents/Text'; +import {DeviceNameWithIcon} from '../../../../sharedComponents/DeviceNameWithIcon'; +import {RoleWithIcon} from '../../../../sharedComponents/RoleWithIcon'; +import { + COORDINATOR_ROLE_ID, + NativeRootNavigationProps, +} from '../../../../sharedTypes'; + +const m = defineMessages({ + unableToCancel: { + id: 'screens.Settings.YourTeam.unableToCancel', + defaultMessage: 'Unable to Cancel Invitation', + }, + deviceHasJoined: { + id: 'screens.Settings.YourTeam.deviceHasJoined', + defaultMessage: 'Device Has Joined {projectName}', + }, + close: { + id: 'screens.Settings.YourTeam.close', + defaultMessage: 'Close', + }, +}); + +export const UnableToCancelInvite = ({ + navigation, + route, +}: NativeRootNavigationProps<'UnableToCancelInvite'>) => { + const {formatMessage} = useIntl(); + const {role, projectName, ...deviceInfo} = route.params; + + return ( + + + + + {formatMessage(m.unableToCancel)} + + + {formatMessage(m.deviceHasJoined, {projectName: projectName})} + + + + + + + ); +}; + +const styles = StyleSheet.create({ + container: { + padding: 20, + paddingTop: 80, + alignItems: 'center', + justifyContent: 'space-between', + flex: 1, + }, +}); From 9e039450f6e0a8faa4fbc364c0e7640c4c4f4bfe Mon Sep 17 00:00:00 2001 From: ErikSin <67773827+ErikSin@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:12:37 -0700 Subject: [PATCH 02/12] chore: translations --- messages/en.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/messages/en.json b/messages/en.json index 6f74e89b9..29ebb3c20 100644 --- a/messages/en.json +++ b/messages/en.json @@ -564,14 +564,14 @@ "screens.Settings.CreateOrJoinProject.whatIsAProject": { "message": "What is a Project" }, - "screens.Settings.YourTeam.InviteDeclined": { - "message": "Invitation Declined" - }, "screens.Settings.YourTeam.close": { "message": "Close" }, - "screens.Settings.YourTeam.inviteDeclinedDes": { - "message": "This device has declined your invitation. They have not joined the project." + "screens.Settings.YourTeam.deviceHasJoined": { + "message": "Device Has Joined {projectName}" + }, + "screens.Settings.YourTeam.unableToCancel": { + "message": "Unable to Cancel Invitation" }, "screens.Settings.aboutMapeo": { "description": "Primary text for 'About Mapeo' link (version info)", From 844a199c890cb0b5ff1dd7f65fd082c00928f6b3 Mon Sep 17 00:00:00 2001 From: ErikSin <67773827+ErikSin@users.noreply.github.com> Date: Fri, 19 Apr 2024 11:07:12 -0700 Subject: [PATCH 03/12] chore:update invite with tanstack --- .../Navigation/ScreenGroups/AppScreens.tsx | 4 +- src/frontend/hooks/server/invites.ts | 19 ++++++++ .../YourTeam/ReviewAndInvite/index.tsx | 47 +++++++++---------- 3 files changed, 43 insertions(+), 27 deletions(-) diff --git a/src/frontend/Navigation/ScreenGroups/AppScreens.tsx b/src/frontend/Navigation/ScreenGroups/AppScreens.tsx index 9271af9d7..5e32a2ea9 100644 --- a/src/frontend/Navigation/ScreenGroups/AppScreens.tsx +++ b/src/frontend/Navigation/ScreenGroups/AppScreens.tsx @@ -196,9 +196,9 @@ export const createDefaultScreenGroup = ( options={props => { const observationId = props.route.params?.observationId; return { - headerLeft: headerProp => ( + headerLeft: headerProps => ( ), diff --git a/src/frontend/hooks/server/invites.ts b/src/frontend/hooks/server/invites.ts index 6394a1265..e1e9a0f35 100644 --- a/src/frontend/hooks/server/invites.ts +++ b/src/frontend/hooks/server/invites.ts @@ -4,6 +4,7 @@ import { useSuspenseQuery, } from '@tanstack/react-query'; import {useApi} from '../../contexts/ApiContext'; +import {useProject} from './projects'; export const INVITE_KEY = 'pending_invites'; @@ -61,3 +62,21 @@ export function useClearAllPendingInvites() { }, }); } + +export function useSendInvite() { + const queryClient = useQueryClient(); + const project = useProject(); + type InviteParams = Parameters; + return useMutation({ + mutationFn: ({ + deviceId, + role, + }: { + deviceId: InviteParams[0]; + role: InviteParams[1]; + }) => project.$member.invite(deviceId, role), + onSuccess: () => { + queryClient.invalidateQueries({queryKey: [INVITE_KEY]}); + }, + }); +} diff --git a/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx index ed0dca8c6..de553107f 100644 --- a/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx +++ b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx @@ -2,11 +2,10 @@ import * as React from 'react'; import {NativeNavigationComponent} from '../../../../../sharedTypes'; import {defineMessages} from 'react-intl'; import {useBottomSheetModal} from '../../../../../sharedComponents/BottomSheetModal'; -import {useQueryClient} from '@tanstack/react-query'; -import {useProject} from '../../../../../hooks/server/projects'; import {ErrorModal} from '../../../../../sharedComponents/ErrorModal'; import {ReviewInvitation} from './ReviewInvitation'; import {WaitingForInviteAccept} from './WaitingForInviteAccept'; +import {useSendInvite} from '../../../../../hooks/server/invites'; const m = defineMessages({ title: { @@ -19,41 +18,39 @@ export const ReviewAndInvite: NativeNavigationComponent<'ReviewAndInvite'> = ({ route, navigation, }) => { - const [inviteStatus, setInviteStatus] = React.useState< - 'reviewing' | 'waiting' - >('reviewing'); const {role, deviceId, deviceType, name} = route.params; const {openSheet, sheetRef, closeSheet, isOpen} = useBottomSheetModal({ openOnMount: false, }); - const project = useProject(); - const queryClient = useQueryClient(); + const sendInviteMutation = useSendInvite(); function sendInvite() { - setInviteStatus('waiting'); - project.$member - .invite(deviceId, {roleId: role}) - .then(val => { - if (val === 'ACCEPT') { - queryClient.invalidateQueries({queryKey: ['projectMembers']}); - navigation.navigate('InviteAccepted', route.params); - return; - } + sendInviteMutation.mutate( + // @ts-ignore + {deviceId, role: {roleId: role}}, + { + onSuccess: val => { + if (val === 'ACCEPT') { + navigation.navigate('InviteAccepted', route.params); + return; + } - if (val === 'REJECT') { - navigation.navigate('InviteDeclined', route.params); - return; - } - }) - .catch(() => { - openSheet(); - }); + if (val === 'REJECT') { + navigation.navigate('InviteDeclined', route.params); + return; + } + }, + onError: () => { + openSheet(); + }, + }, + ); } return ( - {inviteStatus === 'reviewing' ? ( + {sendInviteMutation.isIdle ? ( Date: Fri, 19 Apr 2024 12:21:18 -0700 Subject: [PATCH 04/12] chore: added navigation to unable to invite screen --- src/frontend/hooks/server/invites.ts | 12 ++++++++++ .../UnableToCancelInvite.tsx | 22 ++++++++++-------- .../WaitingForInviteAccept.tsx | 13 +++++------ .../YourTeam/ReviewAndInvite/index.tsx | 23 +++++++++++++++++-- 4 files changed, 52 insertions(+), 18 deletions(-) rename src/frontend/screens/Settings/ProjectSettings/YourTeam/{ => ReviewAndInvite}/UnableToCancelInvite.tsx (71%) diff --git a/src/frontend/hooks/server/invites.ts b/src/frontend/hooks/server/invites.ts index e1e9a0f35..0750c87e4 100644 --- a/src/frontend/hooks/server/invites.ts +++ b/src/frontend/hooks/server/invites.ts @@ -80,3 +80,15 @@ export function useSendInvite() { }, }); } + +export function useRequestCancelInvite() { + const queryClient = useQueryClient(); + const project = useProject(); + return useMutation({ + mutationFn: (deviceId: string) => + project.$member.requestCancelInvite(deviceId), + onSuccess: () => { + queryClient.invalidateQueries({queryKey: [INVITE_KEY]}); + }, + }); +} diff --git a/src/frontend/screens/Settings/ProjectSettings/YourTeam/UnableToCancelInvite.tsx b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/UnableToCancelInvite.tsx similarity index 71% rename from src/frontend/screens/Settings/ProjectSettings/YourTeam/UnableToCancelInvite.tsx rename to src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/UnableToCancelInvite.tsx index a9462a386..8e887ead5 100644 --- a/src/frontend/screens/Settings/ProjectSettings/YourTeam/UnableToCancelInvite.tsx +++ b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/UnableToCancelInvite.tsx @@ -1,15 +1,16 @@ import * as React from 'react'; import {StyleSheet, View} from 'react-native'; -import {Button} from '../../../../sharedComponents/Button'; +import {Button} from '../../../../../sharedComponents/Button'; import ErrorIcon from '../../../../images/Error.svg'; import {defineMessages, useIntl} from 'react-intl'; -import {Text} from '../../../../sharedComponents/Text'; -import {DeviceNameWithIcon} from '../../../../sharedComponents/DeviceNameWithIcon'; -import {RoleWithIcon} from '../../../../sharedComponents/RoleWithIcon'; +import {Text} from '../../../../../sharedComponents/Text'; +import {DeviceNameWithIcon} from '../../../../../sharedComponents/DeviceNameWithIcon'; +import {RoleWithIcon} from '../../../../../sharedComponents/RoleWithIcon'; import { COORDINATOR_ROLE_ID, NativeRootNavigationProps, -} from '../../../../sharedTypes'; +} from '../../../../../sharedTypes'; +import {useProjectSettings} from '../../../../../hooks/server/projects'; const m = defineMessages({ unableToCancel: { @@ -31,7 +32,8 @@ export const UnableToCancelInvite = ({ route, }: NativeRootNavigationProps<'UnableToCancelInvite'>) => { const {formatMessage} = useIntl(); - const {role, projectName, ...deviceInfo} = route.params; + const {role, ...deviceInfo} = route.params; + const {data} = useProjectSettings(); return ( @@ -40,9 +42,11 @@ export const UnableToCancelInvite = ({ {formatMessage(m.unableToCancel)} - - {formatMessage(m.deviceHasJoined, {projectName: projectName})} - + {data?.name && ( + + {formatMessage(m.deviceHasJoined, {projectName: data.name})} + + )} { +export const WaitingForInviteAccept = ({ + cancelInvite, +}: { + cancelInvite: () => void; +}) => { const {formatMessage: t} = useIntl(); const [time, setTime] = React.useState(0); const navigation = useNavigationFromRoot(); @@ -53,12 +57,7 @@ export const WaitingForInviteAccept = () => { {t(m.waitingMessage)} {t(m.timerMessage, {seconds: time})} - { - navigation.navigate('YourTeam'); - }} - /> + ); }; diff --git a/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx index de553107f..15a32dd0f 100644 --- a/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx +++ b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx @@ -5,7 +5,10 @@ import {useBottomSheetModal} from '../../../../../sharedComponents/BottomSheetMo import {ErrorModal} from '../../../../../sharedComponents/ErrorModal'; import {ReviewInvitation} from './ReviewInvitation'; import {WaitingForInviteAccept} from './WaitingForInviteAccept'; -import {useSendInvite} from '../../../../../hooks/server/invites'; +import { + useRequestCancelInvite, + useSendInvite, +} from '../../../../../hooks/server/invites'; const m = defineMessages({ title: { @@ -24,6 +27,7 @@ export const ReviewAndInvite: NativeNavigationComponent<'ReviewAndInvite'> = ({ openOnMount: false, }); const sendInviteMutation = useSendInvite(); + const requestCancelInviteMutation = useRequestCancelInvite(); function sendInvite() { sendInviteMutation.mutate( @@ -31,6 +35,10 @@ export const ReviewAndInvite: NativeNavigationComponent<'ReviewAndInvite'> = ({ {deviceId, role: {roleId: role}}, { onSuccess: val => { + if (val === 'ACCEPT' && requestCancelInviteMutation.isPending) { + navigation.navigate('UnableToCancelInvite', {...route.params}); + return; + } if (val === 'ACCEPT') { navigation.navigate('InviteAccepted', route.params); return; @@ -48,6 +56,17 @@ export const ReviewAndInvite: NativeNavigationComponent<'ReviewAndInvite'> = ({ ); } + function cancelInvite() { + requestCancelInviteMutation.mutate(deviceId, { + onSuccess: () => { + navigation.navigate('YourTeam'); + }, + onError: () => { + openSheet(); + }, + }); + } + return ( {sendInviteMutation.isIdle ? ( @@ -59,7 +78,7 @@ export const ReviewAndInvite: NativeNavigationComponent<'ReviewAndInvite'> = ({ role={role} /> ) : ( - + )} Date: Fri, 19 Apr 2024 12:29:52 -0700 Subject: [PATCH 05/12] chore: add notes --- .../Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx index 15a32dd0f..18f883260 100644 --- a/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx +++ b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx @@ -35,6 +35,7 @@ export const ReviewAndInvite: NativeNavigationComponent<'ReviewAndInvite'> = ({ {deviceId, role: {roleId: role}}, { onSuccess: val => { + // If user has attempted to cancel and invite, but an invite has been accepted, let user know their cancellation was unsuccessfuly if (val === 'ACCEPT' && requestCancelInviteMutation.isPending) { navigation.navigate('UnableToCancelInvite', {...route.params}); return; From 9a61da12a2320c87e19f3dd634621f933b6000e9 Mon Sep 17 00:00:00 2001 From: ErikSin <67773827+ErikSin@users.noreply.github.com> Date: Mon, 22 Apr 2024 10:58:21 -0700 Subject: [PATCH 06/12] chore: added missing useEffect dependency --- src/frontend/contexts/ProjectContext.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/contexts/ProjectContext.tsx b/src/frontend/contexts/ProjectContext.tsx index 4550c6090..09a2d3e63 100644 --- a/src/frontend/contexts/ProjectContext.tsx +++ b/src/frontend/contexts/ProjectContext.tsx @@ -67,7 +67,7 @@ export const ActiveProjectProvider = ({ return () => { cancelled = true; }; - }, [activeProjectId, setActiveProjectId]); + }, [activeProjectId, setActiveProjectId, mapeoApi]); if (!activeProject) { return ; From 9231295f192cf167e75409d461c6f54372dbc53f Mon Sep 17 00:00:00 2001 From: ErikSin <67773827+ErikSin@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:03:36 -0700 Subject: [PATCH 07/12] chore: switch project on accept of invite --- src/frontend/hooks/server/invites.ts | 16 +++++++++++++--- src/frontend/hooks/server/projects.ts | 4 +++- src/frontend/hooks/useProjectInvite.ts | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/src/frontend/hooks/server/invites.ts b/src/frontend/hooks/server/invites.ts index 0750c87e4..bdde81f98 100644 --- a/src/frontend/hooks/server/invites.ts +++ b/src/frontend/hooks/server/invites.ts @@ -4,7 +4,7 @@ import { useSuspenseQuery, } from '@tanstack/react-query'; import {useApi} from '../../contexts/ApiContext'; -import {useProject} from './projects'; +import {PROJECTS_KEY, useProject, useUpdateActiveProjectId} from './projects'; export const INVITE_KEY = 'pending_invites'; @@ -18,16 +18,26 @@ export function usePendingInvites() { }); } -export function useAcceptInvite() { +export function useAcceptInvite(projectId?: string) { const mapeoApi = useApi(); const queryClient = useQueryClient(); + const switchActiveProject = useUpdateActiveProjectId(); + console.log({projectId}); return useMutation({ mutationFn: async ({inviteId}: {inviteId: string}) => { if (!inviteId) return; mapeoApi.invite.accept({inviteId}); }, onSuccess: () => { - queryClient.invalidateQueries({queryKey: [INVITE_KEY]}); + setTimeout(() => { + queryClient + .invalidateQueries({queryKey: [INVITE_KEY, PROJECTS_KEY]}) + .then(() => { + if (projectId) { + switchActiveProject(projectId); + } + }); + }, 5000); }, }); } diff --git a/src/frontend/hooks/server/projects.ts b/src/frontend/hooks/server/projects.ts index e54f721f6..7f5c39e90 100644 --- a/src/frontend/hooks/server/projects.ts +++ b/src/frontend/hooks/server/projects.ts @@ -2,6 +2,8 @@ import {useMutation, useQuery, useQueryClient} from '@tanstack/react-query'; import {useApi} from '../../contexts/ApiContext'; import {useActiveProjectContext} from '../../contexts/ProjectContext'; +export const PROJECTS_KEY = 'all_projects'; + export function useUpdateActiveProjectId() { const projectContext = useActiveProjectContext(); return projectContext.switchProject; @@ -17,7 +19,7 @@ export function useAllProjects() { return useQuery({ queryFn: async () => await api.listProjects(), - queryKey: ['projects'], + queryKey: [PROJECTS_KEY], }); } diff --git a/src/frontend/hooks/useProjectInvite.ts b/src/frontend/hooks/useProjectInvite.ts index db0c74e20..67da14ec0 100644 --- a/src/frontend/hooks/useProjectInvite.ts +++ b/src/frontend/hooks/useProjectInvite.ts @@ -9,7 +9,7 @@ export function useProjectInvite() { const invites = usePendingInvites().data; // this will eventually sort invite by date const invite = invites[0]; - const acceptMutation = useAcceptInvite(); + const acceptMutation = useAcceptInvite(invite?.projectPublicId); const rejectMutation = useRejectInvite(); const clearAllInvites = useClearAllPendingInvites(); From 8d0119b1a30173ecf8f599bf20c803b43636dfa6 Mon Sep 17 00:00:00 2001 From: ErikSin <67773827+ErikSin@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:05:06 -0700 Subject: [PATCH 08/12] chore: added screen to navigation --- src/frontend/Navigation/ScreenGroups/AppScreens.tsx | 7 +++++++ .../YourTeam/ReviewAndInvite/UnableToCancelInvite.tsx | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/frontend/Navigation/ScreenGroups/AppScreens.tsx b/src/frontend/Navigation/ScreenGroups/AppScreens.tsx index 5e32a2ea9..3b4628159 100644 --- a/src/frontend/Navigation/ScreenGroups/AppScreens.tsx +++ b/src/frontend/Navigation/ScreenGroups/AppScreens.tsx @@ -54,6 +54,7 @@ import {useLocation} from '../../hooks/useLocation'; import {useLocationProviderStatus} from '../../hooks/useLocationProviderStatus'; import {getLocationStatus} from '../../lib/utils'; import {InviteDeclined} from '../../screens/Settings/ProjectSettings/YourTeam/InviteDeclined'; +import {UnableToCancelInvite} from '../../screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/UnableToCancelInvite'; export type HomeTabsList = { Map: undefined; @@ -127,6 +128,7 @@ export type AppList = { ReviewAndInvite: InviteProps; InviteAccepted: InviteProps; InviteDeclined: InviteProps; + UnableToCancelInvite: InviteProps; DeviceNameDisplay: undefined; DeviceNameEdit: undefined; }; @@ -340,5 +342,10 @@ export const createDefaultScreenGroup = ( component={InviteDeclined} options={{headerShown: false}} /> + ); diff --git a/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/UnableToCancelInvite.tsx b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/UnableToCancelInvite.tsx index 8e887ead5..e3531c1ac 100644 --- a/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/UnableToCancelInvite.tsx +++ b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/UnableToCancelInvite.tsx @@ -1,7 +1,7 @@ import * as React from 'react'; import {StyleSheet, View} from 'react-native'; import {Button} from '../../../../../sharedComponents/Button'; -import ErrorIcon from '../../../../images/Error.svg'; +import ErrorIcon from '../../../../../images/Error.svg'; import {defineMessages, useIntl} from 'react-intl'; import {Text} from '../../../../../sharedComponents/Text'; import {DeviceNameWithIcon} from '../../../../../sharedComponents/DeviceNameWithIcon'; @@ -39,7 +39,7 @@ export const UnableToCancelInvite = ({ - + {formatMessage(m.unableToCancel)} {data?.name && ( From 11cca63a263e302dcd00740e9b9442e5b72efafc Mon Sep 17 00:00:00 2001 From: ErikSin <67773827+ErikSin@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:12:09 -0700 Subject: [PATCH 09/12] core:remove unneccessary plural --- src/frontend/Navigation/ScreenGroups/AppScreens.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/Navigation/ScreenGroups/AppScreens.tsx b/src/frontend/Navigation/ScreenGroups/AppScreens.tsx index 3b4628159..919b29e19 100644 --- a/src/frontend/Navigation/ScreenGroups/AppScreens.tsx +++ b/src/frontend/Navigation/ScreenGroups/AppScreens.tsx @@ -198,9 +198,9 @@ export const createDefaultScreenGroup = ( options={props => { const observationId = props.route.params?.observationId; return { - headerLeft: headerProps => ( + headerLeft: headerProp => ( ), From c6448dd6117d4a2c9f703449d0865e4caba9caa2 Mon Sep 17 00:00:00 2001 From: ErikSin <67773827+ErikSin@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:12:33 -0700 Subject: [PATCH 10/12] chore: translations --- messages/en.json | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/messages/en.json b/messages/en.json index 29ebb3c20..8534d05ca 100644 --- a/messages/en.json +++ b/messages/en.json @@ -564,12 +564,18 @@ "screens.Settings.CreateOrJoinProject.whatIsAProject": { "message": "What is a Project" }, + "screens.Settings.YourTeam.InviteDeclined": { + "message": "Invitation Declined" + }, "screens.Settings.YourTeam.close": { "message": "Close" }, "screens.Settings.YourTeam.deviceHasJoined": { "message": "Device Has Joined {projectName}" }, + "screens.Settings.YourTeam.inviteDeclinedDes": { + "message": "This device has declined your invitation. They have not joined the project." + }, "screens.Settings.YourTeam.unableToCancel": { "message": "Unable to Cancel Invitation" }, From 294d3980c95103d48777d19507675c82d31cf789 Mon Sep 17 00:00:00 2001 From: ErikSin <67773827+ErikSin@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:15:12 -0700 Subject: [PATCH 11/12] chore: remove unecessary console log --- src/frontend/hooks/server/invites.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/frontend/hooks/server/invites.ts b/src/frontend/hooks/server/invites.ts index bdde81f98..4bd29719a 100644 --- a/src/frontend/hooks/server/invites.ts +++ b/src/frontend/hooks/server/invites.ts @@ -22,7 +22,7 @@ export function useAcceptInvite(projectId?: string) { const mapeoApi = useApi(); const queryClient = useQueryClient(); const switchActiveProject = useUpdateActiveProjectId(); - console.log({projectId}); + return useMutation({ mutationFn: async ({inviteId}: {inviteId: string}) => { if (!inviteId) return; From 81b8932c22db6ebb6e0b625cb63b0a0f2d83b3e0 Mon Sep 17 00:00:00 2001 From: ErikSin <67773827+ErikSin@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:42:40 -0700 Subject: [PATCH 12/12] chore: pr rfixes --- src/frontend/hooks/server/invites.ts | 1 + .../ProjectSettings/YourTeam/ReviewAndInvite/index.tsx | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/frontend/hooks/server/invites.ts b/src/frontend/hooks/server/invites.ts index 4bd29719a..9f73f7d8f 100644 --- a/src/frontend/hooks/server/invites.ts +++ b/src/frontend/hooks/server/invites.ts @@ -29,6 +29,7 @@ export function useAcceptInvite(projectId?: string) { mapeoApi.invite.accept({inviteId}); }, onSuccess: () => { + // This is a workaround. There is a race condition where the project in not available when the invite is accepted. This is temporary and is currently being worked on. setTimeout(() => { queryClient .invalidateQueries({queryKey: [INVITE_KEY, PROJECTS_KEY]}) diff --git a/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx index 18f883260..0a4230183 100644 --- a/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx +++ b/src/frontend/screens/Settings/ProjectSettings/YourTeam/ReviewAndInvite/index.tsx @@ -31,11 +31,10 @@ export const ReviewAndInvite: NativeNavigationComponent<'ReviewAndInvite'> = ({ function sendInvite() { sendInviteMutation.mutate( - // @ts-ignore {deviceId, role: {roleId: role}}, { onSuccess: val => { - // If user has attempted to cancel and invite, but an invite has been accepted, let user know their cancellation was unsuccessfuly + // If user has attempted to cancel an invite, but an invite has already been accepted, let user know their cancellation was unsuccessful if (val === 'ACCEPT' && requestCancelInviteMutation.isPending) { navigation.navigate('UnableToCancelInvite', {...route.params}); return;