This commit is contained in:
Jonathan Chevalier
2022-10-12 17:37:30 +02:00
parent e653f9ff45
commit f250f65814
3 changed files with 11 additions and 21 deletions

View File

@@ -13,6 +13,8 @@ const afterTomorrow =
days: 2
})
const timestampConverter = (digit13) => digit13 / 1000
export const useMMCMStore = defineStore('counter', {
state: () => ({
street: '',
@@ -21,15 +23,16 @@ export const useMMCMStore = defineStore('counter', {
productList: [],
withPrescription: null,
idProduct: null,
dateDelivery: null,
dateCollect :null
dateDelivery: null, // 13 digit timestamp millisecond
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"),
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),
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),
dateDeliveryTimestampInSecond: (state) => timestampConverter(state.dateDelivery)
},
actions: {
setStreet(street) {