fix: Handle invalid frequency in ChoreEdit component
This commit is contained in:
parent
e78008baea
commit
cdf90ff582
2 changed files with 8 additions and 5 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' &&
|
||||||
|
|
|
@ -124,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)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
Loading…
Add table
Reference in a new issue