Fix: add missing imports and currencies fetch in add property form
All checks were successful
Build frontend / build (push) Successful in 41s
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:
@ -51,7 +51,7 @@ import {
|
|||||||
Move
|
Move
|
||||||
} from 'lucide-react';
|
} from 'lucide-react';
|
||||||
import toast, { Toaster } from 'react-hot-toast';
|
import toast, { Toaster } from 'react-hot-toast';
|
||||||
import { addRentProperty } from '../../../utils/api';
|
import { addRentProperty, getCurrencies, uploadPicture } from '../../../utils/api';
|
||||||
import {
|
import {
|
||||||
BuildingType,
|
BuildingType,
|
||||||
RentPropertyCondition,
|
RentPropertyCondition,
|
||||||
@ -140,6 +140,7 @@ export default function AddPropertyPage() {
|
|||||||
const [mapZoom, setMapZoom] = useState(13);
|
const [mapZoom, setMapZoom] = useState(13);
|
||||||
const [searchQuery, setSearchQuery] = useState('');
|
const [searchQuery, setSearchQuery] = useState('');
|
||||||
const [mapLoaded, setMapLoaded] = useState(false);
|
const [mapLoaded, setMapLoaded] = useState(false);
|
||||||
|
const [currencies, setCurrencies] = useState([]);
|
||||||
const [selectedCurrencyId, setSelectedCurrencyId] = useState(Currency.SYP);
|
const [selectedCurrencyId, setSelectedCurrencyId] = useState(Currency.SYP);
|
||||||
|
|
||||||
const [errors, setErrors] = useState({});
|
const [errors, setErrors] = useState({});
|
||||||
@ -188,6 +189,16 @@ export default function AddPropertyPage() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
setMapLoaded(true);
|
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 () => {
|
const handleSearch = async () => {
|
||||||
@ -331,6 +342,7 @@ const handleMapClick = async (coords) => {
|
|||||||
|
|
||||||
const handleImageUpload = async (files) => {
|
const handleImageUpload = async (files) => {
|
||||||
const newImages = Array.from(files);
|
const newImages = Array.from(files);
|
||||||
|
console.log('[AddProperty] handleImageUpload called with', newImages.length, 'files');
|
||||||
|
|
||||||
if (formData.images.length + newImages.length > 10) {
|
if (formData.images.length + newImages.length > 10) {
|
||||||
toast.error('يمكنك رفع 10 صور كحد أقصى');
|
toast.error('يمكنك رفع 10 صور كحد أقصى');
|
||||||
|
|||||||
Reference in New Issue
Block a user