CreateGroupModal: toast on error
This commit is contained in:
parent
3d1c0fa813
commit
2c3006df93
1 changed files with 10 additions and 0 deletions
|
@ -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<ICreateGroupModal> = ({ 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:
|
||||
|
|
Loading…
Reference in a new issue