Skip to content

Commit

Permalink
fixed eslint error
Browse files Browse the repository at this point in the history
  • Loading branch information
rojiphil committed Sep 27, 2024
1 parent 3978c17 commit ea0cfb5
Showing 1 changed file with 14 additions and 38 deletions.
52 changes: 14 additions & 38 deletions src/pages/workspace/WorkspaceInviteMessagePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ import type {StackScreenProps} from '@react-navigation/stack';
import lodashDebounce from 'lodash/debounce';
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';
import {useOnyx} from 'react-native-onyx';
import type {GestureResponderEvent} from 'react-native/Libraries/Types/CoreEventTypes';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
Expand Down Expand Up @@ -35,43 +34,27 @@ import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import INPUT_IDS from '@src/types/form/WorkspaceInviteMessageForm';
import type {InvitedEmailsToAccountIDs, PersonalDetailsList} from '@src/types/onyx';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import AccessOrNotFoundWrapper from './AccessOrNotFoundWrapper';
import withPolicyAndFullscreenLoading from './withPolicyAndFullscreenLoading';
import type {WithPolicyAndFullscreenLoadingProps} from './withPolicyAndFullscreenLoading';

type WorkspaceInviteMessagePageOnyxProps = {
/** All of the personal details for everyone */
allPersonalDetails: OnyxEntry<PersonalDetailsList>;

/** An object containing the accountID for every invited user email */
invitedEmailsToAccountIDsDraft: OnyxEntry<InvitedEmailsToAccountIDs>;

/** Updated workspace invite message */
workspaceInviteMessageDraft: OnyxEntry<string>;
};

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

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

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

const {inputCallbackRef, inputRef} = useAutoFocusInput();

const [invitedEmailsToAccountIDsDraft] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MEMBERS_DRAFT}${route.params.policyID.toString()}`);
const [workspaceInviteMessageDraft] = useOnyx(`${ONYXKEYS.COLLECTION.WORKSPACE_INVITE_MESSAGE_DRAFT}${route.params.policyID.toString()}`);
const [allPersonalDetails] = useOnyx(ONYXKEYS.PERSONAL_DETAILS_LIST);

const welcomeNoteSubject = useMemo(
() => `# ${currentUserPersonalDetails?.displayName ?? ''} invited you to ${policy?.name ?? 'a workspace'}`,
[policy?.name, currentUserPersonalDetails?.displayName],
Expand Down Expand Up @@ -100,6 +83,13 @@ function WorkspaceInviteMessagePage({
// eslint-disable-next-line react-compiler/react-compiler, react-hooks/exhaustive-deps
}, []);

useEffect(() => {
if (isEmptyObject(invitedEmailsToAccountIDsDraft)) {
return;
}
setWelcomeNote(getDefaultWelcomeNote());
}, [invitedEmailsToAccountIDsDraft, workspaceInviteMessageDraft, route.params.policyID, policy]);

Check warning on line 91 in src/pages/workspace/WorkspaceInviteMessagePage.tsx

View workflow job for this annotation

GitHub Actions / Changed files ESLint check

React Hook useEffect has a missing dependency: 'getDefaultWelcomeNote'. Either include it or remove the dependency array

Check warning on line 91 in src/pages/workspace/WorkspaceInviteMessagePage.tsx

View workflow job for this annotation

GitHub Actions / ESLint check

React Hook useEffect has a missing dependency: 'getDefaultWelcomeNote'. Either include it or remove the dependency array

const debouncedSaveDraft = lodashDebounce((newDraft: string | null) => {
Policy.setWorkspaceInviteMessageDraft(route.params.policyID, newDraft);
});
Expand Down Expand Up @@ -221,18 +211,4 @@ function WorkspaceInviteMessagePage({

WorkspaceInviteMessagePage.displayName = 'WorkspaceInviteMessagePage';

export default withPolicyAndFullscreenLoading(
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),
),
);
export default withPolicyAndFullscreenLoading(withCurrentUserPersonalDetails(WorkspaceInviteMessagePage));

0 comments on commit ea0cfb5

Please sign in to comment.