Update 'Create Group' modal title dynamically
This commit is contained in:
parent
7675b18e52
commit
2516fd36e0
|
@ -33,7 +33,9 @@ const CreateGroupModal: React.FC<ICreateGroupModal> = ({ onClose }) => {
|
||||||
const debounce = useDebounce;
|
const debounce = useDebounce;
|
||||||
|
|
||||||
const [group, setGroup] = useState<Group | null>(null);
|
const [group, setGroup] = useState<Group | null>(null);
|
||||||
const [params, setParams] = useState<CreateGroupParams>({});
|
const [params, setParams] = useState<CreateGroupParams>({
|
||||||
|
group_visibility: 'everyone',
|
||||||
|
});
|
||||||
const [currentStep, setCurrentStep] = useState<Steps>(Steps.ONE);
|
const [currentStep, setCurrentStep] = useState<Steps>(Steps.ONE);
|
||||||
|
|
||||||
const { createGroup, isSubmitting } = useCreateGroup();
|
const { createGroup, isSubmitting } = useCreateGroup();
|
||||||
|
@ -96,9 +98,22 @@ const CreateGroupModal: React.FC<ICreateGroupModal> = ({ onClose }) => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const renderModalTitle = () => {
|
||||||
|
switch (currentStep) {
|
||||||
|
case Steps.ONE:
|
||||||
|
return <FormattedMessage id='navigation_bar.create_group' defaultMessage='Create Group' />;
|
||||||
|
default:
|
||||||
|
if (params.group_visibility === 'everyone') {
|
||||||
|
return <FormattedMessage id='navigation_bar.create_group.public' defaultMessage='Create Public Group' />;
|
||||||
|
} else {
|
||||||
|
return <FormattedMessage id='navigation_bar.create_group.private' defaultMessage='Create Private Group' />;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
title={<FormattedMessage id='navigation_bar.create_group' defaultMessage='Create Group' />}
|
title={renderModalTitle()}
|
||||||
confirmationAction={handleNextStep}
|
confirmationAction={handleNextStep}
|
||||||
confirmationText={confirmationText}
|
confirmationText={confirmationText}
|
||||||
confirmationDisabled={isSubmitting || (currentStep === Steps.TWO && !isValid)}
|
confirmationDisabled={isSubmitting || (currentStep === Steps.TWO && !isValid)}
|
||||||
|
|
Loading…
Reference in New Issue