editing the add rent property mouaz is the best in the west
All checks were successful
Build frontend / build (push) Successful in 44s
All checks were successful
Build frontend / build (push) Successful in 44s
This commit is contained in:
@ -100,6 +100,10 @@ export default function AddPropertyPage() {
|
|||||||
bedrooms: 1,
|
bedrooms: 1,
|
||||||
bathrooms: 1,
|
bathrooms: 1,
|
||||||
livingRooms: 1,
|
livingRooms: 1,
|
||||||
|
floorNumber: '',
|
||||||
|
salons: '',
|
||||||
|
balconies: '',
|
||||||
|
space: '',
|
||||||
|
|
||||||
services: {
|
services: {
|
||||||
[PropertyService.ELECTRICITY]: false,
|
[PropertyService.ELECTRICITY]: false,
|
||||||
@ -123,6 +127,7 @@ export default function AddPropertyPage() {
|
|||||||
|
|
||||||
dailyPrice: '',
|
dailyPrice: '',
|
||||||
monthlyPrice: '',
|
monthlyPrice: '',
|
||||||
|
deposit: '',
|
||||||
|
|
||||||
city: '',
|
city: '',
|
||||||
district: '',
|
district: '',
|
||||||
@ -132,7 +137,31 @@ export default function AddPropertyPage() {
|
|||||||
|
|
||||||
description: '',
|
description: '',
|
||||||
|
|
||||||
images: []
|
images: [],
|
||||||
|
|
||||||
|
nearbySchool: '',
|
||||||
|
nearbyHospital: '',
|
||||||
|
nearbyRestaurant: '',
|
||||||
|
nearbyUniversity: '',
|
||||||
|
nearbyPark: '',
|
||||||
|
nearbyMall: '',
|
||||||
|
|
||||||
|
roomAreaType: 'Private room',
|
||||||
|
roomPeopleAllowed: '',
|
||||||
|
roomFurniture: '',
|
||||||
|
roomEntrance: 'Shared entrance',
|
||||||
|
roomBathroom: 'Shared',
|
||||||
|
roomKitchen: 'Not available',
|
||||||
|
roomRestrictedAreas: false,
|
||||||
|
roomResidents: '',
|
||||||
|
roomGender: 'Family',
|
||||||
|
roomLanguage: '',
|
||||||
|
roomChildren: false,
|
||||||
|
roomPets: false,
|
||||||
|
roomDedicatedTo: 'Everyone',
|
||||||
|
roomVisitors: true,
|
||||||
|
roomQuietTimes: false,
|
||||||
|
roomQuietTimesDetails: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
const [imagePreviews, setImagePreviews] = useState([]);
|
const [imagePreviews, setImagePreviews] = useState([]);
|
||||||
@ -559,44 +588,63 @@ const handleMapClick = async (coords) => {
|
|||||||
.filter(([, v]) => v)
|
.filter(([, v]) => v)
|
||||||
.map(([k]) => k);
|
.map(([k]) => k);
|
||||||
|
|
||||||
const detailsJSON = JSON.stringify({
|
const details = {
|
||||||
|
description: formData.description || '',
|
||||||
services: selectedServices,
|
services: selectedServices,
|
||||||
serviceDetails: selectedServices.reduce((acc, s) => ({ ...acc, [s]: 'in general' }), {}),
|
serviceDetails: selectedServices.reduce((acc, s) => ({ ...acc, [s]: formData.serviceDetails[s] || 'in general' }), {}),
|
||||||
terms: selectedTerms,
|
terms: selectedTerms.reduce((acc, k) => ({ ...acc, [k]: true }), {}),
|
||||||
displayType: formData.offerType === 'both' ? 'Both' : formData.offerType === 'daily' ? 'Daily' : 'Monthly',
|
displayType: formData.offerType === 'both' ? 'Both' : formData.offerType === 'daily' ? 'Daily' : 'Monthly',
|
||||||
propertyCondition: formData.furnished ? 'Furnished' : 'Unfurnished',
|
propertyCondition: formData.furnished ? 'WithFurniture' : 'WithoutFurniture',
|
||||||
photos: imagePreviews.map((_, i) => `photo_${i}.jpg`),
|
floorNumber: parseInt(formData.floorNumber) || 0,
|
||||||
room: {
|
numberOfSalons: parseInt(formData.salons) || 0,
|
||||||
areaType: formData.propertyType === 'room' ? 'Shared room' : 'Private room',
|
numberOfBalconies: parseInt(formData.balconies) || 0,
|
||||||
peopleAllowed: String(formData.bedrooms),
|
nearbyDistances: {
|
||||||
entranceType: formData.propertyType === 'room' ? 'Shared entrance' : 'Private entrance',
|
school: formData.nearbySchool || '',
|
||||||
bathroomType: formData.bathrooms > 1 ? 'Private' : 'Shared',
|
hospital: formData.nearbyHospital || '',
|
||||||
kitchenType: 'Not available',
|
restaurant: formData.nearbyRestaurant || '',
|
||||||
hasRestrictedOwnerAreas: false,
|
university: formData.nearbyUniversity || '',
|
||||||
languageDialect: '',
|
park: formData.nearbyPark || '',
|
||||||
hasChildren: false,
|
mall: formData.nearbyMall || '',
|
||||||
hasPets: false,
|
},
|
||||||
dedicatedTo: 'Everyone',
|
};
|
||||||
visitorsAllowed: true,
|
|
||||||
quietTimesEnabled: false,
|
if (formData.propertyType === 'room') {
|
||||||
quietTimes: '',
|
details.room = {
|
||||||
}
|
areaType: formData.roomAreaType || 'Private room',
|
||||||
});
|
peopleAllowed: formData.roomPeopleAllowed || String(formData.bedrooms),
|
||||||
|
furnitureDetails: formData.roomFurniture || '',
|
||||||
|
entranceType: formData.roomEntrance || 'Shared entrance',
|
||||||
|
bathroomType: formData.roomBathroom || 'Shared',
|
||||||
|
kitchenType: formData.roomKitchen || 'Not available',
|
||||||
|
hasRestrictedOwnerAreas: formData.roomRestrictedAreas || false,
|
||||||
|
homeResidentsCount: formData.roomResidents || '',
|
||||||
|
currentPopulationGender: formData.roomGender || 'Family',
|
||||||
|
languageDialect: formData.roomLanguage || '',
|
||||||
|
hasChildren: formData.roomChildren || false,
|
||||||
|
hasPets: formData.roomPets || false,
|
||||||
|
dedicatedTo: formData.roomDedicatedTo || 'Everyone',
|
||||||
|
visitorsAllowed: formData.roomVisitors ?? true,
|
||||||
|
quietTimesEnabled: formData.roomQuietTimes ?? false,
|
||||||
|
quietTimes: formData.roomQuietTimesDetails || '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const detailsJSON = JSON.stringify(details);
|
||||||
|
|
||||||
const propInfo = {
|
const propInfo = {
|
||||||
cordsX: formData.lat ? String(formData.lat) : '',
|
cordsX: formData.lat ? String(formData.lat) : '',
|
||||||
cordsY: formData.lng ? String(formData.lng) : '',
|
cordsY: formData.lng ? String(formData.lng) : '',
|
||||||
|
images: uploadedImagePaths,
|
||||||
address: `${formData.city} - ${formData.district} - ${formData.address}`.trim(),
|
address: `${formData.city} - ${formData.district} - ${formData.address}`.trim(),
|
||||||
description: formData.description || '',
|
description: formData.description || '',
|
||||||
numberOfBathRooms: formData.bathrooms || 0,
|
numberOfBathRooms: formData.bathrooms || 0,
|
||||||
numberOfRooms: (formData.bedrooms || 0) + (formData.livingRooms || 0),
|
numberOfRooms: formData.bedrooms || 0,
|
||||||
numberOfBedRooms: formData.bedrooms || 0,
|
numberOfBedRooms: formData.bedrooms || 0,
|
||||||
space: parseFloat(formData.space) || 0,
|
space: parseFloat(formData.space) || 0,
|
||||||
detailsJSON,
|
detailsJSON,
|
||||||
buildingType: buildingTypeMap[formData.propertyType] ?? BuildingType.APARTMENT,
|
buildingType: buildingTypeMap[formData.propertyType] ?? BuildingType.APARTMENT,
|
||||||
status: 0,
|
status: 0,
|
||||||
propertyType: formData.furnished ? RentPropertyCondition.WITH_FURNITURE : RentPropertyCondition.WITHOUT_FURNITURE,
|
propertyType: formData.furnished ? RentPropertyCondition.WITH_FURNITURE : RentPropertyCondition.WITHOUT_FURNITURE,
|
||||||
images: uploadedImagePaths,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
@ -617,13 +665,11 @@ const handleMapClick = async (coords) => {
|
|||||||
deposit: parseFloat(formData.deposit) || 0,
|
deposit: parseFloat(formData.deposit) || 0,
|
||||||
monthlyRent: parseFloat(formData.monthlyPrice) || 0,
|
monthlyRent: parseFloat(formData.monthlyPrice) || 0,
|
||||||
dailyRent: parseFloat(formData.dailyPrice) || 0,
|
dailyRent: parseFloat(formData.dailyPrice) || 0,
|
||||||
rating: 0,
|
rating: 1,
|
||||||
currencyId: selectedCurrencyId,
|
currencyId: selectedCurrencyId,
|
||||||
rentType: rentTypeMap[formData.offerType] ?? RentType.MONTHLY,
|
rentType: rentTypeMap[formData.offerType] ?? RentType.MONTHLY,
|
||||||
isSmokeAllow: !formData.terms[PropertyTerm.NO_SMOKING],
|
|
||||||
specializedFor: false,
|
|
||||||
isVisitorAllow: !formData.terms[PropertyTerm.NO_PARTIES],
|
|
||||||
type: formData.furnished ? RentPropertyType.FURNISHED : RentPropertyType.UNFURNISHED,
|
type: formData.furnished ? RentPropertyType.FURNISHED : RentPropertyType.UNFURNISHED,
|
||||||
|
allowedPaymentPeriod: '01:00:00:00',
|
||||||
};
|
};
|
||||||
console.log('[AddProperty] Rent payload:', JSON.stringify(payload, null, 2));
|
console.log('[AddProperty] Rent payload:', JSON.stringify(payload, null, 2));
|
||||||
const res = await addRentProperty(payload);
|
const res = await addRentProperty(payload);
|
||||||
@ -786,7 +832,23 @@ const handleMapClick = async (coords) => {
|
|||||||
<p className="text-gray-600">أدخل التفاصيل والخدمات المتاحة</p>
|
<p className="text-gray-600">أدخل التفاصيل والخدمات المتاحة</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-6">
|
<div className="grid grid-cols-1 md:grid-cols-4 gap-6">
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||||
|
المساحة (م²)
|
||||||
|
</label>
|
||||||
|
<div className="relative">
|
||||||
|
<Square className="absolute right-3 top-1/2 transform -translate-y-1/2 w-4 h-4 text-gray-400" />
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={formData.space}
|
||||||
|
onChange={(e) => setFormData({...formData, space: e.target.value})}
|
||||||
|
className="w-full pr-10 pl-3 py-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500"
|
||||||
|
placeholder="مثال: 120"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium text-gray-700 mb-2">
|
<label className="block text-sm font-medium text-gray-700 mb-2">
|
||||||
عدد الغرف <span className="text-red-500">*</span>
|
عدد الغرف <span className="text-red-500">*</span>
|
||||||
@ -872,6 +934,39 @@ const handleMapClick = async (coords) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-2">رقم الطابق</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={formData.floorNumber}
|
||||||
|
onChange={(e) => setFormData({...formData, floorNumber: e.target.value})}
|
||||||
|
className="w-full px-4 py-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500"
|
||||||
|
placeholder="مثال: 3"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-2">عدد الصالونات</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={formData.salons}
|
||||||
|
onChange={(e) => setFormData({...formData, salons: e.target.value})}
|
||||||
|
className="w-full px-4 py-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500"
|
||||||
|
placeholder="مثال: 1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
<div>
|
||||||
|
<label className="block text-sm font-medium text-gray-700 mb-2">عدد البلكونات</label>
|
||||||
|
<input
|
||||||
|
type="number"
|
||||||
|
value={formData.balconies}
|
||||||
|
onChange={(e) => setFormData({...formData, balconies: e.target.value})}
|
||||||
|
className="w-full px-4 py-3 border border-gray-300 rounded-xl focus:outline-none focus:ring-2 focus:ring-amber-500"
|
||||||
|
placeholder="مثال: 1"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<h3 className="text-lg font-bold text-gray-900 mb-4">الخدمات المتوفرة <span className="text-red-500">*</span></h3>
|
<h3 className="text-lg font-bold text-gray-900 mb-4">الخدمات المتوفرة <span className="text-red-500">*</span></h3>
|
||||||
<div className="space-y-3">
|
<div className="space-y-3">
|
||||||
|
|||||||
Reference in New Issue
Block a user