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) {
|
||||
errors.assignedTo = 'Assigned to is required'
|
||||
}
|
||||
if (frequencyType === 'interval' && frequency < 1) {
|
||||
errors.frequency = 'Frequency is required'
|
||||
if (frequencyType === 'interval' && !frequency > 0) {
|
||||
errors.frequency = `Invalid frequency, the ${frequencyMetadata.unit} should be > 0`
|
||||
}
|
||||
if (
|
||||
frequencyType === 'days_of_the_week' &&
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import {
|
||||
Box,
|
||||
Button,
|
||||
Card,
|
||||
Checkbox,
|
||||
Chip,
|
||||
|
@ -53,6 +54,30 @@ const MONTH_WITH_NO_31_DAYS = [
|
|||
'september',
|
||||
'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 = ({
|
||||
frequencyType,
|
||||
frequency,
|
||||
|
@ -99,12 +124,15 @@ const RepeatOnSections = ({
|
|||
<Grid item sm={12} sx={{ display: 'flex', alignItems: 'center' }}>
|
||||
<Typography level='h5'>Every: </Typography>
|
||||
<Input
|
||||
slotProps={{
|
||||
input: {
|
||||
min: 1,
|
||||
max: 1000,
|
||||
},
|
||||
}}
|
||||
type='number'
|
||||
value={frequency}
|
||||
onChange={e => {
|
||||
if (e.target.value < 1) {
|
||||
e.target.value = 1
|
||||
}
|
||||
onFrequencyUpdate(e.target.value)
|
||||
}}
|
||||
/>
|
||||
|
@ -142,19 +170,9 @@ const RepeatOnSections = ({
|
|||
'--ListItem-radius': '20px',
|
||||
}}
|
||||
>
|
||||
{[
|
||||
'monday',
|
||||
'tuesday',
|
||||
'wednesday',
|
||||
'thursday',
|
||||
'friday',
|
||||
'saturday',
|
||||
'sunday',
|
||||
].map(item => (
|
||||
{DAYS.map(item => (
|
||||
<ListItem key={item}>
|
||||
<Checkbox
|
||||
// disabled={index === 0}
|
||||
|
||||
checked={frequencyMetadata?.days?.includes(item) || false}
|
||||
onClick={() => {
|
||||
const newDaysOfTheWeek = frequencyMetadata['days'] || []
|
||||
|
@ -180,6 +198,31 @@ const RepeatOnSections = ({
|
|||
</ListItem>
|
||||
))}
|
||||
</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>
|
||||
</Grid>
|
||||
{timePickerComponent}
|
||||
|
@ -207,35 +250,10 @@ const RepeatOnSections = ({
|
|||
'--ListItem-radius': '20px',
|
||||
}}
|
||||
>
|
||||
{[
|
||||
'january',
|
||||
'february',
|
||||
'march',
|
||||
'april',
|
||||
'may',
|
||||
'june',
|
||||
'july',
|
||||
'august',
|
||||
'september',
|
||||
'october',
|
||||
'november',
|
||||
'december',
|
||||
].map(item => (
|
||||
{MONTHS.map(item => (
|
||||
<ListItem key={item}>
|
||||
<Checkbox
|
||||
// disabled={index === 0}
|
||||
checked={frequencyMetadata?.months?.includes(item)}
|
||||
// checked={months[item] || false}
|
||||
// onClick={() => {
|
||||
// const newMonthsOfTheYear = {
|
||||
// ...monthsOfTheYear,
|
||||
// }
|
||||
// newMonthsOfTheYear[item] = !newMonthsOfTheYear[item]
|
||||
// onFrequencyMetadataUpdate({
|
||||
// months: newMonthsOfTheYear,
|
||||
// })
|
||||
// setMonthsOfTheYear(newMonthsOfTheYear)
|
||||
// }}
|
||||
onClick={() => {
|
||||
const newMonthsOfTheYear =
|
||||
frequencyMetadata['months'] || []
|
||||
|
@ -263,6 +281,31 @@ const RepeatOnSections = ({
|
|||
</ListItem>
|
||||
))}
|
||||
</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>
|
||||
</Grid>
|
||||
<Box
|
||||
|
|
|
@ -128,14 +128,13 @@ const MyChores = () => {
|
|||
}
|
||||
|
||||
const handleLabelFiltering = chipClicked => {
|
||||
console.log('chipClicked', chipClicked)
|
||||
|
||||
if (chipClicked.label) {
|
||||
const label = chipClicked.label
|
||||
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)
|
||||
setSelectedFilter('Label: ' + label.name)
|
||||
} else if (chipClicked.priority) {
|
||||
|
@ -200,9 +199,7 @@ const MyChores = () => {
|
|||
const fuse = new Fuse(
|
||||
chores.map(c => ({
|
||||
...c,
|
||||
raw_label: c.labelsV2
|
||||
.map(l => userLabels.find(x => x.id === l.id).name)
|
||||
.join(' '),
|
||||
raw_label: c.labelsV2.map(c => c.name).join(' '),
|
||||
})),
|
||||
searchOptions,
|
||||
)
|
||||
|
@ -287,7 +284,23 @@ const MyChores = () => {
|
|||
<IconButtonWithMenu
|
||||
key={'icon-menu-labels-filter'}
|
||||
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}
|
||||
onItemSelect={selected => {
|
||||
handleLabelFiltering({ label: selected })
|
||||
|
|
Loading…
Add table
Reference in a new issue