Fix https://github.com/donetick/donetick/issues/604 Enhance ChoreEdit component with dropdown for archive/unarchive actions and add delete option

This commit is contained in:
Mo Tarbin
2026-03-24 17:04:25 -04:00
parent 92e8160505
commit 4ad8b1aef8
2 changed files with 34 additions and 44 deletions

View File

@@ -1,18 +1,23 @@
import { Add, HorizontalRule, Save } from '@mui/icons-material' import { Add, ArrowDropDown, HorizontalRule, Save } from '@mui/icons-material'
import { import {
Avatar, Avatar,
Box, Box,
Button, Button,
ButtonGroup,
Card, Card,
Checkbox, Checkbox,
Chip, Chip,
Container, Container,
Divider, Divider,
Dropdown,
FormControl, FormControl,
FormHelperText, FormHelperText,
IconButton,
Input, Input,
List, List,
ListItem, ListItem,
Menu,
MenuButton,
MenuItem, MenuItem,
Option, Option,
Radio, Radio,
@@ -1638,39 +1643,33 @@ const ChoreEdit = () => {
}} }}
> >
{choreId > 0 && ( {choreId > 0 && (
<> <Dropdown>
{isActive ? ( <ButtonGroup variant='outlined' color={isActive ? 'danger' : 'neutral'}>
<Button <Button
onClick={() => {
isActive
? archiveChore.mutate(choreId)
: unarchiveChore.mutate(choreId)
}}
>
{isActive ? 'Archive' : 'Unarchive'}
</Button>
<MenuButton
slots={{ root: IconButton }}
slotProps={{ root: { variant: 'outlined', color: isActive ? 'danger' : 'neutral' } }}
>
<ArrowDropDown />
</MenuButton>
</ButtonGroup>
<Menu placement='top-end'>
<MenuItem
color='danger' color='danger'
variant='outlined' onClick={handleDelete}
onClick={() => {
archiveChore.mutate(choreId)
}}
> >
Archive Delete
</Button> </MenuItem>
) : ( </Menu>
<Button </Dropdown>
color='neutral'
variant='outlined'
onClick={() => {
unarchiveChore.mutate(choreId)
}}
>
Unarchive
</Button>
)}
<Button
color='danger'
variant='solid'
onClick={() => {
// confirm before deleting:
handleDelete()
}}
>
Delete
</Button>
</>
)} )}
<Button <Button
color='neutral' color='neutral'

View File

@@ -671,7 +671,6 @@ const ChoreView = () => {
color='neutral' color='neutral'
variant='plain' variant='plain'
fullWidth fullWidth
disabled={chore.isActive === false}
onClick={() => { onClick={() => {
navigate(`/chores/${choreId}/history`) navigate(`/chores/${choreId}/history`)
}} }}
@@ -690,7 +689,6 @@ const ChoreView = () => {
color='neutral' color='neutral'
variant='plain' variant='plain'
fullWidth fullWidth
disabled={chore.isActive === false}
sx={{ sx={{
// top right of the card: // top right of the card:
flexDirection: 'column', flexDirection: 'column',
@@ -1016,9 +1014,7 @@ const ChoreView = () => {
size='lg' size='lg'
onClick={handleTaskCompletion} onClick={handleTaskCompletion}
disabled={ disabled={
notInCompletionWindow(chore) || notInCompletionWindow(chore) || chore.isActive === false
(chore.lastCompletedDate !== null &&
chore.frequencyType === 'once')
} }
color='success' color='success'
startDecorator={<Check />} startDecorator={<Check />}
@@ -1050,9 +1046,7 @@ const ChoreView = () => {
}) })
}} }}
disabled={ disabled={
notInCompletionWindow(chore) || notInCompletionWindow(chore) || chore.isActive === false
(chore.lastCompletedDate !== null &&
chore.frequencyType === 'once')
} }
startDecorator={<SwitchAccessShortcut />} startDecorator={<SwitchAccessShortcut />}
sx={{ sx={{
@@ -1081,8 +1075,7 @@ const ChoreView = () => {
disabled={ disabled={
(chore.status === ChoreStatus.PAUSED && (chore.status === ChoreStatus.PAUSED &&
notInCompletionWindow(chore)) || notInCompletionWindow(chore)) ||
(chore.lastCompletedDate !== null && chore.isActive === false
chore.frequencyType === 'once')
} }
chore={chore} chore={chore}
onAction={action => { onAction={action => {
@@ -1108,9 +1101,7 @@ const ChoreView = () => {
variant='soft' variant='soft'
color='success' color='success'
disabled={ disabled={
notInCompletionWindow(chore) || notInCompletionWindow(chore) || chore.isActive === false
(chore.lastCompletedDate !== null &&
chore.frequencyType === 'once')
} }
startDecorator={<PlayArrow />} startDecorator={<PlayArrow />}
sx={{ sx={{