// components/forms/AdForm.js
import { useState } from "react";
import CurrencyInput from "react-currency-input-field";
export default function AdForm({ action, type }) {
const [ad, setAd] = useState({
photos: "",
price: "",
address: "",
bedrooms: "",
toilets: "",
carpark: "",
landsize: "",
landsizetype: "",
type: "",
title: "",
description: "",
features: "",
nearby: "",
loading: "",
});
const handleSubmit = async (e) => {
try {
e.preventDefault();
console.log(ad);
} catch (err) {
console.log(err);
}
};
return (
<>
<form onSubmit={handleSubmit}>
<CurrencyInput
placeholder="Enter price"
defaultValue={ad.price}
className="form-control mb-3"
onValueChange={(value) => setAd({ ...ad, price: value })}
/>
</form>
<pre>{JSON.stringify(ad, null, 4)}</pre>
</>
);
}