From e1c3a826724a5acdcf62da63da42dca3cbe59a37 Mon Sep 17 00:00:00 2001 From: "open-swe-dev-andrinoid[bot]" Date: Thu, 22 Jan 2026 01:38:37 +0000 Subject: [PATCH] Apply patch [skip ci] --- islands/dialogs/PopAddLeaseDialog.tsx | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/islands/dialogs/PopAddLeaseDialog.tsx b/islands/dialogs/PopAddLeaseDialog.tsx index 437f9a5..5decad7 100644 --- a/islands/dialogs/PopAddLeaseDialog.tsx +++ b/islands/dialogs/PopAddLeaseDialog.tsx @@ -11,6 +11,7 @@ export function PopAddLeaseDialog(leases: Lease[], properties: Property[]) { } | null >(null); const [selectedPropertyId, setSelectedPropertyId] = useState(""); + const [showPropertySelection, setShowPropertySelection] = useState(false); function getPropertyInfo(propertyId: string) { const property = properties.find((p) => p.id === propertyId); @@ -26,17 +27,22 @@ export function PopAddLeaseDialog(leases: Lease[], properties: Property[]) { // Show the popup and return a Promise for the answer const popAddLease = ( propertyId?: string, - popupKey: number, + popupKey?: number, ): Promise => { return new Promise((resolve) => { - setPopup({ propertyId, popupKey, resolve }); + if (propertyId) { + setPopup({ propertyId, popupKey: popupKey || 0, resolve }); + } else { + setShowPropertySelection(true); + setPopup({ propertyId: null, popupKey: popupKey || 0, resolve }); + } }); }; // Render the popup if needed - const popupAddLeaseDialog = popup + const popupAddLeaseDialog = popup && popup.propertyId ? (() => { - const { title, address, price } = getPropertyInfo(popup.propertyId || ""); + const { title, address, price } = getPropertyInfo(popup.propertyId); return ( { popup.resolve(false); setPopup(null); + setShowPropertySelection(false); + setSelectedPropertyId(""); }} /> ); @@ -55,7 +63,7 @@ export function PopAddLeaseDialog(leases: Lease[], properties: Property[]) { : null; // Render property selection dialog if no propertyId provided - const propertySelectionDialog = popup && !popup.propertyId + const propertySelectionDialog = showPropertySelection ? (() => { return (
@@ -78,8 +86,10 @@ export function PopAddLeaseDialog(leases: Lease[], properties: Property[]) { type="button" class="px-4 py-2 rounded border" onClick={() => { - popup.resolve(false); + if (popup) popup.resolve(false); setPopup(null); + setShowPropertySelection(false); + setSelectedPropertyId(""); }} > Cancel @@ -89,7 +99,8 @@ export function PopAddLeaseDialog(leases: Lease[], properties: Property[]) { class="px-4 py-2 rounded bg-blue-600 text-white" disabled={!selectedPropertyId} onClick={() => { - setPopup({ ...popup, propertyId: selectedPropertyId }); + setPopup({ ...popup!, propertyId: selectedPropertyId }); + setShowPropertySelection(false); }} > Continue @@ -103,5 +114,3 @@ export function PopAddLeaseDialog(leases: Lease[], properties: Property[]) { return [popAddLease, popupAddLeaseDialog || propertySelectionDialog] as const; } - -