From 874882678fcabc3a0656c3b3e5c01af20cab71de Mon Sep 17 00:00:00 2001 From: dukenv0307 Date: Wed, 10 Apr 2024 11:37:47 +0700 Subject: [PATCH] move welcomeSubject to invite message page --- src/languages/en.ts | 2 -- src/languages/es.ts | 2 -- src/languages/types.ts | 2 +- src/pages/workspace/WorkspaceInviteMessagePage.tsx | 14 ++++---------- src/types/onyx/Policy.ts | 5 ----- 5 files changed, 5 insertions(+), 20 deletions(-) diff --git a/src/languages/en.ts b/src/languages/en.ts index 1c2ffee04e89..3b670f7b6ebc 100755 --- a/src/languages/en.ts +++ b/src/languages/en.ts @@ -2153,8 +2153,6 @@ export default { personalMessagePrompt: 'Message', genericFailureMessage: 'An error occurred inviting the user to the workspace, please try again.', inviteNoMembersError: 'Please select at least one member to invite', - welcomeNote: ({inviterDisplayName, workspaceName, inviteMessage}: WelcomeNoteParams) => - `# ${inviterDisplayName} invited you to ${workspaceName || 'a workspace'}\n\n${inviteMessage}`, }, distanceRates: { oopsNotSoFast: 'Oops! Not so fast...', diff --git a/src/languages/es.ts b/src/languages/es.ts index 7db049641973..5027174b2922 100644 --- a/src/languages/es.ts +++ b/src/languages/es.ts @@ -2181,8 +2181,6 @@ export default { personalMessagePrompt: 'Mensaje', inviteNoMembersError: 'Por favor, selecciona al menos un miembro a invitar', genericFailureMessage: 'Se produjo un error al invitar al usuario al espacio de trabajo. Vuelva a intentarlo..', - welcomeNote: ({inviterDisplayName, workspaceName, inviteMessage}: WelcomeNoteParams) => - `# ${inviterDisplayName} invited you to ${workspaceName || 'a workspace'}\n\n${inviteMessage}`, }, distanceRates: { oopsNotSoFast: 'Ups! No tan rĂ¡pido...', diff --git a/src/languages/types.ts b/src/languages/types.ts index f64291ff6396..c365363f84af 100644 --- a/src/languages/types.ts +++ b/src/languages/types.ts @@ -185,7 +185,7 @@ type UserIsAlreadyMemberParams = {login: string; name: string}; type GoToRoomParams = {roomName: string}; -type WelcomeNoteParams = {workspaceName: string; inviterDisplayName?: string; inviteMessage?: string}; +type WelcomeNoteParams = {workspaceName: string}; type RoomNameReservedErrorParams = {reservedName: string}; diff --git a/src/pages/workspace/WorkspaceInviteMessagePage.tsx b/src/pages/workspace/WorkspaceInviteMessagePage.tsx index 8655c67254c5..01921739eacc 100644 --- a/src/pages/workspace/WorkspaceInviteMessagePage.tsx +++ b/src/pages/workspace/WorkspaceInviteMessagePage.tsx @@ -1,7 +1,7 @@ import type {StackScreenProps} from '@react-navigation/stack'; import ExpensiMark from 'expensify-common/lib/ExpensiMark'; import lodashDebounce from 'lodash/debounce'; -import React, {useEffect, useState} from 'react'; +import React, {useEffect, useMemo, useState} from 'react'; import {Keyboard, View} from 'react-native'; import {withOnyx} from 'react-native-onyx'; import type {OnyxEntry} from 'react-native-onyx'; @@ -73,6 +73,8 @@ function WorkspaceInviteMessagePage({ const {inputCallbackRef} = useAutoFocusInput(); + const welcomeNoteSubject = useMemo(() => `# ${currentUserPersonalDetails?.displayName ?? ''} invited you to ${policy?.name ?? 'a workspace'}`, [policy?.name, currentUserPersonalDetails?.displayName]); + const getDefaultWelcomeNote = () => // workspaceInviteMessageDraft can be an empty string // eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing @@ -102,15 +104,7 @@ function WorkspaceInviteMessagePage({ const sendInvitation = () => { Keyboard.dismiss(); // Please see https://github.com/Expensify/App/blob/main/README.md#Security for more details - Policy.addMembersToWorkspace( - invitedEmailsToAccountIDsDraft ?? {}, - translate('workspace.inviteMessage.welcomeNote', { - workspaceName: policy?.name ?? '', - inviterDisplayName: currentUserPersonalDetails?.displayName ?? '', - inviteMessage: welcomeNote ?? '', - }), - route.params.policyID, - ); + Policy.addMembersToWorkspace(invitedEmailsToAccountIDsDraft ?? {}, `${welcomeNoteSubject}\n\n${welcomeNote}`, route.params.policyID); debouncedSaveDraft(null); SearchInputManager.searchInput = ''; // Pop the invite message page before navigating to the members page. diff --git a/src/types/onyx/Policy.ts b/src/types/onyx/Policy.ts index 0ddd11621c04..a21e98f4bfec 100644 --- a/src/types/onyx/Policy.ts +++ b/src/types/onyx/Policy.ts @@ -437,11 +437,6 @@ type Policy = OnyxCommon.OnyxValueWithOfflineFeedback< /** Indicates if the Policy ownership change is failed */ isChangeOwnerFailed?: boolean; - - /** The welcomeNote of user */ - welcomeNote?: { - user: string; - }; } & Partial, 'generalSettings' | 'addWorkspaceRoom' | keyof ACHAccount >;