Skip to content

Commit

Permalink
fix(ContributionAssistant): fix barcode or category selection. closes #…
Browse files Browse the repository at this point in the history
  • Loading branch information
raphodn committed Dec 8, 2024
1 parent ea6f7b8 commit 9bb39b2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 2 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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: [
Expand Down
2 changes: 1 addition & 1 deletion src/views/AddPriceSingle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export default {
proofType: 'PRICE_TAG',
// price form
addPriceSingleForm: {
mode: '',
type: '',
product: null,
product_code: '',
category_tag: null,
Expand Down
8 changes: 4 additions & 4 deletions src/views/ContributionAssistant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
}
Expand Down

0 comments on commit 9bb39b2

Please sign in to comment.