From 55b677b8c53410cfed5510c523af993eb9de5c56 Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 12 Feb 2019 15:15:46 +0100 Subject: [PATCH] Remap for difference between input and output for prizes --- src/Components/Event/Create/index.js | 23 +++++++++++++++-- src/Components/Event/Edit/queried.js | 38 ++++++++++++++++++++++++++-- 2 files changed, 57 insertions(+), 4 deletions(-) diff --git a/src/Components/Event/Create/index.js b/src/Components/Event/Create/index.js index 9f066524c..3288815b5 100644 --- a/src/Components/Event/Create/index.js +++ b/src/Components/Event/Create/index.js @@ -62,6 +62,25 @@ class Create extends React.Component { this.setState({ [newType]: newVal }); } + remapPrizes = (prizes) => { + const remappedPrizes = []; + + prizes.forEach((prize) => { + remappedPrizes.push({ + condition: { + from: parseInt(prize.from, 10), + to: parseInt(prize.to, 10), + additional: prize.additional, + }, + pool: { + amount: parseInt(prize.amount, 10), + asset: prize.asset, + }, + }); + }); + return remappedPrizes; + } + render() { const { title, @@ -145,7 +164,7 @@ class Create extends React.Component { endDatetime: endDatetime.valueOf() / 1000, formulaId, plotterId, - prizes, + prizes: this.remapPrizes(prizes), rules, }, }, @@ -171,7 +190,7 @@ class Create extends React.Component { endDatetime: endDatetime.valueOf() / 1000, formulaId, plotterId, - prizes, + prizes: this.remapPrizes(prizes), rules, }, }, diff --git a/src/Components/Event/Edit/queried.js b/src/Components/Event/Edit/queried.js index 1ec5de83b..b7ae18c2e 100644 --- a/src/Components/Event/Edit/queried.js +++ b/src/Components/Event/Edit/queried.js @@ -47,7 +47,7 @@ class Queried extends React.Component { endDatetime: this.props.event.endDatetime * 1000, formulaId: this.props.event.formula.id, plotterId: this.props.event.plotter.id, - prizes: this.props.event.prizes, + prizes: this.counterremapPrizes(this.props.event.prizes), rules: this.props.event.rules, }; } @@ -60,6 +60,38 @@ class Queried extends React.Component { this.setState({ [newType]: newVal }); } + counterremapPrizes = (prizes) => { + const counterremapPrizes = []; + prizes.forEach((prize) => { + counterremapPrizes.push({ + from: parseInt(prize.condition.from, 10), + to: parseInt(prize.condition.to, 10), + additional: prize.condition.additional, + amount: parseInt(prize.pool.amount, 10), + asset: prize.pool.asset, + }); + }); + return counterremapPrizes; + } + + remapPrizes = (prizes) => { + const remappedPrizes = []; + + prizes.forEach((prize) => { + remappedPrizes.push({ + condition: { + from: parseInt(prize.from, 10), + to: parseInt(prize.to, 10), + additional: prize.additional, + }, + pool: { + amount: parseInt(prize.amount, 10), + asset: prize.asset, + }, + }); + }); + return remappedPrizes; + } render() { const { @@ -147,6 +179,8 @@ class Queried extends React.Component { endDatetime: endDatetime.valueOf() / 1000, formulaId, plotterId, + prizes: this.remapPrizes(prizes), + rules, }, }, })} @@ -172,7 +206,7 @@ class Queried extends React.Component { endDatetime: endDatetime.valueOf() / 1000, formulaId, plotterId, - prizes, + prizes: this.remapPrizes(prizes), rules, }, },