feat: Add listing submission page with multi-step form
This commit is contained in:
1 parent
c3557fe1e8
commit
7e195ec815
2 files changed
+383
No files matched your search
@@ -0,0 +1,377 @@
|
||||
<div class="container mx-auto py-10 px-4 sm:px-6 lg:px-8">
|
||||
<h1 class="text-3xl font-bold text-indigo-700 mb-8 text-center">Post a New Listing</h1>
|
||||
|
||||
<div id="post-form-steps" class="max-w-3xl mx-auto bg-white p-6 sm:p-8 rounded-lg shadow-xl">
|
||||
<!-- Step Indicators -->
|
||||
<div class="flex justify-between mb-8 sm:mb-10">
|
||||
<div id="step-indicator-1" class="step-indicator active-step text-center flex-1">
|
||||
<div class="w-8 h-8 sm:w-10 sm:h-10 mx-auto rounded-full bg-indigo-700 text-white flex items-center justify-center text-sm sm:text-base">1</div>
|
||||
<p class="text-xs sm:text-sm mt-1 sm:mt-2">Description</p>
|
||||
</div>
|
||||
<div id="step-indicator-2" class="step-indicator text-center text-gray-500 flex-1">
|
||||
<div class="w-8 h-8 sm:w-10 sm:h-10 mx-auto rounded-full bg-gray-300 flex items-center justify-center text-sm sm:text-base">2</div>
|
||||
<p class="text-xs sm:text-sm mt-1 sm:mt-2">Location</p>
|
||||
</div>
|
||||
<div id="step-indicator-3" class="step-indicator text-center text-gray-500 flex-1">
|
||||
<div class="w-8 h-8 sm:w-10 sm:h-10 mx-auto rounded-full bg-gray-300 flex items-center justify-center text-sm sm:text-base">3</div>
|
||||
<p class="text-xs sm:text-sm mt-1 sm:mt-2">Price & Availability</p>
|
||||
</div>
|
||||
<div id="step-indicator-4" class="step-indicator text-center text-gray-500 flex-1">
|
||||
<div class="w-8 h-8 sm:w-10 sm:h-10 mx-auto rounded-full bg-gray-300 flex items-center justify-center text-sm sm:text-base">4</div>
|
||||
<p class="text-xs sm:text-sm mt-1 sm:mt-2">Contact</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<form id="new-listing-form">
|
||||
<!-- Step 1: Description -->
|
||||
<div id="step-1" class="form-step active-step">
|
||||
<h2 class="text-xl sm:text-2xl font-semibold text-indigo-700 mb-6">Step 1: Listing Description</h2>
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<label for="photo" class="block text-sm font-medium text-gray-700 mb-1">Listing Photo</label>
|
||||
<input type="file" id="photo" name="photo" class="w-full text-sm text-gray-500 file:mr-4 file:py-2 file:px-4 file:rounded-lg file:border-0 file:text-sm file:font-semibold file:bg-indigo-50 file:text-indigo-700 hover:file:bg-indigo-100 border border-gray-300 rounded-lg cursor-pointer focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500" accept="image/*">
|
||||
<p class="text-xs text-gray-500 mt-1">Upload one image for your listing (e.g., JPG, PNG).</p>
|
||||
</div>
|
||||
<div>
|
||||
<label for="title" class="block text-sm font-medium text-gray-700 mb-1">Title</label>
|
||||
<input type="text" id="title" name="title" placeholder="e.g., Modern Coworking Hub with Great Coffee" class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label for="description" class="block text-sm font-medium text-gray-700 mb-1">Description</label>
|
||||
<textarea id="description" name="description" rows="4" placeholder="Describe your space, amenities, and what makes it unique..." class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm"></textarea>
|
||||
</div>
|
||||
<div>
|
||||
<label for="space-type" class="block text-sm font-medium text-gray-700 mb-1">Space Type</label>
|
||||
<select id="space-type" name="space-type" class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm bg-white">
|
||||
<option value="">Select a space type</option>
|
||||
<option value="coworking">Coworking</option>
|
||||
<option value="room">Private Room</option>
|
||||
<option value="conference">Conference Room</option>
|
||||
<option value="event-space">Event Space</option>
|
||||
<option value="virtual-office">Virtual Office</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-8 flex justify-end">
|
||||
<button type="button" class="next-step-btn bg-indigo-700 hover:bg-indigo-800 text-white font-semibold py-2 px-6 rounded-lg shadow-md focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-opacity-50 transition-colors">
|
||||
Next <span aria-hidden="true">→</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 2: Location -->
|
||||
<div id="step-2" class="form-step hidden">
|
||||
<h2 class="text-xl sm:text-2xl font-semibold text-indigo-700 mb-6">Step 2: Location</h2>
|
||||
<div class="space-y-5">
|
||||
<div class="relative">
|
||||
<label for="location-search" class="block text-sm font-medium text-gray-700 mb-1">Select Location</label>
|
||||
<input type="text" id="location-search" name="location-search" placeholder="Type to search for a city or area..." class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" autocomplete="off">
|
||||
<div id="location-dropdown" class="absolute z-20 mt-1 w-full rounded-md bg-white shadow-lg hidden ring-1 ring-black ring-opacity-5 max-h-60 overflow-y-auto py-1">
|
||||
<!-- Example items, real implementation would populate this dynamically or use a service -->
|
||||
<a href="#" data-value="Manila, Philippines" class="block px-4 py-2 text-sm text-gray-700 hover:bg-indigo-50 hover:text-indigo-700 location-item">Manila, Philippines</a>
|
||||
<a href="#" data-value="Makati, Philippines" class="block px-4 py-2 text-sm text-gray-700 hover:bg-indigo-50 hover:text-indigo-700 location-item">Makati, Philippines</a>
|
||||
<a href="#" data-value="Quezon City, Philippines" class="block px-4 py-2 text-sm text-gray-700 hover:bg-indigo-50 hover:text-indigo-700 location-item">Quezon City, Philippines</a>
|
||||
<a href="#" data-value="Cebu City, Philippines" class="block px-4 py-2 text-sm text-gray-700 hover:bg-indigo-50 hover:text-indigo-700 location-item">Cebu City, Philippines</a>
|
||||
<a href="#" data-value="Taguig, Philippines" class="block px-4 py-2 text-sm text-gray-700 hover:bg-indigo-50 hover:text-indigo-700 location-item">Taguig, Philippines</a>
|
||||
<p class="px-4 py-2 text-sm text-gray-500 no-results hidden">No locations found.</p>
|
||||
</div>
|
||||
<input type="hidden" id="selected-location" name="selected-location">
|
||||
</div>
|
||||
<div>
|
||||
<label for="address-line-1" class="block text-sm font-medium text-gray-700 mb-1">Address Line 1</label>
|
||||
<input type="text" id="address-line-1" name="address-line-1" placeholder="e.g., 123 Main St, Incub8 Building" class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label for="address-line-2" class="block text-sm font-medium text-gray-700 mb-1">Address Line 2 (Optional)</label>
|
||||
<input type="text" id="address-line-2" name="address-line-2" placeholder="e.g., Centennial Road, Brgy. Batong Dalig" class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-8 flex justify-between">
|
||||
<button type="button" class="prev-step-btn bg-gray-200 hover:bg-gray-300 text-gray-700 font-semibold py-2 px-6 rounded-lg shadow-md focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-opacity-50 transition-colors">
|
||||
<span aria-hidden="true">←</span> Previous
|
||||
</button>
|
||||
<button type="button" class="next-step-btn bg-indigo-700 hover:bg-indigo-800 text-white font-semibold py-2 px-6 rounded-lg shadow-md focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-opacity-50 transition-colors">
|
||||
Next <span aria-hidden="true">→</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 3: Price & Availability -->
|
||||
<div id="step-3" class="form-step hidden">
|
||||
<h2 class="text-xl sm:text-2xl font-semibold text-indigo-700 mb-6">Step 3: Price & Availability</h2>
|
||||
<div class="space-y-6">
|
||||
<div>
|
||||
<label for="price" class="block text-sm font-medium text-gray-700 mb-1">Price (PHP per day)</label>
|
||||
<div class="relative mt-1 rounded-md shadow-sm">
|
||||
<div class="pointer-events-none absolute inset-y-0 left-0 flex items-center pl-3">
|
||||
<span class="text-gray-500 sm:text-sm">₱</span>
|
||||
</div>
|
||||
<input type="number" id="price" name="price" placeholder="e.g., 1200" class="w-full pl-7 pr-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm" min="0">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 class="text-md font-medium text-gray-800 mb-2">Availability Date Range</h3>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label for="availability-start-date" class="block text-xs font-medium text-gray-700 mb-1">Start Date</label>
|
||||
<input type="date" id="availability-start-date" name="availability-start-date" class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label for="availability-end-date" class="block text-xs font-medium text-gray-700 mb-1">End Date</label>
|
||||
<input type="date" id="availability-end-date" name="availability-end-date" class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<h3 class="text-md font-medium text-gray-800 mb-2">Weekly Availability & Hours</h3>
|
||||
<div class="space-y-3">
|
||||
{% assign days = "Monday,Tuesday,Wednesday,Thursday,Friday,Saturday,Sunday" | split: "," %}
|
||||
{% for day in days %}
|
||||
<div class="p-3 border border-gray-200 rounded-lg bg-gray-50">
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="available-{{ day | downcase }}" class="flex items-center cursor-pointer">
|
||||
<input type="checkbox" id="available-{{ day | downcase }}" name="available_days[]" value="{{ day }}" class="h-4 w-4 text-indigo-600 border-gray-300 rounded focus:ring-indigo-500" onchange="toggleTimeSelection('{{ day | downcase }}')">
|
||||
<span class="ml-2 text-sm font-medium text-gray-700">{{ day }}</span>
|
||||
</label>
|
||||
</div>
|
||||
<div id="time-selection-{{ day | downcase }}" class="mt-3 grid grid-cols-1 sm:grid-cols-2 gap-x-4 gap-y-2 hidden">
|
||||
<div>
|
||||
<label for="start-time-{{ day | downcase }}" class="block text-xs font-medium text-gray-600">Open</label>
|
||||
<input type="time" id="start-time-{{ day | downcase }}" name="start_time_{{ day | downcase }}" class="w-full mt-1 px-2 py-1.5 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label for="end-time-{{ day | downcase }}" class="block text-xs font-medium text-gray-600">Close</label>
|
||||
<input type="time" id="end-time-{{ day | downcase }}" name="end_time_{{ day | downcase }}" class="w-full mt-1 px-2 py-1.5 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-1 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-8 flex justify-between">
|
||||
<button type="button" class="prev-step-btn bg-gray-200 hover:bg-gray-300 text-gray-700 font-semibold py-2 px-6 rounded-lg shadow-md focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-opacity-50 transition-colors">
|
||||
<span aria-hidden="true">←</span> Previous
|
||||
</button>
|
||||
<button type="button" class="next-step-btn bg-indigo-700 hover:bg-indigo-800 text-white font-semibold py-2 px-6 rounded-lg shadow-md focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:ring-opacity-50 transition-colors">
|
||||
Next <span aria-hidden="true">→</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Step 4: Contact Information -->
|
||||
<div id="step-4" class="form-step hidden">
|
||||
<h2 class="text-xl sm:text-2xl font-semibold text-indigo-700 mb-6">Step 4: Contact Information</h2>
|
||||
<div class="space-y-5">
|
||||
<div>
|
||||
<label for="space-name" class="block text-sm font-medium text-gray-700 mb-1">Coworking Space Name</label>
|
||||
<input type="text" id="space-name" name="space_name" placeholder="e.g., The Productive Corner" class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label for="contact-first-name" class="block text-sm font-medium text-gray-700 mb-1">Contact Person - First Name</label>
|
||||
<input type="text" id="contact-first-name" name="contact_first_name" placeholder="John" class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label for="contact-last-name" class="block text-sm font-medium text-gray-700 mb-1">Contact Person - Last Name</label>
|
||||
<input type="text" id="contact-last-name" name="contact_last_name" placeholder="Doe" class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label for="contact-number" class="block text-sm font-medium text-gray-700 mb-1">Contact Number</label>
|
||||
<input type="tel" id="contact-number" name="contact_number" placeholder="e.g., 09171234567 or +639171234567" class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
<div>
|
||||
<label for="contact-email" class="block text-sm font-medium text-gray-700 mb-1">Email Address</label>
|
||||
<input type="email" id="contact-email" name="contact_email" placeholder="you@example.com" class="w-full px-3 py-2 border border-gray-300 rounded-lg shadow-sm focus:outline-none focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 sm:text-sm">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-8 flex justify-between items-center">
|
||||
<button type="button" class="prev-step-btn bg-gray-200 hover:bg-gray-300 text-gray-700 font-semibold py-2 px-6 rounded-lg shadow-md focus:outline-none focus:ring-2 focus:ring-gray-400 focus:ring-opacity-50 transition-colors">
|
||||
<span aria-hidden="true">←</span> Previous
|
||||
</button>
|
||||
<button type="submit" class="bg-green-500 hover:bg-green-600 text-white font-bold py-2 px-6 rounded-lg shadow-md focus:outline-none focus:ring-2 focus:ring-green-400 focus:ring-opacity-50 transition-colors text-lg">
|
||||
Submit Listing
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.form-step {
|
||||
/* hidden by default, JS will manage visibility */
|
||||
}
|
||||
.active-step {
|
||||
display: block !important;
|
||||
}
|
||||
.step-indicator.active-step p {
|
||||
color: #4338ca; /* indigo-700 */
|
||||
font-weight: 600; /* semibold */
|
||||
}
|
||||
.step-indicator .bg-indigo-700 {
|
||||
/* Active indicator circle */
|
||||
}
|
||||
.step-indicator .bg-gray-300 {
|
||||
/* Inactive indicator circle */
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
const steps = document.querySelectorAll('.form-step');
|
||||
const stepIndicators = document.querySelectorAll('.step-indicator');
|
||||
let currentStep = 0;
|
||||
|
||||
function showStep(stepIndex) {
|
||||
steps.forEach((step, index) => {
|
||||
step.classList.toggle('active-step', index === stepIndex);
|
||||
step.classList.toggle('hidden', index !== stepIndex);
|
||||
});
|
||||
updateStepIndicators(stepIndex);
|
||||
window.scrollTo(0, 0); // Scroll to top when step changes
|
||||
}
|
||||
|
||||
function updateStepIndicators(activeIndex) {
|
||||
stepIndicators.forEach((indicator, index) => {
|
||||
const circle = indicator.querySelector('div:first-child'); // The numbered circle
|
||||
const text = indicator.querySelector('p'); // The text label
|
||||
|
||||
if (index === activeIndex) {
|
||||
circle.classList.remove('bg-gray-300');
|
||||
circle.classList.add('bg-indigo-700', 'text-white');
|
||||
text.classList.remove('text-gray-500');
|
||||
text.classList.add('text-indigo-700', 'font-semibold');
|
||||
} else if (index < activeIndex) { // Completed steps
|
||||
circle.classList.remove('bg-gray-300');
|
||||
circle.classList.add('bg-indigo-700', 'text-white'); // Mark as completed
|
||||
text.classList.remove('text-gray-500', 'text-indigo-700', 'font-semibold');
|
||||
text.classList.add('text-gray-700'); // Neutral color for completed text
|
||||
} else { // Future steps
|
||||
circle.classList.remove('bg-indigo-700', 'text-white');
|
||||
circle.classList.add('bg-gray-300');
|
||||
text.classList.remove('text-indigo-700', 'font-semibold');
|
||||
text.classList.add('text-gray-500');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
document.querySelectorAll('.next-step-btn').forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
// Add validation logic here if needed before proceeding
|
||||
if (currentStep < steps.length - 1) {
|
||||
currentStep++;
|
||||
showStep(currentStep);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
document.querySelectorAll('.prev-step-btn').forEach(button => {
|
||||
button.addEventListener('click', () => {
|
||||
if (currentStep > 0) {
|
||||
currentStep--;
|
||||
showStep(currentStep);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Location Search Dropdown Logic
|
||||
const locationInput = document.getElementById('location-search');
|
||||
const locationDropdown = document.getElementById('location-dropdown');
|
||||
const selectedLocationInput = document.getElementById('selected-location');
|
||||
const noResultsP = locationDropdown.querySelector('.no-results');
|
||||
const allLocationItems = Array.from(locationDropdown.querySelectorAll('a.location-item'));
|
||||
|
||||
if (locationInput) {
|
||||
locationInput.addEventListener('keyup', function() {
|
||||
const filter = locationInput.value.toLowerCase();
|
||||
let hasVisibleItems = false;
|
||||
allLocationItems.forEach(item => {
|
||||
const text = item.textContent.toLowerCase();
|
||||
if (text.includes(filter)) {
|
||||
item.style.display = '';
|
||||
hasVisibleItems = true;
|
||||
} else {
|
||||
item.style.display = 'none';
|
||||
}
|
||||
});
|
||||
noResultsP.classList.toggle('hidden', hasVisibleItems);
|
||||
locationDropdown.classList.toggle('hidden', !filter && !locationInput.matches(':focus'));
|
||||
if (filter && locationInput.matches(':focus')) {
|
||||
locationDropdown.classList.remove('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
allLocationItems.forEach(item => {
|
||||
item.addEventListener('click', function(event) {
|
||||
event.preventDefault();
|
||||
locationInput.value = this.dataset.value; // Use data-value for cleaner text
|
||||
selectedLocationInput.value = this.dataset.value;
|
||||
locationDropdown.classList.add('hidden');
|
||||
});
|
||||
});
|
||||
|
||||
locationInput.addEventListener('focus', () => {
|
||||
if(locationInput.value || allLocationItems.some(item => item.style.display !== 'none')) {
|
||||
locationDropdown.classList.remove('hidden');
|
||||
}
|
||||
});
|
||||
|
||||
document.addEventListener('click', function(event) {
|
||||
if (!locationInput.contains(event.target) && !locationDropdown.contains(event.target)) {
|
||||
locationDropdown.classList.add('hidden');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Availability: Toggle time selection based on day checkbox
|
||||
window.toggleTimeSelection = function(day) {
|
||||
const checkbox = document.getElementById(`available-${day}`);
|
||||
const timeSelectionDiv = document.getElementById(`time-selection-${day}`);
|
||||
const startTimeInput = document.getElementById(`start-time-${day}`);
|
||||
const endTimeInput = document.getElementById(`end-time-${day}`);
|
||||
|
||||
if (checkbox.checked) {
|
||||
timeSelectionDiv.classList.remove('hidden');
|
||||
} else {
|
||||
timeSelectionDiv.classList.add('hidden');
|
||||
// Optionally clear or disable time inputs when unchecked
|
||||
if(startTimeInput) startTimeInput.value = '';
|
||||
if(endTimeInput) endTimeInput.value = '';
|
||||
}
|
||||
}
|
||||
|
||||
// Form submission
|
||||
const newListingForm = document.getElementById('new-listing-form');
|
||||
if (newListingForm) {
|
||||
newListingForm.addEventListener('submit', function(event) {
|
||||
event.preventDefault();
|
||||
// Basic validation example: Check if title is filled
|
||||
const titleInput = document.getElementById('title');
|
||||
if (titleInput && titleInput.value.trim() === '') {
|
||||
alert('Please enter a title for your listing.');
|
||||
// Potentially switch to the step with the error
|
||||
// showStep(0); // Assuming title is on step 0
|
||||
titleInput.focus();
|
||||
return;
|
||||
}
|
||||
|
||||
// Add more validation as needed for other fields
|
||||
|
||||
alert('Listing Submitted! (This is a demo and data is not saved.)');
|
||||
// For a real submission:
|
||||
// const formData = new FormData(this);
|
||||
// fetch('/your-submit-endpoint', { method: 'POST', body: formData })
|
||||
// .then(response => response.json())
|
||||
// .then(data => console.log(data))
|
||||
// .catch(error => console.error('Error:', error));
|
||||
// this.reset(); // Optionally reset the form
|
||||
// showStep(0); // Go back to the first step
|
||||
});
|
||||
}
|
||||
showStep(currentStep); // Initialize the first step visibility
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
layout: simple
|
||||
permalink: /submit/
|
||||
---
|
||||
|
||||
{% include post.liquid %}
|
||||
Reference in new issue
Block a user