diff --git a/src/views/User/UserActivities.jsx b/src/views/User/UserActivities.jsx index 7a76eef..fa12fcf 100644 --- a/src/views/User/UserActivities.jsx +++ b/src/views/User/UserActivities.jsx @@ -1,14 +1,15 @@ -import CheckCircleIcon from '@mui/icons-material/CheckCircle' -import HourglassEmptyIcon from '@mui/icons-material/HourglassEmpty' -import ThumbDownIcon from '@mui/icons-material/ThumbDown' -import TimelapseIcon from '@mui/icons-material/Timelapse' import { Cell, Pie, PieChart, Tooltip } from 'recharts' import { - Block, + AccessTime, Check, EventBusy, Group, + HourglassEmpty, + Redo, + RunningWithErrors, + Schedule, + ThumbDown, Timeline, Toll, } from '@mui/icons-material' @@ -43,7 +44,9 @@ const groupByDate = history => { const aggregated = {} for (let i = 0; i < history.length; i++) { const item = history[i] - const date = new Date(item.performedAt).toLocaleDateString() + const date = new Date( + item.performedAt || item.updatedAt, + ).toLocaleDateString() if (!aggregated[date]) { aggregated[date] = [] } @@ -56,17 +59,21 @@ const ChoreHistoryItem = ({ time, name, points, status, performer }) => { const getStatusIcon = status => { switch (status) { case 0: - return + return case 1: return case 2: - return + return case 3: - return + return case 4: - return + return + case 5: + return + case 6: + return default: - return + return } } @@ -121,6 +128,10 @@ const ChoreHistoryItem = ({ time, name, points, status, performer }) => { const ChoreHistoryTimeline = ({ history }) => { const groupedHistory = groupByDate(history) + const sortedEntries = Object.entries(groupedHistory).sort( + ([a], [b]) => new Date(b) - new Date(a), + ) + return ( @@ -146,7 +157,9 @@ const ChoreHistoryTimeline = ({ history }) => { <>