Comentarios del PR

This commit is contained in:
Jaume Solís 2024-04-22 10:42:51 +02:00
parent 7f74ea2ac1
commit 9c3379045e
8 changed files with 22 additions and 126 deletions

View File

@ -7,13 +7,6 @@ class PaymentServices {
try { try {
//parameters to return the products that will be purchased //parameters to return the products that will be purchased
const { products, dateExpired, postalCode, customer, type } = req.body const { products, dateExpired, postalCode, customer, type } = req.body
// const _products = await db.getProducts(dateExpired, postalCode)
/* const productsFilter = _products[0].filter((item) => {
if (products.includes(item.id)) {
return item
}
});*/
const productsFilter = await db.getProductById(products[0]); const productsFilter = await db.getProductById(products[0]);
@ -43,11 +36,9 @@ class PaymentServices {
} }
}, },
}) })
const order = await db.orderData_put(jsonOrderData); const order = await db.orderData_put(jsonOrderData);
//const orderFk = order[0][0].catalogueFk;
//const orderFk = jsonOrderData.customer.customerData.products[0].id;
const orderFk = productsFilter[0][0][0].id; const orderFk = productsFilter[0][0][0].id;
console.log(`${orderFk} ${price}` )
if (type === "paypal") { if (type === "paypal") {
const data = await payPalProviders.New(orderFk, price) const data = await payPalProviders.New(orderFk, price)

View File

@ -1,37 +0,0 @@
const Redsys = require('redsys-easy');
const {
SANDBOX_URLS,
PRODUCTION_URLS,
TRANSACTION_TYPES
} = Redsys
class RedsysProviders {
async New(orderFk, price) {
try {
const redsys = new Redsys({
secretKey: 'sq7HjrUOBfKmC576ILgskD5srU870gJ7',
urls: SANDBOX_URLS, // Also PRODUCTION_URLS
});
const obj = {
amount: price,
currency: 'EUR',
order: orderFk,
merchantName: 'Floraner',
merchantCode: '999008881',
transactionType: TRANSACTION_TYPES.AUTHORIZATION, // '0'
terminal: '001',
merchantURL: `${process.env.BASE_URL}/payments/redsys/notification`,
successURL: `${process.env.BASE_URL}/checkout/success?orderId=${orderFk}`,
errorURL: `${process.env.BASE_URL}/checkout/error`
}
const form = redsys.redirectPetition(obj)
return true
} catch (error) {
throw error;
}
}
}
module.exports = new RedsysProviders();

View File

@ -1,32 +0,0 @@
const RedsysPos = require('redsys-pos');
const {
CURRENCIES, TRANSACTION_TYPES
} = RedsysPos;
class RedsysProviders {
async New(orderFk, price) {
try {
const MERCHANT_KEY = "sq7HjrUOBfKmC576ILgskD5srU870gJ7";
const redsys = new RedsysPos(MERCHANT_KEY);
const obj = JSON.stringify({
amount: 100, // 100 euros
orderReference: orderFk,
merchantName: "Floranet",
merchantCode: "999008881",
currency: CURRENCIES.EUR,
transactionType: TRANSACTION_TYPES.AUTHORIZATION, // '0'
terminal: "001",
merchantURL: `${process.env.BASE_URL}/payments/redsys/notification`,
successURL: `${process.env.BASE_URL}/checkout/success?orderId=${orderFk}`,
errorURL: `${process.env.BASE_URL}/checkout/error`
});
const result = redsys.makePaymentParameters(obj);
return ""
} catch (error) {
throw error;
}
}
}
module.exports = new RedsysProviders();

View File

@ -71,7 +71,6 @@ export default defineComponent({
"Se ha producido un error en el proceso de identificación del código postal", "Se ha producido un error en el proceso de identificación del código postal",
}); });
isPostalCodeLoading.value = false; isPostalCodeLoading.value = false;
console.error(`FATAL ERROR ::: ${error}`);
} finally { } finally {
} }

View File

@ -45,31 +45,32 @@ export default defineComponent({
const formStore = useFormStore(); const formStore = useFormStore();
const { getItem } = useLocalStorage(); const { getItem } = useLocalStorage();
const localValues = getItem("availability") const localValues = getItem("availability");
const lengthCp = 5;
const { postalCodeValid } = storeToRefs(formStore); const { postalCodeValid } = storeToRefs(formStore);
let isEventKeyActive = false let isEventKeyActive = false;
function handleFormKeyPress() { function handleFormKeyPress() {
const postalCodeField = document.querySelector("#carousel-form .postal-code-control input") const postalCodeField = document.querySelector("#carousel-form .postal-code-control input");
const modalDate = document.querySelector("#carousel-form .calendar .custom-date-btn") const modalDate = document.querySelector("#carousel-form .calendar .custom-date-btn");
postalCodeField.addEventListener('input', (e) =>{ postalCodeField.addEventListener('input', (e) =>{
if (e.target.value.length === 5) { if (e.target.value.length === lengthCp) {
isEventKeyActive = true isEventKeyActive = true;
} }
}) })
postalCodeField.addEventListener('keypress', e => { postalCodeField.addEventListener('keypress', e => {
if (e.target.value.length === 5 && isEventKeyActive) { if (e.target.value.length === lengthCp && isEventKeyActive) {
if (e.key === 'Enter') { if (e.key === 'Enter') {
e.preventDefault(); e.preventDefault();
modalDate.click() modalDate.click();
isEventKeyActive = false isEventKeyActive = false;
} }
} }
}) })
} }
onMounted(() => { onMounted(() => {
handleFormKeyPress() handleFormKeyPress();
}) })
return { return {
@ -120,7 +121,6 @@ export default defineComponent({
<IconSearch /> ver disponibilidad <IconSearch /> ver disponibilidad
</q-btn> </q-btn>
</form> </form>
<!--<span v-if="postalCodeValid.value.isValid && postalCodeValid.value.dataOptions.length == 0">Para este código postal no existen fechas de entrega posibles</span>-->
</div> </div>
</div> </div>

View File

@ -7,11 +7,11 @@ import { useRoute } from "vue-router";
import IconArrowCircleFilledLeft from "components/icons/IconArrowCircleFilledLeft.vue"; import IconArrowCircleFilledLeft from "components/icons/IconArrowCircleFilledLeft.vue";
import IconArrowCircleFilledRight from "components/icons/IconArrowCircleFilledRight.vue"; import IconArrowCircleFilledRight from "components/icons/IconArrowCircleFilledRight.vue";
import IconPencilGreen from "components/icons/IconPencilGreen.vue"; import IconPencilGreen from "components/icons/IconPencilGreen.vue";
//import IconEmail from "components/icons/social/IconEmail.vue"; import IconEmail from "components/icons/social/IconEmail.vue";
//import IconLinkedin from "components/icons/social/IconLinkedin.vue"; import IconLinkedin from "components/icons/social/IconLinkedin.vue";
//import IconShare from "components/icons/social/IconShare.vue"; import IconShare from "components/icons/social/IconShare.vue";
//import IconTwitter from "components/icons/social/IconTwitter.vue"; import IconTwitter from "components/icons/social/IconTwitter.vue";
//import IconWhatsapp from "components/icons/social/IconWhatsapp.vue"; import IconWhatsapp from "components/icons/social/IconWhatsapp.vue";
import ProductCarousel from "components/quasar-components/carousel/ProductCarousel.vue"; import ProductCarousel from "components/quasar-components/carousel/ProductCarousel.vue";
import DudasSection from "components/sections/DudasSection.vue"; import DudasSection from "components/sections/DudasSection.vue";
import Card from "components/ui/Card.vue"; import Card from "components/ui/Card.vue";
@ -28,11 +28,11 @@ export default defineComponent({
name: "ProductPage", name: "ProductPage",
components: { components: {
IconPencilGreen, IconPencilGreen,
// IconWhatsapp, IconWhatsapp,
// IconLinkedin, IconLinkedin,
// IconTwitter, IconTwitter,
// IconShare, IconShare,
// IconEmail, IconEmail,
DudasSection, DudasSection,
Container, Container,
Card, Card,

View File

@ -195,13 +195,11 @@ export const useCartStore = defineStore("cart", () => {
availabilityForm.value || availability.value availabilityForm.value || availability.value
); );
const correctProduct = await apiBack.get(`products/${product.id}`, { params }); const correctProduct = await apiBack.get(`products/${product.id}`, { params });
//await getProducts(params);
const hasCurrentProduct = computed(() => { const hasCurrentProduct = computed(() => {
return cart.value.find((p) => p.id === product.id); return cart.value.find((p) => p.id === product.id);
}); });
//if (isEmpty.value) {
if (correctProduct.data.length === 0) { if (correctProduct.data.length === 0) {
push("/"); push("/");
return quasarNotify({ return quasarNotify({
@ -211,15 +209,6 @@ export const useCartStore = defineStore("cart", () => {
}); });
} }
// if (!products.value.data.some((item) => item.id === product.id)) {
// push("/");
// return quasarNotify({
// message:
// "Este producto no está disponible en su zona, intente añadir un nuevo código postal",
// type: "erro",
// });
// }
if (hasCurrentProduct.value) { if (hasCurrentProduct.value) {
return quasarNotify({ return quasarNotify({
message: "Este producto ya está en el carrito", message: "Este producto ya está en el carrito",

View File

@ -1,14 +0,0 @@
import { defineStore } from "pinia";
export const useTextInputStore = defineStore("text-input", () => {
const dedication = ref("");
function handleDedicationSubmit() {
}
return {
dedication,
handleDedicationSubmit,
};
});