forked from decentraland/marketplace
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve confirmation modal (decentraland#667)
* feat: remove trailing zeros from confirmation value * feat: show warning if price of land too low * chore: added tests * fix: remove extra break line
- Loading branch information
Showing
7 changed files
with
74 additions
and
7 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { NFTCategory } from '@dcl/schemas' | ||
import { NFT } from '../../../modules/nft/types' | ||
import { showPriceBelowMarketValueWarning } from './utils' | ||
|
||
describe('when showing a price confirmation modal', () => { | ||
let nft: NFT | ||
describe('and the NFT is not a land', () => { | ||
beforeAll(() => { | ||
nft = { category: NFTCategory.WEARABLE } as NFT | ||
}) | ||
it('should NOT show a warning if the price is below threshold', () => { | ||
expect(showPriceBelowMarketValueWarning(nft, 1)).toBe(false) | ||
}) | ||
it('should NOT show a warning if the price is above threshold', () => { | ||
expect(showPriceBelowMarketValueWarning(nft, 1000)).toBe(false) | ||
}) | ||
}) | ||
describe('and the NFT is a parcel', () => { | ||
beforeAll(() => { | ||
nft = { category: NFTCategory.PARCEL } as NFT | ||
}) | ||
it('should show a warning if the price is below threshold', () => { | ||
expect(showPriceBelowMarketValueWarning(nft, 1)).toBe(true) | ||
}) | ||
it('should NOT show a warning if the price is above threshold', () => { | ||
expect(showPriceBelowMarketValueWarning(nft, 1000)).toBe(false) | ||
}) | ||
}) | ||
describe('and the NFT is an estate', () => { | ||
beforeAll(() => { | ||
nft = { category: NFTCategory.ESTATE } as NFT | ||
}) | ||
it('should show a warning if the price is below threshold', () => { | ||
expect(showPriceBelowMarketValueWarning(nft, 1)).toBe(true) | ||
}) | ||
it('should NOT show a warning if the price is above threshold', () => { | ||
expect(showPriceBelowMarketValueWarning(nft, 1000)).toBe(false) | ||
}) | ||
}) | ||
}) |
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,14 @@ | ||
import { NFTCategory } from '@dcl/schemas' | ||
import { NFT } from '../../../modules/nft/types' | ||
|
||
const LAND_PRICE_WARNING_THRESHOLD = 100 // if the listing price of a land is below this number we show a warning | ||
|
||
function isLand(nft: NFT) { | ||
return ( | ||
nft.category === NFTCategory.PARCEL || nft.category === NFTCategory.ESTATE | ||
) | ||
} | ||
|
||
export function showPriceBelowMarketValueWarning(nft: NFT, price: number) { | ||
return isLand(nft) && price <= LAND_PRICE_WARNING_THRESHOLD | ||
} |
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