1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-11-25 11:28:51 +01:00
metamask-extension/ui/components/institutional/jwt-dropdown/jwt-dropdown.js
George Marshall e75535ddfb
Update Text import paths: /institutional (#20064)
* Updating Text import paths and deprecated consts

* Update to button
2023-07-18 08:15:25 -07:00

58 lines
1.5 KiB
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import Dropdown from '../../ui/dropdown';
import { Color } from '../../../helpers/constants/design-system';
import { Box, Text } from '../../component-library';
import { useI18nContext } from '../../../hooks/useI18nContext';
const JwtDropdown = (props) => {
const t = useI18nContext();
const { currentJwt, jwtList } = props;
return (
<Box>
<Text
padding={1}
color={Color.textDefault}
className="custody-search-jwt__select-title"
>
{t('selectJWT')}
</Text>
<Dropdown
data-testid="jwt-dropdown"
className="custody-search-jwt__select"
name="jwt-select"
selectedOption={currentJwt}
options={[
...(jwtList.find((item) => item === currentJwt)
? []
: [
{
value: currentJwt,
name:
currentJwt.length > 9
? `...${currentJwt.slice(-9)}`
: currentJwt,
},
]),
...jwtList.map((text) => {
return {
value: text,
name: `...${text?.slice(-9)}`,
};
}),
]}
onChange={(opt) => props.onChange(opt.value)}
/>
</Box>
);
};
JwtDropdown.propTypes = {
jwtList: PropTypes.array,
currentJwt: PropTypes.string,
onChange: PropTypes.func,
};
export default JwtDropdown;