diff --git a/src/utils/Fetcher.jsx b/src/utils/Fetcher.jsx
index afa9235..1161543 100644
--- a/src/utils/Fetcher.jsx
+++ b/src/utils/Fetcher.jsx
@@ -73,6 +73,16 @@ const MarkChoreComplete = (id, note, completedDate) => {
body: JSON.stringify(body),
})
}
+
+const SkipChore = id => {
+ return Fetch(`${API_URL}/chores/${id}/skip`, {
+ method: 'POST',
+ headers: {
+ 'Content-Type': 'application/json',
+ },
+ body: JSON.stringify({}),
+ })
+}
const CreateChore = chore => {
return Fetch(`${API_URL}/chores/`, {
method: 'POST',
@@ -277,6 +287,7 @@ export {
SaveChore,
SaveThing,
signUp,
+ SkipChore,
UpdateThingState,
UpdateUserDetails,
}
diff --git a/src/views/ChoreEdit/ChoreView.jsx b/src/views/ChoreEdit/ChoreView.jsx
index df45aa7..172ad9b 100644
--- a/src/views/ChoreEdit/ChoreView.jsx
+++ b/src/views/ChoreEdit/ChoreView.jsx
@@ -3,48 +3,53 @@ import {
CancelScheduleSend,
Check,
Checklist,
- Note,
+ History,
PeopleAlt,
Person,
+ SwitchAccessShortcut,
+ Timelapse,
} from '@mui/icons-material'
import {
Box,
Button,
Card,
Checkbox,
+ Chip,
Container,
FormControl,
Grid,
Input,
ListItem,
ListItemContent,
- ListItemDecorator,
Sheet,
Snackbar,
styled,
Typography,
} from '@mui/joy'
+import { Divider } from '@mui/material'
import moment from 'moment'
import { useEffect, useState } from 'react'
-import { useParams, useSearchParams } from 'react-router-dom'
+import { useNavigate, useParams, useSearchParams } from 'react-router-dom'
import {
GetAllUsers,
GetChoreDetailById,
MarkChoreComplete,
+ SkipChore,
} from '../../utils/Fetcher'
+import ConfirmationModal from '../Modals/Inputs/ConfirmationModal'
const IconCard = styled('div')({
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
backgroundColor: '#f0f0f0', // Adjust the background color as needed
borderRadius: '50%',
- minWidth: '50px',
- height: '50px',
+ minWidth: '40px',
+ height: '40px',
marginRight: '16px',
})
const ChoreView = () => {
const [chore, setChore] = useState({})
-
+ const navigate = useNavigate()
const [performers, setPerformers] = useState([])
const [infoCards, setInfoCards] = useState([])
const { choreId } = useParams()
@@ -56,6 +61,8 @@ const ChoreView = () => {
const [timeoutId, setTimeoutId] = useState(null)
const [secondsLeftToCancel, setSecondsLeftToCancel] = useState(null)
const [completedDate, setCompletedDate] = useState(null)
+ const [confirmModelConfig, setConfirmModelConfig] = useState({})
+
useEffect(() => {
Promise.all([
GetChoreDetailById(choreId).then(resp => {
@@ -85,20 +92,20 @@ const ChoreView = () => {
const generateInfoCards = chore => {
const cards = [
{
- icon: ,
- text: 'Due Date',
- subtext: moment(chore.nextDueDate).format('MM/DD/YYYY hh:mm A'),
- },
- {
+ size: 6,
icon: ,
text: 'Assigned To',
subtext: performers.find(p => p.id === chore.assignedTo)?.displayName,
},
{
- icon: ,
- text: 'Created By',
- subtext: performers.find(p => p.id === chore.createdBy)?.displayName,
+ size: 6,
+ icon: ,
+ text: 'Due Date',
+ subtext: chore.nextDueDate
+ ? moment(chore.nextDueDate).fromNow()
+ : 'N/A',
},
+
// {
// icon: ,
// text: 'Frequency',
@@ -107,35 +114,42 @@ const ChoreView = () => {
// chore.frequencyType.slice(1),
// },
{
+ size: 6,
icon: ,
text: 'Total Completed',
- subtext: `${chore.totalCompletedCount}`,
+ subtext: `${chore.totalCompletedCount} times`,
},
- // {
- // icon: ,
- // text: 'Last Completed',
- // subtext:
- // chore.lastCompletedDate &&
- // moment(chore.lastCompletedDate).format('MM/DD/YYYY hh:mm A'),
- // },
{
- icon: ,
+ size: 6,
+ icon: ,
text: 'Last Completed',
+ subtext:
+ // chore.lastCompletedDate &&
+ // moment(chore.lastCompletedDate).format('MM/DD/YYYY hh:mm A'),
+ chore.lastCompletedDate && moment(chore.lastCompletedDate).fromNow(),
+ },
+ {
+ size: 6,
+ icon: ,
+ text: 'Last Performer',
subtext: chore.lastCompletedDate
? `${
- chore.lastCompletedDate &&
- moment(chore.lastCompletedDate).fromNow()
- // moment(chore.lastCompletedDate).format('MM/DD/YYYY hh:mm A'))
- }(${
performers.find(p => p.id === chore.lastCompletedBy)?.displayName
- })`
- : 'Never',
+ }`
+ : '--',
},
{
- icon: ,
- text: 'Recent Note',
- subtext: chore.notes || '--',
+ size: 6,
+ icon: ,
+ text: 'Created By',
+ subtext: performers.find(p => p.id === chore.createdBy)?.displayName,
},
+ // {
+ // size: 12,
+ // icon: ,
+ // text: 'Recent Note',
+ // subtext: chore.notes || '--',
+ // },
]
setInfoCards(cards)
}
@@ -184,7 +198,16 @@ const ChoreView = () => {
setTimeoutId(id)
}
-
+ const handleSkippingTask = () => {
+ SkipChore(choreId).then(response => {
+ if (response.ok) {
+ response.json().then(data => {
+ const newChore = data.res
+ setChore(newChore)
+ })
+ }
+ })
+ }
return (
{
justifyContent: 'space-between',
}}
>
-
+
{chore.name}
+ } size='lg' sx={{ mb: 4 }}>
+ {chore.nextDueDate
+ ? `Due at ${moment(chore.nextDueDate).format('MM/DD/YYYY hh:mm A')}`
+ : 'N/A'}
+
+
+
+
+ Details
+
-
- {infoCards.map((info, index) => (
-
-
-
-
- {info.icon}
-
+
+
+ {infoCards.map((detail, index) => (
+
+ {/* divider between the list items: */}
+
+
-
- {info.text}
-
-
- {info.subtext ? info.subtext : '--'}
+
+ {detail.text}
+
+ {detail.subtext ? detail.subtext : '--'}
+
-
-
- ))}
-
+
+ ))}
+
+
+ {chore.notes && (
+ <>
+
+ Previous note:
+
+
+
+ {chore.notes || '--'}
+
+
+ >
+ )}
{/* */}
-
+
+ Actions
+
{
mt: 2,
}}
>
- Additional Notes
- {
- if (e.target.value.trim() === '') {
- setNote(null)
- return
- }
- setNote(e.target.value)
- }}
- size='md'
- sx={{
- my: 1,
- }}
- />
+
+ Complete the task
+
-
+
+ {
+ if (e.target.checked) {
+ setNote('')
+ } else {
+ setNote(null)
+ }
+ }}
+ overlay
+ sx={
+ {
+ // my: 1,
+ }
+ }
+ label={
+
+ Add Additional Notes
+
+ }
+ />
+
+ {note !== null && (
+ {
+ if (e.target.value.trim() === '') {
+ setNote(null)
+ return
+ }
+ setNote(e.target.value)
+ }}
+ size='md'
+ sx={{
+ mb: 1,
+ }}
+ />
+ )}
+
+
{
}
}}
overlay
- sx={{
- my: 1,
- }}
- label={Set completion date}
+ sx={
+ {
+ // my: 1,
+ }
+ }
+ label={
+
+ Specify completion date
+
+ }
/>
{completedDate !== null && (
@@ -295,22 +411,10 @@ const ChoreView = () => {
}}
/>
)}
- {completedDate === null && (
- // placeholder for the completion date with margin:
-
- )}
- {/* */}
-
+ or
-
- }
- >
-
- Task will be marked as completed in {secondsLeftToCancel} seconds
-
-
+ }
+ size='lg'
+ color='primary'
+ variant='outlined'
+ fullWidth
+ onClick={() => {
+ navigate(`/chores/${choreId}/history`)
+ }}
+ >
+ History
+
+
+
+ {
+ if (timeoutId) {
+ clearTimeout(timeoutId)
+ setIsPendingCompletion(false)
+ setTimeoutId(null)
+ setSecondsLeftToCancel(null) // Reset or adjust as needed
+ }
+ }}
+ size='lg'
+ variant='outlined'
+ color='danger'
+ startDecorator={}
+ >
+ Cancel
+
+ }
+ >
+
+ Task will be marked as completed in {secondsLeftToCancel} seconds
+
+
+
+
)
}
diff --git a/src/views/ChoreEdit/RepeatSection.jsx b/src/views/ChoreEdit/RepeatSection.jsx
index 99f196f..bdf6738 100644
--- a/src/views/ChoreEdit/RepeatSection.jsx
+++ b/src/views/ChoreEdit/RepeatSection.jsx
@@ -509,7 +509,7 @@ const RepeatSection = ({
}}
>
Is this something that should be done when a thing state changes?{' '}
- {!isPlusAccount(userProfile) && (
+ {userProfile && !isPlusAccount(userProfile) && (
Not available in Basic Plan
diff --git a/src/views/Chores/ChoreCard.jsx b/src/views/Chores/ChoreCard.jsx
index 08a5406..97e407a 100644
--- a/src/views/Chores/ChoreCard.jsx
+++ b/src/views/Chores/ChoreCard.jsx
@@ -17,6 +17,7 @@ import {
SwitchAccessShortcut,
TimesOneMobiledata,
Update,
+ ViewCarousel,
Webhook,
} from '@mui/icons-material'
import {
@@ -38,7 +39,7 @@ import moment from 'moment'
import React, { useEffect } from 'react'
import { useNavigate } from 'react-router-dom'
import { API_URL } from '../../Config'
-import { MarkChoreComplete } from '../../utils/Fetcher'
+import { MarkChoreComplete, SkipChore } from '../../utils/Fetcher'
import { Fetch } from '../../utils/TokenManager'
import ConfirmationModal from '../Modals/Inputs/ConfirmationModal'
import DateModal from '../Modals/Inputs/DateModal'
@@ -107,6 +108,9 @@ const ChoreCard = ({
const handleEdit = () => {
navigate(`/chores/${chore.id}/edit`)
}
+ const handleView = () => {
+ navigate(`/chores/${chore.id}`)
+ }
const handleDelete = () => {
setConfirmModelConfig({
isOpen: true,
@@ -521,13 +525,7 @@ const ChoreCard = ({
+