mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
fixes
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import type { ApiKeys } from 'types/api/account';
|
||||
import type { ApiKeys, ApiKeyErrors } from 'types/api/account';
|
||||
|
||||
import handler from 'lib/api/handler';
|
||||
|
||||
const apiKeysHandler = handler<ApiKeys>(() => '/account/v1/user/api_keys', [ 'GET', 'POST' ]);
|
||||
const apiKeysHandler = handler<ApiKeys, ApiKeyErrors>(() => '/account/v1/user/api_keys', [ 'GET', 'POST' ]);
|
||||
|
||||
export default apiKeysHandler;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { CustomAbis } from 'types/api/account';
|
||||
import type { CustomAbis, CustomAbiErrors } from 'types/api/account';
|
||||
|
||||
import handler from 'lib/api/handler';
|
||||
|
||||
const customAbiHandler = handler<CustomAbis>(() => '/account/v1/user/custom_abis', [ 'GET', 'POST' ]);
|
||||
const customAbiHandler = handler<CustomAbis, CustomAbiErrors>(() => '/account/v1/user/custom_abis', [ 'GET', 'POST' ]);
|
||||
|
||||
export default customAbiHandler;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { AddressTags } from 'types/api/account';
|
||||
import type { AddressTags, AddressTagErrors } from 'types/api/account';
|
||||
|
||||
import handler from 'lib/api/handler';
|
||||
|
||||
const addressHandler = handler<AddressTags>(() => '/account/v1/user/tags/address', [ 'GET', 'POST' ]);
|
||||
const addressHandler = handler<AddressTags, AddressTagErrors>(() => '/account/v1/user/tags/address', [ 'GET', 'POST' ]);
|
||||
|
||||
export default addressHandler;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { TransactionTags } from 'types/api/account';
|
||||
import type { TransactionTags, TransactionTagErrors } from 'types/api/account';
|
||||
|
||||
import handler from 'lib/api/handler';
|
||||
|
||||
const transactionHandler = handler<TransactionTags>(() => '/account/v1/user/tags/transaction', [ 'GET', 'POST' ]);
|
||||
const transactionHandler = handler<TransactionTags, TransactionTagErrors>(() => '/account/v1/user/tags/transaction', [ 'GET', 'POST' ]);
|
||||
|
||||
export default transactionHandler;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { PublicTags } from 'types/api/account';
|
||||
import type { PublicTags, PublicTagErrors } from 'types/api/account';
|
||||
|
||||
import handler from 'lib/api/handler';
|
||||
|
||||
const publicKeysHandler = handler<PublicTags>(() => '/account/v1/user/public_tags', [ 'GET', 'POST' ]);
|
||||
const publicKeysHandler = handler<PublicTags, PublicTagErrors>(() => '/account/v1/user/public_tags', [ 'GET', 'POST' ]);
|
||||
|
||||
export default publicKeysHandler;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
import { Flex, Text, FormControl, FormLabel, Textarea } from '@chakra-ui/react';
|
||||
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { useQueryClient } from '@tanstack/react-query';
|
||||
import React, { useCallback, useState } from 'react';
|
||||
import type { ChangeEvent } from 'react';
|
||||
|
||||
import type { PublicTags, PublicTag } from 'types/api/account';
|
||||
|
||||
import fetch from 'lib/client/fetch';
|
||||
import DeleteModal from 'ui/shared/DeleteModal';
|
||||
|
||||
type Props = {
|
||||
@@ -22,27 +23,17 @@ const DeletePublicTagModal: React.FC<Props> = ({ isOpen, onClose, data, onDelete
|
||||
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
const deleteApiKey = (reason: string) => {
|
||||
const deleteApiKey = useCallback(() => {
|
||||
const body = JSON.stringify({ remove_reason: reason });
|
||||
return fetch(`/api/account/public-tags/${ data.id }`, { method: 'DELETE', body });
|
||||
};
|
||||
}, [ data, reason ]);
|
||||
|
||||
const mutation = useMutation(deleteApiKey, {
|
||||
onSuccess: async() => {
|
||||
queryClient.setQueryData([ 'public-tags' ], (prevData: PublicTags | undefined) => {
|
||||
return prevData?.filter((item) => item.id !== data.id);
|
||||
});
|
||||
|
||||
onClose();
|
||||
},
|
||||
// eslint-disable-next-line no-console
|
||||
onError: console.error,
|
||||
});
|
||||
|
||||
const onDelete = useCallback(() => {
|
||||
mutation.mutate(reason);
|
||||
const onSuccess = useCallback(async() => {
|
||||
onDeleteSuccess();
|
||||
}, [ reason, mutation, onDeleteSuccess ]);
|
||||
queryClient.setQueryData([ 'public-tags' ], (prevData: PublicTags | undefined) => {
|
||||
return prevData?.filter((item) => item.id !== data.id);
|
||||
});
|
||||
}, [ queryClient, data, onDeleteSuccess ]);
|
||||
|
||||
const onFieldChange = useCallback((event: ChangeEvent<HTMLTextAreaElement>) => {
|
||||
setReason(event.currentTarget.value);
|
||||
@@ -101,10 +92,10 @@ const DeletePublicTagModal: React.FC<Props> = ({ isOpen, onClose, data, onDelete
|
||||
<DeleteModal
|
||||
isOpen={ isOpen }
|
||||
onClose={ onClose }
|
||||
onDelete={ onDelete }
|
||||
title="Request to remove a public tag"
|
||||
renderContent={ renderContent }
|
||||
pending={ mutation.isLoading }
|
||||
mutationFn={ deleteApiKey }
|
||||
onSuccess={ onSuccess }
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -150,7 +150,7 @@ const PublicTagsForm = ({ changeToDataScreen, data }: Props) => {
|
||||
|
||||
return (
|
||||
<Box width={ `calc(100% - ${ ADDRESS_INPUT_BUTTONS_WIDTH }px)` } maxWidth="844px">
|
||||
{ isAlertVisible && <FormSubmitAlert/> }
|
||||
{ isAlertVisible && <Box mb={ 4 }><FormSubmitAlert/></Box> }
|
||||
<Text size="sm" variant="secondary" paddingBottom={ 5 }>Company info</Text>
|
||||
<Grid templateColumns="1fr 1fr" rowGap={ 4 } columnGap={ 5 }>
|
||||
<GridItem>
|
||||
|
||||
Reference in New Issue
Block a user