Make sure the title respect upper and lower case
This commit is contained in:
commit
93dfd84fa1
1 changed files with 25 additions and 24 deletions
|
@ -1,4 +1,4 @@
|
||||||
import { KeyboardReturnOutlined, OpenInFull } from '@mui/icons-material'
|
import { KeyboardReturnOutlined } from '@mui/icons-material'
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
Button,
|
Button,
|
||||||
|
@ -116,8 +116,8 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => {
|
||||||
setTaskText('')
|
setTaskText('')
|
||||||
}
|
}
|
||||||
|
|
||||||
const parsePriority = sentence => {
|
const parsePriority = inputSentence => {
|
||||||
sentence = sentence.toLowerCase()
|
let sentence = inputSentence.toLowerCase()
|
||||||
const priorityMap = {
|
const priorityMap = {
|
||||||
1: ['p1', 'priority 1', 'high priority', 'urgent', 'asap', 'important'],
|
1: ['p1', 'priority 1', 'high priority', 'urgent', 'asap', 'important'],
|
||||||
2: ['p2', 'priority 2', 'medium priority'],
|
2: ['p2', 'priority 2', 'medium priority'],
|
||||||
|
@ -129,14 +129,18 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => {
|
||||||
if (terms.some(term => sentence.includes(term))) {
|
if (terms.some(term => sentence.includes(term))) {
|
||||||
return {
|
return {
|
||||||
result: priority,
|
result: priority,
|
||||||
cleanedSentence: terms.reduce((s, t) => s.replace(t, ''), sentence),
|
cleanedSentence: terms.reduce(
|
||||||
|
(s, t) => s.replace(t, ''),
|
||||||
|
inputSentence,
|
||||||
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { result: 0, cleanedSentence: sentence }
|
return { result: 0, cleanedSentence: inputSentence }
|
||||||
}
|
}
|
||||||
|
|
||||||
const parseRepeatV2 = sentence => {
|
const parseRepeatV2 = inputSentence => {
|
||||||
|
const sentence = inputSentence.toLowerCase()
|
||||||
const result = {
|
const result = {
|
||||||
frequency: 1,
|
frequency: 1,
|
||||||
frequencyType: null,
|
frequencyType: null,
|
||||||
|
@ -231,7 +235,7 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => {
|
||||||
return {
|
return {
|
||||||
result,
|
result,
|
||||||
name: pattern.name,
|
name: pattern.name,
|
||||||
cleanedSentence: sentence.replace(match[0], '').trim(),
|
cleanedSentence: inputSentence.replace(match[0], '').trim(),
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'interval':
|
case 'interval':
|
||||||
|
@ -242,7 +246,7 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => {
|
||||||
name: pattern.name
|
name: pattern.name
|
||||||
.replace('{frequency}', result.frequency)
|
.replace('{frequency}', result.frequency)
|
||||||
.replace('{unit}', result.frequencyMetadata.unit),
|
.replace('{unit}', result.frequencyMetadata.unit),
|
||||||
cleanedSentence: sentence.replace(match[0], '').trim(),
|
cleanedSentence: inputSentence.replace(match[0], '').trim(),
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'days_of_the_week':
|
case 'days_of_the_week':
|
||||||
|
@ -253,14 +257,14 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => {
|
||||||
.filter(day => VALID_DAYS[day])
|
.filter(day => VALID_DAYS[day])
|
||||||
.map(day => VALID_DAYS[day])
|
.map(day => VALID_DAYS[day])
|
||||||
if (!result.frequencyMetadata.days.length)
|
if (!result.frequencyMetadata.days.length)
|
||||||
return { result: null, name: null, cleanedSentence: sentence }
|
return { result: null, name: null, cleanedSentence: inputSentence }
|
||||||
return {
|
return {
|
||||||
result,
|
result,
|
||||||
name: pattern.name.replace(
|
name: pattern.name.replace(
|
||||||
'{days}',
|
'{days}',
|
||||||
result.frequencyMetadata.days.join(', '),
|
result.frequencyMetadata.days.join(', '),
|
||||||
),
|
),
|
||||||
cleanedSentence: sentence.replace(match[0], '').trim(),
|
cleanedSentence: inputSentence.replace(match[0], '').trim(),
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'day_of_the_month':
|
case 'day_of_the_month':
|
||||||
|
@ -277,7 +281,7 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => {
|
||||||
name: pattern.name
|
name: pattern.name
|
||||||
.replace('{day}', result.frequency)
|
.replace('{day}', result.frequency)
|
||||||
.replace('{months}', result.frequencyMetadata.months.join(', ')),
|
.replace('{months}', result.frequencyMetadata.months.join(', ')),
|
||||||
cleanedSentence: sentence.replace(match[0], '').trim(),
|
cleanedSentence: inputSentence.replace(match[0], '').trim(),
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'interval:every_other':
|
case 'interval:every_other':
|
||||||
|
@ -288,7 +292,7 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => {
|
||||||
return {
|
return {
|
||||||
result,
|
result,
|
||||||
name: pattern.name,
|
name: pattern.name,
|
||||||
cleanedSentence: sentence.replace(match[0], '').trim(),
|
cleanedSentence: inputSentence.replace(match[0], '').trim(),
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'day_of_the_month:every':
|
case 'day_of_the_month:every':
|
||||||
|
@ -300,11 +304,11 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => {
|
||||||
name: pattern.name
|
name: pattern.name
|
||||||
.replace('{day}', result.frequency)
|
.replace('{day}', result.frequency)
|
||||||
.replace('{months}', result.frequencyMetadata.months.join(', ')),
|
.replace('{months}', result.frequencyMetadata.months.join(', ')),
|
||||||
cleanedSentence: sentence.replace(match[0], '').trim(),
|
cleanedSentence: inputSentence.replace(match[0], '').trim(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return { result: null, name: null, cleanedSentence: sentence }
|
return { result: null, name: null, cleanedSentence: inputSentence }
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleTextChange = e => {
|
const handleTextChange = e => {
|
||||||
|
@ -410,22 +414,19 @@ const TaskInput = ({ autoFocus, onChoreUpdate }) => {
|
||||||
|
|
||||||
<Modal open={openModal} onClose={handleCloseModal}>
|
<Modal open={openModal} onClose={handleCloseModal}>
|
||||||
<ModalDialog>
|
<ModalDialog>
|
||||||
<Button
|
{/* <Button
|
||||||
size='sm'
|
size='sm'
|
||||||
onClick={() => navigate(`/chores/create`)}
|
onClick={() => navigate(`/chores/create`)}
|
||||||
variant='outlined'
|
variant='outlined'
|
||||||
sx={{ position: 'absolute', right: 20 }}
|
sx={{ position: 'absolute', right: 20 }}
|
||||||
startDecorator={<OpenInFull />}
|
startDecorator={<OpenInFull />}
|
||||||
>
|
>
|
||||||
Advance Mode
|
Full Editor
|
||||||
</Button>
|
</Button> */}
|
||||||
<Typography level='h4'>
|
<Typography level='h4'>Create new task</Typography>
|
||||||
Create new task
|
|
||||||
<Chip startDecorator='🚧' variant='soft' color='warning' size='sm'>
|
<Chip startDecorator='🚧' variant='soft' color='warning' size='sm'>
|
||||||
Experimental
|
Experimental
|
||||||
</Chip>
|
</Chip>
|
||||||
</Typography>
|
|
||||||
|
|
||||||
<Box>
|
<Box>
|
||||||
<Typography level='body-sm'>Task in a sentence:</Typography>
|
<Typography level='body-sm'>Task in a sentence:</Typography>
|
||||||
<Input
|
<Input
|
||||||
|
|
Loading…
Add table
Reference in a new issue