Add sort to selected dates list
This commit is contained in:
parent
950e2e3165
commit
a97f8dc1c3
@ -2,9 +2,9 @@ import React from 'react';
|
||||
|
||||
import { Divider, Icon, IconButton } from 'rsuite';
|
||||
|
||||
export default function SelectedDates({ datesList, eventsList, handleDelete }) {
|
||||
export default function SelectedDates({ datesList, handleDelete }) {
|
||||
return (
|
||||
<div>
|
||||
<>
|
||||
<h3>Dates selected</h3>
|
||||
<ul>
|
||||
{datesList.map((date) => (
|
||||
@ -21,6 +21,6 @@ export default function SelectedDates({ datesList, eventsList, handleDelete }) {
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ export default function Schedule() {
|
||||
|
||||
useEffect(() => {
|
||||
// Update selected dates
|
||||
let updatedDates = eventsToDates(eventsList);
|
||||
let updatedDates = eventsToDates(eventsList).sort();
|
||||
setDatesList(updatedDates);
|
||||
}, [eventsList]);
|
||||
|
||||
@ -136,7 +136,6 @@ export default function Schedule() {
|
||||
<FormGroup>
|
||||
<SelectedDates
|
||||
datesList={datesList}
|
||||
eventsList={eventsList}
|
||||
handleDelete={handleDelete}
|
||||
/>
|
||||
<Button>Confirm dates</Button>
|
||||
@ -155,16 +154,3 @@ const eventsToDates = (events) => {
|
||||
});
|
||||
return dates;
|
||||
};
|
||||
|
||||
// Convert Luxon Datetime objects to events
|
||||
const datesToEvents = (dates) => {
|
||||
let events = [];
|
||||
dates.forEach((date) => {
|
||||
let event = {
|
||||
start: date.toFormat('yyyy-MM-dd'),
|
||||
display: 'background',
|
||||
};
|
||||
events.push(event);
|
||||
});
|
||||
return events;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user