Skip to content

Commit

Permalink
Merge pull request Expensify#38487 from narefyev91/add-generic-invite…
Browse files Browse the repository at this point in the history
…-description-for-workspace

Add default description for Workspace
  • Loading branch information
luacmartins authored Mar 19, 2024
2 parents 447fee8 + 5ff76af commit 5ab8d8d
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/languages/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1767,6 +1767,8 @@ export default {
moreFeatures: 'More features',
requested: 'Requested',
distanceRates: 'Distance rates',
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.`,
},
type: {
free: 'Free',
Expand Down Expand Up @@ -1992,8 +1994,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: ({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.`,
},
distanceRates: {
oopsNotSoFast: 'Oops! Not so fast...',
Expand Down
4 changes: 2 additions & 2 deletions src/languages/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1791,6 +1791,8 @@ export default {
moreFeatures: 'Más características',
requested: 'Solicitado',
distanceRates: 'Tasas de distancia',
welcomeNote: ({workspaceName}: WelcomeNoteParams) =>
`¡Has sido invitado a ${workspaceName}! Descargue la aplicación móvil Expensify en use.expensify.com/download para comenzar a rastrear sus gastos.`,
},
type: {
free: 'Gratis',
Expand Down Expand Up @@ -2017,8 +2019,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: ({workspaceName}: WelcomeNoteParams) =>
`¡Has sido invitado a ${workspaceName}! Descargue la aplicación móvil Expensify en use.expensify.com/download para comenzar a rastrear sus gastos.`,
},
distanceRates: {
oopsNotSoFast: 'Ups! No tan rápido...',
Expand Down
2 changes: 1 addition & 1 deletion src/libs/actions/Policy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2170,7 +2170,7 @@ function setWorkspaceInviteMembersDraft(policyID: string, invitedEmailsToAccount
Onyx.set(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${policyID}`, invitedEmailsToAccountIDs);
}

function setWorkspaceInviteMessageDraft(policyID: string, message: string) {
function setWorkspaceInviteMessageDraft(policyID: string, message: string | null) {
Onyx.set(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${policyID}`, message);
}

Expand Down
19 changes: 14 additions & 5 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 Down Expand Up @@ -52,6 +53,8 @@ type WorkspaceInviteMessagePageProps = WithPolicyAndFullscreenLoadingProps &
WorkspaceInviteMessagePageOnyxProps &
StackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.INVITE_MESSAGE>;

const parser = new ExpensiMark();

function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsToAccountIDsDraft, policy, route, allPersonalDetails}: WorkspaceInviteMessagePageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand All @@ -64,27 +67,33 @@ function WorkspaceInviteMessagePage({workspaceInviteMessageDraft, invitedEmailsT
// workspaceInviteMessageDraft can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
workspaceInviteMessageDraft ||
translate('workspace.inviteMessage.welcomeNote', {
workspaceName: policy?.name ?? '',
});
// policy?.description can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
policy?.description ||
parser.replace(
translate('workspace.common.welcomeNote', {
workspaceName: policy?.name ?? '',
}),
);

useEffect(() => {
if (!isEmptyObject(invitedEmailsToAccountIDsDraft)) {
setWelcomeNote(getDefaultWelcomeNote());
setWelcomeNote(parser.htmlToMarkdown(getDefaultWelcomeNote()));
return;
}
Navigation.goBack(ROUTES.WORKSPACE_INVITE.getRoute(route.params.policyID), true);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const debouncedSaveDraft = lodashDebounce((newDraft: string) => {
const debouncedSaveDraft = lodashDebounce((newDraft: string | null) => {
Policy.setWorkspaceInviteMessageDraft(route.params.policyID, newDraft);
});

const sendInvitation = () => {
Keyboard.dismiss();
// Please see https://github.com/Expensify/App/blob/main/README.md#Security for more details
Policy.addMembersToWorkspace(invitedEmailsToAccountIDsDraft ?? {}, welcomeNote ?? '', route.params.policyID);
debouncedSaveDraft(null);
SearchInputManager.searchInput = '';
// Pop the invite message page before navigating to the members page.
Navigation.goBack();
Expand Down
13 changes: 12 additions & 1 deletion src/pages/workspace/WorkspaceProfileDescriptionPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,18 @@ const parser = new ExpensiMark();
function WorkspaceProfileDescriptionPage({policy}: Props) {
const styles = useThemeStyles();
const {translate} = useLocalize();
const [description, setDescription] = useState(() => parser.htmlToMarkdown(policy?.description ?? ''));
const [description, setDescription] = useState(() =>
parser.htmlToMarkdown(
// policy?.description can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
policy?.description ||
parser.replace(
translate('workspace.common.welcomeNote', {
workspaceName: policy?.name ?? '',
}),
),
),
);

/**
* @param {Object} values - form input values passed by the Form component
Expand Down
13 changes: 12 additions & 1 deletion src/pages/workspace/WorkspaceProfilePage.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import ExpensiMark from 'expensify-common/lib/ExpensiMark';
import React, {useCallback, useState} from 'react';
import type {ImageStyle, StyleProp} from 'react-native';
import {Image, StyleSheet, View} from 'react-native';
Expand Down Expand Up @@ -41,6 +42,8 @@ type WorkSpaceProfilePageOnyxProps = {

type WorkSpaceProfilePageProps = WithPolicyProps & WorkSpaceProfilePageOnyxProps;

const parser = new ExpensiMark();

function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfilePageProps) {
const styles = useThemeStyles();
const {translate} = useLocalize();
Expand All @@ -58,7 +61,15 @@ function WorkspaceProfilePage({policy, currencyList = {}, route}: WorkSpaceProfi
const onPressShare = useCallback(() => Navigation.navigate(ROUTES.WORKSPACE_PROFILE_SHARE.getRoute(policy?.id ?? '')), [policy?.id]);

const policyName = policy?.name ?? '';
const policyDescription = policy?.description ?? '';
const policyDescription =
// policy?.description can be an empty string
// eslint-disable-next-line @typescript-eslint/prefer-nullish-coalescing
policy?.description ||
parser.replace(
translate('workspace.common.welcomeNote', {
workspaceName: policy?.name ?? '',
}),
);
const readOnly = !PolicyUtils.isPolicyAdmin(policy);
const imageStyle: StyleProp<ImageStyle> = isSmallScreenWidth ? [styles.mhv12, styles.mhn5, styles.mbn5] : [styles.mhv8, styles.mhn8, styles.mbn5];

Expand Down

0 comments on commit 5ab8d8d

Please sign in to comment.