Files
NexHome/templates/properties/edit.html
T
2026-06-11 15:05:08 +08:00

177 lines
9.2 KiB
HTML

{% extends "base.html" %}
{% block title %}Edit Listing - NexHome{% endblock %}
{% block content %}
<div class="max-w-3xl mx-auto px-4 py-10">
<h1 class="text-3xl font-bold text-primary mb-2">Edit Property</h1>
<p class="text-gray-500 mb-8">Update the details of your listing.</p>
{% if error %}
<div class="bg-red-100 border border-red-200 text-red-800 rounded-lg p-4 mb-6 text-sm">
{{ error }}
</div>
{% endif %}
<form method="POST" action="/properties/{{ prop.id }}/edit" enctype="multipart/form-data" class="bg-white rounded-2xl shadow-lg p-8 space-y-6">
<!-- Title -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Property Title *</label>
<input type="text" name="title" required
value="{{ prop.title }}"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
</div>
<!-- Description -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Description *</label>
<textarea name="description" required rows="5"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">{{ prop.description }}</textarea>
</div>
<!-- Price & Type -->
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Price (USD) *</label>
<div class="relative">
<span class="absolute left-3 top-3 text-gray-500 font-medium">$</span>
<input type="number" name="price" required min="0"
value="{{ prop.price }}"
class="w-full pl-8 pr-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
</div>
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Property Type *</label>
<select name="property_type" required
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
<option value="house" {% if prop.property_type == 'house' %}selected{% endif %}>House</option>
<option value="condo" {% if prop.property_type == 'condo' %}selected{% endif %}>Condo</option>
<option value="townhouse" {% if prop.property_type == 'townhouse' %}selected{% endif %}>Townhouse</option>
<option value="land" {% if prop.property_type == 'land' %}selected{% endif %}>Land</option>
</select>
</div>
</div>
<!-- Beds / Baths / Sqft -->
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Bedrooms *</label>
<input type="number" name="bedrooms" required min="0" max="20"
value="{{ prop.bedrooms }}"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Bathrooms *</label>
<input type="number" name="bathrooms" required min="0" max="20" step="0.5"
value="{{ prop.bathrooms }}"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Area (sqft) *</label>
<input type="number" name="area_sqft" required min="0"
value="{{ prop.area_sqft }}"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
</div>
</div>
<!-- Address -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Street Address *</label>
<input type="text" name="address" required
value="{{ prop.address }}"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
</div>
<!-- City / State / Zip -->
<div class="grid grid-cols-1 sm:grid-cols-3 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">City *</label>
<input type="text" name="city" required
value="{{ prop.city }}"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">State *</label>
<input type="text" name="state" required maxlength="2"
value="{{ prop.state }}"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Zip Code *</label>
<input type="text" name="zip_code" required maxlength="10"
value="{{ prop.zip_code }}"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
</div>
</div>
<!-- Year Built & Status -->
<div class="grid grid-cols-1 sm:grid-cols-2 gap-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Year Built</label>
<input type="number" name="year_built" min="1800" max="2030"
value="{{ prop.year_built or '' }}"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
</div>
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Status</label>
<select name="status"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
<option value="active" {% if prop.status == 'active' %}selected{% endif %}>Active</option>
<option value="pending" {% if prop.status == 'pending' %}selected{% endif %}>Pending</option>
<option value="sold" {% if prop.status == 'sold' %}selected{% endif %}>Sold</option>
</select>
</div>
</div>
<!-- Contact Info -->
<div class="border-t pt-6">
<h3 class="text-lg font-semibold text-primary mb-4">Contact Information</h3>
<p class="text-sm text-gray-500 mb-4">Provide at least one contact method (email or phone).</p>
<div class="space-y-4">
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Contact Email</label>
<input type="email" name="contact_email"
value="{{ prop.contact_email or '' }}"
placeholder="seller@example.com"
class="w-full px-4 py-3 border border-gray-300 rounded-lg focus:ring-2 focus:ring-accent outline-none transition">
</div>
<div class="relative">
{% set phone_value = prop.contact_phone or "" %}
{% include "components/phone_input.html" %}
</div>
</div>
</div>
<!-- Current Image -->
{% if primary_image %}
<div>
<label class="block text-sm font-medium text-gray-700 mb-2">Current Image</label>
<img src="/static/{{ primary_image.image_path }}" alt="Current"
class="h-40 w-56 object-cover rounded-lg border">
</div>
{% endif %}
<!-- New Image Upload -->
<div>
<label class="block text-sm font-medium text-gray-700 mb-1">Replace Image</label>
<input type="file" name="image" accept="image/*"
class="block 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-accent file:text-white hover:file:bg-blue-700 transition">
<p class="text-xs text-gray-400 mt-1">Leave empty to keep the current image.</p>
</div>
<!-- Submit -->
<div class="flex gap-4 pt-4">
<button type="submit"
class="flex-1 bg-accent hover:bg-blue-700 text-white font-semibold py-3.5 rounded-lg transition">
Save Changes
</button>
<a href="/properties/{{ prop.id }}"
class="px-8 py-3.5 border border-gray-300 text-gray-700 font-medium rounded-lg hover:bg-gray-50 transition">
Cancel
</a>
</div>
</form>
</div>
{% endblock %}