cambios de la reunion de hoy

This commit is contained in:
Jaume Solís 2024-04-16 18:58:29 +02:00
parent 16d06ffc4c
commit 5b4292e06f
8 changed files with 24 additions and 15 deletions

View File

@ -97,11 +97,11 @@ class ProductController {
async findById(req, res) {
const { dateExpired, postalCode } = req.query
const id = Number(req.params.id)
const _products = await db.getProducts(dateExpired, postalCode);
const filterProduct = _products[0].filter(item => item.itemFk === id)
const product = await db.getProductById(req.params.id);
//const filterProduct = _products[0].filter(item => item.itemFk === id)
return res.status(200).send({
data: filterProduct
data: product
})
}
}

View File

@ -23,6 +23,12 @@ async function getProducts(dateExpired, postalCode) {
return rows;
}
async function getProductById(id) {
const conn = await connect();
const rows = await conn.query(`CALL catalogue_findById(${id})`);
return rows;
}
//Procedure for create transactions, do not carry out any manipulation at the bank
async function orderData_put(jsonOrderData) {
const conn = await connect();
@ -81,6 +87,7 @@ async function findAll_banner() {
module.exports = {
getProducts,
getProductById,
orderData_get,
orderData_put,
getProvinces,

View File

@ -34,6 +34,7 @@ export default defineComponent({
default: "",
},
isNew: String,
hasPostalCode: Boolean,
size: {
type: String,
default: "md-card",
@ -77,7 +78,7 @@ export default defineComponent({
<template>
<div class="card-container" :class="size">
<RouterLink
:to="`/product/${id}`"
:to="(hasPostalCode)?`/product/${id}`:''"
class="card-container-head"
:class="[headClass]"
role="heading"
@ -112,7 +113,7 @@ export default defineComponent({
<div class="card-container-body">
<p class="card-name" v-if="title">{{ title }}</p>
<div class="card-values">
<div class="card-values" v-if="hasPostalCode">
<p class="price" v-if="finalValue">{{ finalValue }}</p>
<p class="price offer tachado" v-if="+price !== finalValue">
{{ price }}

View File

@ -205,7 +205,7 @@ export function useCheckoutForm() {
const handleFetchPaymentMethod = async ({ type, values }) => {
try {
const productsId = cart.map((item) => item.itemFk);
const productsId = cart.map((item) => item.id);
const cartItensData = cart.map(({ id, message, ...rest }) => ({
id,
message: message || "",

View File

@ -275,14 +275,15 @@ export default defineComponent({
<div class="products-section-body">
<Container cardContainer class="category-container">
<template v-for="item in products.data" :key="item?.itemFk">
<template v-for="item in products.data" :key="item?.id">
<Card
v-if="item"
:price="item.price"
:title="item.name"
:imgSrc="item.image"
:isNew="item.isNew"
:id="item.itemFk"
:id="item.id"
:hasPostalCode="(item.postalCode !== 'undefined')?true:false"
/>
</template>
</Container>

View File

@ -68,8 +68,8 @@ export default defineComponent({
<div class="products-body">
<Container cardContainer>
<template v-for="({ id, name, price, image, isNew }, i) in products?.data" :key="id">
<Card v-if="i < 8" :id="id" :price="price" :title="name" :imgSrc="image" :isNew="isNew"
<template v-for="({ id, name, price, image, isNew, postalCode }, i) in products?.data" :key="id">
<Card v-if="i < 8" :id="id" :price="price" :title="name" :imgSrc="image" :isNew="isNew" :hasPostalCode="(postalCode !== 'undefined')?true:false"
imgClass="list-products" size="md-card" />
</template>
</Container>

View File

@ -190,9 +190,9 @@ export default defineComponent({
<p class="product-content-paragraph">
SKU:
<span class="green-text" style="display: inline-flex">
{{ products.current?.itemFk }}
{{ products.current?.id }}
<q-skeleton
v-if="!products.current?.itemFk"
v-if="!products.current?.id"
width="100px"
type="text"
/>
@ -303,7 +303,7 @@ export default defineComponent({
</q-btn>
<q-btn
v-if="products.next?.itemFk"
v-if="products.next?.id"
color="white"
class="btn outlined rounded sm-btn product-pag-item product-next-btn"
:to="`${+$route.params.id + 1}`"

View File

@ -197,7 +197,7 @@ export const useCartStore = defineStore("cart", () => {
await getProducts(params);
const hasCurrentProduct = computed(() => {
return cart.value.find((p) => p.itemFk === product.itemFk);
return cart.value.find((p) => p.id === product.id);
});
if (isEmpty.value) {
@ -209,7 +209,7 @@ export const useCartStore = defineStore("cart", () => {
});
}
if (!products.value.data.some((item) => item.itemFk === product.itemFk)) {
if (!products.value.data.some((item) => item.id === product.id)) {
push("/");
return quasarNotify({
message: