fix(InviteToAnswer): Hide components when not necessary

This commit is contained in:
haitaoo 2023-05-31 19:25:27 +08:00
parent 9104b31231
commit edba84c47e
1 changed files with 10 additions and 4 deletions

View File

@ -73,9 +73,15 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {
}, [questionId]);
const showAddButton = editing && (!users || users.length < MAX_ASK_NUMBER);
const showInviteDesc = !editing && users?.length === 0;
const showInviteFeat = !editing && users?.length === 0;
const showInviteButton = showInviteFeat && !readOnly;
const showEditButton = !readOnly && !editing && users?.length;
const showSaveButton = !readOnly && editing;
const showEmpty = readOnly && users?.length === 0;
if (showEmpty) {
return null;
}
return (
<Card className="mt-4">
@ -136,10 +142,10 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {
onSelect={updateInviteUsers}
/>
</div>
{showInviteDesc ? (
{showInviteFeat ? (
<>
<div className="text-muted">{t('desc')}</div>
{readOnly ? null : (
{showInviteButton ? (
<Button
size="sm"
variant="outline-primary"
@ -147,7 +153,7 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {
onClick={() => setEditing(true)}>
{t('invite')}
</Button>
)}
) : null}
</>
) : null}
</Card.Body>