feat: add deposit and weekend km allowance to vehicles, update migrations and booking flow
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
+11
-1
@@ -230,6 +230,8 @@ function loadForEdit(id) {
|
||||
vehicleForm.daily_price_eur.value = v.daily_price_eur;
|
||||
vehicleForm.weekend_price_eur.value = v.weekend_price_eur || 0;
|
||||
vehicleForm.max_daily_km.value = v.max_daily_km || 150;
|
||||
vehicleForm.kaution_eur.value = v.kaution_eur || 5000;
|
||||
vehicleForm.max_km_weekend.value = v.max_km_weekend || '';
|
||||
vehicleForm.sort_order.value = v.sort_order;
|
||||
vehicleForm.location.value = v.location;
|
||||
vehicleForm.description_de.value = v.description_de;
|
||||
@@ -250,6 +252,8 @@ resetBtn.addEventListener("click", () => {
|
||||
vehicleForm.seats.value = 2;
|
||||
vehicleForm.max_daily_km.value = 150;
|
||||
vehicleForm.weekend_price_eur.value = 0;
|
||||
vehicleForm.kaution_eur.value = 5000;
|
||||
vehicleForm.max_km_weekend.value = '';
|
||||
state.currentPhotoPath = null;
|
||||
updatePreview("");
|
||||
formTitle.textContent = "Neues Fahrzeug";
|
||||
@@ -273,6 +277,8 @@ vehicleForm.addEventListener("submit", async (e) => {
|
||||
daily_price_eur: +fd.get("daily_price_eur") || 0,
|
||||
weekend_price_eur: +fd.get("weekend_price_eur") || 0,
|
||||
max_daily_km: +fd.get("max_daily_km") || 150,
|
||||
kaution_eur: +fd.get("kaution_eur") || 5000,
|
||||
max_km_weekend: fd.get("max_km_weekend") ? +fd.get("max_km_weekend") : null,
|
||||
sort_order: +fd.get("sort_order") || 100,
|
||||
location: fd.get("location") || "Steiermark (TBD)",
|
||||
description_de: fd.get("description_de") || "",
|
||||
@@ -316,11 +322,15 @@ photoInput.addEventListener("change", async () => {
|
||||
formFeedback.className = "form-feedback";
|
||||
formFeedback.textContent = "Uploading photo...";
|
||||
try {
|
||||
// Delete old photo if exists
|
||||
if (state.currentPhotoPath) {
|
||||
await supabase.storage.from("vehicle-photos").remove([state.currentPhotoPath]);
|
||||
}
|
||||
const ext = (file.name.split(".").pop() || "jpg").toLowerCase();
|
||||
const path = `${crypto.randomUUID()}.${ext}`;
|
||||
const { error: upErr } = await supabase.storage
|
||||
.from("vehicle-photos")
|
||||
.upload(path, file, { contentType: file.type, upsert: false });
|
||||
.upload(path, file, { contentType: file.type, upsert: true });
|
||||
if (upErr) throw upErr;
|
||||
const { data: pub } = supabase.storage.from("vehicle-photos").getPublicUrl(path);
|
||||
state.currentPhotoPath = path;
|
||||
|
||||
Reference in New Issue
Block a user