diff --git a/src/components/UserProfile/Info/Contacts.tsx b/src/components/UserProfile/Info/Contacts.tsx new file mode 100644 index 0000000..f3c8f4e --- /dev/null +++ b/src/components/UserProfile/Info/Contacts.tsx @@ -0,0 +1,37 @@ +import React from 'react'; +import { observer } from 'mobx-react'; +import { Button, HStack } from '@chakra-ui/react'; +import { FaPhone, FaTelegram, FaTwitter } from 'react-icons/fa'; +import type { IContactsProps } from '.'; + +const Contacts: React.FC = observer(({ contacts }) => { + if (contacts === null) return null; + + const { phone_number, twitter_id, telegram_id } = contacts; + + const phoneHandler = () => window.open(`tel:${phone_number}`, '_blank'); + const twitterHandler = () => window.open(`https://twitter.com/${twitter_id?.substring(1)}`, '_blank'); + const telegramHandler = () => window.open(`https://t.me/${telegram_id?.substring(1)}`, '_blank'); + + return ( + + {phone_number && ( + + )} + {twitter_id && ( + + )} + {telegram_id && ( + + )} + + ); +}); + +export { Contacts }; diff --git a/src/components/UserProfile/Info/index.ts b/src/components/UserProfile/Info/index.ts index 7ce80d6..6f3cb03 100644 --- a/src/components/UserProfile/Info/index.ts +++ b/src/components/UserProfile/Info/index.ts @@ -3,6 +3,7 @@ import { Info } from './Info'; import { Heading } from './Heading'; import { Details } from './Details'; import { About } from './About'; +import { Contacts } from './Contacts'; export interface IHeadingProps { fullname: string; @@ -18,4 +19,8 @@ export interface IAboutProps { about: IUser['about']; } -export { Info, Heading, Details, About }; +export interface IContactsProps { + contacts: IUser['contacts']; +} + +export { Info, Heading, Details, About, Contacts }; diff --git a/src/components/UserProfile/index.tsx b/src/components/UserProfile/index.tsx index ac7ee50..a3bdbd2 100644 --- a/src/components/UserProfile/index.tsx +++ b/src/components/UserProfile/index.tsx @@ -2,7 +2,17 @@ import React from 'react'; import { BoxProps, Flex, FlexProps } from '@chakra-ui/react'; import { Base } from './Base'; import { Avatar, ChatButton, IAvatarProps, IChatButtonProps } from './Avatar'; -import { About, Details, Heading, IAboutProps, IDetailsProps, IHeadingProps, Info } from './Info'; +import { + About, + Contacts, + Details, + Heading, + IAboutProps, + IContactsProps, + IDetailsProps, + IHeadingProps, + Info, +} from './Info'; import { Settings } from './Settings'; import { ISettingsComposition } from './Settings/Settings'; @@ -14,6 +24,7 @@ interface IUserProfileComposition { Heading: React.FC; Details: React.FC; About: React.FC; + Contacts: React.FC; Settings: React.FC & ISettingsComposition; } @@ -32,6 +43,7 @@ UserProfile.Info = Info; UserProfile.Heading = Heading; UserProfile.Details = Details; UserProfile.About = About; +UserProfile.Contacts = Contacts; UserProfile.Settings = Settings; export { UserProfile }; diff --git a/src/pages/profile/profile.tsx b/src/pages/profile/profile.tsx index 4fc65dd..d85df00 100644 --- a/src/pages/profile/profile.tsx +++ b/src/pages/profile/profile.tsx @@ -40,6 +40,7 @@ const ProfilePage: React.FC = () => { + diff --git a/src/pages/user/user.tsx b/src/pages/user/user.tsx index bd7a4c2..17840c9 100644 --- a/src/pages/user/user.tsx +++ b/src/pages/user/user.tsx @@ -42,6 +42,7 @@ const UserPage: React.FC = () => { +