diff --git a/src/constants.js b/src/constants.js index 9ab8e22530c..9711378d7c1 100644 --- a/src/constants.js +++ b/src/constants.js @@ -10,6 +10,7 @@ const PRICE_TYPE_PRODUCT = 'PRODUCT' const PRICE_TYPE_PRODUCT_ICON = 'mdi-barcode' const PRICE_TYPE_CATEGORY = 'CATEGORY' const PRICE_TYPE_CATEGORY_ICON = 'mdi-basket-outline' +const PRODUCT_CATEGORY_LABEL_ORGANIC = 'en:organic' const PROOF_TYPE_PRICE_TAG = 'PRICE_TAG' const PROOF_TYPE_PRICE_TAG_ICON = 'mdi-library-shelves' const PROOF_TYPE_RECEIPT = 'RECEIPT' @@ -63,6 +64,7 @@ export default { {key: PRICE_TYPE_PRODUCT, value: 'Barcode', icon: PRICE_TYPE_PRODUCT_ICON}, {key: PRICE_TYPE_CATEGORY, value: 'Category', icon: PRICE_TYPE_CATEGORY_ICON} ], + PRODUCT_CATEGORY_LABEL_ORGANIC: PRODUCT_CATEGORY_LABEL_ORGANIC, PRODUCT_QUANTITY_UNIT_G: 'g', PRODUCT_QUANTITY_UNIT_ML: 'ml', PRODUCT_SOURCE_LIST: [ diff --git a/src/views/AddPriceSingle.vue b/src/views/AddPriceSingle.vue index 5d216152444..364c1282d8c 100644 --- a/src/views/AddPriceSingle.vue +++ b/src/views/AddPriceSingle.vue @@ -109,7 +109,7 @@ export default { proofType: 'PRICE_TAG', // price form addPriceSingleForm: { - mode: '', + type: '', product: null, product_code: '', category_tag: null, diff --git a/src/views/ContributionAssistant.vue b/src/views/ContributionAssistant.vue index 0c3bce05bbe..137423f8f58 100644 --- a/src/views/ContributionAssistant.vue +++ b/src/views/ContributionAssistant.vue @@ -234,10 +234,10 @@ export default { const barcodeString = label.barcode ? label.barcode.toString().replace(/\s/g, '') : '' // TODO: some of these will be None if gemini did not give a proper reply, so detection and error handling is needed const productPriceForm = { - mode: barcodeString.length > 10 ? 'barcode' : 'category', + type: barcodeString.length > 10 ? constants.PRICE_TYPE_PRODUCT : constants.PRICE_TYPE_CATEGORY, category_tag: label.product, origins_tags: [label.origin], - labels_tags: label.organic ? ["en:organic"] : [], + labels_tags: label.organic ? [constants.PRODUCT_CATEGORY_LABEL_ORGANIC] : [], price: label.price.toString(), price_per: label.unit, price_is_discounted: false, @@ -277,12 +277,12 @@ export default { proof_id: this.proofForm.id } // Cleanup unwanted fields for API - if (productPriceForm.type == 'PRODUCT') { + if (productPriceForm.type == constants.PRICE_TYPE_PRODUCT) { delete priceData.price_per delete priceData.category_tag delete priceData.origins_tags delete priceData.labels_tags - } else if (productPriceForm.type == 'CATEGORY') { + } else if (productPriceForm.type == constants.PRICE_TYPE_CATEGORY) { delete priceData.product_code delete priceData.product }