From 7f4e5928492a71135f6817874461c80a0ecc155c Mon Sep 17 00:00:00 2001 From: Mo Tarbin Date: Tue, 16 Jul 2024 19:37:18 -0400 Subject: Add SkipChore function to Fetcher utility module, Update Loading Comp --- src/views/History/ChoreHistory.jsx | 140 ++++++++++++++++--------------------- 1 file changed, 61 insertions(+), 79 deletions(-) (limited to 'src/views/History/ChoreHistory.jsx') diff --git a/src/views/History/ChoreHistory.jsx b/src/views/History/ChoreHistory.jsx index b85e456..1db1f06 100644 --- a/src/views/History/ChoreHistory.jsx +++ b/src/views/History/ChoreHistory.jsx @@ -1,15 +1,13 @@ -import { Checklist, EventBusy, Timelapse } from '@mui/icons-material' +import { Checklist, EventBusy, Group, Timelapse } from '@mui/icons-material' import { Avatar, - Box, Button, - CircularProgress, + Chip, Container, Grid, List, ListItem, ListItemContent, - ListItemDecorator, Sheet, Typography, } from '@mui/joy' @@ -19,6 +17,7 @@ import { Link, useParams } from 'react-router-dom' import { API_URL } from '../../Config' import { GetAllCircleMembers } from '../../utils/Fetcher' import { Fetch } from '../../utils/TokenManager' +import LoadingComponent from '../components/Loading' import HistoryCard from './HistoryCard' const ChoreHistory = () => { @@ -92,59 +91,49 @@ const ChoreHistory = () => { const historyInfo = [ { - icon: ( - - - - ), - text: `${histories.length} completed`, - subtext: `${Object.keys(userHistories).length} users contributed`, + icon: , + text: 'Total Completed', + subtext: `${histories.length} times`, }, { - icon: ( - - - - ), - text: `Completed within ${moment - .duration(averageDelayMoment) - .humanize()}`, - subtext: `Maximum delay was ${moment - .duration(maxDelayMoment) - .humanize()}`, + icon: , + text: 'Usually Within', + subtext: moment.duration(averageDelayMoment).humanize(), }, { - icon: , - text: `${ + icon: , + text: 'Maximum Delay', + subtext: moment.duration(maxDelayMoment).humanize(), + }, + { + icon: , + text: ' Completed Most', + subtext: `${ performers.find(p => p.userId === Number(userCompletedByMost)) ?.displayName - } completed most`, - subtext: `${userHistories[userCompletedByMost]} time/s`, + } `, + }, + // contributes: + { + icon: , + text: 'Total Performers', + subtext: `${Object.keys(userHistories).length} users`, + }, + { + icon: , + text: 'Last Completed', + subtext: `${ + performers.find(p => p.userId === Number(histories[0].completedBy)) + ?.displayName + }`, }, ] - if (userCompletedByLeast !== userCompletedByMost) { - historyInfo.push({ - icon: ( - - { - performers.find(p => p.userId === userCompletedByLeast) - ?.displayName - } - - ), - text: `${ - performers.find(p => p.userId === Number(userCompletedByLeast)) - .displayName - } completed least`, - subtext: `${userHistories[userCompletedByLeast]} time/s`, - }) - } setHistoryInfo(historyInfo) } if (isLoading) { - return // Show loading indicator + return } if (!choreHistory.length) { return ( @@ -184,50 +173,43 @@ const ChoreHistory = () => { return ( - + Summary: - {/* - - - - - - - - - {choreHistory.length} completed - - - {Object.keys(userHistory).length} users contributed - - - - */} - - {historyInfo.map((info, index) => ( - - - - {info.icon} + + + {historyInfo.map((info, index) => ( + + {/* divider between the list items: */} + + - + {info.text} - - {info.subtext} - + + {info.subtext ? info.subtext : '--'} + - - - ))} - + + ))} + + + {/* User History Cards */} - + History: - + {/* Chore History List (Updated Style) */} @@ -241,7 +223,7 @@ const ChoreHistory = () => { /> ))} - + ) } -- cgit