fix(InviteToAnswer): Optimising the control logic of the `edit` button

This commit is contained in:
haitaoo 2023-05-24 17:33:03 +08:00
parent 2a02b9d5c0
commit 6eed25f48c
1 changed files with 4 additions and 2 deletions

View File

@ -74,17 +74,19 @@ const Index: FC<Props> = ({ questionId, readOnly = false }) => {
const showAddButton = editing && (!users || users.length < MAX_ASK_NUMBER);
const showInviteDesc = !editing && users?.length === 0;
const showEditButton = !readOnly && !editing && users?.length;
const showSaveButton = !readOnly && editing;
return (
<Card className="mt-4">
<Card.Header className="text-nowrap d-flex justify-content-between text-capitalize">
{t('title')}
{!readOnly && editing ? (
{showSaveButton ? (
<Button onClick={saveInviteUsers} variant="link" className="p-0">
{t('save', { keyPrefix: 'btns' })}
</Button>
) : null}
{!readOnly && !editing ? (
{showEditButton ? (
<Button
onClick={() => setEditing(true)}
variant="link"