|
|
@@ -3,11 +3,13 @@
|
|
|
import CreatorBaseInputs from '$lib/modules/CreatorBaseInputs.svelte';
|
|
|
import CreatorInputs from '$lib/modules/CreatorInputs.svelte';
|
|
|
import CreatorTimeInputs from '$lib/modules/CreatorTimeInputs.svelte';
|
|
|
+ import { tick } from 'svelte';
|
|
|
|
|
|
let creatorInputs: AppointmentInputs[] = [{ name: '', type: 'text' }];
|
|
|
let topic: string;
|
|
|
let location: string;
|
|
|
let selectedWeek: number = 202502;
|
|
|
+ let previousWeek: number = selectedWeek;
|
|
|
let duration: number = 15;
|
|
|
let renderTimeSelection: boolean = false;
|
|
|
|
|
|
@@ -28,14 +30,19 @@
|
|
|
}
|
|
|
];
|
|
|
|
|
|
- function changeWeek() {
|
|
|
+ async function changeWeek() {
|
|
|
+ await tick();
|
|
|
console.log("changed");
|
|
|
+ console.log(selectedWeek);
|
|
|
renderTimeSelection = false;
|
|
|
|
|
|
+ /*
|
|
|
const index = appointmentList.findIndex((entry) => entry.week === selectedWeek);
|
|
|
if (index !== -1 && selectedWeekAppointments !== undefined) {
|
|
|
appointmentList[index].appointments = selectedWeekAppointments;
|
|
|
+ //console.log(appointmentList[index].appointments);
|
|
|
}
|
|
|
+ */
|
|
|
|
|
|
const ix = appointmentList.findIndex((entry) => entry.week === selectedWeek);
|
|
|
if (ix === -1) {
|
|
|
@@ -52,12 +59,20 @@
|
|
|
]
|
|
|
}
|
|
|
appointmentList = [... appointmentList, tmp];
|
|
|
- }
|
|
|
+ selectedWeekAppointments = tmp.appointments;
|
|
|
+ console.log("not found");
|
|
|
+ } else {
|
|
|
+ console.log("test");
|
|
|
+ console.log(appointmentList);
|
|
|
+ selectedWeekAppointments = appointmentList.find(
|
|
|
+ (entry) => entry.week === selectedWeek
|
|
|
+ )?.appointments;
|
|
|
+ console.log("found and send entry");
|
|
|
+ }
|
|
|
|
|
|
- selectedWeekAppointments = appointmentList.find(
|
|
|
- (entry) => entry.week === selectedWeek
|
|
|
- )?.appointments;
|
|
|
+
|
|
|
renderTimeSelection = true;
|
|
|
+ previousWeek = selectedWeek;
|
|
|
//setTimeout(() => renderTimeSelection = false, 2000);
|
|
|
}
|
|
|
|
|
|
@@ -66,9 +81,12 @@
|
|
|
)?.appointments;
|
|
|
|
|
|
$: {
|
|
|
+ // deactivate when changing weeks to prevent override
|
|
|
const ix = appointmentList.findIndex((entry) => entry.week === selectedWeek);
|
|
|
- if (ix !== -1 && selectedWeekAppointments !== undefined) {
|
|
|
+ if (ix !== -1 && selectedWeekAppointments !== undefined && previousWeek === selectedWeek) {
|
|
|
appointmentList[ix].appointments = selectedWeekAppointments;
|
|
|
+ console.log("updated");
|
|
|
+ console.log(appointmentList[ix].appointments);
|
|
|
//renderTimeSelection = true;
|
|
|
//setTimeout(() => renderTimeSelection = false, 2000);
|
|
|
}
|