I have several pages with a datepicker. When I choose dates, I initialise a chart showing data from this period. When I navigate to another page, datepicker inputs are shown in their initial state on this component. I want the datepickers on other pages remember a period which I chose before. I suppose I need to pass this to the global state but I am not sure how.
Here is my datepickers:
<template>
...
<datepicker v-model="periodStart"
minimum-view="month"
format="MMMM yyyy"/>
<datepicker v-model="periodEnd"
minimum-view="month"
format="MMMM yyyy"/>
...
<template>
<script>
...
data() {
return {
periodStart: new Date(),
periodEnd: new Date(),
};
},
methods: {
...mapActions(['loadActiveUsers']),
report() {
this.loadActiveUsers({ params: {
start_date: moment(this.periodStart).startOf('month').format('YYYY-MM-DD'),
end_date: moment(this.periodEnd).endOf('month').format('YYYY-MM-DD'),
}
});
},
},
...
<script>
Vuex module:
export default {
state: {
report: {
isLoaded: false,
data: {},
},
},
},
...