Add description field to ChoreEdit form and Choreview
This commit is contained in:
parent
56f66e9e8f
commit
2d4fb2b163
3 changed files with 77 additions and 1 deletions
|
@ -22,6 +22,7 @@ import {
|
||||||
Snackbar,
|
Snackbar,
|
||||||
Stack,
|
Stack,
|
||||||
Switch,
|
Switch,
|
||||||
|
Textarea,
|
||||||
Typography,
|
Typography,
|
||||||
} from '@mui/joy'
|
} from '@mui/joy'
|
||||||
import moment from 'moment'
|
import moment from 'moment'
|
||||||
|
@ -61,6 +62,7 @@ const ChoreEdit = () => {
|
||||||
const [userHistory, setUserHistory] = useState({})
|
const [userHistory, setUserHistory] = useState({})
|
||||||
const { choreId } = useParams()
|
const { choreId } = useParams()
|
||||||
const [name, setName] = useState('')
|
const [name, setName] = useState('')
|
||||||
|
const [description, setDescription] = useState('')
|
||||||
const [confirmModelConfig, setConfirmModelConfig] = useState({})
|
const [confirmModelConfig, setConfirmModelConfig] = useState({})
|
||||||
const [assignees, setAssignees] = useState([])
|
const [assignees, setAssignees] = useState([])
|
||||||
const [performers, setPerformers] = useState([])
|
const [performers, setPerformers] = useState([])
|
||||||
|
@ -186,6 +188,7 @@ const ChoreEdit = () => {
|
||||||
const chore = {
|
const chore = {
|
||||||
id: Number(choreId),
|
id: Number(choreId),
|
||||||
name: name,
|
name: name,
|
||||||
|
description: description,
|
||||||
assignees: assignees,
|
assignees: assignees,
|
||||||
dueDate: dueDate ? new Date(dueDate).toISOString() : null,
|
dueDate: dueDate ? new Date(dueDate).toISOString() : null,
|
||||||
frequencyType: frequencyType,
|
frequencyType: frequencyType,
|
||||||
|
@ -241,6 +244,7 @@ const ChoreEdit = () => {
|
||||||
.then(data => {
|
.then(data => {
|
||||||
setChore(data.res)
|
setChore(data.res)
|
||||||
setName(data.res.name ? data.res.name : '')
|
setName(data.res.name ? data.res.name : '')
|
||||||
|
setDescription(data.res.description ? data.res.description : '')
|
||||||
setAssignees(data.res.assignees ? data.res.assignees : [])
|
setAssignees(data.res.assignees ? data.res.assignees : [])
|
||||||
setAssignedTo(data.res.assignedTo)
|
setAssignedTo(data.res.assignedTo)
|
||||||
setFrequencyType(
|
setFrequencyType(
|
||||||
|
@ -379,11 +383,22 @@ const ChoreEdit = () => {
|
||||||
<Box>
|
<Box>
|
||||||
<FormControl error={errors.name}>
|
<FormControl error={errors.name}>
|
||||||
<Typography level='h4'>Title :</Typography>
|
<Typography level='h4'>Title :</Typography>
|
||||||
<Typography level='h5'>What is this chore about?</Typography>
|
<Typography level='h5'> What is the name of this chore?</Typography>
|
||||||
<Input value={name} onChange={e => setName(e.target.value)} />
|
<Input value={name} onChange={e => setName(e.target.value)} />
|
||||||
<FormHelperText error>{errors.name}</FormHelperText>
|
<FormHelperText error>{errors.name}</FormHelperText>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Box>
|
</Box>
|
||||||
|
<Box mt={2}>
|
||||||
|
<FormControl error={errors.description}>
|
||||||
|
<Typography level='h4'>Details:</Typography>
|
||||||
|
<Typography level='h5'>What is this chore about?</Typography>
|
||||||
|
<Textarea
|
||||||
|
value={description}
|
||||||
|
onChange={e => setDescription(e.target.value)}
|
||||||
|
/>
|
||||||
|
<FormHelperText error>{errors.name}</FormHelperText>
|
||||||
|
</FormControl>
|
||||||
|
</Box>
|
||||||
<Box mt={2}>
|
<Box mt={2}>
|
||||||
<Typography level='h4'>Assignees :</Typography>
|
<Typography level='h4'>Assignees :</Typography>
|
||||||
<Typography level='h5'>Who can do this chore?</Typography>
|
<Typography level='h5'>Who can do this chore?</Typography>
|
||||||
|
|
|
@ -3,9 +3,11 @@ import {
|
||||||
CancelScheduleSend,
|
CancelScheduleSend,
|
||||||
Check,
|
Check,
|
||||||
Checklist,
|
Checklist,
|
||||||
|
CloseFullscreen,
|
||||||
Edit,
|
Edit,
|
||||||
History,
|
History,
|
||||||
LowPriority,
|
LowPriority,
|
||||||
|
OpenInFull,
|
||||||
PeopleAlt,
|
PeopleAlt,
|
||||||
Person,
|
Person,
|
||||||
SwitchAccessShortcut,
|
SwitchAccessShortcut,
|
||||||
|
@ -21,6 +23,7 @@ import {
|
||||||
Dropdown,
|
Dropdown,
|
||||||
FormControl,
|
FormControl,
|
||||||
Grid,
|
Grid,
|
||||||
|
IconButton,
|
||||||
Input,
|
Input,
|
||||||
ListItem,
|
ListItem,
|
||||||
ListItemContent,
|
ListItemContent,
|
||||||
|
@ -74,6 +77,7 @@ const ChoreView = () => {
|
||||||
const [completedDate, setCompletedDate] = useState(null)
|
const [completedDate, setCompletedDate] = useState(null)
|
||||||
const [confirmModelConfig, setConfirmModelConfig] = useState({})
|
const [confirmModelConfig, setConfirmModelConfig] = useState({})
|
||||||
const [chorePriority, setChorePriority] = useState(null)
|
const [chorePriority, setChorePriority] = useState(null)
|
||||||
|
const [isDescriptionOpen, setIsDescriptionOpen] = useState(false)
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
GetChoreDetailById(choreId).then(resp => {
|
GetChoreDetailById(choreId).then(resp => {
|
||||||
|
@ -420,6 +424,47 @@ const ChoreView = () => {
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
|
|
||||||
|
{chore.description && (
|
||||||
|
<>
|
||||||
|
<Typography level='title-md' sx={{ mb: 1 }}>
|
||||||
|
Description :
|
||||||
|
</Typography>
|
||||||
|
|
||||||
|
<Sheet
|
||||||
|
variant='outlined'
|
||||||
|
sx={{
|
||||||
|
p: 2,
|
||||||
|
borderRadius: 'lg',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<IconButton
|
||||||
|
variant='plain'
|
||||||
|
onClick={() => {
|
||||||
|
setIsDescriptionOpen(!isDescriptionOpen)
|
||||||
|
}}
|
||||||
|
size='sm'
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
bottom: 5,
|
||||||
|
right: 5,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{isDescriptionOpen ? <CloseFullscreen /> : <OpenInFull />}
|
||||||
|
</IconButton>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
maxHeight: isDescriptionOpen ? 'none' : '100px',
|
||||||
|
overflowY: 'auto',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography level='body-md' sx={{ mb: 1 }}>
|
||||||
|
{chore.description || '--'}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Sheet>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
{chore.notes && (
|
{chore.notes && (
|
||||||
<>
|
<>
|
||||||
<Typography level='title-md' sx={{ mb: 1 }}>
|
<Typography level='title-md' sx={{ mb: 1 }}>
|
||||||
|
|
|
@ -195,6 +195,11 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => {
|
||||||
regex: /(every day|daily)$/i,
|
regex: /(every day|daily)$/i,
|
||||||
name: 'Every day',
|
name: 'Every day',
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
frequencyType: 'daily:time',
|
||||||
|
regex: /every (morning|noon|afternoon|evening|night)$/i,
|
||||||
|
name: 'Every {time} daily',
|
||||||
|
},
|
||||||
{
|
{
|
||||||
frequencyType: 'weekly',
|
frequencyType: 'weekly',
|
||||||
regex: /(every week|weekly)$/i,
|
regex: /(every week|weekly)$/i,
|
||||||
|
@ -324,6 +329,17 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => {
|
||||||
name: pattern.name,
|
name: pattern.name,
|
||||||
cleanedSentence: inputSentence.replace(match[0], '').trim(),
|
cleanedSentence: inputSentence.replace(match[0], '').trim(),
|
||||||
}
|
}
|
||||||
|
case 'daily:time':
|
||||||
|
result.frequency = 1
|
||||||
|
result.frequencyMetadata.unit = 'days'
|
||||||
|
result.frequencyType = 'daily'
|
||||||
|
return {
|
||||||
|
result,
|
||||||
|
name: pattern.name.replace('{time}', match[1]),
|
||||||
|
// replace every x with ''
|
||||||
|
|
||||||
|
cleanedSentence: inputSentence.replace(match[0], '').trim(),
|
||||||
|
}
|
||||||
|
|
||||||
case 'day_of_the_month:every':
|
case 'day_of_the_month:every':
|
||||||
result.frequency = parseInt(match[1], 10)
|
result.frequency = parseInt(match[1], 10)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue