diff --git a/src/router/guards/piniaCheck.js b/src/router/guards/piniaCheck.js index 0f132ac..2e07860 100644 --- a/src/router/guards/piniaCheck.js +++ b/src/router/guards/piniaCheck.js @@ -5,7 +5,7 @@ export default function (routeTo) { const store = useMMCMStore() if (routeTo.path === '/delivery-option-step-1') { - return store.street !== '' && store.city !== '' && store.zipCode !== ''; + return store.productList.length > 0; } else if (routeTo.path === '/delivery-option-step-2') { return store.withPrescription !== null diff --git a/src/stores/mmcm.js b/src/stores/mmcm.js index 8f16699..72dd67f 100644 --- a/src/stores/mmcm.js +++ b/src/stores/mmcm.js @@ -1,4 +1,17 @@ import {defineStore} from 'pinia' +import {add} from "date-fns"; + +const today = new Date(); + +const tomorrow = + add(new Date(), { + days: 1 + }) + +const afterTomorrow = + add(new Date(), { + days: 2 + }) export const useMMCMStore = defineStore('counter', { state: () => ({ @@ -8,12 +21,15 @@ export const useMMCMStore = defineStore('counter', { productList: [], withPrescription: null, idProduct: null, - dateDelivery: null + dateDelivery: null, + dateCollect :null }), getters: { fullAddress: (state) => state.street + ' ' + state.zipCode + ' ' + state.city, deliveryMethod: (state) => state.productList.filter(p => p.id === state.idProduct)[0].name, - dateDeliveryString: (state) => new Date(state.dateDelivery).toLocaleDateString("fr-FR") + dateDeliveryString: (state) => new Date(state.dateDelivery).toLocaleDateString("fr-FR"), + minDateForDelivery : (state) => (state.productList.filter(p => p.id === state.idProduct)[0].ref === 'MMCM_EXPRESS') ? today : tomorrow , + needPrescriptionDateCollect : (state) => !!(state.productList.filter(p => p.id === state.idProduct)[0].ref === 'MMCM_FACTEUR' && state.withPrescription), }, actions: { setStreet(street) { diff --git a/src/views/address-check.vue b/src/views/address-check.vue index 3c8b160..2dc4b7e 100644 --- a/src/views/address-check.vue +++ b/src/views/address-check.vue @@ -21,18 +21,29 @@ {{ item.properties.label }} + + +