the best in the west is mouaz
All checks were successful
Build frontend / build (push) Successful in 55s

This commit is contained in:
mouazkh
2026-05-25 21:27:39 +03:00
parent a5577765ed
commit 00ccf5f262
35 changed files with 4876 additions and 2433 deletions

View File

@ -664,6 +664,31 @@ export async function addRentProperty(data) {
});
}
export async function editRentProperty(id, data) {
console.log('[API] Editing rent property:', id, data.PropertyInformation?.Address);
return apiFetch(`/RentProperties/EditRentProperty/${id}`, {
method: 'PUT',
body: JSON.stringify(data),
});
}
export async function addSaleProperty(data) {
console.log('[API] Adding sale property');
return apiFetch('/SaleProperties/AddSaleProperty', {
method: 'POST',
body: JSON.stringify(data),
});
}
export async function getMySaleListings() {
console.log('[API] Fetching my sale listings');
return apiFetch('/SaleProperties/GetMySaleListings');
}
export async function getSalePropertyById(id) {
return apiFetch(`/SaleProperties/${id}`);
}
// ─── Currencies ───
export async function getCurrencies() {
@ -920,4 +945,160 @@ export async function updateBookingStatus(bookingId, status) {
method: 'PUT',
body: JSON.stringify({ bookingId, status }),
});
}
// ─── Owner / Reservations ───
export async function getOwnerReservationRequests() {
return apiFetch('/Reservations/GetOwnerResevationRequests');
}
export async function getOwnerReservationsByStatuses(filterStatuses) {
return apiFetch('/Reservations/GetAllReservationsByStateForOwner', {
method: 'POST',
body: JSON.stringify({ filterStatuses }),
});
}
export async function getUserReservations() {
return apiFetch('/Reservations/GetUserResevations');
}
export async function ownerConfirmReservation(id) {
return apiFetch(`/Reservations/OwnerConfirmReservation/owner-confirm/${id}`, {
method: 'PUT',
});
}
// ─── Payments ───
export async function payDeposit(data) {
return apiFetch('/Reservations/PayDeposit/pay-deposit', {
method: 'POST',
body: JSON.stringify(data),
});
}
// ─── Owner Contact & Stats ───
export async function getOwnerContactInformation(propertyInformationId) {
return apiFetch(`/Owner/GetOwnerContactInformation?propertyInformationId=${propertyInformationId}`);
}
export async function getOwnerStatistics() {
return apiFetch('/Statistics/GetOwnerStatistics');
}
// ─── Agent Registration ───
export async function registerRealEstateAgent(formData) {
console.log('[API] Registering real estate agent (multipart)');
const token = AuthService.getToken();
const res = await fetch(`${API_BASE}/RealEstateAgent/Add`, {
method: 'POST',
headers: { ...(token && { Authorization: `Bearer ${token}` }) },
body: formData,
});
const text = await res.text();
let data = null;
try { data = text ? JSON.parse(text) : null; if (data && typeof data === 'object' && 'data' in data) data = data.data; } catch { data = text; }
return { status: res.status, data, ok: res.ok || res.status === 206, message: data?.message };
}
// ─── Change Password ───
export async function changePassword(oldPassword, newPassword) {
return apiFetch(`/User/ChangePassword?oldPassword=${encodeURIComponent(oldPassword)}&newPassword=${encodeURIComponent(newPassword)}`, {
method: 'PUT',
});
}
// ─── Forget Password (OTP flow) ───
export async function requestForgetPasswordOtp(email) {
return apiFetch(`/User/ForgetPassword?email=${encodeURIComponent(email)}`, { method: 'POST' });
}
export async function verifyForgetPasswordOtp(email, code, newPassword) {
return apiFetch(`/User/VerifyForgetPasswordOTP?email=${encodeURIComponent(email)}&code=${encodeURIComponent(code)}&newPassword=${encodeURIComponent(newPassword)}`, {
method: 'POST',
});
}
// ─── Reset Password (token flow) ───
export async function resetPassword(token) {
return apiFetch(`/Auth/ResetPassword?token=${encodeURIComponent(token)}`);
}
// ─── Delete Account ───
export async function deleteMyAccount(password) {
return apiFetch(`/User/DeleteMyAccount?password=${encodeURIComponent(password)}`, {
method: 'DELETE',
});
}
// ─── Set FCM Token ───
export async function setFCMToken(token, deviceType = 2) {
return apiFetch('/User/SetFCMToken', {
method: 'POST',
body: JSON.stringify({ token, deviceType }),
});
}
// ─── Filter Rent Properties ───
export async function filterRentProperties(params = {}) {
const qs = new URLSearchParams();
Object.entries(params).forEach(([k, v]) => { if (v != null && v !== '') qs.set(k, v); });
const query = qs.toString();
return apiFetch(`/RentProperties/FilterRentProperties${query ? `?${query}` : ''}`);
}
// ─── Reports ───
export async function submitReport(subject, body) {
return apiFetch('/Reports', {
method: 'POST',
body: JSON.stringify({ subject, body }),
});
}
export async function submitReservationReport(data) {
return apiFetch('/ReservationReports', {
method: 'POST',
body: JSON.stringify(data),
});
}
export async function updateReservationReport(id, data) {
return apiFetch(`/ReservationReports/${id}`, {
method: 'PUT',
body: JSON.stringify(data),
});
}
export async function submitSaleReport(data) {
return apiFetch('/SaleReports', {
method: 'POST',
body: JSON.stringify(data),
});
}
export async function updateSaleReport(id, data) {
return apiFetch(`/SaleReports/${id}`, {
method: 'PUT',
body: JSON.stringify(data),
});
}
// ─── Terms (Add) ───
export async function addTerm(name, description) {
return apiFetch('/Terms', {
method: 'POST',
body: JSON.stringify({ name, description }),
});
}