mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
form submit
This commit is contained in:
@@ -118,6 +118,13 @@ export const RESOURCES = {
|
||||
basePath: appConfig.adminServiceApi.basePath,
|
||||
},
|
||||
|
||||
token_info_application: {
|
||||
path: '/api/v1/chains/:chainId/token-info-submissions',
|
||||
pathParams: [ 'chainId' as const ],
|
||||
endpoint: appConfig.adminServiceApi.endpoint,
|
||||
basePath: appConfig.adminServiceApi.basePath,
|
||||
},
|
||||
|
||||
// STATS
|
||||
stats_counters: {
|
||||
path: '/api/v1/counters',
|
||||
|
||||
@@ -175,3 +175,32 @@ export interface VerifiedAddressResponse {
|
||||
export interface TokenInfoApplicationConfig {
|
||||
projectSectors: Array<string>;
|
||||
}
|
||||
|
||||
export interface TokenInfoApplication {
|
||||
coinGeckoTicker?: string;
|
||||
coinMarketCapTicker?: string;
|
||||
defiLlamaTicker?: string;
|
||||
discord?: string;
|
||||
docs?: string;
|
||||
facebook?: string;
|
||||
github?: string;
|
||||
iconUrl: string;
|
||||
id: string;
|
||||
linkedin?: string;
|
||||
medium?: string;
|
||||
openSea?: string;
|
||||
projectDescription?: string;
|
||||
projectEmail: string;
|
||||
projectName?: string;
|
||||
projectSector?: string;
|
||||
projectWebsite: string;
|
||||
reddit?: string;
|
||||
requesterEmail: string;
|
||||
requesterName: string;
|
||||
slack?: string;
|
||||
status: 'STATUS_UNKNOWN' | 'IN_PROCESS' | 'APPROVED' | 'REJECTED' | 'UPDATE_REQUIRED';
|
||||
support?: string;
|
||||
telegram?: string;
|
||||
tokenAddress: string;
|
||||
twitter?: string;
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import { useForm } from 'react-hook-form';
|
||||
import type { Fields } from './types';
|
||||
|
||||
import appConfig from 'configs/app/config';
|
||||
import useApiFetch from 'lib/api/useApiFetch';
|
||||
import useApiQuery from 'lib/api/useApiQuery';
|
||||
import ContentLoader from 'ui/shared/ContentLoader';
|
||||
import DataFetchAlert from 'ui/shared/DataFetchAlert';
|
||||
@@ -24,6 +25,7 @@ import TokenInfoFieldRequesterName from './fields/TokenInfoFieldRequesterName';
|
||||
import TokenInfoFieldSocialLink from './fields/TokenInfoFieldSocialLink';
|
||||
import TokenInfoFieldSupport from './fields/TokenInfoFieldSupport';
|
||||
import TokenInfoFormSectionHeader from './TokenInfoFormSectionHeader';
|
||||
import { prepareRequestBody } from './utils';
|
||||
|
||||
interface Props {
|
||||
address: string;
|
||||
@@ -31,6 +33,8 @@ interface Props {
|
||||
|
||||
const TokenInfoForm = ({ address }: Props) => {
|
||||
|
||||
const apiFetch = useApiFetch();
|
||||
|
||||
const configQuery = useApiQuery('token_info_application_config', {
|
||||
pathParams: { chainId: appConfig.network.id },
|
||||
});
|
||||
@@ -44,9 +48,17 @@ const TokenInfoForm = ({ address }: Props) => {
|
||||
const { handleSubmit, formState, control, trigger } = formApi;
|
||||
|
||||
const onFormSubmit: SubmitHandler<Fields> = React.useCallback(async(data) => {
|
||||
// eslint-disable-next-line no-console
|
||||
console.log('__>__', data);
|
||||
}, [ ]);
|
||||
try {
|
||||
const submission = prepareRequestBody(data);
|
||||
await apiFetch('token_info_application', {
|
||||
pathParams: { chainId: appConfig.network.id },
|
||||
fetchParams: {
|
||||
method: 'POST',
|
||||
body: { submission },
|
||||
},
|
||||
});
|
||||
} catch (error) {}
|
||||
}, [ apiFetch ]);
|
||||
|
||||
const onSubmit = handleSubmit(onFormSubmit);
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
import type { Fields } from './types';
|
||||
import type { TokenInfoApplication } from 'types/api/account';
|
||||
|
||||
export function prepareRequestBody(data: Fields): Omit<TokenInfoApplication, 'id' | 'status'> {
|
||||
return {
|
||||
coinGeckoTicker: data.ticker_coin_gecko,
|
||||
coinMarketCapTicker: data.ticker_coin_market_cap,
|
||||
defiLlamaTicker: data.ticker_defi_llama,
|
||||
discord: data.discord,
|
||||
docs: data.docs,
|
||||
facebook: data.facebook,
|
||||
github: data.github,
|
||||
iconUrl: data.icon_url,
|
||||
linkedin: data.linkedin,
|
||||
medium: data.medium,
|
||||
openSea: data.opensea,
|
||||
projectDescription: data.project_description,
|
||||
projectEmail: data.project_email,
|
||||
projectName: data.project_name,
|
||||
projectSector: data.project_sector?.value,
|
||||
projectWebsite: data.project_website,
|
||||
reddit: data.reddit,
|
||||
requesterEmail: data.requester_email,
|
||||
requesterName: data.requester_name,
|
||||
slack: data.slack,
|
||||
support: data.support,
|
||||
telegram: data.telegram,
|
||||
tokenAddress: data.address,
|
||||
twitter: data.twitter,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user