-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddScheduleDialog.js
More file actions
84 lines (79 loc) · 2.46 KB
/
AddScheduleDialog.js
File metadata and controls
84 lines (79 loc) · 2.46 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
// AddScheduleDialog.js
function AddScheduleDialog({ isOpen, onClose, onAddSchedule }) {
const [date, setDate] = React.useState('');
const [time, setTime] = React.useState('');
const [friend, setFriend] = React.useState('');
const [diningType, setDiningType] = React.useState('Breakfast');
if (!isOpen) return null;
function handleSubmit(e) {
e.preventDefault();
const newSchedule = {
id: Date.now().toString(),
date,
time,
friend,
diningType,
avatar: '/assets/3d_avatar_1.png', // Adjust as needed
status: 'pending'
};
onAddSchedule(newSchedule);
onClose();
// Reset form fields
setDate('');
setTime('');
setFriend('');
setDiningType('Breakfast');
}
return (
<div className="dialog-overlay">
<div className="dialog">
<h2>Add New Schedule</h2>
<form onSubmit={handleSubmit}>
<label>
Date:
<input
type="date"
value={date}
onChange={(e) => setDate(e.target.value)}
required
/>
</label>
<label>
Time:
<input
type="text"
value={time}
onChange={(e) => setTime(e.target.value)}
placeholder="e.g. 12:00 - 1:00 PM"
required
/>
</label>
<label>
Friend:
<input
type="text"
value={friend}
onChange={(e) => setFriend(e.target.value)}
required
/>
</label>
<label>
Dining Type:
<select value={diningType} onChange={(e) => setDiningType(e.target.value)}>
<option value="Breakfast">Breakfast</option>
<option value="Brunch">Brunch</option>
<option value="Lunch">Lunch</option>
<option value="Afternoon Snack">Afternoon Snack</option>
<option value="Dinner">Dinner</option>
</select>
</label>
<div className="dialog-actions">
<button type="button" onClick={onClose}>Cancel</button>
<button type="submit">Add Schedule</button>
</div>
</form>
</div>
</div>
);
}
window.AddScheduleDialog = AddScheduleDialog;