Fix Frequance Field not accepting 01 and zero prefix
Fix #38 Labels on task not working with other user in circle
This commit is contained in:
commit
8adf555c05
3 changed files with 106 additions and 50 deletions
|
@ -113,8 +113,8 @@ const ChoreEdit = () => {
|
||||||
if (assignedTo < 0) {
|
if (assignedTo < 0) {
|
||||||
errors.assignedTo = 'Assigned to is required'
|
errors.assignedTo = 'Assigned to is required'
|
||||||
}
|
}
|
||||||
if (frequencyType === 'interval' && frequency < 1) {
|
if (frequencyType === 'interval' && !frequency > 0) {
|
||||||
errors.frequency = 'Frequency is required'
|
errors.frequency = `Invalid frequency, the ${frequencyMetadata.unit} should be > 0`
|
||||||
}
|
}
|
||||||
if (
|
if (
|
||||||
frequencyType === 'days_of_the_week' &&
|
frequencyType === 'days_of_the_week' &&
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import {
|
import {
|
||||||
Box,
|
Box,
|
||||||
|
Button,
|
||||||
Card,
|
Card,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
Chip,
|
Chip,
|
||||||
|
@ -53,6 +54,30 @@ const MONTH_WITH_NO_31_DAYS = [
|
||||||
'september',
|
'september',
|
||||||
'november',
|
'november',
|
||||||
]
|
]
|
||||||
|
const MONTHS = [
|
||||||
|
'january',
|
||||||
|
'february',
|
||||||
|
'march',
|
||||||
|
'april',
|
||||||
|
'may',
|
||||||
|
'june',
|
||||||
|
'july',
|
||||||
|
'august',
|
||||||
|
'september',
|
||||||
|
'october',
|
||||||
|
'november',
|
||||||
|
'december',
|
||||||
|
]
|
||||||
|
|
||||||
|
const DAYS = [
|
||||||
|
'monday',
|
||||||
|
'tuesday',
|
||||||
|
'wednesday',
|
||||||
|
'thursday',
|
||||||
|
'friday',
|
||||||
|
'saturday',
|
||||||
|
'sunday',
|
||||||
|
]
|
||||||
const RepeatOnSections = ({
|
const RepeatOnSections = ({
|
||||||
frequencyType,
|
frequencyType,
|
||||||
frequency,
|
frequency,
|
||||||
|
@ -99,12 +124,15 @@ const RepeatOnSections = ({
|
||||||
<Grid item sm={12} sx={{ display: 'flex', alignItems: 'center' }}>
|
<Grid item sm={12} sx={{ display: 'flex', alignItems: 'center' }}>
|
||||||
<Typography level='h5'>Every: </Typography>
|
<Typography level='h5'>Every: </Typography>
|
||||||
<Input
|
<Input
|
||||||
|
slotProps={{
|
||||||
|
input: {
|
||||||
|
min: 1,
|
||||||
|
max: 1000,
|
||||||
|
},
|
||||||
|
}}
|
||||||
type='number'
|
type='number'
|
||||||
value={frequency}
|
value={frequency}
|
||||||
onChange={e => {
|
onChange={e => {
|
||||||
if (e.target.value < 1) {
|
|
||||||
e.target.value = 1
|
|
||||||
}
|
|
||||||
onFrequencyUpdate(e.target.value)
|
onFrequencyUpdate(e.target.value)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
@ -142,19 +170,9 @@ const RepeatOnSections = ({
|
||||||
'--ListItem-radius': '20px',
|
'--ListItem-radius': '20px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{[
|
{DAYS.map(item => (
|
||||||
'monday',
|
|
||||||
'tuesday',
|
|
||||||
'wednesday',
|
|
||||||
'thursday',
|
|
||||||
'friday',
|
|
||||||
'saturday',
|
|
||||||
'sunday',
|
|
||||||
].map(item => (
|
|
||||||
<ListItem key={item}>
|
<ListItem key={item}>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
// disabled={index === 0}
|
|
||||||
|
|
||||||
checked={frequencyMetadata?.days?.includes(item) || false}
|
checked={frequencyMetadata?.days?.includes(item) || false}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const newDaysOfTheWeek = frequencyMetadata['days'] || []
|
const newDaysOfTheWeek = frequencyMetadata['days'] || []
|
||||||
|
@ -180,6 +198,31 @@ const RepeatOnSections = ({
|
||||||
</ListItem>
|
</ListItem>
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
|
<Button
|
||||||
|
size='sm'
|
||||||
|
variant='soft'
|
||||||
|
color='neutral'
|
||||||
|
checked={frequencyMetadata?.days?.length === 7}
|
||||||
|
onClick={() => {
|
||||||
|
if (frequencyMetadata?.days?.length === 7) {
|
||||||
|
onFrequencyMetadataUpdate({
|
||||||
|
...frequencyMetadata,
|
||||||
|
days: [],
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
onFrequencyMetadataUpdate({
|
||||||
|
...frequencyMetadata,
|
||||||
|
days: DAYS.map(item => item),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
overlay
|
||||||
|
disableIcon
|
||||||
|
>
|
||||||
|
{frequencyMetadata?.days?.length === 7
|
||||||
|
? 'Unselect All'
|
||||||
|
: 'Select All'}
|
||||||
|
</Button>
|
||||||
</Card>
|
</Card>
|
||||||
</Grid>
|
</Grid>
|
||||||
{timePickerComponent}
|
{timePickerComponent}
|
||||||
|
@ -207,35 +250,10 @@ const RepeatOnSections = ({
|
||||||
'--ListItem-radius': '20px',
|
'--ListItem-radius': '20px',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{[
|
{MONTHS.map(item => (
|
||||||
'january',
|
|
||||||
'february',
|
|
||||||
'march',
|
|
||||||
'april',
|
|
||||||
'may',
|
|
||||||
'june',
|
|
||||||
'july',
|
|
||||||
'august',
|
|
||||||
'september',
|
|
||||||
'october',
|
|
||||||
'november',
|
|
||||||
'december',
|
|
||||||
].map(item => (
|
|
||||||
<ListItem key={item}>
|
<ListItem key={item}>
|
||||||
<Checkbox
|
<Checkbox
|
||||||
// disabled={index === 0}
|
|
||||||
checked={frequencyMetadata?.months?.includes(item)}
|
checked={frequencyMetadata?.months?.includes(item)}
|
||||||
// checked={months[item] || false}
|
|
||||||
// onClick={() => {
|
|
||||||
// const newMonthsOfTheYear = {
|
|
||||||
// ...monthsOfTheYear,
|
|
||||||
// }
|
|
||||||
// newMonthsOfTheYear[item] = !newMonthsOfTheYear[item]
|
|
||||||
// onFrequencyMetadataUpdate({
|
|
||||||
// months: newMonthsOfTheYear,
|
|
||||||
// })
|
|
||||||
// setMonthsOfTheYear(newMonthsOfTheYear)
|
|
||||||
// }}
|
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const newMonthsOfTheYear =
|
const newMonthsOfTheYear =
|
||||||
frequencyMetadata['months'] || []
|
frequencyMetadata['months'] || []
|
||||||
|
@ -263,6 +281,31 @@ const RepeatOnSections = ({
|
||||||
</ListItem>
|
</ListItem>
|
||||||
))}
|
))}
|
||||||
</List>
|
</List>
|
||||||
|
<Button
|
||||||
|
size='sm'
|
||||||
|
variant='soft'
|
||||||
|
color='neutral'
|
||||||
|
checked={frequencyMetadata?.months?.length === 12}
|
||||||
|
onClick={() => {
|
||||||
|
if (frequencyMetadata?.months?.length === 12) {
|
||||||
|
onFrequencyMetadataUpdate({
|
||||||
|
...frequencyMetadata,
|
||||||
|
months: [],
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
onFrequencyMetadataUpdate({
|
||||||
|
...frequencyMetadata,
|
||||||
|
months: MONTHS.map(item => item),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
overlay
|
||||||
|
disableIcon
|
||||||
|
>
|
||||||
|
{frequencyMetadata?.months?.length === 12
|
||||||
|
? 'Unselect All'
|
||||||
|
: 'Select All'}
|
||||||
|
</Button>
|
||||||
</Card>
|
</Card>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Box
|
<Box
|
||||||
|
|
|
@ -128,14 +128,13 @@ const MyChores = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleLabelFiltering = chipClicked => {
|
const handleLabelFiltering = chipClicked => {
|
||||||
console.log('chipClicked', chipClicked)
|
|
||||||
|
|
||||||
if (chipClicked.label) {
|
if (chipClicked.label) {
|
||||||
const label = chipClicked.label
|
const label = chipClicked.label
|
||||||
const labelFiltered = [...chores].filter(chore =>
|
const labelFiltered = [...chores].filter(chore =>
|
||||||
chore.labelsV2.some(l => l.id === label.id),
|
chore.labelsV2.some(
|
||||||
|
l => l.id === label.id && l.created_by === label.created_by,
|
||||||
|
),
|
||||||
)
|
)
|
||||||
console.log('labelFiltered', labelFiltered)
|
|
||||||
setFilteredChores(labelFiltered)
|
setFilteredChores(labelFiltered)
|
||||||
setSelectedFilter('Label: ' + label.name)
|
setSelectedFilter('Label: ' + label.name)
|
||||||
} else if (chipClicked.priority) {
|
} else if (chipClicked.priority) {
|
||||||
|
@ -200,9 +199,7 @@ const MyChores = () => {
|
||||||
const fuse = new Fuse(
|
const fuse = new Fuse(
|
||||||
chores.map(c => ({
|
chores.map(c => ({
|
||||||
...c,
|
...c,
|
||||||
raw_label: c.labelsV2
|
raw_label: c.labelsV2.map(c => c.name).join(' '),
|
||||||
.map(l => userLabels.find(x => x.id === l.id).name)
|
|
||||||
.join(' '),
|
|
||||||
})),
|
})),
|
||||||
searchOptions,
|
searchOptions,
|
||||||
)
|
)
|
||||||
|
@ -287,7 +284,23 @@ const MyChores = () => {
|
||||||
<IconButtonWithMenu
|
<IconButtonWithMenu
|
||||||
key={'icon-menu-labels-filter'}
|
key={'icon-menu-labels-filter'}
|
||||||
icon={<Style />}
|
icon={<Style />}
|
||||||
options={userLabels}
|
// TODO : this need simplification we want to display both user labels and chore labels
|
||||||
|
// that why we are merging them here.
|
||||||
|
// we also filter out the labels that user created as those will be part of user labels
|
||||||
|
options={[
|
||||||
|
...userLabels,
|
||||||
|
...chores
|
||||||
|
.map(c => c.labelsV2)
|
||||||
|
.flat()
|
||||||
|
.filter(l => l.created_by !== userProfile.id)
|
||||||
|
.map(l => {
|
||||||
|
// if user created it don't show it:
|
||||||
|
return {
|
||||||
|
...l,
|
||||||
|
name: l.name + ' (Shared Label)',
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
]}
|
||||||
selectedItem={selectedFilter}
|
selectedItem={selectedFilter}
|
||||||
onItemSelect={selected => {
|
onItemSelect={selected => {
|
||||||
handleLabelFiltering({ label: selected })
|
handleLabelFiltering({ label: selected })
|
||||||
|
|
Loading…
Add table
Reference in a new issue