diff --git a/apps/README.md b/apps/README.md index e1874dad259d2e0b77d9a248284716d4dc8cd20c..b919ad63cf3e0027b8d9699befbcec06962d79d0 100644 --- a/apps/README.md +++ b/apps/README.md @@ -63,6 +63,10 @@ $ cd sidenor-cli $ node index.js register --asset-name "Slag 1" Registered asset asst_07b75e28-6685-4e18-b810-75e410dd37f2 +$ node index.js composition +? Select asset asst_a9e0bd5d-aaa2-412e-95ee-c7cff1f831dc (Slag 1, type: 10, status: slag) +? Choose the percentage of CaO content in the slag (min: 40%, max 70%): 43 + $ node index.js to-cone ? Select asset asst_07b75e28-6685-4e18-b810-75e410dd37f2 (Slag 1, type: 10, status: slag) Moved to cone c28bed645434c46376369bc5cc400b4c @@ -82,9 +86,9 @@ $ node index.js to-cone Moved to cone 513be341a8c15c74dc06ca434b33cb36 $ node index.js to-stock -? Select asset 6007feb7e2984c92d8efc13c23606fbb (undefined, type: 1002, status: batched) +? Select asset 513be341a8c15c74dc06ca434b33cb36 (Slag batch (in cone), type: 1002, status: batched) ? Select the stock where the cone will be merged newStock (New stock, type: 10 02, status: stocked) -Moved to stock caaa642c25d96a5d8f14cf031a898fed +Moved to stock 6007feb7e2984c92d8efc13c23606fbb $ cd ../cement-cli $ node index.js bid diff --git a/apps/cement-cli/lib.js b/apps/cement-cli/lib.js index fc54b70c2aad9bb1d1dbb0fc7df8b60f9bef4ec8..56b512a021ffdb4dd0126e679ba43196ed4c766a 100644 --- a/apps/cement-cli/lib.js +++ b/apps/cement-cli/lib.js @@ -20,7 +20,11 @@ const bidAsset = async ( type: "number", name: "inputQuantity", message: `Choose an amount of slag to bid for (max: ${assetToBid.quantity} ${assetToBid.units}):`, - default: Math.floor(assetToBid.quantity * 0.1) // Default: 10% + default: Math.floor(assetToBid.quantity * 0.1), // Default: 10% + validate: n => { + if (n > 0) return true + return "Please, provide a quantity to bid for." + } } ]) chosenQuantity = inputQuantity @@ -32,7 +36,12 @@ const bidAsset = async ( { type: "number", name: "inputPrice", - message: "Provide the offered price (in €):" + message: "Provide the offered price (in €):", + default: 0, + validate: n => { + if (n > 0) return true + return `Please, provide a price for ${chosenQuantity} ${assetToBid.units} in €.` + } } ]) chosenPrice = inputPrice diff --git a/apps/sidenor-cli/lib.js b/apps/sidenor-cli/lib.js index 816c74ffb714686beadf1e513e335c7a5acb01b4..94ee5ee96263907bc1b07f9a0338b6a70d77f0b3 100644 --- a/apps/sidenor-cli/lib.js +++ b/apps/sidenor-cli/lib.js @@ -15,7 +15,7 @@ const createAsset = async (apiClient, { assetName }) => { id: `asst_${faker.datatype.uuid()}`, type: TYPES.RESIDUO_PROCESOS_TERMICOS, units: "kg", - quantity: faker.datatype.number({ max: 5000 }), + quantity: faker.datatype.number({ min: 0, max: 5000 }), fields: { description: "Escoria", name: assetName, @@ -42,11 +42,14 @@ const editComposition = async ( const { inputCaoPercentage } = await inquirer.prompt([ { type: "number", - name: "inputQuantity", + name: "inputCaoPercentage", message: "Choose the percentage of CaO content in the slag (min: 40%, max 70%):", default: faker.datatype.number({ min: 40, max: 70 }), - validate: n => n >= 40 && n <= 70 + validate: n => { + if (n >= 40 && n <= 70) return true + return "The CaO percentage must be between 40 and 70" + } } ]) chosenCaoPercentage = inputCaoPercentage @@ -101,6 +104,7 @@ const sendToCone = async (apiClient, { assetId: paramAssetId }) => { units: "kg", quantity: newConeQuantity, fields: { + name: "Slag batch (in cone)", status: STATUSES.SLAG_BATCH } }