Skip to content
Snippets Groups Projects
Commit 58fea059 authored by Gomez Goiri, Aitor's avatar Gomez Goiri, Aitor
Browse files

Accepting user input to specify first bid amount

parent 3034968f
No related branches found
No related tags found
No related merge requests found
...@@ -41,16 +41,23 @@ const simulateCycle = async (arg1, cmd) => { ...@@ -41,16 +41,23 @@ const simulateCycle = async (arg1, cmd) => {
batchId = await createAssetAndSendToCone(apiClient, "simulated asset 2") batchId = await createAssetAndSendToCone(apiClient, "simulated asset 2")
batchId = await createAssetAndSendToCone(apiClient, "simulated asset 3") batchId = await createAssetAndSendToCone(apiClient, "simulated asset 3")
const stockId = await sendToStock(apiClient, { assetId: batchId }) const selectedStock = await sendToStock(apiClient, { assetId: batchId })
await signInAs(apiClient, otherArgs.cement1User, password) await signInAs(apiClient, otherArgs.cement1User, password)
await bidAsset(apiClient, { assetId: stockId, quantity: 1000, price: 2 }) await bidAsset(apiClient, {
assetId: selectedStock.id,
price: 2
})
await signInAs(apiClient, otherArgs.cement2User, password) await signInAs(apiClient, otherArgs.cement2User, password)
await bidAsset(apiClient, { assetId: stockId, quantity: 500, price: 3 }) await bidAsset(apiClient, {
assetId: selectedStock.id,
quantity: selectedStock.quantity - 500,
price: 3
})
await signInAs(apiClient, otherArgs.sidenorUser, password) await signInAs(apiClient, otherArgs.sidenorUser, password)
await acceptBid(apiClient, { assetId: stockId }) await acceptBid(apiClient, { assetId: selectedStock.id })
} }
const program = createCLIApp() const program = createCLIApp()
......
...@@ -11,6 +11,7 @@ const bidAsset = async ( ...@@ -11,6 +11,7 @@ const bidAsset = async (
const biddableAssets = await apiClient.getBiddableAssets() const biddableAssets = await apiClient.getBiddableAssets()
const assetId = paramAssetId || (await promptAssetSelection(biddableAssets)) const assetId = paramAssetId || (await promptAssetSelection(biddableAssets))
const assetToBid = biddableAssets.find(({ id }) => id === assetId)
let chosenQuantity = quantity let chosenQuantity = quantity
if (!quantity) { if (!quantity) {
...@@ -18,19 +19,19 @@ const bidAsset = async ( ...@@ -18,19 +19,19 @@ const bidAsset = async (
{ {
type: "number", type: "number",
name: "inputQuantity", name: "inputQuantity",
message: "Choose an ammount of slag" message: `Choose an ammount of slag (in ${assetToBid.units}, max ${assetToBid.quantity}):`
} }
]) ])
chosenQuantity = inputQuantity chosenQuantity = inputQuantity
} }
let chosenPrice = price let chosenPrice = price
if (!quantity) { if (!price) {
const { inputPrice } = await inquirer.prompt([ const { inputPrice } = await inquirer.prompt([
{ {
type: "number", type: "number",
name: "inputPrice", name: "inputPrice",
message: "Provide the offered price" message: "Provide the offered price (in €):"
} }
]) ])
chosenPrice = inputPrice chosenPrice = inputPrice
......
...@@ -169,7 +169,7 @@ const sendToStock = async (apiClient, { assetId: paramAssetId }) => { ...@@ -169,7 +169,7 @@ const sendToStock = async (apiClient, { assetId: paramAssetId }) => {
console.log("Moved to stock", newStockAsset.id) console.log("Moved to stock", newStockAsset.id)
return newStockAsset.id return newStockAsset
} }
const bidResponse = const bidResponse =
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment