fixed some login and booking bugs
This commit is contained in:
@@ -31,8 +31,28 @@
|
||||
<div class="card">
|
||||
<form id="bookingForm">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="service_id">Service ID</label>
|
||||
<input class="form-input" type="text" id="service_id" name="service_id" placeholder="Enter service ID" required>
|
||||
<label class="form-label" for="service_option">Service Option</label>
|
||||
<select class="form-input" id="service_option" name="service_option" required>
|
||||
<option value="">Select a service option...</option>
|
||||
<option value="Small Bundle">Small Bundle</option>
|
||||
<option value="Medium Bundle">Medium Bundle</option>
|
||||
<option value="Large Bundle">Large Bundle</option>
|
||||
<option value="Balloons Only">Balloons Only</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="event_type">Event Type</label>
|
||||
<select class="form-input" id="event_type" name="event_type" required>
|
||||
<option value="">Select an event type...</option>
|
||||
<option value="Birthday">Birthday</option>
|
||||
<option value="Wedding">Wedding</option>
|
||||
<option value="Anniversary">Anniversary</option>
|
||||
<option value="Baby Shower">Baby Shower</option>
|
||||
<option value="Graduation">Graduation</option>
|
||||
<option value="Corporate Event">Corporate Event</option>
|
||||
<option value="Other">Other</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -41,8 +61,9 @@
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="address">Address</label>
|
||||
<input class="form-input" type="text" id="address" name="address" placeholder="Event location">
|
||||
<label class="form-label" for="address">Address <span style="color: hsl(var(--destructive));">*</span></label>
|
||||
<input class="form-input" type="text" id="address" name="address" placeholder="123 Main St, Sydney NSW 2000" required>
|
||||
<small style="color: hsl(var(--muted-foreground)); font-size: 0.875rem;">Please include street, suburb, state, and postcode</small>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@@ -62,18 +83,63 @@
|
||||
{{template "footer"}}
|
||||
{{template "theme-script"}}
|
||||
<script>
|
||||
function validateAustralianAddress(address) {
|
||||
if (!address || address.trim().length < 10) {
|
||||
return { valid: false, message: 'Address is too short. Please provide a complete address.' };
|
||||
}
|
||||
|
||||
const australianStates = ['NSW', 'VIC', 'QLD', 'SA', 'WA', 'TAS', 'NT', 'ACT'];
|
||||
const hasState = australianStates.some(state =>
|
||||
address.toUpperCase().includes(state) ||
|
||||
address.toUpperCase().includes(state.toLowerCase())
|
||||
);
|
||||
|
||||
const postcodePattern = /\b\d{4}\b/;
|
||||
const hasPostcode = postcodePattern.test(address);
|
||||
|
||||
if (!hasState && !hasPostcode) {
|
||||
return {
|
||||
valid: false,
|
||||
message: 'Please include an Australian state (NSW, VIC, QLD, etc.) and postcode in your address.'
|
||||
};
|
||||
}
|
||||
|
||||
if (!hasState) {
|
||||
return {
|
||||
valid: false,
|
||||
message: 'Please include an Australian state (NSW, VIC, QLD, SA, WA, TAS, NT, or ACT) in your address.'
|
||||
};
|
||||
}
|
||||
|
||||
if (!hasPostcode) {
|
||||
return {
|
||||
valid: false,
|
||||
message: 'Please include a 4-digit postcode in your address.'
|
||||
};
|
||||
}
|
||||
|
||||
return { valid: true };
|
||||
}
|
||||
|
||||
document.getElementById('bookingForm').addEventListener('submit', async function(e){
|
||||
e.preventDefault();
|
||||
const f = e.target;
|
||||
const submitBtn = f.querySelector('button[type="submit"]');
|
||||
const originalText = submitBtn.textContent;
|
||||
|
||||
const addressValidation = validateAustralianAddress(f.address.value);
|
||||
if (!addressValidation.valid) {
|
||||
alert(addressValidation.message);
|
||||
return;
|
||||
}
|
||||
|
||||
submitBtn.disabled = true;
|
||||
submitBtn.textContent = 'Submitting...';
|
||||
|
||||
const body = {
|
||||
user_id: "",
|
||||
service_id: f.service_id.value,
|
||||
service_option: f.service_option.value,
|
||||
event_type: f.event_type.value,
|
||||
event_date: new Date(f.event_date.value).toISOString(),
|
||||
address: f.address.value,
|
||||
notes: f.notes.value
|
||||
|
||||
Reference in New Issue
Block a user