forked from amer2004/SweetHome
Added api for add property
This commit is contained in:
@ -52,7 +52,7 @@ import {
|
||||
Trees
|
||||
} from 'lucide-react';
|
||||
import toast, { Toaster } from 'react-hot-toast';
|
||||
import { addRentProperty, addSaleProperty, getCurrencies, uploadPicture } from '../../../utils/api';
|
||||
import { addRentProperty, addSaleProperty, buildRentPropertyPayload, getCurrencies, uploadPicture } from '../../../utils/api';
|
||||
import {
|
||||
BuildingType,
|
||||
RentPropertyCondition,
|
||||
@ -683,6 +683,7 @@ const handleMarkerDragEnd = async (lat, lng) => {
|
||||
propertyType: formData.furnished ? RentPropertyCondition.WITH_FURNITURE : RentPropertyCondition.WITHOUT_FURNITURE,
|
||||
documentType: formData.documentType,
|
||||
governorate: formData.city,
|
||||
city: formData.city,
|
||||
};
|
||||
|
||||
try {
|
||||
@ -696,8 +697,11 @@ const handleMarkerDragEnd = async (lat, lng) => {
|
||||
toast.success(t('toast.salePropertySuccess'));
|
||||
} else {
|
||||
const rentTypeMap = { daily: RentType.DAILY, monthly: RentType.MONTHLY, both: RentType.MONTHLY };
|
||||
const payload = {
|
||||
const payload = buildRentPropertyPayload({
|
||||
propertyInformation: propInfo,
|
||||
city: formData.city,
|
||||
governorate: formData.city,
|
||||
documentType: formData.documentType,
|
||||
deposit: parseFloat(formData.deposit) || 0,
|
||||
monthlyRent: parseFloat(formData.monthlyPrice) || 0,
|
||||
dailyRent: parseFloat(formData.dailyPrice) || 0,
|
||||
@ -706,7 +710,7 @@ const handleMarkerDragEnd = async (lat, lng) => {
|
||||
rentType: rentTypeMap[formData.offerType] ?? RentType.MONTHLY,
|
||||
type: formData.furnished ? RentPropertyType.FURNISHED : RentPropertyType.UNFURNISHED,
|
||||
allowedPaymentPeriod: formData.allowedPaymentPeriod || '',
|
||||
};
|
||||
});
|
||||
const res = await addRentProperty(payload);
|
||||
toast.success(t('toast.rentPropertySuccess'));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user