Skip to content

Commit

Permalink
feat: Aumentar en decimales si es agranel
Browse files Browse the repository at this point in the history
  • Loading branch information
christopher-qc committed Jun 26, 2024
1 parent 84ce4af commit 2b7df33
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 69 deletions.
101 changes: 64 additions & 37 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,42 +1,69 @@
// http://eslint.org/docs/user-guide/configuring

module.exports = {
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module'
},
env: {
browser: true,
},
extends: 'airbnb-base',
// required to lint *.vue files
plugins: [
'html'
],
// check if imports actually resolve
'settings': {
'import/resolver': {
'webpack': {
'config': 'build/webpack.base.conf.js'
}
}
},
// add your custom rules here
'rules': {
// don't require .vue extension when importing
'import/extensions': ['error', 'always', {
'js': 'never',
'vue': 'never'
}],
// allow optionalDependencies
"linebreak-style": 0,
'import/no-extraneous-dependencies': ['error', {
'optionalDependencies': ['test/unit/index.js']
}],
// allow debugger during development
root: true,
parser: 'babel-eslint',
parserOptions: {
sourceType: 'module',
},
env: {
browser: true,
},
extends: 'airbnb-base',
// required to lint *.vue files
plugins: ['html'],
// check if imports actually resolve
settings: {
'import/resolver': {
webpack: {
config: 'build/webpack.base.conf.js',
},
},
},
// add your custom rules here
rules: {
'comma-dangle': 'off',
'arrow-parens': ['off', 'off'], // Desactiva la regla o ajusta según tu preferencia
'import/no-extraneous-dependencies': 'off', // Desactiva la regla import/no-extraneous-dependencies
'no-mixed-operators': 'off', // Activar la regla no-mixed-operators
indent: 'off', // Indentación con tabs
'no-mixed-spaces-and-tabs': 'off', // Evitar mezcla de espacios y tabs
// 'indent': ['error', 'tab'], // Indentación con tabs
'max-len': [
'error',
{
code: 120,
ignoreStrings: true,
ignoreTemplateLiterals: true,
ignoreComments: true, // Ignorar longitud de línea en comentarios largos
ignoreUrls: true, // Ignorar longitud de línea en URLs largas
ignoreRegExpLiterals: true, // Ignorar longitud de línea en expresiones regulares largas
ignorePattern: '^[ \t]*<(\\w+)([^>]*)>(.|\n)*?<\\/\\1>', // Ignorar líneas dentro de JSX
ignorePattern: '^\\s*\\{', // Ignorar líneas dentro de objetos de configuración largos
},
],
// don't require .vue extension when importing
'import/extensions': [
'error',
'always',
{
js: 'never',
vue: 'never',
},
],
// allow optionalDependencies
'import/no-extraneous-dependencies': [
'error',
{
optionalDependencies: ['test/unit/index.js'],
},
],
'linebreak-style': ['error', 'windows'],
// allow debugger during development
'no-debugger': process.env.NODE_ENV === 'production' ? 2 : 0,
'no-tabs': 0,
'indent': ['error', 'tab']
}
}
// 'indent': 'off',
// 'no-mixed-spaces-and-tabs': 'off',
'linebreak-style': 0,
},
};
33 changes: 27 additions & 6 deletions src/components/products/product-in-car.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@
<quantityButton
class="continer-quantity-button"
:number="product.quantity"
:product="product"
@input="inputQuantity"
@click="clickQuantity"
:max-quantity="maxQuantity"
/>
Expand Down Expand Up @@ -163,15 +165,32 @@ function showComments() {
this.show = !this.show;
}
function inputQuantity(value) {
this.product.quantity = Number(value);
this.clickQuantity();
}
function clickQuantity(val) {
let { quantity } = this.product;
const { unit } = this.product;
const opt = {
more: 1,
less: -1,
};
quantity += opt[val];
quantity = quantity < 1 ? 1 : quantity;
if (val) {
if (this.product.category.type === 2) {
this.opt = {
more: 0.1,
less: -0.1,
};
quantity += this.opt[val];
quantity = +quantity.toFixed(2);
quantity = quantity < 0.1 ? 0.1 : quantity;
} else {
this.opt = {
more: 1,
less: -1,
};
quantity += this.opt[val];
quantity = quantity < 1 ? 1 : quantity;
}
}
this.quantityStock = parseInt(unit.quantity * quantity, 10);
if (this.showUnity) {
if (quantity >= this.stockAvaible && !this.$allowOrderStockNegative) {
Expand Down Expand Up @@ -222,6 +241,7 @@ function data() {
return {
comments: '',
show: false,
opt: {},
maxQuantity: false,
};
}
Expand All @@ -245,6 +265,7 @@ export default {
deleteProduct,
showComments,
goToProduct,
inputQuantity,
},
props: {
product: {
Expand Down
91 changes: 65 additions & 26 deletions src/components/shared/buttons/quantity-button.vue
Original file line number Diff line number Diff line change
@@ -1,11 +1,39 @@
<template>
<div class="quantity-button">
<button data-cy="less-quantity" class="item" @click="$emit('click', 'less')">-</button>
<div data-cy="quantity-to-buy" class="item item-number" :style="`color:${globalColors.title}`">{{number}}</div>
<button data-cy="more-quantity" :disabled="maxQuantity" class="item" @click="$emit('click', 'more')">+</button>
<button
data-cy="less-quantity"
class="item"
@click="$emit('click', 'less')"
>
-
</button>
<input
v-if="product.category.type === 2"
class="input-number"
type="number"
v-model="number"
@input="$emit('input', $event.target.value )"
></input>
<div
v-else
data-cy="quantity-to-buy"
class="item item-number"
:style="`color:${globalColors.title}`"
>
{{ number }}
</div>
<button
data-cy="more-quantity"
:disabled="maxQuantity"
class="item"
@click="$emit('click', 'more')"
>
+
</button>
</div>
</template>
<script>
export default {
name: 'quantity-button',
props: {
Expand All @@ -17,35 +45,46 @@ export default {
type: Boolean,
default: false,
},
product: {
type: Object,
},
},
};
</script>
<style lang="scss" scoped>
.quantity-button {
border: 1px solid color(base);
border-radius: 5px;
color: color(base);
display: flex;
font-family: font(bold);
font-size: size(medium);
height: 27px;
width: 116px;
.quantity-button {
border: 1px solid color(base);
border-radius: 5px;
color: color(base);
display: flex;
font-family: font(bold);
font-size: size(medium);
height: 27px;
width: 116px;
.item {
flex: 1 1 auto;
}
.item {
flex: 1 1 auto;
}
.item-number {
align-items: center;
border-left: 1px solid color(base);
border-right: 1px solid color(base);
display: flex;
font-family: font(heavy);
justify-content: center;
}
.item-number {
align-items: center;
border-left: 1px solid color(base);
border-right: 1px solid color(base);
display: flex;
font-family: font(heavy);
justify-content: center;
}
button:hover {
background-color: color(border);
}
button:hover {
background-color: color(border);
}
.input-number {
width: 50px;
text-align: center;
border-left: 1px solid color(base);
border-right: 1px solid color(base);
font-family: font(heavy);
}
}
</style>

0 comments on commit 2b7df33

Please sign in to comment.