From a1741e25dda2c22f38d56ad531862db0d5c1fa57 Mon Sep 17 00:00:00 2001 From: Aditya Anand M C Date: Wed, 29 Apr 2020 07:50:01 +0530 Subject: [PATCH] cross: redo payout flow --- app/assets/v2/css/bounty.css | 21 +- app/assets/v2/css/colors.css | 5 + app/assets/v2/js/pages/bounty_details2.js | 41 ++-- app/assets/v2/js/vue-filters.js | 8 + app/dashboard/sync/etc.py | 1 - app/dashboard/templates/bounty/details2.html | 219 +++++++++++++++---- app/dashboard/views.py | 4 + 7 files changed, 239 insertions(+), 60 deletions(-) diff --git a/app/assets/v2/css/bounty.css b/app/assets/v2/css/bounty.css index c7f86df8925..d131b23e886 100644 --- a/app/assets/v2/css/bounty.css +++ b/app/assets/v2/css/bounty.css @@ -88,6 +88,11 @@ body { height: 80px; } +.avatar-small { + width: 25px; + height: 25px; +} + #status { color: #00A55E; text-transform: uppercase; @@ -110,10 +115,6 @@ body { list-style-type: none; } -.related-bounties .bounty-title { - color: #3E00FF; -} - .related-bounties .static-stars .far { font-size: 0.8rem; } @@ -464,6 +465,7 @@ a.btn { padding: 0.5rem; } +.related-bounties .bounty-title, #funder_notif_info #bounty_funded_by, #funder_notif_info i { color: #3E00FF; @@ -750,7 +752,7 @@ a.btn { border-top: none; border-left: none; border-right: none; - max-width: 5rem; + max-width: 12rem; outline: none; color: #03B16B; } @@ -835,6 +837,15 @@ a.btn { } } +.payout-summary-container { + background: #F9F7FF; +} + +#submit_transaction .payout-tx-container { + border: 1px solid #D8D8D8; + border-radius: 3px; +} + @media (min-width: 769px) { .activity-time { margin-left: 0.625rem !important; diff --git a/app/assets/v2/css/colors.css b/app/assets/v2/css/colors.css index 3bcb8ccd392..0ec44ecc7fc 100644 --- a/app/assets/v2/css/colors.css +++ b/app/assets/v2/css/colors.css @@ -19,6 +19,7 @@ --gc-grey: #fafafa; --gc-blue-grey: #f2f6f9; --gc-dark-grey: #868789; + --gc-medium-dark-gray: #666666; --gc-darker-grey: #3d3d3d; --text-light: #D8D8D8; @@ -56,3 +57,7 @@ .text-highlight-yellow { color: var(--gc-yellow); } + +.text-medium-dark-grey { + color: var(--gc-medium-dark-gray); +} \ No newline at end of file diff --git a/app/assets/v2/js/pages/bounty_details2.js b/app/assets/v2/js/pages/bounty_details2.js index a06a1fd4366..58951dd5533 100644 --- a/app/assets/v2/js/pages/bounty_details2.js +++ b/app/assets/v2/js/pages/bounty_details2.js @@ -235,15 +235,22 @@ Vue.mixin({ }); } }, - fulfillmentComplete: function(fulfillment_id, amount, event) { + fulfillmentComplete: function(fulfillment_id, event) { let vm = this; + const token_name = vm.bounty.token_name; const decimals = tokenNameToDetails('mainnet', token_name).decimals; + const amount = vm.fulfillment_context.amount; + const payout_tx_id = vm.fulfillment_context.payout_tx_id ? vm.fulfillment_context.payout_tx_id : null; + const bounty_owner_address = vm.bounty.bounty_owner_address; + const payload = { amount: amount * 10 ** decimals, token_name: token_name, - bounty_owner_address: vm.bounty.bounty_owner_address + bounty_owner_address: bounty_owner_address, + payout_tx_id: payout_tx_id }; + const apiUrlBounty = `/api/v1/bounty/payout/${fulfillment_id}`; event.target.disabled = true; @@ -252,8 +259,14 @@ Vue.mixin({ event.target.disabled = false; if (200 <= response.status && response.status <= 204) { console.log('success', response); + vm.fetchBounty(); this.$refs['payout-modal'][0].closeModal(); + + vm.fulfillment_context = { + active_step: 'payout_amount' + }; + } else { _alert('Unable to make payout bounty. Please try again later', 'error'); console.error(`error: bounty payment failed with status: ${response.status} and message: ${response.message}`); @@ -401,15 +414,14 @@ Vue.mixin({ return false; }, - totalAmountPaid: function(inputAmount) { + goToStep: function(nextStep, currentStep, flow) { let vm = this; - let amount_paid = 0; - - vm.bounty.fulfillments.forEach(fulfillment => { - amount_paid += (fulfillment.payout_amount / 10 ** vm.decimals); - }); - vm.bounty.amount_paid = parseFloat(amount_paid) + parseFloat(inputAmount); + if (flow) { + vm.fulfillment_context.flow = flow; + } + vm.fulfillment_context.referrer = currentStep; + vm.fulfillment_context.active_step = nextStep; } }, computed: { @@ -437,7 +449,6 @@ Vue.mixin({ } }); - if (document.getElementById('gc-bounty-detail')) { appBounty = new Vue({ delimiters: [ '[[', ']]' ], @@ -451,8 +462,11 @@ if (document.getElementById('gc-bounty-detail')) { isOwner: false, isOwnerAddress: false, is_bounties_network: is_bounties_network, - inputAmount: 0, - decimals: 18, + fulfillment_context: { + active_step: 'check_wallet_owner', + amount: 0 + }, + decimals: 18, // TODO: UPDATE BASED ON TOKEN inputBountyOwnerAddress: bounty.bounty_owner_address, contxt: document.contxt, quickLinks: [] @@ -515,9 +529,6 @@ var show_extend_deadline_modal = function() { extend_expiration(document.result['pk'], { deadline: extended_time }); - // setTimeout(function() { - // window.location.reload(); - // }, 2000); }); }); }); diff --git a/app/assets/v2/js/vue-filters.js b/app/assets/v2/js/vue-filters.js index cbabf0d16a4..9936246f5e5 100644 --- a/app/assets/v2/js/vue-filters.js +++ b/app/assets/v2/js/vue-filters.js @@ -110,3 +110,11 @@ Vue.filter('capitalize', function(value) { value = value.toString(); return value.charAt(0).toUpperCase() + value.slice(1); }); + +Vue.filter('toUppercase', function(value) { + return value.toUpperCase(); +}); + +Vue.filter('toLower', function(value) { + return value.toLowerCase(); +}); \ No newline at end of file diff --git a/app/dashboard/sync/etc.py b/app/dashboard/sync/etc.py index bb26bae3e51..73876b0b678 100644 --- a/app/dashboard/sync/etc.py +++ b/app/dashboard/sync/etc.py @@ -8,7 +8,6 @@ def find_txn_on_etc_explorer(fulfillment, network='mainnet'): token_name = fulfillment.token_name if token_name != 'ETC': return None - funderAddress = fulfillment.bounty.bounty_owner_address amount = fulfillment.payout_amount payeeAddress = fulfillment.fulfiller_address diff --git a/app/dashboard/templates/bounty/details2.html b/app/dashboard/templates/bounty/details2.html index 9b114d0c989..9df6f5f9228 100644 --- a/app/dashboard/templates/bounty/details2.html +++ b/app/dashboard/templates/bounty/details2.html @@ -164,7 +164,7 @@

[[bounty.title]]< - @@ -356,39 +356,180 @@

{% trans "SUBMISSIONS" %}
Hours worked: [[ fulfillment.fulfiller_metadata.data.payload.fulfiller.hoursWorked ]]

+
-
-

- - -

- -

- Payout [[ fulfillment.profile.handle ]] -

- -

- Scan QR code using address - [[bounty.bounty_owner_address]] -

- -

- - [[ bounty.token_name ]] -

- - Scan the QR code above with your ETC Wallet to payout - + +
+ +
+

Payout

+ + +

+ + +

+ +

+ @[[ fulfillment.fulfiller_github_username ]] + + [[ fulfillment.fulfiller_address | truncateHash ]] +

+
+ +
+ +

+ This bounty can only be paid out from the same wallet address that funded it. +

+

+ Make sure you’re paying out from this address + + [[ bounty.bounty_owner_address ]] + ? +

+ +

+ + I don’t have access to this address + +

+ +
+ +
+

How much are you paying out to this person?

+ +

+ + [[ bounty.token_name ]] +

+ + + + +

+ + + Previous Step + +

+
+ +
+

Scan the QR code with your [[ bounty.token_name ]] wallet to payout.

+

+ + ( Don't have a QR wallet ? ) + +

+ +
+

+ From: [[ bounty.bounty_owner_address ]] +

+

+ Amount: [[ fulfillment_context.amount ]] [[ bounty.token_name ]] +

+

To:

+

+ + [[ fulfillment.fulfiller_address ]] + + Copy + +

+
+ +
+ +
+ +

+ + + Previous Step + +

+
+ +
+

Pay out with the owner wallet address

+

+ + ( Switch to QR code payment ) + +

+ +

+ 1. Contact the owner of wallet + [[ bounty.bounty_owner_address | truncateHash ]] + to make the payment with the details below: +

+ +
+

+ From: [[ bounty.bounty_owner_address ]] +

+

+ Amount: [[ fulfillment_context.amount ]] [[ bounty.token_name ]] +

+

To:

+

+ + [[ fulfillment.fulfiller_address ]] + + Copy + +

+
+ +

+ 2. Input the Transaction ID of the payment: +

+
+ +
+ + + +

+ + + Previous Step + +

+ +
+
+
@@ -402,7 +543,7 @@
{% trans "SUBMISSIONS" %}
-
{% trans "APPLICANTS" %}
+
APPLICANTS
@@ -458,7 +599,7 @@
{% trans "APPLICANTS" %}
-
{% trans "ALL ACTIVITY" %}
+
ALL ACTIVITY
@@ -509,7 +650,7 @@
{% trans "ALL ACTIVITY" %}
-
{% trans "Funder" %}
+
Funder
@@ -524,7 +665,7 @@
{% trans "Funder" %}
- {% trans "Email" %} : + Email : [[ bounty.bounty_owner_email ]]
@@ -543,7 +684,7 @@
{% trans "Funder" %}
{% if prize_projects %}
-
{% trans "Projects" %}
+
Projects
{% for project in prize_projects %}
diff --git a/app/dashboard/views.py b/app/dashboard/views.py index 7eba2610a70..309e220a6e5 100644 --- a/app/dashboard/views.py +++ b/app/dashboard/views.py @@ -5055,6 +5055,10 @@ def payout_bounty_v1(request, fulfillment_id): response['message'] = 'error: missing parameter token_name' return JsonResponse(response) + payout_tx_id = request.POST.get('payout_tx_id') + if payout_tx_id: + fulfillment.payout_tx_id = payout_tx_id + fulfillment.payout_amount = amount fulfillment.payout_status = 'pending' fulfillment.token_name = token_name