aboutsummaryrefslogblamecommitdiffstats
path: root/src/components/AdForm.jsx
blob: 3274803ded55dd7ea83306b1199e37e8eb05366c (plain) (tree)







































                                                        
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;