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,7 +23,7 @@ export const useMMCMStore = defineStore('counter', {
productList: [],
withPrescription: null,
idProduct: null,
dateDelivery: null,
dateDelivery: null, // 13 digit timestamp millisecond
dateCollect: null
}),
getters: {
@@ -30,6 +32,7 @@ export const useMMCMStore = defineStore('counter', {
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),
dateDeliveryTimestampInSecond: (state) => timestampConverter(state.dateDelivery)
},
actions: {
setStreet(street) {

View File

@@ -1,19 +1,4 @@
<template>
<div v-if="store.needPrescriptionDateCollect">
<div class="step_title">Date de collecte de l'ordonnance :</div>
<div class="input-group has-validation">
<Datepicker v-model="dateCollect" autoApply @update:modelValue="isErrorCollect = false" model-type="timestamp"
select-text="Choisir" cancel-text="Annuler"
monthNameFormat="long" format="dd MMMM yyyy" :minDate="store.minDateForDelivery" :enableTimePicker="false"
:disabledWeekDays="[6, 0]" :format-locale="fr" locale="fr-FR"/>
<button class="btn btn-primary" @click="gotToNextStep"><i class="fa-regular fa-circle-check fa-fw"></i> Valider
</button>
<div v-if="isErrorCollect" class="invalid-feedback d-block text-start">
Merci de renseigner la date
</div>
</div>
</div>
<div class="step_title">Date de livraison des médicaments :</div>
<div class="input-group has-validation">
<Datepicker v-model="dateDelivery" autoApply @update:modelValue="isErrorDelivery = false" model-type="timestamp"

View File

@@ -33,18 +33,20 @@ export default {
},
name: "delivery-option-summary",
methods: {
addToCart: async function (idProduct) {
this.suspens = true
let urlApi = '/php/api/v3/mmcm.php?EXEC=addToCart&ID_PRODUCT=' + this.store.idProduct
+ '&with_prescription=' + this.store.withPrescription
+ '&date_delivery=' + this.store.dateDelivery
+ '&date_delivery=' + this.store.dateDeliveryTimestampInSecond
+ '&street=' + encodeURI(this.store.street)
+ '&zip_code=' + this.store.zipCode
+ '&city=' +this.store.city
;
if(import.meta.env.DEV){
urlApi += '&ID_SESSION=xcn6c41b'
urlApi += '&ID_SESSION=uYkQcd22'
console.log(urlApi)
}