-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathOptionsService.ts
More file actions
28 lines (23 loc) · 927 Bytes
/
Copy pathOptionsService.ts
File metadata and controls
28 lines (23 loc) · 927 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { Options, OptionsWithDimensions } from '@/models/Options';
import DateRange from '@/types/interfaces/DateRange';
import { daysBeforeToday, endOfToday } from '@/utilities/date';
export namespace OptionsService {
export const CACHE_TIME_SECONDS = 60 * 10; // 10 Minutes
export const DefaultOptions: Options = {
colour: '#4BB5FC',
bgColour: 'transparent',
dotColour: '#E5E5E5',
days: 30,
borderRadius: 4.5,
};
export function getOptions(options: Partial<Options> = {}): OptionsWithDimensions {
const mergedOptions = { ...DefaultOptions, ...options };
const width = mergedOptions.days * 25 + 100;
return { ...mergedOptions, width, height: 330 };
}
export function getDateRange(options: Options): DateRange {
const from = daysBeforeToday(options.days);
const to = endOfToday();
return { from, to };
}
}