diff --git a/web/invite-links/manage-invite-links-modal.react.js b/web/invite-links/manage-invite-links-modal.react.js index 48feafe14..b3981ecee 100644 --- a/web/invite-links/manage-invite-links-modal.react.js +++ b/web/invite-links/manage-invite-links-modal.react.js @@ -1,56 +1,64 @@ // @flow import * as React from 'react'; import { useModalContext } from 'lib/components/modal-provider.react.js'; import { primaryInviteLinksSelector } from 'lib/selectors/invite-links-selectors.js'; +import { threadInfoSelector } from 'lib/selectors/thread-selectors.js'; import type { InviteLink } from 'lib/types/link-types.js'; import EditLinkModal from './manage/edit-link-modal.react.js'; import EmptyLinkContent from './manage/empty-link-content.react.js'; import ExistingLinkContent from './manage/existing-link-content.react.js'; import css from './manage/manage-invite-links-modal.css'; import Modal from '../modals/modal.react.js'; import { useSelector } from '../redux/redux-utils.js'; type Props = { +communityID: string, }; function ManageInviteLinksModal(props: Props): React.Node { const { communityID } = props; const inviteLink: ?InviteLink = useSelector(primaryInviteLinksSelector)[ communityID ]; + const community = useSelector( + state => threadInfoSelector(state)[communityID], + ); const { popModal } = useModalContext(); const [modalStage, setModalStage] = React.useState('view'); const enterEditMode = React.useCallback(() => setModalStage('edit'), []); const enterViewMode = React.useCallback(() => setModalStage('view'), []); if (modalStage === 'edit') { return ( - + ); } let content; if (inviteLink) { content = ( ); } else { content = ; } return (
{content}
); } export default ManageInviteLinksModal; diff --git a/web/invite-links/manage/edit-link-modal.react.js b/web/invite-links/manage/edit-link-modal.react.js index db1af5595..ad76ec341 100644 --- a/web/invite-links/manage/edit-link-modal.react.js +++ b/web/invite-links/manage/edit-link-modal.react.js @@ -1,67 +1,85 @@ // @flow import classnames from 'classnames'; import * as React from 'react'; import { useModalContext } from 'lib/components/modal-provider.react.js'; import { inviteLinkUrl } from 'lib/facts/links.js'; +import { useInviteLinksActions } from 'lib/hooks/invite-links.js'; import type { InviteLink } from 'lib/types/link-types.js'; +import type { ThreadInfo } from 'lib/types/thread-types.js'; import css from './manage-invite-links-modal.css'; import Button from '../../components/button.react.js'; import Input from '../../modals/input.react.js'; import Modal from '../../modals/modal.react.js'; type Props = { +inviteLink: ?InviteLink, +enterViewMode: () => mixed, + +community: ThreadInfo, }; function EditLinkModal(props: Props): React.Node { - const { inviteLink, enterViewMode } = props; - const [name, setName] = React.useState( - inviteLink?.name ?? Math.random().toString(36).slice(-9), - ); + const { inviteLink, enterViewMode, community } = props; const { popModal } = useModalContext(); + const { error, isLoading, name, setName, createOrUpdateInviteLink } = + useInviteLinksActions(community.id, inviteLink); const onChangeName = React.useCallback( (event: SyntheticEvent) => { setName(event.currentTarget.value); }, - [], + [setName], ); + let errorComponent = null; + if (error) { + errorComponent =
{error}
; + } + return (

Invite links make it easy for your friends to join your community. Anybody who knows your community’s invite link will be able to join it.

Note that if you change your public link’s URL, other communities will be able to claim the old URL.


Invite URL
{inviteLinkUrl('')}
-
-
- - + {errorComponent} +
+ + +
); } export default EditLinkModal; diff --git a/web/invite-links/manage/manage-invite-links-modal.css b/web/invite-links/manage/manage-invite-links-modal.css index 425c93633..e6707f145 100644 --- a/web/invite-links/manage/manage-invite-links-modal.css +++ b/web/invite-links/manage/manage-invite-links-modal.css @@ -1,71 +1,83 @@ .container { font-size: var(--m-font-16); padding: 24px 32px; } .sectionHeaderRow { display: flex; flex-direction: row; justify-content: space-between; align-items: center; } .sectionHeaderText { color: var(--fg); margin-bottom: 16px; } .description { font-size: var(--s-font-14); color: var(--fg); margin-top: 8px; } .inlineButton { display: inline; font-size: var(--s-font-14); } .editLinkContainer { display: flex; flex-direction: column; gap: 32px; color: var(--modal-fg); font-size: var(--s-font-14); } .editLinkDescription { font-weight: var(--semi-bold); color: var(--modal-fg); display: flex; flex-direction: column; gap: 12px; } .editLinkDescription p { font-size: var(--s-font-14); } .separator { border-color: var(--border-color); margin: 0; } .linkSection { display: flex; flex-direction: column; gap: 16px; } .linkRow { display: flex; font-size: var(--m-font-16); align-items: center; gap: 8px; } .buttonRow { display: flex; justify-content: flex-end; gap: 8px; + margin-top: 16px; +} + +.buttonRowWithError { + margin-top: 8px; +} + +.errorContainer { + display: flex; + justify-content: center; + font-size: var(--s-font-14); + color: var(--error-primary); }