-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFilterComponents.js
More file actions
62 lines (57 loc) · 2.03 KB
/
FilterComponents.js
File metadata and controls
62 lines (57 loc) · 2.03 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
// FilterComponent.js
function FilterComponent({ schedules, filters, onFilterChange }) {
// Get unique dates from schedules
const uniqueDates = Array.from(new Set(schedules.map(schedule => schedule.date)));
// Get unique dining types
const diningTypes = Array.from(new Set(schedules.map(schedule => schedule.diningType)));
// Define status options
const statusOptions = ['confirmed', 'pending', 'declined'];
return (
<div className="filter-container">
<div className="filter-group">
<select
className="filter-select"
value={filters.diningType}
onChange={(e) => onFilterChange('diningType', e.target.value)}
>
<option value="">All Dining Types</option>
{diningTypes.map(type => (
<option key={type} value={type}>{type}</option>
))}
</select>
<select
className="filter-select"
value={filters.date}
onChange={(e) => onFilterChange('date', e.target.value)}
>
<option value="">All Dates</option>
{uniqueDates.map(date => {
const formattedDate = new Date(date).toLocaleDateString(undefined, {
weekday: 'short',
month: 'short',
day: 'numeric'
});
return (
<option key={date} value={date}>
{formattedDate}
</option>
);
})}
</select>
<select
className="filter-select"
value={filters.status}
onChange={(e) => onFilterChange('status', e.target.value)}
>
<option value="">All Statuses</option>
{statusOptions.map(status => (
<option key={status} value={status}>
{status.charAt(0).toUpperCase() + status.slice(1)}
</option>
))}
</select>
</div>
</div>
);
}
window.FilterComponent = FilterComponent;