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';
|
import { Divider, Icon, IconButton } from 'rsuite';
|
||||||
|
|
||||||
export default function SelectedDates({ datesList, eventsList, handleDelete }) {
|
export default function SelectedDates({ datesList, handleDelete }) {
|
||||||
return (
|
return (
|
||||||
<div>
|
<>
|
||||||
<h3>Dates selected</h3>
|
<h3>Dates selected</h3>
|
||||||
<ul>
|
<ul>
|
||||||
{datesList.map((date) => (
|
{datesList.map((date) => (
|
||||||
@ -21,6 +21,6 @@ export default function SelectedDates({ datesList, eventsList, handleDelete }) {
|
|||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ export default function Schedule() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Update selected dates
|
// Update selected dates
|
||||||
let updatedDates = eventsToDates(eventsList);
|
let updatedDates = eventsToDates(eventsList).sort();
|
||||||
setDatesList(updatedDates);
|
setDatesList(updatedDates);
|
||||||
}, [eventsList]);
|
}, [eventsList]);
|
||||||
|
|
||||||
@ -136,7 +136,6 @@ export default function Schedule() {
|
|||||||
<FormGroup>
|
<FormGroup>
|
||||||
<SelectedDates
|
<SelectedDates
|
||||||
datesList={datesList}
|
datesList={datesList}
|
||||||
eventsList={eventsList}
|
|
||||||
handleDelete={handleDelete}
|
handleDelete={handleDelete}
|
||||||
/>
|
/>
|
||||||
<Button>Confirm dates</Button>
|
<Button>Confirm dates</Button>
|
||||||
@ -155,16 +154,3 @@ const eventsToDates = (events) => {
|
|||||||
});
|
});
|
||||||
return dates;
|
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