2022-09-09 17:18:04 +00:00
|
|
|
|
import React, { useState } from 'react';
|
2022-04-17 19:14:22 +00:00
|
|
|
|
import { useTranslation } from 'react-i18next';
|
2023-03-03 15:25:21 +00:00
|
|
|
|
import useAutocomplete from '@mui/base/useAutocomplete';
|
2022-03-29 23:16:59 +00:00
|
|
|
|
import { styled } from '@mui/material/styles';
|
2023-10-27 10:01:59 +00:00
|
|
|
|
import {
|
|
|
|
|
Button,
|
|
|
|
|
Fade,
|
|
|
|
|
Tooltip,
|
|
|
|
|
Typography,
|
|
|
|
|
Grow,
|
|
|
|
|
useTheme,
|
|
|
|
|
type SxProps,
|
|
|
|
|
type Theme,
|
|
|
|
|
} from '@mui/material';
|
2022-10-20 18:06:16 +00:00
|
|
|
|
import { fiatMethods, swapMethods, PaymentIcon } from '../PaymentMethods';
|
2022-04-01 14:52:44 +00:00
|
|
|
|
|
2022-05-08 15:43:08 +00:00
|
|
|
|
// Icons
|
2022-03-29 23:16:59 +00:00
|
|
|
|
import DashboardCustomizeIcon from '@mui/icons-material/DashboardCustomize';
|
2022-05-08 15:43:08 +00:00
|
|
|
|
import CheckIcon from '@mui/icons-material/Check';
|
|
|
|
|
import CloseIcon from '@mui/icons-material/Close';
|
2022-03-29 23:16:59 +00:00
|
|
|
|
|
|
|
|
|
const Root = styled('div')(
|
|
|
|
|
({ theme }) => `
|
2022-10-14 12:10:12 +00:00
|
|
|
|
color: ${theme.palette.text.primary};
|
|
|
|
|
font-size: ${theme.typography.fontSize};
|
2022-03-29 23:16:59 +00:00
|
|
|
|
`,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const Label = styled('label')(
|
2022-10-14 12:10:12 +00:00
|
|
|
|
({ theme, error, sx }) => `
|
2022-09-09 17:18:04 +00:00
|
|
|
|
color: ${
|
2023-10-27 10:01:59 +00:00
|
|
|
|
theme.palette.mode === 'dark'
|
|
|
|
|
? error === true
|
|
|
|
|
? '#f44336'
|
|
|
|
|
: '#cfcfcf'
|
|
|
|
|
: error === true
|
2023-12-02 17:41:47 +00:00
|
|
|
|
? '#dd0000'
|
|
|
|
|
: '#717171'
|
2022-09-09 17:18:04 +00:00
|
|
|
|
};
|
2022-10-14 12:10:12 +00:00
|
|
|
|
pointer-events: none;
|
|
|
|
|
position: relative;
|
|
|
|
|
left: 1em;
|
2023-10-27 10:01:59 +00:00
|
|
|
|
top: ${String(sx.top) ?? '0.72em'};
|
2022-10-14 12:10:12 +00:00
|
|
|
|
maxHeight: 0em;
|
|
|
|
|
height: 0em;
|
|
|
|
|
white-space: no-wrap;
|
|
|
|
|
font-size: 1em;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
`,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const InputWrapper = styled('div')(
|
2022-10-14 12:10:12 +00:00
|
|
|
|
({ theme, error, sx }) => `
|
2023-10-27 10:01:59 +00:00
|
|
|
|
min-height: ${String(sx.minHeight)};
|
|
|
|
|
max-height: ${String(sx.maxHeight)};
|
2022-09-09 17:18:04 +00:00
|
|
|
|
border: 1px solid ${
|
2023-10-27 10:01:59 +00:00
|
|
|
|
theme.palette.mode === 'dark'
|
|
|
|
|
? error === ''
|
|
|
|
|
? '#f44336'
|
|
|
|
|
: '#434343'
|
|
|
|
|
: error === ''
|
2023-12-02 17:41:47 +00:00
|
|
|
|
? '#dd0000'
|
|
|
|
|
: '#c4c4c4'
|
2022-09-09 17:18:04 +00:00
|
|
|
|
};
|
2022-03-29 23:16:59 +00:00
|
|
|
|
background-color: ${theme.palette.mode === 'dark' ? '#141414' : '#fff'};
|
2022-09-09 16:27:08 +00:00
|
|
|
|
border-radius: 4px;
|
2023-10-27 10:01:59 +00:00
|
|
|
|
border-color: ${sx.borderColor !== undefined ? `border-color ${String(sx.borderColor)}` : ''}
|
2022-03-29 23:16:59 +00:00
|
|
|
|
padding: 1px;
|
|
|
|
|
display: flex;
|
|
|
|
|
flex-wrap: wrap;
|
|
|
|
|
overflow-y:auto;
|
2022-10-14 12:10:12 +00:00
|
|
|
|
align-items: center;
|
2022-05-02 19:28:34 +00:00
|
|
|
|
|
2022-03-29 23:16:59 +00:00
|
|
|
|
&:hover {
|
2022-09-09 17:18:04 +00:00
|
|
|
|
border-color: ${
|
|
|
|
|
theme.palette.mode === 'dark'
|
2023-10-27 10:01:59 +00:00
|
|
|
|
? error === true
|
2022-09-09 17:18:04 +00:00
|
|
|
|
? '#f44336'
|
2023-10-27 10:01:59 +00:00
|
|
|
|
: String(sx.hoverBorderColor)
|
|
|
|
|
: error === true
|
2023-12-02 17:41:47 +00:00
|
|
|
|
? '#dd0000'
|
|
|
|
|
: '#2f2f2f'
|
2022-09-09 17:18:04 +00:00
|
|
|
|
};
|
2022-03-29 23:16:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
&.focused {
|
2022-09-09 17:18:04 +00:00
|
|
|
|
border: 2px solid ${
|
|
|
|
|
theme.palette.mode === 'dark'
|
2023-10-27 10:01:59 +00:00
|
|
|
|
? error === true
|
2022-09-09 17:18:04 +00:00
|
|
|
|
? '#f44336'
|
|
|
|
|
: '#90caf9'
|
2023-10-27 10:01:59 +00:00
|
|
|
|
: error === true
|
2023-12-02 17:41:47 +00:00
|
|
|
|
? '#dd0000'
|
|
|
|
|
: '#1976d2'
|
2022-09-09 17:18:04 +00:00
|
|
|
|
};
|
2022-03-29 23:16:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& input {
|
|
|
|
|
background-color: ${theme.palette.mode === 'dark' ? '#141414' : '#fff'};
|
2022-09-09 17:18:04 +00:00
|
|
|
|
color: ${theme.palette.mode === 'dark' ? 'rgba(255,255,255,0.65)' : 'rgba(0,0,0,.85)'};
|
2022-10-22 14:32:33 +00:00
|
|
|
|
height: 2em;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
box-sizing: border-box;
|
2022-10-22 14:32:33 +00:00
|
|
|
|
padding: 0.28em 0.4em;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
width: 0;
|
2022-10-14 12:10:12 +00:00
|
|
|
|
min-width: 2.15em;
|
|
|
|
|
font-size: ${theme.typography.fontSize * 1.0714};
|
2022-03-29 23:16:59 +00:00
|
|
|
|
flex-grow: 1;
|
|
|
|
|
border: 0;
|
|
|
|
|
margin: 0;
|
|
|
|
|
outline: 0;
|
2022-10-14 12:10:12 +00:00
|
|
|
|
max-height: 8.6em;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
);
|
|
|
|
|
|
2023-03-03 15:25:21 +00:00
|
|
|
|
interface TagProps {
|
|
|
|
|
label: string;
|
|
|
|
|
icon: string;
|
|
|
|
|
onDelete: () => void;
|
2023-10-12 12:57:51 +00:00
|
|
|
|
onClick: () => void;
|
2023-03-03 15:25:21 +00:00
|
|
|
|
}
|
2023-10-27 10:01:59 +00:00
|
|
|
|
|
|
|
|
|
const Tag: React.FC<TagProps> = ({ label, icon, onDelete, onClick, ...other }) => {
|
2022-10-22 14:32:33 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const iconSize = 1.5 * theme.typography.fontSize;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
return (
|
|
|
|
|
<div {...other}>
|
2023-10-12 12:57:51 +00:00
|
|
|
|
<div style={{ position: 'relative', left: '-5px', top: '0.28em' }} onClick={onClick}>
|
2022-10-22 14:32:33 +00:00
|
|
|
|
<PaymentIcon width={iconSize} height={iconSize} icon={icon} />
|
2022-09-09 17:18:04 +00:00
|
|
|
|
</div>
|
2023-10-12 12:57:51 +00:00
|
|
|
|
<span style={{ position: 'relative', left: '2px' }} onClick={onClick}>
|
|
|
|
|
{label}
|
|
|
|
|
</span>
|
2022-03-29 23:16:59 +00:00
|
|
|
|
<CloseIcon onClick={onDelete} />
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const StyledTag = styled(Tag)(
|
2022-10-14 12:10:12 +00:00
|
|
|
|
({ theme, sx }) => `
|
2022-03-29 23:16:59 +00:00
|
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
2023-10-27 10:01:59 +00:00
|
|
|
|
height: ${String(sx?.height ?? '2.1em')};
|
2022-09-09 16:27:08 +00:00
|
|
|
|
margin: 2px;
|
2022-10-14 12:10:12 +00:00
|
|
|
|
line-height: 1.5em;
|
2022-09-09 17:18:04 +00:00
|
|
|
|
background-color: ${theme.palette.mode === 'dark' ? 'rgba(255,255,255,0.08)' : '#fafafa'};
|
2022-03-29 23:16:59 +00:00
|
|
|
|
border: 1px solid ${theme.palette.mode === 'dark' ? '#303030' : '#e8e8e8'};
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
box-sizing: content-box;
|
2022-10-22 14:32:33 +00:00
|
|
|
|
padding: 0 0.28em 0 0.65em;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
outline: 0;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
|
|
|
|
|
&:focus {
|
|
|
|
|
border-color: ${theme.palette.mode === 'dark' ? '#177ddc' : '#40a9ff'};
|
|
|
|
|
background-color: ${theme.palette.mode === 'dark' ? '#003b57' : '#e6f7ff'};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& span {
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
text-overflow: ellipsis;
|
2022-10-14 12:10:12 +00:00
|
|
|
|
font-size: 0.928em;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& svg {
|
2022-10-14 12:10:12 +00:00
|
|
|
|
font-size: 0.857em;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
cursor: pointer;
|
2022-10-22 14:32:33 +00:00
|
|
|
|
padding: 0.28em;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const ListHeader = styled('span')(
|
2022-09-09 17:18:04 +00:00
|
|
|
|
({ theme }) => `
|
2022-03-29 23:16:59 +00:00
|
|
|
|
color: ${theme.palette.mode === 'dark' ? '#90caf9' : '#1976d2'};
|
Spanish translation (#96)
* Translate tp Spanish (#93)
* update_es.json
* Update es.json
Translate eng to esp from line 222 to end
Co-authored-by: mamifiero <99733022+mamifiero@users.noreply.github.com>
* Fit book and maker UI for variable length text
* Correction and style of the Spanish translation (#95)
* Correction and style of the Spanish translation
The following terms have been unified and adjusted only in Spanish, but can be done in English base too:
* Satoshis, satoshis, sats = Sats (in honour of RoboSats)
* Robot (always first capital letter in honour of RoboSats)
* Lightning, lightning, LN, Lightning Network = Lightningç
* Telegram, TG = Telegram
* Trade, Swap = Trade (Intercambio)
* Trade counterpart, Peer, Trading peer = Peer (Compañero)
* Hold invoice, Bond & Fidelity Bond = Bond (Fianza)
* Trade collateral, Collateral, Trade escrow, Escrow = Collateral (Colateral)
* Burner contact method, Burner email = Burner contact method (Método de contacto de usar y tirar)
* Hidden service (deprecated), Onion services, .onion site = Onion site (sitio cebolla)
https://tb-manual.torproject.org/es/onion-services/
* Tor Browser (Navegador Tor)
https://tb-manual.torproject.org/es/about/
* Craiglist is not common on spanish countries, so now inserted WallaPop
* Update es.json
Co-authored-by: decentralized.b <58108487+decentralizedb@users.noreply.github.com>
Co-authored-by: mamifiero <99733022+mamifiero@users.noreply.github.com>
Co-authored-by: ibertario <68381662+ibertario@users.noreply.github.com>
2022-04-15 16:15:57 +00:00
|
|
|
|
align: left;
|
2022-10-22 14:32:33 +00:00
|
|
|
|
line-height:0.7em;
|
|
|
|
|
max-height: 10.7em;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
display: inline-block;
|
|
|
|
|
background-color: ${theme.palette.mode === 'dark' ? '#141414' : '#ffffff'};
|
2022-10-14 12:10:12 +00:00
|
|
|
|
font-size: 0.875em;
|
2022-03-30 10:57:56 +00:00
|
|
|
|
pointer-events: none;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
`,
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
const Listbox = styled('ul')(
|
2022-10-14 12:10:12 +00:00
|
|
|
|
({ theme, sx }) => `
|
2023-10-27 10:01:59 +00:00
|
|
|
|
width: ${String(sx?.width ?? '15.6em')};
|
2022-03-29 23:16:59 +00:00
|
|
|
|
margin: 2px 0 0;
|
|
|
|
|
padding: 0;
|
|
|
|
|
position: absolute;
|
|
|
|
|
list-style: none;
|
|
|
|
|
background-color: ${theme.palette.mode === 'dark' ? '#141414' : '#fff'};
|
|
|
|
|
overflow: auto;
|
2022-10-14 12:10:12 +00:00
|
|
|
|
max-height: 17em;
|
2022-09-09 16:27:08 +00:00
|
|
|
|
border-radius: 4px;
|
|
|
|
|
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
|
2022-03-29 23:16:59 +00:00
|
|
|
|
z-index: 999;
|
|
|
|
|
|
|
|
|
|
& li {
|
2022-10-14 12:10:12 +00:00
|
|
|
|
padding: 0em 0em;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
display: flex;
|
|
|
|
|
|
|
|
|
|
& span {
|
|
|
|
|
flex-grow: 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& svg {
|
|
|
|
|
color: transparent;
|
|
|
|
|
}
|
2022-04-01 14:52:44 +00:00
|
|
|
|
|
2022-03-29 23:16:59 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& li[aria-selected='true'] {
|
|
|
|
|
background-color: ${theme.palette.mode === 'dark' ? '#2b2b2b' : '#fafafa'};
|
|
|
|
|
font-weight: 600;
|
|
|
|
|
|
|
|
|
|
& svg {
|
2022-04-01 14:52:44 +00:00
|
|
|
|
color: ${theme.palette.primary.main};
|
2022-03-29 23:16:59 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
& li[data-focus='true'] {
|
|
|
|
|
background-color: ${theme.palette.mode === 'dark' ? '#003b57' : '#e6f7ff'};
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
|
|
|
|
|
& svg {
|
|
|
|
|
color: currentColor;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
`,
|
|
|
|
|
);
|
|
|
|
|
|
2023-10-27 10:01:59 +00:00
|
|
|
|
interface AutocompletePaymentsProps {
|
|
|
|
|
value: string;
|
|
|
|
|
optionsType: 'fiat' | 'swap';
|
|
|
|
|
onAutocompleteChange: (value: string) => void;
|
|
|
|
|
tooltipTitle: string;
|
|
|
|
|
labelProps: any;
|
|
|
|
|
tagProps: any;
|
|
|
|
|
listBoxProps: any;
|
|
|
|
|
error: string;
|
|
|
|
|
label: string;
|
|
|
|
|
sx: SxProps<Theme>;
|
|
|
|
|
addNewButtonText: string;
|
|
|
|
|
isFilter: boolean;
|
|
|
|
|
listHeaderText: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const AutocompletePayments: React.FC<AutocompletePaymentsProps> = (props) => {
|
2022-05-08 15:43:08 +00:00
|
|
|
|
const { t } = useTranslation();
|
2022-03-29 23:16:59 +00:00
|
|
|
|
const {
|
|
|
|
|
getRootProps,
|
|
|
|
|
getInputLabelProps,
|
|
|
|
|
getInputProps,
|
|
|
|
|
getTagProps,
|
|
|
|
|
getListboxProps,
|
|
|
|
|
getOptionProps,
|
|
|
|
|
groupedOptions,
|
|
|
|
|
value,
|
2023-10-27 10:01:59 +00:00
|
|
|
|
focused = true,
|
2022-03-29 23:16:59 +00:00
|
|
|
|
setAnchorEl,
|
|
|
|
|
} = useAutocomplete({
|
2022-10-14 12:10:12 +00:00
|
|
|
|
fullWidth: true,
|
2022-03-29 23:16:59 +00:00
|
|
|
|
id: 'payment-methods',
|
|
|
|
|
multiple: true,
|
2022-10-14 12:10:12 +00:00
|
|
|
|
value: props.value,
|
2023-10-27 10:01:59 +00:00
|
|
|
|
options: props.optionsType === 'fiat' ? fiatMethods : swapMethods,
|
2022-03-29 23:16:59 +00:00
|
|
|
|
getOptionLabel: (option) => option.name,
|
2023-05-09 00:37:23 +00:00
|
|
|
|
onInputChange: (e) => {
|
2023-10-27 10:01:59 +00:00
|
|
|
|
setVal(e.target.value ?? '');
|
|
|
|
|
},
|
|
|
|
|
onChange: (event, value) => {
|
|
|
|
|
props.onAutocompleteChange(value);
|
2023-05-09 00:37:23 +00:00
|
|
|
|
},
|
|
|
|
|
onClose: () => {
|
|
|
|
|
setVal(() => '');
|
|
|
|
|
},
|
2022-03-29 23:16:59 +00:00
|
|
|
|
});
|
2022-03-30 10:57:56 +00:00
|
|
|
|
|
2022-10-14 12:10:12 +00:00
|
|
|
|
const [val, setVal] = useState('');
|
|
|
|
|
const fewerOptions = groupedOptions.length > 8 ? groupedOptions.slice(0, 8) : groupedOptions;
|
2022-10-22 14:32:33 +00:00
|
|
|
|
const theme = useTheme();
|
|
|
|
|
const iconSize = 1.5 * theme.typography.fontSize;
|
2022-03-29 23:16:59 +00:00
|
|
|
|
|
2023-10-27 10:01:59 +00:00
|
|
|
|
function handleAddNew(inputProps: any): void {
|
2022-10-20 18:06:16 +00:00
|
|
|
|
fiatMethods.push({ name: inputProps.value, icon: 'custom' });
|
2022-09-09 17:33:29 +00:00
|
|
|
|
const a = value.push({ name: inputProps.value, icon: 'custom' });
|
2022-09-09 17:18:04 +00:00
|
|
|
|
setVal(() => '');
|
2022-03-29 23:16:59 +00:00
|
|
|
|
|
2023-10-27 10:01:59 +00:00
|
|
|
|
if (a !== undefined) {
|
2022-10-14 12:10:12 +00:00
|
|
|
|
props.onAutocompleteChange(value);
|
2022-09-09 17:18:04 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
2022-05-02 19:28:34 +00:00
|
|
|
|
|
2022-03-29 23:16:59 +00:00
|
|
|
|
return (
|
|
|
|
|
<Root>
|
2022-09-09 17:18:04 +00:00
|
|
|
|
<Tooltip
|
|
|
|
|
placement='top'
|
2023-10-27 10:01:59 +00:00
|
|
|
|
enterTouchDelay={props.tooltipTitle === '' ? 99999 : 300}
|
|
|
|
|
enterDelay={props.tooltipTitle === '' ? 99999 : 700}
|
2022-09-09 17:18:04 +00:00
|
|
|
|
enterNextDelay={2000}
|
|
|
|
|
title={props.tooltipTitle}
|
|
|
|
|
>
|
|
|
|
|
<div {...getRootProps()}>
|
2022-10-14 12:10:12 +00:00
|
|
|
|
<Fade
|
|
|
|
|
appear={false}
|
2023-10-27 10:01:59 +00:00
|
|
|
|
in={fewerOptions.length === 0 && value.length === 0 && val.length === 0}
|
2022-10-14 12:10:12 +00:00
|
|
|
|
>
|
|
|
|
|
<div style={{ height: 0, display: 'flex', alignItems: 'flex-start' }}>
|
|
|
|
|
<Label
|
|
|
|
|
{...getInputLabelProps()}
|
2023-10-27 10:01:59 +00:00
|
|
|
|
sx={{ top: '0.72em', ...(props.labelProps?.sx ?? {}) }}
|
|
|
|
|
error={Boolean(props.error)}
|
2022-10-14 12:10:12 +00:00
|
|
|
|
>
|
|
|
|
|
{props.label}
|
|
|
|
|
</Label>
|
|
|
|
|
</div>
|
|
|
|
|
</Fade>
|
2022-09-09 17:18:04 +00:00
|
|
|
|
<InputWrapper
|
|
|
|
|
ref={setAnchorEl}
|
2023-10-27 10:01:59 +00:00
|
|
|
|
error={Boolean(props.error)}
|
2022-09-09 17:18:04 +00:00
|
|
|
|
className={focused ? 'focused' : ''}
|
2022-10-14 12:10:12 +00:00
|
|
|
|
sx={{
|
|
|
|
|
minHeight: '2.9em',
|
|
|
|
|
maxHeight: '8.6em',
|
|
|
|
|
hoverBorderColor: '#ffffff',
|
|
|
|
|
...props.sx,
|
|
|
|
|
}}
|
2022-09-09 17:18:04 +00:00
|
|
|
|
>
|
2022-05-10 18:44:12 +00:00
|
|
|
|
{value.map((option, index) => (
|
2022-10-14 12:10:12 +00:00
|
|
|
|
<StyledTag
|
2023-10-27 10:01:59 +00:00
|
|
|
|
key={index}
|
2022-10-14 12:10:12 +00:00
|
|
|
|
label={t(option.name)}
|
|
|
|
|
icon={option.icon}
|
2023-10-12 12:57:51 +00:00
|
|
|
|
onClick={props.onClick}
|
2023-10-27 10:01:59 +00:00
|
|
|
|
sx={{ height: '2.1em', ...(props.tagProps ?? {}) }}
|
2022-10-14 12:10:12 +00:00
|
|
|
|
{...getTagProps({ index })}
|
|
|
|
|
/>
|
2022-05-10 18:44:12 +00:00
|
|
|
|
))}
|
2022-10-14 12:10:12 +00:00
|
|
|
|
{value.length > 0 && props.isFilter ? null : <input {...getInputProps()} value={val} />}
|
2022-05-10 18:44:12 +00:00
|
|
|
|
</InputWrapper>
|
|
|
|
|
</div>
|
|
|
|
|
</Tooltip>
|
2022-10-14 12:10:12 +00:00
|
|
|
|
<Grow in={fewerOptions.length > 0}>
|
2023-10-27 10:01:59 +00:00
|
|
|
|
<Listbox sx={props.listBoxProps?.sx ?? undefined} {...getListboxProps()}>
|
2022-10-14 12:10:12 +00:00
|
|
|
|
{!props.isFilter ? (
|
|
|
|
|
<div
|
|
|
|
|
style={{
|
|
|
|
|
position: 'fixed',
|
|
|
|
|
minHeight: '1.428em',
|
|
|
|
|
marginLeft: `${3 - props.listHeaderText.length * 0.05}em`,
|
|
|
|
|
marginTop: '-0.928em',
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<ListHeader>
|
|
|
|
|
<i>{props.listHeaderText + ' '} </i>{' '}
|
|
|
|
|
</ListHeader>
|
|
|
|
|
</div>
|
|
|
|
|
) : null}
|
|
|
|
|
{fewerOptions.map((option, index) => (
|
2022-05-02 19:28:34 +00:00
|
|
|
|
<li key={option.name} {...getOptionProps({ option, index })}>
|
2022-09-09 17:18:04 +00:00
|
|
|
|
<Button
|
|
|
|
|
fullWidth={true}
|
|
|
|
|
color='inherit'
|
|
|
|
|
size='small'
|
|
|
|
|
sx={{ textTransform: 'none' }}
|
|
|
|
|
style={{ justifyContent: 'flex-start' }}
|
|
|
|
|
>
|
2022-10-14 12:10:12 +00:00
|
|
|
|
<div style={{ padding: '0.286em', position: 'relative', top: '0.35em' }}>
|
2022-10-22 14:32:33 +00:00
|
|
|
|
<PaymentIcon width={iconSize} height={iconSize} icon={option.icon} />
|
2022-09-09 17:18:04 +00:00
|
|
|
|
</div>
|
2022-10-14 12:10:12 +00:00
|
|
|
|
<Typography variant='inherit' align='left'>
|
|
|
|
|
{t(option.name)}
|
|
|
|
|
</Typography>
|
2022-04-01 14:52:44 +00:00
|
|
|
|
</Button>
|
2022-10-14 12:10:12 +00:00
|
|
|
|
<div style={{ position: 'relative', top: '0.357em' }}>
|
2022-09-09 17:18:04 +00:00
|
|
|
|
<CheckIcon />
|
|
|
|
|
</div>
|
2022-03-29 23:16:59 +00:00
|
|
|
|
</li>
|
|
|
|
|
))}
|
2022-10-14 12:10:12 +00:00
|
|
|
|
{val != null || !props.isFilter ? (
|
2022-09-09 17:18:04 +00:00
|
|
|
|
val.length > 2 ? (
|
2023-10-27 10:01:59 +00:00
|
|
|
|
<Button
|
|
|
|
|
size='small'
|
|
|
|
|
fullWidth={true}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
handleAddNew(getInputProps());
|
|
|
|
|
}}
|
|
|
|
|
>
|
2022-10-14 12:10:12 +00:00
|
|
|
|
<DashboardCustomizeIcon sx={{ width: '1em', height: '1em' }} />
|
2022-09-09 17:18:04 +00:00
|
|
|
|
{props.addNewButtonText}
|
|
|
|
|
</Button>
|
|
|
|
|
) : null
|
|
|
|
|
) : null}
|
2022-03-29 23:16:59 +00:00
|
|
|
|
</Listbox>
|
2022-10-14 12:10:12 +00:00
|
|
|
|
</Grow>
|
|
|
|
|
|
|
|
|
|
{/* Here goes what happens if there is no fewerOptions */}
|
|
|
|
|
<Grow in={getInputProps().value.length > 0 && !props.isFilter && fewerOptions.length === 0}>
|
2022-03-29 23:16:59 +00:00
|
|
|
|
<Listbox {...getListboxProps()}>
|
2023-10-27 10:01:59 +00:00
|
|
|
|
<Button
|
|
|
|
|
fullWidth={true}
|
|
|
|
|
onClick={() => {
|
|
|
|
|
handleAddNew(getInputProps());
|
|
|
|
|
}}
|
|
|
|
|
>
|
2022-10-14 12:10:12 +00:00
|
|
|
|
<DashboardCustomizeIcon sx={{ width: '1.28em', height: '1.28em' }} />
|
2022-09-09 17:18:04 +00:00
|
|
|
|
{props.addNewButtonText}
|
|
|
|
|
</Button>
|
2022-03-29 23:16:59 +00:00
|
|
|
|
</Listbox>
|
2022-10-14 12:10:12 +00:00
|
|
|
|
</Grow>
|
2022-03-29 23:16:59 +00:00
|
|
|
|
</Root>
|
|
|
|
|
);
|
2023-10-27 10:01:59 +00:00
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default AutocompletePayments;
|