This commit is contained in:
Jonathan Chevalier
2022-10-11 17:15:24 +02:00
parent acdbde8b84
commit e653f9ff45
5 changed files with 66 additions and 33 deletions

View File

@@ -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) {