Compare commits
3 Commits
4207584997
...
5e44109ee5
Author | SHA1 | Date |
---|---|---|
|
5e44109ee5 | |
|
a5e39fdc7f | |
|
63783d1515 |
|
@ -95,8 +95,9 @@ class ProductController {
|
||||||
}
|
}
|
||||||
|
|
||||||
async findById(req, res) {
|
async findById(req, res) {
|
||||||
|
const { dateExpired, postalCode } = req.query
|
||||||
const id = Number(req.params.id)
|
const id = Number(req.params.id)
|
||||||
const _products = await db.getProducts();
|
const _products = await db.getProducts(dateExpired, postalCode);
|
||||||
const filterProduct = _products[0].filter(item => item.id === id)
|
const filterProduct = _products[0].filter(item => item.id === id)
|
||||||
|
|
||||||
return res.status(200).send({
|
return res.status(200).send({
|
||||||
|
|
|
@ -88,7 +88,7 @@ export default defineComponent({
|
||||||
:model-value="modelValue"
|
:model-value="modelValue"
|
||||||
@update:model-value="updateModel"
|
@update:model-value="updateModel"
|
||||||
v-bind="bindValue"
|
v-bind="bindValue"
|
||||||
class="custom-main-paragraph"
|
class="custom-main-paragraph field-postal-code"
|
||||||
:error="false"
|
:error="false"
|
||||||
placeholder="código postal"
|
placeholder="código postal"
|
||||||
mask="#####"
|
mask="#####"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
|
import { storeToRefs } from "pinia";
|
||||||
import { defineComponent } from "vue";
|
import { defineComponent } from "vue";
|
||||||
|
|
||||||
import Calendar from "src/components/@inputs/Calendar.vue";
|
import Calendar from "src/components/@inputs/Calendar.vue";
|
||||||
|
@ -6,6 +7,8 @@ import PostalCode from "src/components/@inputs/PostalCode.vue";
|
||||||
import IconSearch from "src/components/icons/IconSearch.vue";
|
import IconSearch from "src/components/icons/IconSearch.vue";
|
||||||
import { usePostalCalendar } from "src/hooks/usePostalCalendar";
|
import { usePostalCalendar } from "src/hooks/usePostalCalendar";
|
||||||
import { useVerticalCarouselImgs } from "src/hooks/useVerticalCarouselImgs";
|
import { useVerticalCarouselImgs } from "src/hooks/useVerticalCarouselImgs";
|
||||||
|
import { useFormStore } from "src/stores/forms";
|
||||||
|
import { onMounted } from "vue";
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name: "vertical-carousel-imgs",
|
name: "vertical-carousel-imgs",
|
||||||
|
@ -26,6 +29,30 @@ export default defineComponent({
|
||||||
} = usePostalCalendar({ type: "home" });
|
} = usePostalCalendar({ type: "home" });
|
||||||
const { navPos, screenWidth, slide, target } = useVerticalCarouselImgs();
|
const { navPos, screenWidth, slide, target } = useVerticalCarouselImgs();
|
||||||
|
|
||||||
|
const formStore = useFormStore();
|
||||||
|
const {postalCodeValid } = storeToRefs(formStore);
|
||||||
|
|
||||||
|
function handleFormKeyPress() {
|
||||||
|
const postalCodeField = document.querySelector("#carousel-form .postal-code-control input")
|
||||||
|
const modalDate = document.querySelector("#carousel-form .calendar .custom-date-btn")
|
||||||
|
let isEventKeyActive = false
|
||||||
|
postalCodeField.addEventListener('input', (e) =>{
|
||||||
|
isEventKeyActive = true
|
||||||
|
})
|
||||||
|
postalCodeField.addEventListener('keypress', e => {
|
||||||
|
if (e.target.value.length === 5 && isEventKeyActive) {
|
||||||
|
if (e.key === 'Enter') {
|
||||||
|
e.preventDefault();
|
||||||
|
modalDate.click()
|
||||||
|
isEventKeyActive = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
onMounted(() => {
|
||||||
|
handleFormKeyPress()
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
slide,
|
slide,
|
||||||
navPos,
|
navPos,
|
||||||
|
@ -48,19 +75,24 @@ export default defineComponent({
|
||||||
<div ref="target" class="vertical-carousel-container" style="min-height: 100dvh">
|
<div ref="target" class="vertical-carousel-container" style="min-height: 100dvh">
|
||||||
<q-carousel navigation-position="right" style="min-height: 100dvh" v-model="slide" navigation autoplay infinite
|
<q-carousel navigation-position="right" style="min-height: 100dvh" v-model="slide" navigation autoplay infinite
|
||||||
animated v-if="!!banners.length" class="custom-carousel">
|
animated v-if="!!banners.length" class="custom-carousel">
|
||||||
<q-carousel-slide v-for="(item, i) in banners[0]" :key="i" :name="item.longName" :img-src="item.url">
|
<q-carousel-slide v-for="(item, i) in banners" :key="i" :name="item.title" :img-src="item.image">
|
||||||
<div class="vertical-carousel-content">
|
<div class="vertical-carousel-content">
|
||||||
<header class="carousel-content-header">
|
<header class="carousel-content-header">
|
||||||
<h1 class="carousel-header-title">
|
<h1 class="carousel-header-title">
|
||||||
|
{{ item.title }}
|
||||||
</h1>
|
</h1>
|
||||||
</header>
|
</header>
|
||||||
|
</div>
|
||||||
|
</q-carousel-slide>
|
||||||
|
</q-carousel>
|
||||||
|
|
||||||
<form @submit="onSubmit" class="carousel-content-body">
|
<div class="carousel-form">
|
||||||
<div class="carousel-content-item">
|
<form @submit="onSubmit" class="carousel-content-body" id="carousel-form">
|
||||||
|
<div class="carousel-content-item postal-code-control">
|
||||||
<PostalCode v-model="postalCode" v-bind:bindValue="postalCodeAttrs" :setFieldError="setFieldError" />
|
<PostalCode v-model="postalCode" v-bind:bindValue="postalCodeAttrs" :setFieldError="setFieldError" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="carousel-content-item">
|
<div class="carousel-content-item date-expired-control">
|
||||||
<Calendar v-model="calendar" v-bind:bindValue="calendarAttrs" :setValues="setValues" />
|
<Calendar v-model="calendar" v-bind:bindValue="calendarAttrs" :setValues="setValues" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -69,9 +101,6 @@ export default defineComponent({
|
||||||
</q-btn>
|
</q-btn>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
</q-carousel-slide>
|
|
||||||
</q-carousel>
|
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
@ -83,39 +112,15 @@ export default defineComponent({
|
||||||
& .custom-carousel {
|
& .custom-carousel {
|
||||||
user-select: none;
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
.carousel-form{
|
||||||
& .vertical-carousel-content {
|
max-width: 850px;
|
||||||
|
margin: 0 auto;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
min-height: fit-content;
|
bottom: 15vh;
|
||||||
left: 0;
|
left: 0;
|
||||||
right: 0;
|
right: 0;
|
||||||
bottom: 110px;
|
|
||||||
width: min(100%, 845px);
|
|
||||||
margin: 0 auto;
|
|
||||||
|
|
||||||
& .carousel-content-header {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 17px;
|
|
||||||
color: $white;
|
|
||||||
text-align: center;
|
|
||||||
margin-bottom: 27px;
|
|
||||||
|
|
||||||
& .carousel-header-title {
|
|
||||||
font-size: $font-35;
|
|
||||||
font-weight: 500;
|
|
||||||
line-height: 30px;
|
|
||||||
color: currentColor;
|
|
||||||
}
|
}
|
||||||
|
.carousel-content-body {
|
||||||
& .carousel-header-paragraph {
|
|
||||||
color: currentColor;
|
|
||||||
font-family: $font-lora;
|
|
||||||
line-height: 22px;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
& .carousel-content-body {
|
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
border-radius: 10px 0 0 10px;
|
border-radius: 10px 0 0 10px;
|
||||||
|
@ -173,6 +178,36 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
& .vertical-carousel-content {
|
||||||
|
min-height: fit-content;
|
||||||
|
width: min(100%, 845px);
|
||||||
|
margin: 0 auto;
|
||||||
|
|
||||||
|
& .carousel-content-header {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 17px;
|
||||||
|
color: $white;
|
||||||
|
text-align: center;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 30vh;
|
||||||
|
left: 0;
|
||||||
|
width: 100%;
|
||||||
|
margin-bottom: 27px;
|
||||||
|
|
||||||
|
& .carousel-header-title {
|
||||||
|
font-size: $font-35;
|
||||||
|
font-weight: 500;
|
||||||
|
line-height: 30px;
|
||||||
|
color: currentColor;
|
||||||
|
}
|
||||||
|
|
||||||
|
& .carousel-header-paragraph {
|
||||||
|
color: currentColor;
|
||||||
|
font-family: $font-lora;
|
||||||
|
line-height: 22px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
& .carousel-content-footer {
|
& .carousel-content-footer {
|
||||||
display: grid;
|
display: grid;
|
||||||
|
@ -181,12 +216,12 @@ export default defineComponent({
|
||||||
|
|
||||||
@media only screen and (max-width: $med-xmd) {
|
@media only screen and (max-width: $med-xmd) {
|
||||||
padding-inline: 20px;
|
padding-inline: 20px;
|
||||||
top: 50%;
|
|
||||||
transform: translateY(-50%);
|
|
||||||
|
|
||||||
& .carousel-content-header {
|
& .carousel-content-header {
|
||||||
gap: 15px;
|
gap: 15px;
|
||||||
margin-bottom: 49px;
|
margin-bottom: 20px;
|
||||||
|
bottom: initial;
|
||||||
|
top: calc(10dvh + 120px);
|
||||||
|
|
||||||
& .carousel-header-title {
|
& .carousel-header-title {
|
||||||
font-size: $font-28;
|
font-size: $font-28;
|
||||||
|
@ -199,6 +234,24 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
& .carousel-content-footer {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media only screen and (max-width: $med-md) {}
|
||||||
|
|
||||||
|
@media only screen and (max-height: 360px) {
|
||||||
|
/* background-color: tomato; */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@media only screen and (max-width: $med-xmd) {
|
||||||
|
.carousel-form{
|
||||||
|
bottom: 0;
|
||||||
|
top: 120px;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
}
|
||||||
& .carousel-content-body {
|
& .carousel-content-body {
|
||||||
margin-bottom: initial;
|
margin-bottom: initial;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
@ -217,17 +270,6 @@ export default defineComponent({
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
& .carousel-content-footer {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@media only screen and (max-width: $med-md) {}
|
|
||||||
|
|
||||||
@media only screen and (max-height: 360px) {
|
|
||||||
/* background-color: tomato; */
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -77,7 +77,7 @@ export default defineComponent({
|
||||||
const { products, addCartLoadingBtn } = storeToRefs(cartStore);
|
const { products, addCartLoadingBtn } = storeToRefs(cartStore);
|
||||||
|
|
||||||
onBeforeMount(async () => {
|
onBeforeMount(async () => {
|
||||||
await getProduct(route.params.id);
|
await getProduct(route.params.id, availability.value);
|
||||||
});
|
});
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
|
|
@ -147,11 +147,10 @@ export const useCartStore = defineStore("cart", () => {
|
||||||
routeId.value = id;
|
routeId.value = id;
|
||||||
try {
|
try {
|
||||||
const params = transformOptionsToParams(options);
|
const params = transformOptionsToParams(options);
|
||||||
|
|
||||||
const promises = [
|
const promises = [
|
||||||
apiBack.get(`products/${+id - 1}`),
|
apiBack.get(`products/${+id - 1}`, { params }),
|
||||||
apiBack.get(`products/${+id}`),
|
apiBack.get(`products/${+id}`, { params }),
|
||||||
apiBack.get(`products/${+id + 1}`),
|
apiBack.get(`products/${+id + 1}`, { params }),
|
||||||
];
|
];
|
||||||
const results = await Promise.allSettled(promises);
|
const results = await Promise.allSettled(promises);
|
||||||
const [prev, current, next] = results.map((res) => {
|
const [prev, current, next] = results.map((res) => {
|
||||||
|
|
Loading…
Reference in New Issue