Fix: add missing imports and currencies fetch in add property form
All checks were successful
Build frontend / build (push) Successful in 41s

- Import getCurrencies and uploadPicture were missing from import statement
- Added currencies state and fetch call in useEffect
- Added debug log in handleImageUpload
This commit is contained in:
Claw AI
2026-03-30 01:25:48 +00:00
parent 505dcd4bb0
commit 9d671f1985

View File

@ -51,7 +51,7 @@ import {
Move
} from 'lucide-react';
import toast, { Toaster } from 'react-hot-toast';
import { addRentProperty } from '../../../utils/api';
import { addRentProperty, getCurrencies, uploadPicture } from '../../../utils/api';
import {
BuildingType,
RentPropertyCondition,
@ -140,6 +140,7 @@ export default function AddPropertyPage() {
const [mapZoom, setMapZoom] = useState(13);
const [searchQuery, setSearchQuery] = useState('');
const [mapLoaded, setMapLoaded] = useState(false);
const [currencies, setCurrencies] = useState([]);
const [selectedCurrencyId, setSelectedCurrencyId] = useState(Currency.SYP);
const [errors, setErrors] = useState({});
@ -188,6 +189,16 @@ export default function AddPropertyPage() {
});
}
setMapLoaded(true);
// Fetch available currencies
getCurrencies().then((data) => {
if (Array.isArray(data) && data.length > 0) {
setCurrencies(data);
console.log('[AddProperty] Currencies loaded:', data);
}
}).catch((err) => {
console.warn('[AddProperty] Failed to load currencies:', err);
});
}, []);
const handleSearch = async () => {
@ -331,6 +342,7 @@ const handleMapClick = async (coords) => {
const handleImageUpload = async (files) => {
const newImages = Array.from(files);
console.log('[AddProperty] handleImageUpload called with', newImages.length, 'files');
if (formData.images.length + newImages.length > 10) {
toast.error('يمكنك رفع 10 صور كحد أقصى');