Commit c8074e70 authored by isstuev's avatar isstuev

fixes

parent 36547c01
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;
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;
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;
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;
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;
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>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment