mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* Update styles of form inputs * update token info form * update demo values * fix preset for sepolia * update screenshots
49 lines
1.4 KiB
TypeScript
49 lines
1.4 KiB
TypeScript
import React from 'react';
|
|
import type { Control, ControllerProps } from 'react-hook-form';
|
|
import { Controller } from 'react-hook-form';
|
|
|
|
import type { Fields } from '../types';
|
|
import type { TokenInfoApplicationConfig } from 'types/api/account';
|
|
|
|
import useIsMobile from 'lib/hooks/useIsMobile';
|
|
import FancySelect from 'ui/shared/FancySelect/FancySelect';
|
|
|
|
interface Props {
|
|
control: Control<Fields>;
|
|
isReadOnly?: boolean;
|
|
config: TokenInfoApplicationConfig['projectSectors'];
|
|
}
|
|
|
|
const TokenInfoFieldProjectSector = ({ control, isReadOnly, config }: Props) => {
|
|
const isMobile = useIsMobile();
|
|
|
|
const options = React.useMemo(() => {
|
|
return config.map((option) => ({ label: option, value: option }));
|
|
}, [ config ]);
|
|
|
|
const renderControl: ControllerProps<Fields, 'project_sector'>['render'] = React.useCallback(({ field, fieldState, formState }) => {
|
|
|
|
return (
|
|
<FancySelect
|
|
{ ...field }
|
|
options={ options }
|
|
size={ isMobile ? 'md' : 'lg' }
|
|
placeholder="Project industry"
|
|
isDisabled={ formState.isSubmitting }
|
|
isReadOnly={ isReadOnly }
|
|
error={ fieldState.error }
|
|
/>
|
|
);
|
|
}, [ isReadOnly, options, isMobile ]);
|
|
|
|
return (
|
|
<Controller
|
|
name="project_sector"
|
|
control={ control }
|
|
render={ renderControl }
|
|
/>
|
|
);
|
|
};
|
|
|
|
export default React.memo(TokenInfoFieldProjectSector);
|