Make method picker functional. Add Swap methods and icons.
@ -196,7 +196,7 @@ class Order(models.Model):
|
|||||||
has_range = models.BooleanField(default=False, null=False, blank=False)
|
has_range = models.BooleanField(default=False, null=False, blank=False)
|
||||||
min_amount = models.DecimalField(max_digits=18, decimal_places=8, null=True, blank=True)
|
min_amount = models.DecimalField(max_digits=18, decimal_places=8, null=True, blank=True)
|
||||||
max_amount = models.DecimalField(max_digits=18, decimal_places=8, null=True, blank=True)
|
max_amount = models.DecimalField(max_digits=18, decimal_places=8, null=True, blank=True)
|
||||||
payment_method = models.CharField(max_length=35,
|
payment_method = models.CharField(max_length=70,
|
||||||
null=False,
|
null=False,
|
||||||
default="not specified",
|
default="not specified",
|
||||||
blank=True)
|
blank=True)
|
||||||
|
@ -160,11 +160,18 @@ export default class MakerPage extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handlePaymentMethodChange=(value)=>{
|
handlePaymentMethodChange=(value)=>{
|
||||||
|
if (value.length > 65){
|
||||||
|
this.setState({
|
||||||
|
badPaymentMethod: true,
|
||||||
|
});
|
||||||
|
}else{
|
||||||
this.setState({
|
this.setState({
|
||||||
payment_method: value,
|
payment_method: value.substring(0,68),
|
||||||
badPaymentMethod: value.length > 35,
|
badPaymentMethod: value.length > 65,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handlePremiumChange=(e)=>{
|
handlePremiumChange=(e)=>{
|
||||||
if(e.target.value > 999){
|
if(e.target.value > 999){
|
||||||
var bad_premium = "Must be less than 999%"
|
var bad_premium = "Must be less than 999%"
|
||||||
@ -317,29 +324,12 @@ export default class MakerPage extends Component {
|
|||||||
</Grid>
|
</Grid>
|
||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
<Tooltip placement="top" enterTouchDelay="300" enterDelay="700" enterNextDelay="2000" title="Enter your preferred fiat payment methods. Fast methods are highly recommended.">
|
<Tooltip placement="top" enterTouchDelay="300" enterDelay="700" enterNextDelay="2000" title="Enter your preferred fiat payment methods. Fast methods are highly recommended.">
|
||||||
{/* <TextField
|
|
||||||
sx={{width:240}}
|
|
||||||
label={this.state.currency==1000 ? "Swap Destination (e.g. rBTC)":"Fiat Payment Method(s)"}
|
|
||||||
error={this.state.badPaymentMethod}
|
|
||||||
helperText={this.state.badPaymentMethod ? "Must be shorter than 35 characters":""}
|
|
||||||
type="text"
|
|
||||||
require={true}
|
|
||||||
inputProps={{
|
|
||||||
style: {textAlign:"center"},
|
|
||||||
maxLength: 35
|
|
||||||
}}
|
|
||||||
onChange={this.handlePaymentMethodChange}
|
|
||||||
/> */}
|
|
||||||
<AutocompletePayments
|
<AutocompletePayments
|
||||||
onAutocompleteChange={this.handlePaymentMethodChange}
|
onAutocompleteChange={this.handlePaymentMethodChange}
|
||||||
// inputProps={{
|
optionsType={this.state.currency==1000 ? "swap":"fiat"}
|
||||||
// style: {textAlign:"center"},
|
|
||||||
// maxLength: 35
|
|
||||||
// }}
|
|
||||||
type="text"
|
|
||||||
error={this.state.badPaymentMethod}
|
error={this.state.badPaymentMethod}
|
||||||
helperText={this.state.badPaymentMethod ? "Must be shorter than 35 characters":""}
|
helperText={this.state.badPaymentMethod ? "Must be shorter than 65 characters":""}
|
||||||
label={this.state.currency==1000 ? "Swap Destination (e.g. rBTC)":"Fiat Payment Method(s)"}
|
label={this.state.currency==1000 ? "Swap Destination(s)" : "Fiat Payment Method(s)"}
|
||||||
/>
|
/>
|
||||||
</Tooltip>
|
</Tooltip>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -18,23 +18,23 @@ const Root = styled('div')(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const Label = styled('label')(
|
const Label = styled('label')(
|
||||||
({ theme }) => `
|
({ theme , error}) => `
|
||||||
color: ${theme.palette.mode === 'dark' ? '#cfcfcf' : '#717171'};
|
color: ${theme.palette.mode === 'dark' ? (error? '#f44336': '#cfcfcf') : (error? '#dd0000':'#717171')};
|
||||||
aling: center;
|
aling: center;
|
||||||
padding: 0 0 4px;
|
padding: 0 0 4px;
|
||||||
line-height: 1.5;
|
line-height: 1.5; f44336
|
||||||
display: block;
|
display: block;
|
||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
|
|
||||||
const InputWrapper = styled('div')(
|
const InputWrapper = styled('div')(
|
||||||
({ theme }) => `
|
({ theme , error}) => `
|
||||||
width: 244px;
|
width: 244px;
|
||||||
min-height: 44px;
|
min-height: 44px;
|
||||||
max-height: 166px;
|
max-height: 128px;
|
||||||
max-rows: 5;
|
max-rows: 5;
|
||||||
border: 1px solid ${theme.palette.mode === 'dark' ? '#434343' : '#c4c4c4'};
|
border: 1px solid ${theme.palette.mode === 'dark' ? (error? '#f44336': '#434343') : (error? '#dd0000':'#c4c4c4')};
|
||||||
background-color: ${theme.palette.mode === 'dark' ? '#141414' : '#fff'};
|
background-color: ${theme.palette.mode === 'dark' ? '#141414' : '#fff'};
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
padding: 1px;
|
padding: 1px;
|
||||||
@ -43,11 +43,11 @@ const InputWrapper = styled('div')(
|
|||||||
overflow-y:auto;
|
overflow-y:auto;
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
border-color: ${theme.palette.mode === 'dark' ? '#ffffff' : '#2f2f2f'};
|
border-color: ${theme.palette.mode === 'dark' ? (error? '#f44336':'#ffffff') : (error? '#dd0000' :'#2f2f2f')};
|
||||||
}
|
}
|
||||||
|
|
||||||
&.focused {
|
&.focused {
|
||||||
border: 2px solid ${theme.palette.mode === 'dark' ? '#90caf9' : '#1976d2'};
|
border: 2px solid ${theme.palette.mode === 'dark' ? (error? '#f44336':'#90caf9') : (error? '#dd0000' :'#1976d2')};
|
||||||
}
|
}
|
||||||
|
|
||||||
& input {
|
& input {
|
||||||
@ -65,7 +65,7 @@ const InputWrapper = styled('div')(
|
|||||||
border: 0;
|
border: 0;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
outline: 0;
|
outline: 0;
|
||||||
max-height: 166px;
|
max-height: 128px;
|
||||||
}
|
}
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
@ -130,10 +130,13 @@ const ListHeader = styled('span')(
|
|||||||
({ theme }) => `
|
({ theme }) => `
|
||||||
color: ${theme.palette.mode === 'dark' ? '#90caf9' : '#1976d2'};
|
color: ${theme.palette.mode === 'dark' ? '#90caf9' : '#1976d2'};
|
||||||
aling: center;
|
aling: center;
|
||||||
width: 187px;
|
width: 141px;
|
||||||
|
line-height:10px;
|
||||||
|
max-height: 10px;
|
||||||
display: inline-block;
|
display: inline-block;
|
||||||
background-color: ${theme.palette.mode === 'dark' ? '#141414' : '#ffffff'};
|
background-color: ${theme.palette.mode === 'dark' ? '#141414' : '#ffffff'};
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
|
pointer-events: none;
|
||||||
`,
|
`,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -200,43 +203,39 @@ export default function AutocompletePayments(props) {
|
|||||||
sx: {width:'200px', align:'left'},
|
sx: {width:'200px', align:'left'},
|
||||||
id: 'payment-methods',
|
id: 'payment-methods',
|
||||||
multiple: true,
|
multiple: true,
|
||||||
options: somePaymentMethods,
|
options: props.optionsType=="fiat" ? somePaymentMethods : someSwapDestinations,
|
||||||
getOptionLabel: (option) => option.name,
|
getOptionLabel: (option) => option.name,
|
||||||
onInputChange: (e) => setVal(e.target.value) & props.onAutocompleteChange(optionsToString()),
|
onInputChange: (e) => setVal(e.target.value),
|
||||||
onChange: () => props.onAutocompleteChange(optionsToString()),
|
onChange: (event, value) => props.onAutocompleteChange(optionsToString(value)),
|
||||||
|
onClose: () => (setVal(() => "")),
|
||||||
});
|
});
|
||||||
|
|
||||||
const [val, setVal] = useState();
|
const [val, setVal] = useState();
|
||||||
|
|
||||||
function optionsToString(){
|
function optionsToString(newValue){
|
||||||
var str = '';
|
var str = '';
|
||||||
var arrayLength = value.length;
|
var arrayLength = newValue.length;
|
||||||
for (var i = 0; i < arrayLength; i++) {
|
for (var i = 0; i < arrayLength; i++) {
|
||||||
str += value[i].name + ' ';
|
str += newValue[i].name + ' ';
|
||||||
}
|
}
|
||||||
return str;
|
return str.slice(0, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleAddNew(inputProps){
|
function handleAddNew(inputProps){
|
||||||
console.log(inputProps)
|
|
||||||
somePaymentMethods.push({name: inputProps.value, icon:'custom'})
|
somePaymentMethods.push({name: inputProps.value, icon:'custom'})
|
||||||
var a = value.push({name: inputProps.value, icon:'custom'});
|
var a = value.push({name: inputProps.value, icon:'custom'});
|
||||||
setVal(() => "");
|
setVal(() => "");
|
||||||
|
|
||||||
if(a || a == null){props.onAutocompleteChange(optionsToString())}
|
if(a || a == null){props.onAutocompleteChange(optionsToString(value))}
|
||||||
|
return false
|
||||||
};
|
};
|
||||||
|
|
||||||
// function handleInputChange(e){
|
|
||||||
// getInputProps().onChange(e)
|
|
||||||
// setVal(() => e.target.value);
|
|
||||||
// };
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Root>
|
<Root>
|
||||||
{console.log(()=>props.onAutocompleteChange(value))}
|
<div style={{height:'5px'}}></div>
|
||||||
<div style={{height:'5px'}}></div>
|
|
||||||
<div {...getRootProps()} >
|
<div {...getRootProps()} >
|
||||||
<Label {...getInputLabelProps()}>Payment method(s)</Label>
|
<Label {...getInputLabelProps()} error={props.error}>{props.label}</Label>
|
||||||
<InputWrapper ref={setAnchorEl} className={focused ? 'focused' : ''}>
|
<InputWrapper ref={setAnchorEl} error={props.error} className={focused ? 'focused' : ''}>
|
||||||
{value.map((option, index) => (
|
{value.map((option, index) => (
|
||||||
<StyledTag label={option.name} icon={option.icon} {...getTagProps({ index })} />
|
<StyledTag label={option.name} icon={option.icon} {...getTagProps({ index })} />
|
||||||
))}
|
))}
|
||||||
@ -245,7 +244,7 @@ export default function AutocompletePayments(props) {
|
|||||||
</div>
|
</div>
|
||||||
{groupedOptions.length > 0 ? (
|
{groupedOptions.length > 0 ? (
|
||||||
<Listbox {...getListboxProps()}>
|
<Listbox {...getListboxProps()}>
|
||||||
<div style={{position:'fixed', minHeight:'20px', marginLeft: '30px', marginTop: '-13px'}}>
|
<div style={{position:'fixed', minHeight:'20px', marginLeft: '53px', marginTop: '-13px'}}>
|
||||||
<ListHeader><i>You can add any method </i></ListHeader>
|
<ListHeader><i>You can add any method </i></ListHeader>
|
||||||
</div>
|
</div>
|
||||||
{groupedOptions.map((option, index) => (
|
{groupedOptions.map((option, index) => (
|
||||||
@ -301,3 +300,10 @@ var somePaymentMethods = [
|
|||||||
{name: "Tigo Pesa",icon:'tigopesa'},
|
{name: "Tigo Pesa",icon:'tigopesa'},
|
||||||
{name: "Cash F2F",icon:'cash'},
|
{name: "Cash F2F",icon:'cash'},
|
||||||
];
|
];
|
||||||
|
|
||||||
|
var someSwapDestinations = [
|
||||||
|
{name: "On-Chain BTC",icon:'onchain'},
|
||||||
|
{name: "RBTC",icon:'rbtc'},
|
||||||
|
{name: "LBTC",icon:'lbtc'},
|
||||||
|
{name: "WBTC",icon:'wbtc'},
|
||||||
|
];
|
Before Width: | Height: | Size: 208 KiB After Width: | Height: | Size: 208 KiB |
BIN
frontend/src/components/payment-method-images/lbtc.png
Normal file
After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 4.1 KiB After Width: | Height: | Size: 4.1 KiB |
Before Width: | Height: | Size: 98 KiB After Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 10 KiB After Width: | Height: | Size: 10 KiB |
BIN
frontend/src/components/payment-method-images/onchain.png
Normal file
After Width: | Height: | Size: 105 KiB |
BIN
frontend/src/components/payment-method-images/rbtc.png
Normal file
After Width: | Height: | Size: 65 KiB |
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 20 KiB |
BIN
frontend/src/components/payment-method-images/wbtc.png
Normal file
After Width: | Height: | Size: 21 KiB |
Before Width: | Height: | Size: 28 KiB After Width: | Height: | Size: 28 KiB |