perbaikan fetch villa
This commit is contained in:
@@ -145,6 +145,9 @@
|
||||
|
||||
function goToPage(page: number) {
|
||||
if (page >= 1 && page <= totalPages) currentPage = page;
|
||||
offset = (currentPage - 1) * rowsPerPage;
|
||||
fetchVillas(null, "created_at", "desc", rowsPerPage, offset);
|
||||
console.log(`Fetching page ${currentPage} with offset ${offset}`);
|
||||
}
|
||||
|
||||
// Modal Logic
|
||||
@@ -173,27 +176,27 @@
|
||||
const errors: { [key: string]: string } = {};
|
||||
const requiredFields = [
|
||||
"villa_name",
|
||||
// "villa_manager",
|
||||
// "villa_location",
|
||||
// "villa_manager",
|
||||
// "villa_location",
|
||||
"villa_status",
|
||||
"no_of_bedrooms",
|
||||
// "villa_condition",
|
||||
// "season_1_rate",
|
||||
// "season_2_rate",
|
||||
// "season_3_rate",
|
||||
// "season_4_rate",
|
||||
// "season_5_rate",
|
||||
// "season_6_rate",
|
||||
// "season_7_rate",
|
||||
// "villa_email_address",
|
||||
// "owner_portal_username",
|
||||
// "owner_portal_password",
|
||||
// "closeable_living_room",
|
||||
// "monthly_rental_pre_approved_status",
|
||||
// "long_term_rental_pre_approval",
|
||||
// "pet_allowed_pre_approval_status",
|
||||
// "villa_recovery_email_adress",
|
||||
// "villa_email_address",
|
||||
// "villa_condition",
|
||||
// "season_1_rate",
|
||||
// "season_2_rate",
|
||||
// "season_3_rate",
|
||||
// "season_4_rate",
|
||||
// "season_5_rate",
|
||||
// "season_6_rate",
|
||||
// "season_7_rate",
|
||||
// "villa_email_address",
|
||||
// "owner_portal_username",
|
||||
// "owner_portal_password",
|
||||
// "closeable_living_room",
|
||||
// "monthly_rental_pre_approved_status",
|
||||
// "long_term_rental_pre_approval",
|
||||
// "pet_allowed_pre_approval_status",
|
||||
// "villa_recovery_email_adress",
|
||||
// "villa_email_address",
|
||||
];
|
||||
requiredFields.forEach((field) => {
|
||||
if (!formData.get(field) || formData.get(field) === "") {
|
||||
@@ -229,7 +232,9 @@
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
const { error } = await supabase.from("vb_villas").insert([newVilla]);
|
||||
const { error } = await supabase
|
||||
.from("vb_villas")
|
||||
.insert([newVilla]);
|
||||
if (error) {
|
||||
alert("Error adding villa: " + error.message);
|
||||
return;
|
||||
@@ -410,9 +415,10 @@
|
||||
<option value="" disabled
|
||||
>SELECT STATUS</option
|
||||
>
|
||||
<option value="Active">ACTIVE</option
|
||||
<option value="Active">ACTIVE</option>
|
||||
<option value="Inactive"
|
||||
>INACTIVE</option
|
||||
>
|
||||
<option value="Inactive">INACTIVE</option>
|
||||
</select>
|
||||
</td>
|
||||
{:else if col.key === "villa_condition"}
|
||||
@@ -433,10 +439,18 @@
|
||||
<option value="" disabled
|
||||
>SELECT CONDITION</option
|
||||
>
|
||||
<option value="Occupied">Occupied</option>
|
||||
<option value="Vacant clean">Vacant clean</option>
|
||||
<option value="Vacant dirty">Vacant Dirty</option>
|
||||
<option value="Ready for Inspection">Ready for Inspection</option>
|
||||
<option value="Occupied"
|
||||
>Occupied</option
|
||||
>
|
||||
<option value="Vacant clean"
|
||||
>Vacant clean</option
|
||||
>
|
||||
<option value="Vacant dirty"
|
||||
>Vacant Dirty</option
|
||||
>
|
||||
<option value="Ready for Inspection"
|
||||
>Ready for Inspection</option
|
||||
>
|
||||
</select>
|
||||
</td>
|
||||
{:else if col.key === "villa_manager"}
|
||||
@@ -591,19 +605,19 @@
|
||||
<div class="space-y-1">
|
||||
<label class="block text-sm font-medium text-gray-700"
|
||||
>{col.title}
|
||||
<select
|
||||
name={col.key}
|
||||
class="w-full border px-3 py-2 rounded {errorClass(
|
||||
col.key,
|
||||
)}"
|
||||
bind:value={newVilla[col.key]}
|
||||
>
|
||||
<option value="" disabled selected
|
||||
>SELECT STATUS</option
|
||||
<select
|
||||
name={col.key}
|
||||
class="w-full border px-3 py-2 rounded {errorClass(
|
||||
col.key,
|
||||
)}"
|
||||
bind:value={newVilla[col.key]}
|
||||
>
|
||||
<option value="available">ACTIVE</option>
|
||||
<option value="rented">INACTIVE</option>
|
||||
</select>
|
||||
<option value="" disabled selected
|
||||
>SELECT STATUS</option
|
||||
>
|
||||
<option value="available">ACTIVE</option>
|
||||
<option value="rented">INACTIVE</option>
|
||||
</select>
|
||||
</label>
|
||||
</div>
|
||||
{#if $formErrors.villa_status}
|
||||
|
||||
Reference in New Issue
Block a user