diff --git a/lib/shared/community-utils.js b/lib/shared/community-utils.js --- a/lib/shared/community-utils.js +++ b/lib/shared/community-utils.js @@ -18,6 +18,7 @@ 'Tag a Farcaster channel so followers can find your Comm community!', CHANNEL_NAME_HEADER: 'Selected channel:', NO_CHANNEL_TAGGED: 'No Farcaster channel tagged', + REMOVE_TAG_BUTTON: 'Remove tag', }; const tagFarcasterChannelErrorMessages: { +[string]: string } = { diff --git a/native/community-settings/tag-farcaster-channel/remove-tag-button.react.js b/native/community-settings/tag-farcaster-channel/remove-tag-button.react.js --- a/native/community-settings/tag-farcaster-channel/remove-tag-button.react.js +++ b/native/community-settings/tag-farcaster-channel/remove-tag-button.react.js @@ -3,7 +3,10 @@ import * as React from 'react'; import { View, Text, ActivityIndicator } from 'react-native'; -import { useRemoveFarcasterChannelTag } from 'lib/shared/community-utils.js'; +import { + tagFarcasterChannelCopy, + useRemoveFarcasterChannelTag, +} from 'lib/shared/community-utils.js'; import type { SetState } from 'lib/types/hook-types.js'; import Button from '../../components/button.react.js'; @@ -34,7 +37,11 @@ ); } - return Remove tag; + return ( + + {tagFarcasterChannelCopy.REMOVE_TAG_BUTTON} + + ); }, [colors.panelForegroundLabel, isLoading, styles.buttonText]); return ( diff --git a/web/tag-farcaster-channel/remove-tag-button.react.js b/web/tag-farcaster-channel/remove-tag-button.react.js new file mode 100644 --- /dev/null +++ b/web/tag-farcaster-channel/remove-tag-button.react.js @@ -0,0 +1,40 @@ +// @flow + +import * as React from 'react'; + +import { + tagFarcasterChannelCopy, + useRemoveFarcasterChannelTag, +} from 'lib/shared/community-utils.js'; +import type { SetState } from 'lib/types/hook-types.js'; + +import Button, { buttonThemes } from '../components/button.react.js'; + +type Props = { + +communityID: string, + +channelID: string, + +setError: SetState, +}; + +function RemoveTagButton(props: Props): React.Node { + const { communityID, channelID, setError } = props; + + const { removeTag, isLoading } = useRemoveFarcasterChannelTag( + communityID, + channelID, + setError, + ); + + return ( + + ); +} + +export default RemoveTagButton; diff --git a/web/tag-farcaster-channel/tag-farcaster-channel-modal.css b/web/tag-farcaster-channel/tag-farcaster-channel-modal.css --- a/web/tag-farcaster-channel/tag-farcaster-channel-modal.css +++ b/web/tag-farcaster-channel/tag-farcaster-channel-modal.css @@ -20,3 +20,15 @@ color: var(--text-background-secondary-default); font-size: var(--m-font-16); } + +.errorMessage { + color: var(--text-background-danger-default); + font-size: var(--s-font-14); + margin-top: 4px; + text-align: center; + visibility: hidden; +} + +.errorMessageVisible { + visibility: visible; +} diff --git a/web/tag-farcaster-channel/tag-farcaster-channel-modal.react.js b/web/tag-farcaster-channel/tag-farcaster-channel-modal.react.js --- a/web/tag-farcaster-channel/tag-farcaster-channel-modal.react.js +++ b/web/tag-farcaster-channel/tag-farcaster-channel-modal.react.js @@ -1,11 +1,16 @@ // @flow +import classNames from 'classnames'; import * as React from 'react'; import { useModalContext } from 'lib/components/modal-provider.react.js'; -import { tagFarcasterChannelCopy } from 'lib/shared/community-utils.js'; +import { + tagFarcasterChannelCopy, + tagFarcasterChannelErrorMessages, +} from 'lib/shared/community-utils.js'; import type { CommunityInfo } from 'lib/types/community-types.js'; +import RemoveTagButton from './remove-tag-button.react.js'; import css from './tag-farcaster-channel-modal.css'; import Modal from '../modals/modal.react.js'; import { useSelector } from '../redux/redux-utils.js'; @@ -23,6 +28,8 @@ state => state.communityStore.communityInfos[communityID], ); + const [removeTagError, setRemoveTagError] = React.useState(); + const channelNameTextContent = React.useMemo(() => { if (!communityInfo?.farcasterChannelID) { return ( @@ -39,9 +46,37 @@ ); }, [communityInfo?.farcasterChannelID]); + const primaryButton = React.useMemo(() => { + if (communityInfo?.farcasterChannelID) { + return ( + + ); + } + // TODO: Implement TagChannelButton + return null; + }, [communityID, communityInfo?.farcasterChannelID]); + + const errorMessageClassName = classNames(css.errorMessage, { + [css.errorMessageVisible]: removeTagError, + }); + + const errorMessage = + removeTagError && tagFarcasterChannelErrorMessages[removeTagError] + ? tagFarcasterChannelErrorMessages[removeTagError] + : 'Unknown error.'; + const tagFarcasterChannelModal = React.useMemo( () => ( - +
{tagFarcasterChannelCopy.DESCRIPTION}
@@ -49,9 +84,16 @@ {tagFarcasterChannelCopy.CHANNEL_NAME_HEADER} {channelNameTextContent} +
{errorMessage}
), - [channelNameTextContent, popModal], + [ + channelNameTextContent, + errorMessage, + errorMessageClassName, + popModal, + primaryButton, + ], ); return tagFarcasterChannelModal;