aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/AdForm.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'src/components/AdForm.jsx')
-rw-r--r--src/components/AdForm.jsx40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/components/AdForm.jsx b/src/components/AdForm.jsx
new file mode 100644
index 0000000..3274803
--- /dev/null
+++ b/src/components/AdForm.jsx
@@ -0,0 +1,40 @@
+import React, { useState } from 'react';
+
+const AdForm = ({ onAddAd }) => {
+ const [title, setTitle] = useState('');
+ const [description, setDescription] = useState('');
+ const [image, setImage] = useState('');
+
+ const handleSubmit = (e) => {
+ e.preventDefault();
+ onAddAd({ title, description, image });
+ setTitle('');
+ setDescription('');
+ setImage('');
+ };
+
+ return (
+ <form onSubmit={handleSubmit}>
+ <input
+ type="text"
+ placeholder="Title"
+ value={title}
+ onChange={(e) => setTitle(e.target.value)}
+ />
+ <textarea
+ placeholder="Description"
+ value={description}
+ onChange={(e) => setDescription(e.target.value)}
+ />
+ <input
+ type="text"
+ placeholder="Image URL"
+ value={image}
+ onChange={(e) => setImage(e.target.value)}
+ />
+ <button type="submit">Add Ad</button>
+ </form>
+ );
+};
+
+export default AdForm;