Replace axios with fetch
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import React from 'react';
|
||||
import { defineMessages, FormattedMessage, useIntl } from 'react-intl';
|
||||
|
||||
import { fetchGroupRelationshipsSuccess } from 'soapbox/actions/groups';
|
||||
import { openModal } from 'soapbox/actions/modals';
|
||||
import { useCancelMembershipRequest, useJoinGroup, useLeaveGroup } from 'soapbox/api/hooks';
|
||||
import { Button } from 'soapbox/components/ui';
|
||||
@@ -43,7 +42,6 @@ const GroupActionButton = ({ group }: IGroupActionButton) => {
|
||||
const onJoinGroup = () => joinGroup.mutate({}, {
|
||||
onSuccess(entity) {
|
||||
joinGroup.invalidate();
|
||||
dispatch(fetchGroupRelationshipsSuccess([entity]));
|
||||
|
||||
toast.success(
|
||||
group.locked
|
||||
@@ -67,7 +65,6 @@ const GroupActionButton = ({ group }: IGroupActionButton) => {
|
||||
onConfirm: () => leaveGroup.mutate(group.relationship?.id as string, {
|
||||
onSuccess(entity) {
|
||||
leaveGroup.invalidate();
|
||||
dispatch(fetchGroupRelationshipsSuccess([entity]));
|
||||
toast.success(intl.formatMessage(messages.leaveSuccess));
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import { AxiosError } from 'axios';
|
||||
import React, { useEffect } from 'react';
|
||||
import { FormattedMessage, defineMessages, useIntl } from 'react-intl';
|
||||
|
||||
@@ -83,12 +82,12 @@ const GroupMembershipRequests: React.FC<IGroupMembershipRequests> = ({ params })
|
||||
async function handleAuthorize(account: AccountEntity) {
|
||||
return authorize(account.id)
|
||||
.then(() => Promise.resolve())
|
||||
.catch((error: AxiosError) => {
|
||||
.catch((error: { response: Response }) => {
|
||||
refetch();
|
||||
|
||||
let message = intl.formatMessage(messages.authorizeFail, { name: account.username });
|
||||
if (error.response?.status === 409) {
|
||||
message = (error.response?.data as any).error;
|
||||
message = (error.response?.json as any).error;
|
||||
}
|
||||
toast.error(message);
|
||||
|
||||
@@ -99,12 +98,12 @@ const GroupMembershipRequests: React.FC<IGroupMembershipRequests> = ({ params })
|
||||
async function handleReject(account: AccountEntity) {
|
||||
return reject(account.id)
|
||||
.then(() => Promise.resolve())
|
||||
.catch((error: AxiosError) => {
|
||||
.catch((error: { response: Response }) => {
|
||||
refetch();
|
||||
|
||||
let message = intl.formatMessage(messages.rejectFail, { name: account.username });
|
||||
if (error.response?.status === 409) {
|
||||
message = (error.response?.data as any).error;
|
||||
message = (error.response?.json as any).error;
|
||||
}
|
||||
toast.error(message);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user