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