diff --git a/web/modals/user-profile/user-profile-message-button.react.js b/web/modals/user-profile/user-profile-message-button.react.js new file mode 100644 --- /dev/null +++ b/web/modals/user-profile/user-profile-message-button.react.js @@ -0,0 +1,43 @@ +// @flow + +import * as React from 'react'; + +import { useModalContext } from 'lib/components/modal-provider.react.js'; +import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; +import type { ThreadInfo } from 'lib/types/thread-types.js'; + +import css from './user-profile.css'; +import Button from '../../components/button.react.js'; +import { useOnClickThread } from '../../selectors/thread-selectors.js'; + +type Props = { + +threadInfo: ThreadInfo, +}; + +function UserProfileMessageButton(props: Props): React.Node { + const { threadInfo } = props; + + const { clearModals } = useModalContext(); + const onClickThread = useOnClickThread(threadInfo); + + const onClickMessageButton = React.useCallback( + (event: SyntheticEvent) => { + clearModals(); + onClickThread(event); + }, + [clearModals, onClickThread], + ); + + return ( + + ); +} + +export default UserProfileMessageButton; diff --git a/web/modals/user-profile/user-profile.css b/web/modals/user-profile/user-profile.css --- a/web/modals/user-profile/user-profile.css +++ b/web/modals/user-profile/user-profile.css @@ -1,7 +1,10 @@ .container { + padding: 0 32px 32px; +} + +.userInfoContainer { display: flex; align-items: center; - padding: 0 32px 32px; } .usernameContainer { @@ -29,3 +32,8 @@ font-size: var(--xs-font-12); margin-left: 4px; } + +.actionButton { + column-gap: 8px; + flex-grow: 1; +} diff --git a/web/modals/user-profile/user-profile.react.js b/web/modals/user-profile/user-profile.react.js --- a/web/modals/user-profile/user-profile.react.js +++ b/web/modals/user-profile/user-profile.react.js @@ -3,10 +3,13 @@ import * as React from 'react'; import SWMansionIcon from 'lib/components/SWMansionIcon.react.js'; +import { relationshipBlockedInEitherDirection } from 'lib/shared/relationship-utils.js'; +import { useUserProfileThreadInfo } from 'lib/shared/thread-utils.js'; import { stringForUserExplicit } from 'lib/shared/user-utils.js'; import type { UserInfo } from 'lib/types/user-types'; import sleep from 'lib/utils/sleep.js'; +import UserProfileMessageButton from './user-profile-message-button.react.js'; import css from './user-profile.css'; import UserAvatar from '../../avatars/user-avatar.react.js'; @@ -17,6 +20,8 @@ function UserProfile(props: Props): React.Node { const { userInfo } = props; + const userProfileThreadInfo = useUserProfileThreadInfo(userInfo); + const usernameText = stringForUserExplicit(userInfo); const [usernameCopied, setUsernameCopied] = React.useState(false); @@ -32,21 +37,40 @@ setUsernameCopied(false); }, [usernameCopied, usernameText]); + const messageButton = React.useMemo(() => { + if ( + !userProfileThreadInfo || + relationshipBlockedInEitherDirection(userInfo?.relationshipStatus) + ) { + return null; + } + + return ( + + ); + }, [userInfo?.relationshipStatus, userProfileThreadInfo]); + return (
- -
-
{usernameText}
-
- -

- {!usernameCopied ? 'Copy username' : 'Username copied!'} -

+
+ +
+
{usernameText}
+
+ +

+ {!usernameCopied ? 'Copy username' : 'Username copied!'} +

+
+ {messageButton}
); }