From 2c3006df935747516ab118177f193ace2e2d2abd Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 4 Apr 2023 11:50:37 -0500 Subject: [PATCH] CreateGroupModal: toast on error --- .../modals/manage-group-modal/create-group-modal.tsx | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/soapbox/features/ui/components/modals/manage-group-modal/create-group-modal.tsx b/app/soapbox/features/ui/components/modals/manage-group-modal/create-group-modal.tsx index 2d4bea51a8..bbeb2d43ec 100644 --- a/app/soapbox/features/ui/components/modals/manage-group-modal/create-group-modal.tsx +++ b/app/soapbox/features/ui/components/modals/manage-group-modal/create-group-modal.tsx @@ -1,3 +1,4 @@ +import { AxiosError } from 'axios'; import React, { useMemo, useState } from 'react'; import { defineMessages, FormattedMessage, useIntl } from 'react-intl'; @@ -5,6 +6,7 @@ import { Modal, Stack } from 'soapbox/components/ui'; import { useDebounce } from 'soapbox/hooks'; import { useCreateGroup, useGroupValidation, type CreateGroupParams } from 'soapbox/hooks/api'; import { type Group } from 'soapbox/schemas'; +import toast from 'soapbox/toast'; import ConfirmationStep from './steps/confirmation-step'; import DetailsStep from './steps/details-step'; @@ -65,6 +67,14 @@ const CreateGroupModal: React.FC = ({ onClose }) => { setCurrentStep(Steps.THREE); setGroup(group); }, + onError(error) { + if (error instanceof AxiosError) { + const msg = error.response?.data.error; + if (typeof msg === 'string') { + toast.error(msg); + } + } + }, }); break; case Steps.THREE: