Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update welcome note #38023

Merged
merged 19 commits into from
Apr 15, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1906,8 +1906,14 @@ 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: ({workspaceName}: WelcomeNoteParams) =>
`You have been invited to ${workspaceName || 'a workspace'}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.`,
welcomeNote: ({workspaceName, senderDisplayName, senderLogin, workspaceDescription, workspaceLink}: WelcomeNoteParams) => `${
senderDisplayName ? `#${senderDisplayName} (${senderLogin}) invited you to Expensify` : `#${senderLogin} invited you to Expensify`
}\nHi there -\n\nTo join "${workspaceName}", [click here](${workspaceLink}) to start tracking your expenses!\n\nThey also added the message:\nYou have been invited to ${
workspaceName || 'a workspace'
}! Download the Expensify mobile app at use.expensify.com/download to start tracking your expenses.\n\n${
workspaceDescription ? `Additionally, here is the workspace description:\n ${workspaceDescription}` : ''
}
`,
},
editor: {
descriptionInputLabel: 'Description',
Expand Down
2 changes: 1 addition & 1 deletion src/languages/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ type UserIsAlreadyMemberParams = {login: string; name: string};

type GoToRoomParams = {roomName: string};

type WelcomeNoteParams = {workspaceName: string};
type WelcomeNoteParams = {workspaceName: string; senderDisplayName: string; senderLogin: string; workspaceDescription: string; workspaceLink: string};

type RoomNameReservedErrorParams = {reservedName: string};

Expand Down
42 changes: 30 additions & 12 deletions src/pages/workspace/WorkspaceInviteMessagePage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
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 {Keyboard, View} from 'react-native';
Expand All @@ -16,6 +17,8 @@ import type {AnimatedTextInputRef} from '@components/RNTextInput';
import ScreenWrapper from '@components/ScreenWrapper';
import Text from '@components/Text';
import TextInput from '@components/TextInput';
import type {WithCurrentUserPersonalDetailsProps} from '@components/withCurrentUserPersonalDetails';
import withCurrentUserPersonalDetails from '@components/withCurrentUserPersonalDetails';
import useAutoFocusInput from '@hooks/useAutoFocusInput';
import useLocalize from '@hooks/useLocalize';
import useThemeStyles from '@hooks/useThemeStyles';
Expand Down Expand Up @@ -50,11 +53,20 @@ type WorkspaceInviteMessagePageOnyxProps = {

type WorkspaceInviteMessagePageProps = WithPolicyAndFullscreenLoadingProps &
WorkspaceInviteMessagePageOnyxProps &
WithCurrentUserPersonalDetailsProps &
StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.INVITE_MESSAGE>;

function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsToAccountIDsDraft, policy, route, allPersonalDetails}: WorkspaceInviteMessagePageProps) {
function WorkspaceInviteMessagePage({
workspaceInviteMessageDraft,
invitedEmailsToAccountIDsDraft,
policy,
route,
allPersonalDetails,
currentUserPersonalDetails,
}: WorkspaceInviteMessagePageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const parser = new ExpensiMark();

const [welcomeNote, setWelcomeNote] = useState<string>();

Expand All @@ -66,6 +78,10 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT
workspaceInviteMessageDraft ||
translate('workspace.inviteMessage.welcomeNote', {
workspaceName: policy?.name ?? '',
senderDisplayName: currentUserPersonalDetails?.displayName ?? '',
senderLogin: currentUserPersonalDetails?.login ?? '',
workspaceDescription: parser.htmlToMarkdown(policy?.description ?? ''),
workspaceLink: ROUTES.WORKSPACE_PROFILE.getRoute(route.params.policyID),
});

useEffect(() => {
Expand Down Expand Up @@ -200,15 +216,17 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT
WorkspaceInviteMessagePage.displayName = 'WorkspaceInviteMessagePage';

export default withPolicyAndFullscreenLoading(
withOnyx<WorkspaceInviteMessagePageProps, WorkspaceInviteMessagePageOnyxProps>({
allPersonalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
invitedEmailsToAccountIDsDraft: {
key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`,
},
workspaceInviteMessageDraft: {
key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`,
},
})(WorkspaceInviteMessagePage),
withCurrentUserPersonalDetails(
withOnyx<WorkspaceInviteMessagePageProps, WorkspaceInviteMessagePageOnyxProps>({
allPersonalDetails: {
key: ONYXKEYS.PERSONAL_DETAILS_LIST,
},
invitedEmailsToAccountIDsDraft: {
key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`,
},
workspaceInviteMessageDraft: {
key: ({route}) => `${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`,
},
})(WorkspaceInviteMessagePage),
),
);
Loading