This commit is contained in:
@ -317,26 +317,63 @@ export async function getMyRentListings() {
|
|||||||
return apiFetch("/RentProperties/GetMyRentListings");
|
return apiFetch("/RentProperties/GetMyRentListings");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function normalizeLocationValue(value) {
|
||||||
|
if (value === null || value === undefined || value === "") return "";
|
||||||
|
|
||||||
|
const normalizedValue = String(value).trim();
|
||||||
|
const map = {
|
||||||
|
"دمشق": "Damascus",
|
||||||
|
"حلب": "Aleppo",
|
||||||
|
"حمص": "Homs",
|
||||||
|
"اللاذقية": "Latakia",
|
||||||
|
"درعا": "Daraa",
|
||||||
|
"طرطوس": "Tartous",
|
||||||
|
"السويداء": "Suweida",
|
||||||
|
"دير الزور": "DeirEzzor",
|
||||||
|
"الرقة": "Raqqa",
|
||||||
|
"إدلب": "Idlib",
|
||||||
|
"الحسكة": "Hasakah",
|
||||||
|
"القامشلي": "Qamishli",
|
||||||
|
"ريف دمشق": "RuralDamascus",
|
||||||
|
Damascus: "Damascus",
|
||||||
|
Aleppo: "Aleppo",
|
||||||
|
Homs: "Homs",
|
||||||
|
Latakia: "Latakia",
|
||||||
|
Daraa: "Daraa",
|
||||||
|
Tartous: "Tartous",
|
||||||
|
Sweida: "Suweida",
|
||||||
|
DeirEzzor: "DeirEzzor",
|
||||||
|
Raqqa: "Raqqa",
|
||||||
|
Idlib: "Idlib",
|
||||||
|
Hasakah: "Hasakah",
|
||||||
|
Qamishli: "Qamishli",
|
||||||
|
RuralDamascus: "RuralDamascus",
|
||||||
|
};
|
||||||
|
|
||||||
|
return map[normalizedValue] ?? normalizedValue;
|
||||||
|
}
|
||||||
|
|
||||||
export function buildRentPropertyPayload(data = {}) {
|
export function buildRentPropertyPayload(data = {}) {
|
||||||
const propertyInformation = data?.propertyInformation || {};
|
const propertyInformation = data?.propertyInformation || {};
|
||||||
const cityValue =
|
const rawCityValue =
|
||||||
data?.city ??
|
data?.city ??
|
||||||
data?.governorate ??
|
data?.governorate ??
|
||||||
propertyInformation?.city ??
|
propertyInformation?.city ??
|
||||||
propertyInformation?.governorate ??
|
propertyInformation?.governorate ??
|
||||||
"";
|
"";
|
||||||
|
const normalizedCityValue = normalizeLocationValue(rawCityValue);
|
||||||
const documentTypeValue =
|
const documentTypeValue =
|
||||||
data?.documentType ?? propertyInformation?.documentType ?? "";
|
data?.documentType ?? propertyInformation?.documentType ?? "";
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...data,
|
...data,
|
||||||
city: cityValue,
|
city: normalizedCityValue,
|
||||||
governorate: cityValue,
|
governorate: normalizedCityValue,
|
||||||
documentType: documentTypeValue,
|
documentType: documentTypeValue,
|
||||||
propertyInformation: {
|
propertyInformation: {
|
||||||
...propertyInformation,
|
...propertyInformation,
|
||||||
city: cityValue,
|
city: normalizedCityValue,
|
||||||
governorate: propertyInformation?.governorate ?? cityValue,
|
governorate: normalizeLocationValue(propertyInformation?.governorate ?? normalizedCityValue),
|
||||||
documentType: documentTypeValue,
|
documentType: documentTypeValue,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -345,14 +382,14 @@ export function buildRentPropertyPayload(data = {}) {
|
|||||||
export async function addRentProperty(data) {
|
export async function addRentProperty(data) {
|
||||||
return apiFetch("/RentProperties/AddRentProperty", {
|
return apiFetch("/RentProperties/AddRentProperty", {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
body: buildRentPropertyPayload(data),
|
body: { rentPropertyDto: buildRentPropertyPayload(data) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function editRentProperty(id, data) {
|
export async function editRentProperty(id, data) {
|
||||||
return apiFetch(`/RentProperties/EditRentProperty/${id}`, {
|
return apiFetch(`/RentProperties/EditRentProperty/${id}`, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
body: data,
|
body: { rentPropertyDto: buildRentPropertyPayload(data) },
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user