-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBirthdayForm.js
37 lines (30 loc) · 1.03 KB
/
BirthdayForm.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import React, { useState } from 'react';
function BirthdayForm({ addBirthday }) {
const [name, setName] = useState('');
const [date, setDate] = useState('');
const [image, setImage] = useState('');
const handleSubmit = (e) => {
e.preventDefault();
if (name && date && image) {
addBirthday({ name, date, image });
setName('');
setDate('');
setImage('');
}
};
return (
<div className="birthday-form">
<h2 style={{ fontweight:'bold'}}>Add a New Birthday</h2>
<form onSubmit={handleSubmit}>
<label>Name:</label>
<input type="text" value={name} onChange={(e) => setName(e.target.value)} />
<label>Date:</label>
<input type="date" value={date} onChange={(e) => setDate(e.target.value)} />
<label>Image URL:</label>
<input type="text" value={image} onChange={(e) => setImage(e.target.value)} />
<button type="submit">Add Birthday</button>
</form>
</div>
);
}
export default BirthdayForm;