diff --git a/app/utils/api.js b/app/utils/api.js index 083b675..de68de1 100644 --- a/app/utils/api.js +++ b/app/utils/api.js @@ -332,9 +332,44 @@ export async function addRentProperty(data) { } export async function editRentProperty(id, data) { + const pi = data?.propertyInformation || {}; + const images = Array.isArray(pi.images) ? pi.images : []; + + const body = { + propertyInformation: { + activityStatus: 1, + images: images.length > 0 ? images : [""], + cordsX: pi.cordsX ?? null, + cordsY: pi.cordsY ?? null, + address: pi.address ?? "", + description: pi.description ?? null, + numberOfBathRooms: pi.numberOfBathRooms ?? 0, + numberOfRooms: pi.numberOfRooms ?? 0, + numberOfBedRooms: pi.numberOfBedRooms ?? 0, + space: pi.space ?? 0, + detailsJSON: pi.detailsJSON ?? "", + buildingType: pi.buildingType ?? 0, + status: pi.status ?? 0, + propertyType: pi.propertyType ?? 0, + city: data.city ?? pi.city ?? 1, + }, + deposit: data.deposit ?? 0, + acceptedCertificate: data.acceptedCertificate ?? 0, + monthlyRent: data.monthlyRent ?? 0, + dailyRent: data.dailyRent ?? 0, + rating: data.rating ?? 1, + currencyId: data.currencyId ?? 1, + rentType: data.rentType ?? 0, + isSmokeAllow: data.isSmokeAllow ?? false, + specializedFor: data.specializedFor ?? null, + isVisitorAllow: data.isVisitorAllow ?? false, + allowedPaymentPeriod: data.allowedPaymentPeriod ?? "", + type: data.type ?? 0, + }; + return apiFetch(`/RentProperties/EditRentProperty/${id}`, { method: "PUT", - body: { rentPropertyDto: buildRentPropertyPayload(data) }, + body, }); }