forked from PalisadoesFoundation/talawa-admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
restructure and modularize for better readability
- Loading branch information
Showing
6 changed files
with
126 additions
and
117 deletions.
There are no files selected for viewing
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,3 @@ | ||
export * from './recurrenceTypes'; | ||
export * from './recurrenceConstants'; | ||
export * from './recurrenceUtilityFunctions'; |
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,63 @@ | ||
/* | ||
Recurrence constants | ||
*/ | ||
|
||
import { RecurrenceEndOption, WeekDays } from './recurrenceTypes'; | ||
|
||
// recurrence days options to select from in the UI | ||
export const daysOptions = ['S', 'M', 'T', 'W', 'T', 'F', 'S']; | ||
|
||
// recurrence days array | ||
export const Days = [ | ||
WeekDays.SU, | ||
WeekDays.MO, | ||
WeekDays.TU, | ||
WeekDays.WE, | ||
WeekDays.TH, | ||
WeekDays.FR, | ||
WeekDays.SA, | ||
]; | ||
|
||
// recurrence end options array | ||
export const recurrenceEndOptions = [ | ||
RecurrenceEndOption.never, | ||
RecurrenceEndOption.on, | ||
RecurrenceEndOption.after, | ||
]; | ||
|
||
// constants for recurrence end options | ||
export const endsNever = RecurrenceEndOption.never; | ||
export const endsOn = RecurrenceEndOption.on; | ||
export const endsAfter = RecurrenceEndOption.after; | ||
|
||
// array of week days containing 'MO' to 'FR | ||
export const mondayToFriday = Days.filter( | ||
(day) => day !== WeekDays.SA && day !== WeekDays.SU, | ||
); | ||
|
||
// names of week days | ||
export const dayNames = { | ||
[WeekDays.SU]: 'Sunday', | ||
[WeekDays.MO]: 'Monday', | ||
[WeekDays.TU]: 'Tuesday', | ||
[WeekDays.WE]: 'Wednesday', | ||
[WeekDays.TH]: 'Thursday', | ||
[WeekDays.FR]: 'Friday', | ||
[WeekDays.SA]: 'Saturday', | ||
}; | ||
|
||
// names of months | ||
export const monthNames = [ | ||
'January', | ||
'February', | ||
'March', | ||
'April', | ||
'May', | ||
'June', | ||
'July', | ||
'August', | ||
'September', | ||
'October', | ||
'November', | ||
'December', | ||
]; |
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,45 @@ | ||
/* | ||
Recurrence types | ||
*/ | ||
|
||
// interface for the recurrenceRuleData that we would send to the backend | ||
export interface InterfaceRecurrenceRule { | ||
frequency: Frequency; | ||
weekDays: WeekDays[]; | ||
count: number | undefined; | ||
} | ||
|
||
// recurrence frequency | ||
export enum Frequency { | ||
DAILY = 'DAILY', | ||
WEEKLY = 'WEEKLY', | ||
MONTHLY = 'MONTHLY', | ||
YEARLY = 'YEARLY', | ||
} | ||
|
||
// recurrence frequency mapping | ||
export const frequencies = { | ||
[Frequency.DAILY]: 'Day', | ||
[Frequency.WEEKLY]: 'Week', | ||
[Frequency.MONTHLY]: 'Month', | ||
[Frequency.YEARLY]: 'Year', | ||
}; | ||
|
||
// recurrence week days | ||
export enum WeekDays { | ||
SU = 'SU', | ||
MO = 'MO', | ||
TU = 'TU', | ||
WE = 'WE', | ||
TH = 'TH', | ||
FR = 'FR', | ||
SA = 'SA', | ||
} | ||
|
||
// recurrence end options | ||
// i.e. whether it 'never' ends, ends 'on' a certain date, or 'after' a certain number of occurences | ||
export enum RecurrenceEndOption { | ||
never = 'never', | ||
on = 'on', | ||
after = 'after', | ||
} |
113 changes: 5 additions & 108 deletions
113
src/utils/recurrenceRuleUtils.ts → ...rrenceUtils/recurrenceUtilityFunctions.ts
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