Add consistency check just in case
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
import {ref, onMounted, watch} from "vue";
|
||||
import { datePickerStore } from "@/stores/CalendarStore.ts";
|
||||
import { Calendar } from "@/models/Calendar.ts";
|
||||
import router from "@/router";
|
||||
|
||||
const calendar = new Calendar();
|
||||
const datePicker = datePickerStore();
|
||||
@@ -25,6 +26,19 @@
|
||||
calendar.setDay(day);
|
||||
toggleSelectedDay(event.target.id, calendar.getDate());
|
||||
highlightSelectedDay(event.target);
|
||||
checkConsistency();
|
||||
}
|
||||
|
||||
function checkConsistency(){
|
||||
|
||||
let selected = selectedDays.value;
|
||||
let stored = datePicker.value;
|
||||
|
||||
if(selected.size != stored.length){
|
||||
datePicker.clear();
|
||||
selected.clear();
|
||||
router.push('/error')
|
||||
}
|
||||
}
|
||||
|
||||
function toggleSelectedDay(id : string, date : Date) : void {
|
||||
|
||||
@@ -12,6 +12,7 @@ const router = createRouter({
|
||||
{ path: '/about', name: 'about', component: AboutView},
|
||||
{ path: '/create', name: 'create', component: CreateView},
|
||||
{ path: '/join', name: 'join', component: JoinView},
|
||||
{ path: '/error', name: 'error', component: ErrorView},
|
||||
{ path: '/:pathMatch(.*)*', component: ErrorView }
|
||||
]
|
||||
})
|
||||
|
||||
@@ -5,10 +5,15 @@ export const datePickerStore = defineStore('datePicker', {
|
||||
state: () => {
|
||||
return { dates: [] as TimeStamp[] }
|
||||
},
|
||||
getters: {
|
||||
value: (state) : TimeStamp[] => state.dates as TimeStamp[],
|
||||
},
|
||||
actions: {
|
||||
update(dates : Date[]) {
|
||||
update(dates : Date[]) : void {
|
||||
this.dates = dates.map(date => new TimeStamp(date));
|
||||
console.log(this.dates);
|
||||
},
|
||||
clear() : void {
|
||||
this.dates = [] as TimeStamp[];
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user