|
@@ -1809,26 +1809,29 @@ createApp({
|
|
|
editRef.value = null;
|
|
editRef.value = null;
|
|
|
const original = selection.value?.[field] ?? '';
|
|
const original = selection.value?.[field] ?? '';
|
|
|
if (newVal === null || newVal === original) return;
|
|
if (newVal === null || newVal === original) return;
|
|
|
|
|
+ const targetUid = selection.value.uid;
|
|
|
|
|
+ const targetCheckin = selection.value.checkin_date;
|
|
|
stateRef.value = 'saving';
|
|
stateRef.value = 'saving';
|
|
|
try {
|
|
try {
|
|
|
- const res = await fetch(`/reservation/${selection.value.uid}`, {
|
|
|
|
|
|
|
+ const res = await fetch(`/reservation/${targetUid}`, {
|
|
|
method: 'PATCH',
|
|
method: 'PATCH',
|
|
|
headers: { 'Content-Type': 'application/json' },
|
|
headers: { 'Content-Type': 'application/json' },
|
|
|
- body: JSON.stringify({ checkin_date: selection.value.checkin_date, [field]: newVal }),
|
|
|
|
|
|
|
+ body: JSON.stringify({ checkin_date: targetCheckin, [field]: newVal }),
|
|
|
});
|
|
});
|
|
|
if (!res.ok) throw new Error(await res.text());
|
|
if (!res.ok) throw new Error(await res.text());
|
|
|
const updated = await res.json();
|
|
const updated = await res.json();
|
|
|
|
|
+ if (selection.value?.uid !== targetUid) return;
|
|
|
selection.value.wifi_key = updated.wifi_key ?? selection.value.wifi_key;
|
|
selection.value.wifi_key = updated.wifi_key ?? selection.value.wifi_key;
|
|
|
selection.value.wifi_ssid = updated.wifi_ssid ?? selection.value.wifi_ssid;
|
|
selection.value.wifi_ssid = updated.wifi_ssid ?? selection.value.wifi_ssid;
|
|
|
selection.value.door_code = updated.door_code ?? selection.value.door_code;
|
|
selection.value.door_code = updated.door_code ?? selection.value.door_code;
|
|
|
- const cd = selection.value.checkin_date;
|
|
|
|
|
- if (reservations.value[cd]) {
|
|
|
|
|
- Object.assign(reservations.value[cd], {
|
|
|
|
|
|
|
+ if (reservations.value[targetCheckin]) {
|
|
|
|
|
+ Object.assign(reservations.value[targetCheckin], {
|
|
|
wifi_key: updated.wifi_key, wifi_ssid: updated.wifi_ssid, door_code: updated.door_code,
|
|
wifi_key: updated.wifi_key, wifi_ssid: updated.wifi_ssid, door_code: updated.door_code,
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
stateRef.value = null;
|
|
stateRef.value = null;
|
|
|
} catch {
|
|
} catch {
|
|
|
|
|
+ if (selection.value?.uid !== targetUid) return;
|
|
|
setError(stateRef);
|
|
setError(stateRef);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|