Merge branch 'dev'
This commit is contained in:
@@ -532,15 +532,17 @@ const ChoreCard = ({
|
||||
<Box display='flex' flexDirection='column'>
|
||||
<Typography level='title-md'>{getName(chore.name)}</Typography>
|
||||
{userProfile && chore.assignedTo !== userProfile.id && (
|
||||
<Typography level='body-md' color='text.disabled'>
|
||||
Assigned to{' '}
|
||||
<Box display='flex' alignItems='center' gap={0.5}>
|
||||
<Typography level='body-md' color='text.disabled'>
|
||||
Assigned to
|
||||
</Typography>
|
||||
<Chip variant='outlined'>
|
||||
{
|
||||
performers.find(p => p.id === chore.assignedTo)
|
||||
?.displayName
|
||||
}
|
||||
</Chip>
|
||||
</Typography>
|
||||
</Box>
|
||||
)}
|
||||
<Box key={`${chore.id}-labels`}>
|
||||
{chore.priority > 0 && (
|
||||
|
||||
@@ -464,7 +464,7 @@ const CompactChoreCard = ({
|
||||
...sx,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
px: 1,
|
||||
// px: 1,
|
||||
// py: 0.75,
|
||||
minHeight: 56, // More compact height
|
||||
cursor: 'pointer',
|
||||
@@ -594,11 +594,11 @@ const CompactChoreCard = ({
|
||||
}
|
||||
}}
|
||||
style={{
|
||||
display: 'inline-block',
|
||||
cursor: 'pointer',
|
||||
// remove any padding or margin:
|
||||
padding: 0,
|
||||
margin: 0,
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
}}
|
||||
key={`compact-chorecard-${chore.id}-label-${l.id}`}
|
||||
>
|
||||
|
||||
@@ -34,12 +34,7 @@ import { useContext, useEffect, useRef, useState } from 'react'
|
||||
import { useNavigate } from 'react-router-dom'
|
||||
import { UserContext } from '../../contexts/UserContext'
|
||||
import { useChores } from '../../queries/ChoreQueries'
|
||||
import {
|
||||
GetAllUsers,
|
||||
GetArchivedChores,
|
||||
GetChores,
|
||||
GetUserProfile,
|
||||
} from '../../utils/Fetcher'
|
||||
import { GetArchivedChores } from '../../utils/Fetcher'
|
||||
import Priorities from '../../utils/Priorities'
|
||||
import LoadingComponent from '../components/Loading'
|
||||
import { useLabels } from '../Labels/LabelQueries'
|
||||
@@ -47,6 +42,7 @@ import ChoreCard from './ChoreCard'
|
||||
import CompactChoreCard from './CompactChoreCard'
|
||||
import IconButtonWithMenu from './IconButtonWithMenu'
|
||||
|
||||
import { useCircleMembers } from '../../queries/UserQueries'
|
||||
import { ChoreFilters, ChoresGrouper, ChoreSorter } from '../../utils/Chores'
|
||||
import TaskInput from '../components/AddTaskModal'
|
||||
import {
|
||||
@@ -95,58 +91,11 @@ const MyChores = () => {
|
||||
isLoading: choresLoading,
|
||||
refetch: refetchChores,
|
||||
} = useChores()
|
||||
const { data: membersData, isLoading: membersLoading } = useCircleMembers()
|
||||
|
||||
useEffect(() => {
|
||||
Promise.all([GetChores(), GetAllUsers(), GetUserProfile()]).then(
|
||||
responses => {
|
||||
const [choresResponse, usersResponse, userProfileResponse] = responses
|
||||
if (!choresResponse.ok) {
|
||||
throw new Error(choresResponse.statusText)
|
||||
}
|
||||
if (!usersResponse.ok) {
|
||||
throw new Error(usersResponse.statusText)
|
||||
}
|
||||
if (!userProfileResponse.ok) {
|
||||
throw new Error(userProfileResponse.statusText)
|
||||
}
|
||||
Promise.all([
|
||||
userProfileResponse.json(),
|
||||
choresResponse.json(),
|
||||
usersResponse.json(),
|
||||
]).then(data => {
|
||||
const [userProfileData, choresData, usersData] = data
|
||||
setUserProfile(userProfileData.res)
|
||||
setChores(choresData.res)
|
||||
setFilteredChores(choresData.res)
|
||||
setPerformers(usersData.res)
|
||||
if (canScheduleNotification()) {
|
||||
scheduleChoreNotification(
|
||||
choresData.res,
|
||||
userProfileData.res,
|
||||
usersData.res,
|
||||
)
|
||||
}
|
||||
})
|
||||
},
|
||||
)
|
||||
|
||||
// GetAllUsers()
|
||||
// .then(response => response.json())
|
||||
// .then(data => {
|
||||
// setPerformers(data.res)
|
||||
// })
|
||||
// GetUserProfile().then(response => response.json()).then(data => {
|
||||
// setUserProfile(data.res)
|
||||
// })
|
||||
|
||||
// const currentUser = JSON.parse(localStorage.getItem('user'))
|
||||
// if (currentUser !== null) {
|
||||
// setActiveUserId(currentUser.id)
|
||||
// }
|
||||
}, [])
|
||||
|
||||
useEffect(() => {
|
||||
if (choresData) {
|
||||
if (!choresLoading && !membersLoading && userProfile) {
|
||||
setPerformers(membersData.res)
|
||||
const sortedChores = choresData.res.sort(ChoreSorter)
|
||||
setChores(sortedChores)
|
||||
setFilteredChores(sortedChores)
|
||||
@@ -165,8 +114,12 @@ const MyChores = () => {
|
||||
}, {}),
|
||||
)
|
||||
}
|
||||
|
||||
if (canScheduleNotification()) {
|
||||
scheduleChoreNotification(choresData.res, userProfile, membersData.res)
|
||||
}
|
||||
}
|
||||
}, [choresData, choresLoading])
|
||||
}, [membersLoading, choresLoading, userProfile])
|
||||
|
||||
useEffect(() => {
|
||||
document.addEventListener('mousedown', handleMenuOutsideClick)
|
||||
@@ -768,7 +721,11 @@ const MyChores = () => {
|
||||
<AccordionDetails
|
||||
sx={{
|
||||
flexDirection: 'column',
|
||||
my: 0,
|
||||
['& > *']: {
|
||||
// px: 0.5,
|
||||
px: 0.5,
|
||||
// pr: 0,
|
||||
},
|
||||
}}
|
||||
>
|
||||
{section.content?.map(chore => renderChoreCard(chore))}
|
||||
|
||||
@@ -23,11 +23,6 @@ const WelcomeCard = () => {
|
||||
member.userId === userProfile?.id &&
|
||||
(member.role === 'admin' || member.role === 'manager'),
|
||||
)
|
||||
members.forEach(m =>
|
||||
console.log('Member:', userProfile?.id, m.id, m.role),
|
||||
)
|
||||
console.log('Circle Members:', members)
|
||||
console.log(isUserAdmin)
|
||||
|
||||
setIsAdmin(isUserAdmin)
|
||||
}
|
||||
|
||||
@@ -20,12 +20,7 @@ import { useCreateChore } from '../../queries/ChoreQueries'
|
||||
import { useCircleMembers } from '../../queries/UserQueries'
|
||||
import { isPlusAccount } from '../../utils/Helpers'
|
||||
import { useLabels } from '../Labels/LabelQueries'
|
||||
import {
|
||||
parseAssignees,
|
||||
parseLabels,
|
||||
parsePriority,
|
||||
parseRepeatV2,
|
||||
} from './CustomParsers'
|
||||
import { parseLabels, parsePriority, parseRepeatV2 } from './CustomParsers'
|
||||
import SmartTaskTitleInput from './SmartTaskTitleInput'
|
||||
|
||||
import LearnMoreButton from './LearnMore'
|
||||
@@ -212,33 +207,32 @@ const TaskInput = ({ autoFocus, onChoreUpdate, isModalOpen, onClose }) => {
|
||||
cleanedSentence = repeat.cleanedSentence
|
||||
}
|
||||
// Parse assignees using circle members
|
||||
const circleMembersList = circleMembers?.res || []
|
||||
const assigneesForParsing = circleMembersList.map(member => ({
|
||||
userId: member.userId,
|
||||
username:
|
||||
member.username ||
|
||||
member.displayName?.toLowerCase().replace(/\s+/g, ''),
|
||||
displayName: member.displayName,
|
||||
name: member.displayName,
|
||||
id: member.userId,
|
||||
}))
|
||||
// const circleMembersList = circleMembers?.res || []
|
||||
// const assigneesForParsing = circleMembersList.map(member => ({
|
||||
// userId: member.userId,
|
||||
// username:
|
||||
// member.username ||
|
||||
// member.displayName?.toLowerCase().replace(/\s+/g, ''),
|
||||
// displayName: member.displayName,
|
||||
// name: member.displayName,
|
||||
// id: member.userId,
|
||||
// }))
|
||||
|
||||
const assigneesResult = parseAssignees(sentence, assigneesForParsing)
|
||||
if (assigneesResult.result) {
|
||||
cleanedSentence = assigneesResult.cleanedSentence
|
||||
setAssignees(assigneesResult.result)
|
||||
} else {
|
||||
// Default to current user if no assignees parsed
|
||||
setAssignees([
|
||||
{
|
||||
userId: userProfile.id,
|
||||
username: userProfile.username,
|
||||
displayName: userProfile.displayName,
|
||||
name: userProfile.displayName,
|
||||
id: userProfile.id,
|
||||
},
|
||||
])
|
||||
}
|
||||
// const assigneesResult = parseAssignees(sentence, assigneesForParsing)
|
||||
// if (assigneesResult.result) {
|
||||
// cleanedSentence = assigneesResult.cleanedSentence
|
||||
// setAssignees(
|
||||
// assigneesResult.result.map(assignee => ({
|
||||
// userId: assignee.userId,
|
||||
// })),
|
||||
// )
|
||||
// } else {
|
||||
// setAssignees([
|
||||
// {
|
||||
// userId: userProfile.id,
|
||||
// },
|
||||
// ])
|
||||
// }
|
||||
const parsedDueDate = chrono.parse(sentence, new Date(), {
|
||||
forwardDate: true,
|
||||
})
|
||||
@@ -327,7 +321,8 @@ const TaskInput = ({ autoFocus, onChoreUpdate, isModalOpen, onClose }) => {
|
||||
const createChore = () => {
|
||||
const chore = {
|
||||
name: taskTitle,
|
||||
assignees: assignees.map(assignee => ({ userId: assignee.userId })),
|
||||
assignees:
|
||||
assignees.length > 0 ? assignees : [{ userId: userProfile.id }],
|
||||
dueDate: dueDate ? new Date(dueDate).toISOString() : null,
|
||||
assignedTo: assignees.length > 0 ? assignees[0].userId : userProfile.id,
|
||||
assignStrategy: 'random',
|
||||
@@ -590,7 +585,7 @@ const TaskInput = ({ autoFocus, onChoreUpdate, isModalOpen, onClose }) => {
|
||||
gap: 2,
|
||||
}}
|
||||
>
|
||||
<FormControl>
|
||||
{/* <FormControl>
|
||||
<Typography level='body-sm'>Assignees</Typography>
|
||||
<Box sx={{ display: 'flex', flexWrap: 'wrap', gap: 0.5 }}>
|
||||
{assignees.length > 0 ? (
|
||||
@@ -598,7 +593,7 @@ const TaskInput = ({ autoFocus, onChoreUpdate, isModalOpen, onClose }) => {
|
||||
<Chip
|
||||
key={assignee.userId || index}
|
||||
variant='soft'
|
||||
size='sm'
|
||||
size='lg'
|
||||
color='primary'
|
||||
>
|
||||
{assignee.displayName || assignee.username}
|
||||
@@ -610,7 +605,7 @@ const TaskInput = ({ autoFocus, onChoreUpdate, isModalOpen, onClose }) => {
|
||||
</Chip>
|
||||
)}
|
||||
</Box>
|
||||
</FormControl>
|
||||
</FormControl> */}
|
||||
<FormControl>
|
||||
<Typography level='body-sm'>Frequency</Typography>
|
||||
<Input value={frequencyHumanReadable || 'Once'} variant='plain' />
|
||||
|
||||
Reference in New Issue
Block a user