Handle null group in confirmation step

environments/review-handle-nul-v2hx0g/deployments/3258
Chewbacca 2023-04-25 10:03:21 -04:00
rodzic e5cf1dfa85
commit 6cda34fb69
2 zmienionych plików z 9 dodań i 5 usunięć

Wyświetl plik

@ -94,7 +94,7 @@ const CreateGroupModal: React.FC<ICreateGroupModal> = ({ onClose }) => {
case Steps.TWO: case Steps.TWO:
return <DetailsStep params={params} onChange={setParams} />; return <DetailsStep params={params} onChange={setParams} />;
case Steps.THREE: case Steps.THREE:
return <ConfirmationStep group={group!} />; return <ConfirmationStep group={group} />;
} }
}; };

Wyświetl plik

@ -8,7 +8,7 @@ import copy from 'soapbox/utils/copy';
import type { Group } from 'soapbox/schemas'; import type { Group } from 'soapbox/schemas';
interface IConfirmationStep { interface IConfirmationStep {
group: Group group: Group | null
} }
const messages = defineMessages({ const messages = defineMessages({
@ -19,20 +19,24 @@ const ConfirmationStep: React.FC<IConfirmationStep> = ({ group }) => {
const intl = useIntl(); const intl = useIntl();
const handleCopyLink = () => { const handleCopyLink = () => {
copy(`${window.location.origin}/group/${group.slug}`, () => { copy(`${window.location.origin}/group/${group?.slug}`, () => {
toast.success(intl.formatMessage(messages.copied)); toast.success(intl.formatMessage(messages.copied));
}); });
}; };
const handleShare = () => { const handleShare = () => {
navigator.share({ navigator.share({
text: group.display_name, text: group?.display_name,
url: group.uri, url: group?.uri,
}).catch((e) => { }).catch((e) => {
if (e.name !== 'AbortError') console.error(e); if (e.name !== 'AbortError') console.error(e);
}); });
}; };
if (!group) {
return null;
}
return ( return (
<Stack space={9}> <Stack space={9}>
<Stack space={3}> <Stack space={3}>