diff --git a/api/models.py b/api/models.py index 60ed9c1a..7c8b710d 100644 --- a/api/models.py +++ b/api/models.py @@ -50,7 +50,8 @@ class Order(models.Model): type = models.PositiveSmallIntegerField(choices=Types.choices, null=False) currency = models.PositiveSmallIntegerField(choices=Currencies.choices, null=False) amount = models.DecimalField(max_digits=9, decimal_places=4, validators=[MinValueValidator(0.00001)]) - premium = models.DecimalField(max_digits=3, decimal_places=2, default=0, null=True, validators=[MinValueValidator(-100), MaxValueValidator(1000)]) + payment_method = models.CharField(max_length=30, null=False, default="Not specified") + premium = models.DecimalField(max_digits=5, decimal_places=2, default=0, null=True, validators=[MinValueValidator(-100), MaxValueValidator(999)]) satoshis = models.PositiveBigIntegerField(null=True, validators=[MinValueValidator(min_satoshis_trade), MaxValueValidator(max_satoshis_trade)]) # order participants diff --git a/api/serializers.py b/api/serializers.py index 9435ecdd..d0e88419 100644 --- a/api/serializers.py +++ b/api/serializers.py @@ -4,9 +4,9 @@ from .models import Order class OrderSerializer(serializers.ModelSerializer): class Meta: model = Order - fields = ('id','status','created_at','type','currency','amount','premium','satoshis','maker') + fields = ('id','status','created_at','type','currency','amount','payment_method','premium','satoshis','maker') class MakeOrderSerializer(serializers.ModelSerializer): class Meta: model = Order - fields = ('type','currency','amount','premium','satoshis') \ No newline at end of file + fields = ('type','currency','amount','payment_method','premium','satoshis') \ No newline at end of file diff --git a/api/views.py b/api/views.py index acdddf2e..490dd537 100644 --- a/api/views.py +++ b/api/views.py @@ -18,6 +18,7 @@ class MakeOrder(APIView): otype = serializer.data.get('type') currency = serializer.data.get('currency') amount = serializer.data.get('amount') + payment_method = serializer.data.get('payment_method') premium = serializer.data.get('premium') satoshis = serializer.data.get('satoshis') @@ -30,6 +31,7 @@ class MakeOrder(APIView): type=otype, currency=currency, amount=amount, + payment_method=payment_method, premium=premium, satoshis=satoshis) order.save() diff --git a/frontend/src/components/MakerPage.js b/frontend/src/components/MakerPage.js index 889a7627..bc236a4e 100644 --- a/frontend/src/components/MakerPage.js +++ b/frontend/src/components/MakerPage.js @@ -23,6 +23,7 @@ export default class MakerPage extends Component { defaultCurrency = 1; defaultCurrencyCode = 'USD'; defaultAmount = 0 ; + defaultPaymentMethod = "Not specified"; defaultPremium = 0; constructor(props) { @@ -33,6 +34,7 @@ export default class MakerPage extends Component { currency: this.defaultCurrency, currencyCode: this.defaultCurrencyCode, amount: this.defaultAmount, + payment_method: this.defaultPaymentMethod, premium: 0, satoshis: null, } @@ -55,6 +57,11 @@ export default class MakerPage extends Component { amount: e.target.value, }); } + handlePaymentMethodChange=(e)=>{ + this.setState({ + payment_method: e.target.value, + }); + } handlePremiumChange=(e)=>{ this.setState({ premium: e.target.value, @@ -89,6 +96,7 @@ export default class MakerPage extends Component { type: this.state.type, currency: this.state.currency, amount: this.state.amount, + payment_method: this.state.payment_method, premium: this.state.premium, satoshis: this.state.satoshis, }), @@ -108,11 +116,6 @@ export default class MakerPage extends Component { - -
- Choose Buy or Sell Bitcoin -
-
+ +
+ Choose Buy or Sell Bitcoin +
+
- -
- Select Payment Currency -
-
+ +
+ Select Payment Currency +
+
- -
- Amount of Fiat to Trade -
-
+ +
+ Amount of Fiat to Trade +
+
+
+ + + + +
+ Enter the Payment Method(s) +
+
+
- -
- Choose a pricing method -
-
+ +
+ Choose a Pricing Method +
+
{/* conditional shows either Premium % field or Satoshis field based on pricing method */} { this.state.isExplicit ? - -
- Explicit Amount in Satoshis -
-
+ +
+ Explicit Amount in Satoshis +
+
: - -
- Premium Relative to Market Price (%) -
-
+ +
+ Premium Relative to Market Price (%) +
+
} - +
Create a BTC {this.state.type==0 ? "buy":"sell"} order for {this.state.amount} {this.state.currencyCode} @@ -247,9 +276,6 @@ export default class MakerPage extends Component { }
-