Apply patch [skip ci]

This commit is contained in:
open-swe-dev-andrinoid[bot] 2026-01-22 01:38:37 +00:00
parent 34c04a4ef4
commit e1c3a82672

View File

@ -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<boolean> => {
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 (
<AddLeaseDialog
leases={leases}
@ -48,6 +54,8 @@ export function PopAddLeaseDialog(leases: Lease[], properties: Property[]) {
onClose={() => {
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 (
<div class="fixed inset-0 flex items-center justify-center bg-black bg-opacity-30 z-50">
@ -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;
}