-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* save button * release notes * custom component shows * custom input and saving working * updated getUpcomingDays to handle custom values * close modal after save * test around getUpcomingDays * updated to use more accurate timespan calculation * fix for scheduled events only occurring till end of period * add a day * fixed input step down
- Loading branch information
1 parent
1f5e5d4
commit f09f4af
Showing
5 changed files
with
170 additions
and
6 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
packages/desktop-client/src/components/schedules/CustomUpcomingLength.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { useEffect, useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { Input } from '../common/Input'; | ||
import { Select } from '../common/Select'; | ||
|
||
type CustomUpcomingLengthProps = { | ||
onChange: (value: string) => void; | ||
tempValue: string; | ||
}; | ||
|
||
export function CustomUpcomingLength({ | ||
onChange, | ||
tempValue, | ||
}: CustomUpcomingLengthProps) { | ||
const { t } = useTranslation(); | ||
|
||
const options = [ | ||
{ value: 'day', label: t('Days') }, | ||
{ value: 'week', label: t('Weeks') }, | ||
{ value: 'month', label: t('Months') }, | ||
{ value: 'year', label: t('Years') }, | ||
]; | ||
|
||
let timePeriod = []; | ||
if (tempValue === 'custom') { | ||
timePeriod = ['1', 'day']; | ||
} else { | ||
timePeriod = tempValue.split('-'); | ||
} | ||
|
||
const [numValue, setNumValue] = useState(parseInt(timePeriod[0])); | ||
const [unit, setUnit] = useState(timePeriod[1]); | ||
|
||
useEffect(() => { | ||
onChange(`${numValue}-${unit}`); | ||
}, [numValue, onChange, unit]); | ||
|
||
return ( | ||
<div | ||
style={{ display: 'flex', alignItems: 'center', gap: 5, marginTop: 10 }} | ||
> | ||
<Input | ||
id="length" | ||
style={{ width: 40 }} | ||
type="number" | ||
min={1} | ||
onChange={e => setNumValue(parseInt(e.target.value))} | ||
defaultValue={numValue || 1} | ||
/> | ||
<Select | ||
options={options.map(x => [x.value, x.label])} | ||
value={unit} | ||
onChange={newValue => setUnit(newValue)} | ||
/> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
category: Features | ||
authors: [ SamBobBarnes ] | ||
--- | ||
|
||
Add option for custom upcoming length |