|
|
|
|
@ -23,7 +23,8 @@
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<!-- {{ trainersWithTimeslots }} -->
|
|
|
|
|
<OrderPopup @closePopup="closePopup" :trainer="selectedTrainer" :timeslot="selectedTimeslot" v-if="showPopup" ></OrderPopup>
|
|
|
|
|
<OrderPopup @closePopup="closePopup" :trainer="selectedTrainer" :timeslot="selectedTimeslot" v-if="showPopup">
|
|
|
|
|
</OrderPopup>
|
|
|
|
|
</div>
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
@ -111,6 +112,9 @@ export default {
|
|
|
|
|
TrainerSelector,
|
|
|
|
|
OrderPopup
|
|
|
|
|
},
|
|
|
|
|
created() {
|
|
|
|
|
this.parseQueryFilters();
|
|
|
|
|
},
|
|
|
|
|
data() {
|
|
|
|
|
return {
|
|
|
|
|
range: {
|
|
|
|
|
@ -177,17 +181,9 @@ export default {
|
|
|
|
|
openPopup(trainer: Trainer, timeslot: Timeslot) {
|
|
|
|
|
this.selectedTrainer = trainer;
|
|
|
|
|
this.selectedTimeslot = timeslot;
|
|
|
|
|
this.setSearchQueryFilters();
|
|
|
|
|
this.showPopup = true;
|
|
|
|
|
},
|
|
|
|
|
createOrder(trainer: Trainer, timeslot: Timeslot) {
|
|
|
|
|
this.$router.push({
|
|
|
|
|
path: "/createOrder", query: {
|
|
|
|
|
trainer: trainer.id,
|
|
|
|
|
startDate: new Date(timeslot.startDate).toISOString(),
|
|
|
|
|
endDate: new Date(timeslot.endDate).toISOString()
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
},
|
|
|
|
|
formatDate(date: Date): string {
|
|
|
|
|
let output: string = dayjs(date).locale("da").format("dddd D. MMM YYYY");
|
|
|
|
|
let outputStringArray = output.split("");
|
|
|
|
|
@ -203,16 +199,49 @@ export default {
|
|
|
|
|
},
|
|
|
|
|
centerSelectionChanged(selection: number[]) {
|
|
|
|
|
this.centers = selection;
|
|
|
|
|
this.setSearchQueryFilters();
|
|
|
|
|
},
|
|
|
|
|
trainerSelectionChanged(selection: number[]) {
|
|
|
|
|
this.trainers = selection;
|
|
|
|
|
this.setSearchQueryFilters();
|
|
|
|
|
},
|
|
|
|
|
async fetchTimeslots() {
|
|
|
|
|
parseQueryFilters() {
|
|
|
|
|
const filters = this.$route.query as any;
|
|
|
|
|
if (filters.center)
|
|
|
|
|
if (Array.isArray(filters.center))
|
|
|
|
|
this.centers = filters.center;
|
|
|
|
|
else
|
|
|
|
|
this.centers = [filters.center];
|
|
|
|
|
if (filters.trainer)
|
|
|
|
|
if (Array.isArray(filters.trainer))
|
|
|
|
|
this.trainers = filters.trainer;
|
|
|
|
|
else
|
|
|
|
|
this.trainers = [filters.trainer];
|
|
|
|
|
if (filters.startDate)
|
|
|
|
|
this.range.start = new Date(filters.startDate);
|
|
|
|
|
if (filters.endDate)
|
|
|
|
|
this.range.end = new Date(filters.endDate);
|
|
|
|
|
},
|
|
|
|
|
setSearchQueryFilters() {
|
|
|
|
|
this.$router.replace({
|
|
|
|
|
query: {
|
|
|
|
|
center: this.centers,
|
|
|
|
|
trainer: this.trainers,
|
|
|
|
|
startDate: this.range.start.toISOString(),
|
|
|
|
|
endDate: this.range.end.toISOString()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
},
|
|
|
|
|
getSearchQueryFilters(): string {
|
|
|
|
|
const centerFilters = this.centers.map(c => `center=${c}`);
|
|
|
|
|
const trainerFilters = this.trainers.map(c => `trainer=${c}`);
|
|
|
|
|
const startDateFilter = `startDate=${this.range.start.toISOString()}`;
|
|
|
|
|
const endDateFilter = `endDate=${this.range.end.toISOString()}`;
|
|
|
|
|
const filters = [...centerFilters, ...trainerFilters, startDateFilter, endDateFilter].join("&");
|
|
|
|
|
return filters;
|
|
|
|
|
},
|
|
|
|
|
async fetchTimeslots() {
|
|
|
|
|
const filters = this.getSearchQueryFilters();
|
|
|
|
|
const res = await fetch(`${import.meta.env.VITE_BASE_API_URL}/timeslot?${filters}`);
|
|
|
|
|
if (res.status === 200) {
|
|
|
|
|
this.trainersWithTimeslots = await res.json();
|
|
|
|
|
|