diff --git a/src/widgets/RRule.tsx b/src/widgets/RRule.tsx
index 6c9034e..aa85190 100644
--- a/src/widgets/RRule.tsx
+++ b/src/widgets/RRule.tsx
@@ -2,33 +2,29 @@ import * as React from 'react';
import { TextField, Select, MenuItem, FormGroup, FormControlLabel, Checkbox, InputLabel, FormControl } from '@material-ui/core';
import DateTimePicker from '../widgets/DateTimePicker';
import { isNumber } from 'util';
+import * as ICAL from 'ical.js';
interface PropsType {
onChange: (rrule: RRuleOptions) => void;
rrule: RRuleOptions;
}
+type Frequency = 'YEARLY' | 'MONTHLY' | 'WEEKLY' | 'DAILY' | 'HOURLY' | 'MINUTELY' | 'SECONDLY';
+
export interface RRuleOptions {
freq: Frequency;
- interval: number;
- until?: Date;
+ interval?: number;
+ wkst?: WeekDay;
+ until?: ICAL.Time;
count?: number;
- byweekday?: Weekday[];
- bymonthday?: number;
- byyearday?: number;
- byweekno?: number;
- bymonth?: Months;
- bysetpos?: number;
- wkst?: Weekday;
bysecond?: number[];
byminute?: number[];
+ byhour?: number[];
byday?: number[];
-
-}
-enum Frequency {
- YEARLY,
- MONTHLY,
- WEEKLY,
- DAILY,
+ bymonthday?: number[];
+ byyearday?: number[];
+ byweekno?: number[];
+ bymonth?: number[];
+ bysetpos?: number[];
}
enum Ends {
Never,
@@ -53,14 +49,14 @@ enum MonthRepeat {
Bysetpos,
Bymonthday,
}
-enum Weekday {
+enum WeekDay {
+ Su = 1,
Mo,
Tu,
We,
Th,
Fr,
Sa,
- Su
}
const menuItemsMonths = Object.keys(Months).filter((key) => Number(key)).map((key) => {
@@ -73,10 +69,10 @@ const menuItemsEnds = [Ends.Never, Ends.Date, Ends.After].map((key) => {
);
});
-const weekdays = [Weekday.Mo, Weekday.Tu, Weekday.We, Weekday.Th, Weekday.Fr, Weekday.Sa, Weekday.Su];
-const menuItemsFrequency = [Frequency.YEARLY, Frequency.MONTHLY, Frequency.WEEKLY, Frequency.DAILY].map((value) => {
+const weekdays = [WeekDay.Su, WeekDay.Mo, WeekDay.Tu, WeekDay.We, WeekDay.Th, WeekDay.Fr, WeekDay.Sa];
+const menuItemsFrequency = ['YEARLY', 'MONTHLY', 'WEEKLY', 'DAILY'].map((value) => {
return (
-
+
);
});
@@ -101,7 +97,7 @@ export default function RRuleEteSync(props: PropsType) {
function handleCheckboxWeekday(event: React.FormEvent<{ value: unknown }>): void {
const checkbox = event.target as HTMLInputElement;
const weekday = Number(checkbox.value);
- let byweekdayArray = options.byweekday as Weekday[];
+ let byweekdayArray = options.byday as WeekDay[];
let byweekday;
if (!checkbox.checked && byweekdayArray) {
byweekday = byweekdayArray.filter((day) => day !== weekday);
@@ -111,30 +107,29 @@ export default function RRuleEteSync(props: PropsType) {
} else {
byweekday = [weekday];
}
- updateRule({ byweekday: byweekday });
+ updateRule({ byday: byweekday });
}
function isWeekdayChecked(day: number): boolean {
- const weekdayArray = options.byweekday;
- if (weekdayArray) {
- return isNumber(weekdayArray.find((value) => Weekday[value] === Weekday[day]));
+ if (options.byday) {
+ return isNumber(options.byday.find((value) => WeekDay[value] === WeekDay[day]));
} else {
return false;
}
}
- const checkboxWeekDays = weekdays.map((_, index) => {
+ const checkboxWeekDays = weekdays.map((day) => {
return (