-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add multi-callee support to the frontend #498
Merged
Merged
Changes from 10 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
9f9b329
Add types
aomafarag edfd9be
Add new types to helpers/generateFakeAuction
aomafarag 8f3f23c
Create MarketPriceSelection component and stories
aomafarag f211ed5
Emit from MarketPriceSelection to sync marketId
aomafarag 4be5323
Initial implementation
aomafarag 3cbd019
Adjust component layout and finalize implementation
aomafarag 5112a99
Pass marketId down to the store
aomafarag 4121563
Change console.log to console.info to avoid lint error
aomafarag cc19d85
Sort callees
aomafarag c6f85ca
Modify types
aomafarag 596db9a
Merge branch 'main' into market-price-selection
valiafetisov 3fcc0e3
Reflect change in marketId in all related values
aomafarag d99db0e
Remove duplicate type
aomafarag c9a3445
Modify stories to reflect callee selection
aomafarag 06265c1
Make market price selection persist
aomafarag e2e5432
Pass marketId up for execution
aomafarag 5a61905
Sort callees ascendingly
aomafarag 48a31c0
Pre-select suggestedMarketId
aomafarag c510d3f
Lint
aomafarag File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
frontend/components/auction/collateral/MarketPriceSelection.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { storiesOf } from '@storybook/vue'; | ||
import MarketPriceSelection from './MarketPriceSelection'; | ||
import { generateFakeAuctionTransaction } from '~/helpers/generateFakeAuction.ts'; | ||
|
||
const fakeAuctionTransaction = generateFakeAuctionTransaction(); | ||
|
||
const common = { | ||
components: { | ||
MarketPriceSelection, | ||
}, | ||
data: () => ({ | ||
auctionTransaction: fakeAuctionTransaction, | ||
marketId: '', | ||
}), | ||
template: `<MarketPriceSelection :auction-transaction="auctionTransaction" :market-id.sync="marketId" />`, | ||
}; | ||
|
||
storiesOf('Auction/Collateral/MarketPriceSelection', module).add('Default', () => ({ ...common })); |
117 changes: 117 additions & 0 deletions
117
frontend/components/auction/collateral/MarketPriceSelection.vue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,117 @@ | ||
<template> | ||
<div> | ||
<div class="flex justify-between"> | ||
<button class="Title" type="button" @click="isExpanded = !isExpanded"> | ||
<Icon v-if="!isExpanded" type="caret-right" class="Icon" /> | ||
<Icon v-else type="caret-down" class="Icon" /> | ||
Market Unit Price | ||
<span class="text-gray-300">({{ suggestionOrSelection }})</span> | ||
</button> | ||
<div v-show="!isExpanded"> | ||
<FormatCurrency :value="marketUnitPrice" currency="DAI" /> per | ||
<span class="uppercase">{{ auctionTransaction.collateralSymbol }}</span> | ||
</div> | ||
</div> | ||
<CollapseTransition> | ||
<div v-show="isExpanded" class="Content overflow-x-auto"> | ||
<table class="table-auto"> | ||
<tbody> | ||
<tr v-for="callee in callees" :key="callee[0]"> | ||
<td class="pr-2 whitespace-nowrap">{{ callee[0] }}</td> | ||
<td class="pr-2 whitespace-nowrap"> | ||
<span v-for="currency in callee[1].route" :key="currency" | ||
>{{ currency }} → | ||
</span> | ||
DAI | ||
</td> | ||
<td class="w-full text-right whitespace-nowrap"> | ||
<div v-if="callee[1].unitPrice && !callee[1].unitPrice.isNaN()"> | ||
<button type="button" @click="$emit('update:marketId', callee[0])"> | ||
<span v-if="marketId === callee[0]" class="opacity-50">Selected</span> | ||
aomafarag marked this conversation as resolved.
Show resolved
Hide resolved
|
||
<span v-else class="text-green-500">Select</span> | ||
</button> | ||
<span class="pl-1"> | ||
<FormatCurrency :value="callee[1].unitPrice" currency="DAI" /> per | ||
<span class="uppercase">{{ auctionTransaction.collateralSymbol }}</span> | ||
</span> | ||
</div> | ||
<div v-else class="opacity-50">Unknown</div> | ||
</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</div> | ||
</CollapseTransition> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import Vue from 'vue'; | ||
import BigNumber from 'bignumber.js'; | ||
import { Icon } from 'ant-design-vue'; | ||
import CollapseTransition from '@ivanv/vue-collapse-transition'; | ||
import { AuctionTransaction, MarketData } from 'auctions-core/src/types'; | ||
import FormatCurrency from '~/components/common/formatters/FormatCurrency.vue'; | ||
|
||
export default Vue.extend({ | ||
components: { | ||
Icon, | ||
FormatCurrency, | ||
CollapseTransition, | ||
}, | ||
props: { | ||
auctionTransaction: { | ||
type: Object as Vue.PropType<AuctionTransaction>, | ||
required: true, | ||
}, | ||
marketId: { | ||
type: String, | ||
default: '', | ||
}, | ||
}, | ||
data() { | ||
return { | ||
isExpanded: false, | ||
}; | ||
}, | ||
computed: { | ||
suggestionOrSelection(): string | undefined { | ||
return this.marketId || this.auctionTransaction.suggestedMarketId; | ||
}, | ||
marketUnitPrice(): BigNumber | undefined { | ||
if (this.auctionTransaction.marketData && this.suggestionOrSelection) { | ||
return this.auctionTransaction.marketData[this.suggestionOrSelection].unitPrice; | ||
} | ||
return undefined; | ||
}, | ||
callees(): Array<Array<[string, MarketData]>> { | ||
const sorted = []; | ||
const unknown = []; | ||
for (const callee in this.auctionTransaction.marketData) { | ||
if ( | ||
this.auctionTransaction.marketData[callee].unitPrice && | ||
!this.auctionTransaction.marketData[callee].unitPrice.isNaN() | ||
) { | ||
sorted.push([callee, this.auctionTransaction.marketData[callee]]); | ||
} else { | ||
unknown.push([callee, this.auctionTransaction.marketData[callee]]); | ||
} | ||
} | ||
sorted.sort((a, b) => a[1].unitPrice.minus(b[1].unitPrice).toNumber()); | ||
return [...sorted, ...unknown]; | ||
}, | ||
}, | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
.Title { | ||
@apply text-left text-green-500; | ||
} | ||
.Icon { | ||
@apply inline; | ||
} | ||
.Content { | ||
@apply pl-4; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you raised in the issue and I answered: the values underneath this row is dependent on the selected
marketId
. They all now taken from themarketData[marketId]
object: so that switchingmarketId
displays new valuesThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Exactly. But the calculation of the market difference, profitability, etc. happens in the core. So, shouldn't that be implemented there by using the
marketId
that is sent to the store?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, nvm. For some reason, I've just noticed the comment you made last week 😅.