diff --git a/frontend/src/App/State/AppState.ts b/frontend/src/App/State/AppState.ts index 60524fe10..f8b1593c6 100644 --- a/frontend/src/App/State/AppState.ts +++ b/frontend/src/App/State/AppState.ts @@ -1,6 +1,6 @@ import ModelBase from 'App/ModelBase'; -import { DateFilterValue } from 'Components/Filter/Builder/DateFilterBuilderRowValue'; import { FilterBuilderTypes } from 'Helpers/Props/filterBuilderTypes'; +import { DateFilterValue, FilterType } from 'Helpers/Props/filterTypes'; import { Error } from './AppSectionState'; import BlocklistAppState from './BlocklistAppState'; import CalendarAppState from './CalendarAppState'; @@ -42,7 +42,7 @@ export interface FilterBuilderProp { export interface PropertyFilter { key: string; value: string | string[] | number[] | boolean[] | DateFilterValue; - type: string; + type: FilterType; } export interface Filter { diff --git a/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.tsx index 92a059bd0..82cd703a7 100644 --- a/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.tsx +++ b/frontend/src/Components/Filter/Builder/DateFilterBuilderRowValue.tsx @@ -4,17 +4,16 @@ import SelectInput from 'Components/Form/SelectInput'; import TextInput from 'Components/Form/TextInput'; import usePrevious from 'Helpers/Hooks/usePrevious'; import { - IN_LAST, - IN_NEXT, - NOT_IN_LAST, - NOT_IN_NEXT, + DateFilterBuilderTime, + DateFilterValue, + FilterType, } from 'Helpers/Props/filterTypes'; import { InputChanged, InputOnChange } from 'typings/inputs'; import isString from 'Utilities/String/isString'; import { FilterBuilderRowValueProps, NAME } from './FilterBuilderRowValue'; import styles from './DateFilterBuilderRowValue.css'; -const timeOptions = [ +const timeOptions: DateFilterBuilderTime[] = [ { key: 'seconds', value: 'seconds' }, { key: 'minutes', value: 'minutes' }, { key: 'hours', value: 'hours' }, @@ -23,20 +22,15 @@ const timeOptions = [ { key: 'months', value: 'months' }, ]; -function isInFilter(filterType: string | undefined) { +function isInFilter(filterType: FilterType) { return ( - filterType === IN_LAST || - filterType === NOT_IN_LAST || - filterType === IN_NEXT || - filterType === NOT_IN_NEXT + filterType === 'inLast' || + filterType === 'notInLast' || + filterType === 'inNext' || + filterType === 'notInNext' ); } -export interface DateFilterValue { - time: string; - value: number | null; -} - interface DateFilterBuilderRowValueProps extends Omit< FilterBuilderRowValueProps, diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.tsx b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.tsx index 0ddf13d9c..752c15ef7 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.tsx +++ b/frontend/src/Components/Filter/Builder/FilterBuilderModalContent.tsx @@ -23,10 +23,10 @@ import translate from 'Utilities/String/translate'; import FilterBuilderRow from './FilterBuilderRow'; import styles from './FilterBuilderModalContent.css'; -const NEW_FILTER: Partial = { - key: undefined, - value: undefined, - type: '', +const NEW_FILTER: PropertyFilter = { + key: '', + value: '', + type: 'unknown', }; interface FilterBuilderModalContentProps { @@ -76,7 +76,7 @@ function FilterBuilderModalContent({ const [label, setLabel] = useState(initialLabel); // Push an empty filter if there aren't any filters. FilterBuilderRow // will handle initializing the filter. - const [filters, setFilters] = useState[]>( + const [filters, setFilters] = useState( initialFilters.length ? initialFilters : [NEW_FILTER] ); const [labelErrors, setLabelErrors] = useState([]); diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRow.tsx b/frontend/src/Components/Filter/Builder/FilterBuilderRow.tsx index a97e153bf..353a109e3 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRow.tsx +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRow.tsx @@ -7,12 +7,11 @@ import { FilterBuilderTypes, possibleFilterTypes, } from 'Helpers/Props/filterBuilderTypes'; +import { DateFilterValue, FilterType } from 'Helpers/Props/filterTypes'; import { InputChanged } from 'typings/inputs'; import sortByProp from 'Utilities/Array/sortByProp'; import BoolFilterBuilderRowValue from './BoolFilterBuilderRowValue'; -import DateFilterBuilderRowValue, { - DateFilterValue, -} from './DateFilterBuilderRowValue'; +import DateFilterBuilderRowValue from './DateFilterBuilderRowValue'; import DefaultFilterBuilderRowValue from './DefaultFilterBuilderRowValue'; import HistoryEventTypeFilterBuilderRowValue from './HistoryEventTypeFilterBuilderRowValue'; import IndexerFilterBuilderRowValue from './IndexerFilterBuilderRowValue'; @@ -134,7 +133,7 @@ interface FilterBuilderRowProps { index: number; filterKey?: string; filterValue?: (DateFilterValue | string) | string[] | number[] | boolean[]; - filterType?: string; + filterType: FilterType; filterCount: number; filterBuilderProps: FilterBuilderProp[]; sectionItems: T[]; @@ -195,7 +194,7 @@ function FilterBuilderRow({ ); const handleFilterTypeChange = useCallback( - ({ value }: InputChanged) => { + ({ value }: InputChanged) => { if (filterKey == null || filterValue == null || filterType == null) { return; } diff --git a/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.tsx b/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.tsx index ab76efb83..2bce5838b 100644 --- a/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.tsx +++ b/frontend/src/Components/Filter/Builder/FilterBuilderRowValue.tsx @@ -6,6 +6,7 @@ import { filterBuilderValueTypes, kinds, } from 'Helpers/Props'; +import { FilterType } from 'Helpers/Props/filterTypes'; import { InputOnChange } from 'typings/inputs'; import convertToBytes from 'Utilities/Number/convertToBytes'; import formatBytes from 'Utilities/Number/formatBytes'; @@ -93,7 +94,7 @@ export interface FilterBuilderRowValueProps< T, V extends string | number | boolean > { - filterType?: string; + filterType: FilterType; filterValue: V[]; sectionItems: T[]; selectedFilterBuilderProp: FilterBuilderProp; diff --git a/frontend/src/Helpers/Props/filterBuilderTypes.ts b/frontend/src/Helpers/Props/filterBuilderTypes.ts index c936464c5..e7aa8916e 100644 --- a/frontend/src/Helpers/Props/filterBuilderTypes.ts +++ b/frontend/src/Helpers/Props/filterBuilderTypes.ts @@ -1,5 +1,5 @@ import translate from 'Utilities/String/translate'; -import * as filterTypes from './filterTypes'; +import { FilterType } from './filterTypes'; export const ARRAY = 'array'; export const CONTAINS = 'contains'; @@ -11,6 +11,11 @@ export const STRING = 'string'; export const all = [ARRAY, CONTAINS, DATE, EQUAL, EXACT, NUMBER, STRING]; +interface FilterBuilderTypeOption { + key: FilterType; + value: () => string; +} + export type FilterBuilderTypes = | 'array' | 'contains' @@ -20,128 +25,131 @@ export type FilterBuilderTypes = | 'number' | 'string'; -export const possibleFilterTypes = { +export const possibleFilterTypes: Record< + FilterBuilderTypes, + FilterBuilderTypeOption[] +> = { array: [ { - key: filterTypes.CONTAINS, + key: 'contains', value: () => translate('FilterContains'), }, { - key: filterTypes.NOT_CONTAINS, + key: 'notContains', value: () => translate('FilterDoesNotContain'), }, ], contains: [ { - key: filterTypes.CONTAINS, + key: 'contains', value: () => translate('FilterContains'), }, ], date: [ { - key: filterTypes.LESS_THAN, + key: 'lessThan', value: () => translate('FilterIsBefore'), }, { - key: filterTypes.GREATER_THAN, + key: 'greaterThan', value: () => translate('FilterIsAfter'), }, { - key: filterTypes.IN_LAST, + key: 'inLast', value: () => translate('FilterInLast'), }, { - key: filterTypes.NOT_IN_LAST, + key: 'notInLast', value: () => translate('FilterNotInLast'), }, { - key: filterTypes.IN_NEXT, + key: 'inNext', value: () => translate('FilterInNext'), }, { - key: filterTypes.NOT_IN_NEXT, + key: 'notInNext', value: () => translate('FilterNotInNext'), }, ], equal: [ { - key: filterTypes.EQUAL, + key: 'equal', value: () => translate('FilterIs'), }, ], exact: [ { - key: filterTypes.EQUAL, + key: 'equal', value: () => translate('FilterIs'), }, { - key: filterTypes.NOT_EQUAL, + key: 'notEqual', value: () => translate('FilterIsNot'), }, ], number: [ { - key: filterTypes.EQUAL, + key: 'equal', value: () => translate('FilterEqual'), }, { - key: filterTypes.GREATER_THAN, + key: 'greaterThan', value: () => translate('FilterGreaterThan'), }, { - key: filterTypes.GREATER_THAN_OR_EQUAL, + key: 'greaterThanOrEqual', value: () => translate('FilterGreaterThanOrEqual'), }, { - key: filterTypes.LESS_THAN, + key: 'lessThan', value: () => translate('FilterLessThan'), }, { - key: filterTypes.LESS_THAN_OR_EQUAL, + key: 'lessThanOrEqual', value: () => translate('FilterLessThanOrEqual'), }, { - key: filterTypes.NOT_EQUAL, + key: 'notEqual', value: () => translate('FilterNotEqual'), }, ], string: [ { - key: filterTypes.CONTAINS, + key: 'contains', value: () => translate('FilterContains'), }, { - key: filterTypes.NOT_CONTAINS, + key: 'notContains', value: () => translate('FilterDoesNotContain'), }, { - key: filterTypes.EQUAL, + key: 'equal', value: () => translate('FilterEqual'), }, { - key: filterTypes.NOT_EQUAL, + key: 'notEqual', value: () => translate('FilterNotEqual'), }, { - key: filterTypes.STARTS_WITH, + key: 'startsWith', value: () => translate('FilterStartsWith'), }, { - key: filterTypes.NOT_STARTS_WITH, + key: 'notStartsWith', value: () => translate('FilterDoesNotStartWith'), }, { - key: filterTypes.ENDS_WITH, + key: 'endsWith', value: () => translate('FilterEndsWith'), }, { - key: filterTypes.NOT_ENDS_WITH, + key: 'notEndsWith', value: () => translate('FilterDoesNotEndWith'), }, ], diff --git a/frontend/src/Helpers/Props/filterTypes.js b/frontend/src/Helpers/Props/filterTypes.ts similarity index 60% rename from frontend/src/Helpers/Props/filterTypes.js rename to frontend/src/Helpers/Props/filterTypes.ts index 239a4e7e9..00c7138dc 100644 --- a/frontend/src/Helpers/Props/filterTypes.js +++ b/frontend/src/Helpers/Props/filterTypes.ts @@ -31,5 +31,42 @@ export const all = [ STARTS_WITH, NOT_STARTS_WITH, ENDS_WITH, - NOT_ENDS_WITH + NOT_ENDS_WITH, ]; + +export type FilterType = + | 'unknown' + | 'contains' + | 'equal' + | 'greaterThan' + | 'greaterThanOrEqual' + | 'inLast' + | 'notInLast' + | 'inNext' + | 'notInNext' + | 'lessThan' + | 'lessThanOrEqual' + | 'notContains' + | 'notEqual' + | 'startsWith' + | 'notStartsWith' + | 'endsWith' + | 'notEndsWith'; + +export type FilterDateType = + | 'seconds' + | 'minutes' + | 'hours' + | 'days' + | 'weeks' + | 'months'; + +export interface DateFilterBuilderTime { + key: FilterDateType; + value: string; +} + +export interface DateFilterValue { + time: string; + value: number | null; +} diff --git a/frontend/src/Utilities/Date/dateFilterPredicate.js b/frontend/src/Utilities/Date/dateFilterPredicate.js deleted file mode 100644 index 59407e3ba..000000000 --- a/frontend/src/Utilities/Date/dateFilterPredicate.js +++ /dev/null @@ -1,43 +0,0 @@ -import moment from 'moment'; -import * as filterTypes from 'Helpers/Props/filterTypes'; -import isAfter from 'Utilities/Date/isAfter'; -import isBefore from 'Utilities/Date/isBefore'; - -export default function(itemValue, filterValue, type) { - if (!itemValue) { - return false; - } - - switch (type) { - case filterTypes.LESS_THAN: - return moment(itemValue).isBefore(filterValue); - - case filterTypes.GREATER_THAN: - return moment(itemValue).isAfter(filterValue); - - case filterTypes.IN_LAST: - return ( - isAfter(itemValue, { [filterValue.time]: filterValue.value * -1 }) && - isBefore(itemValue) - ); - - case filterTypes.NOT_IN_LAST: - return ( - isBefore(itemValue, { [filterValue.time]: filterValue.value * -1 }) - ); - - case filterTypes.IN_NEXT: - return ( - isAfter(itemValue) && - isBefore(itemValue, { [filterValue.time]: filterValue.value }) - ); - - case filterTypes.NOT_IN_NEXT: - return ( - isAfter(itemValue, { [filterValue.time]: filterValue.value }) - ); - - default: - return false; - } -} diff --git a/frontend/src/Utilities/Date/dateFilterPredicate.ts b/frontend/src/Utilities/Date/dateFilterPredicate.ts new file mode 100644 index 000000000..3b32bd71b --- /dev/null +++ b/frontend/src/Utilities/Date/dateFilterPredicate.ts @@ -0,0 +1,50 @@ +import moment, { MomentInput } from 'moment'; +import { FilterType } from 'Helpers/Props/filterTypes'; +import isAfter from 'Utilities/Date/isAfter'; +import isBefore from 'Utilities/Date/isBefore'; + +export default function ( + itemValue: MomentInput, + filterValue: string | { time: string; value: number }, + type: FilterType +) { + if (!itemValue) { + return false; + } + + if (typeof filterValue === 'string') { + if (type === 'lessThan') { + return moment(itemValue).isSame(filterValue); + } + + if (type === 'greaterThan') { + return moment(itemValue).isAfter(filterValue); + } + + return false; + } + + if (type === 'inLast') { + return ( + isAfter(itemValue, { [filterValue.time]: filterValue.value * -1 }) && + isBefore(itemValue) + ); + } + + if (type === 'notInLast') { + return isBefore(itemValue, { [filterValue.time]: filterValue.value * -1 }); + } + + if (type === 'inNext') { + return ( + isAfter(itemValue) && + isBefore(itemValue, { [filterValue.time]: filterValue.value }) + ); + } + + if (type === 'notInNext') { + return isAfter(itemValue, { [filterValue.time]: filterValue.value }); + } + + return false; +} diff --git a/frontend/src/Utilities/Date/formatDate.js b/frontend/src/Utilities/Date/formatDate.ts similarity index 50% rename from frontend/src/Utilities/Date/formatDate.js rename to frontend/src/Utilities/Date/formatDate.ts index 92eb57840..323c9ebae 100644 --- a/frontend/src/Utilities/Date/formatDate.js +++ b/frontend/src/Utilities/Date/formatDate.ts @@ -1,6 +1,6 @@ -import moment from 'moment'; +import moment, { MomentInput } from 'moment'; -function formatDate(date, dateFormat) { +function formatDate(date: MomentInput, dateFormat: string) { if (!date) { return ''; } diff --git a/frontend/src/Utilities/Date/formatDateTime.js b/frontend/src/Utilities/Date/formatDateTime.ts similarity index 59% rename from frontend/src/Utilities/Date/formatDateTime.js rename to frontend/src/Utilities/Date/formatDateTime.ts index fb50230e1..048296ba1 100644 --- a/frontend/src/Utilities/Date/formatDateTime.js +++ b/frontend/src/Utilities/Date/formatDateTime.ts @@ -1,11 +1,11 @@ -import moment from 'moment'; +import moment, { MomentInput } from 'moment'; import translate from 'Utilities/String/translate'; import formatTime from './formatTime'; import isToday from './isToday'; import isTomorrow from './isTomorrow'; import isYesterday from './isYesterday'; -function getRelativeDay(date, includeRelativeDate) { +function getRelativeDay(date: MomentInput, includeRelativeDate: boolean) { if (!includeRelativeDate) { return ''; } @@ -25,17 +25,29 @@ function getRelativeDay(date, includeRelativeDate) { return ''; } -function formatDateTime(date, dateFormat, timeFormat, { includeSeconds = false, includeRelativeDay = false } = {}) { +function formatDateTime( + date: MomentInput, + dateFormat: string, + timeFormat: string, + { includeSeconds = false, includeRelativeDay = false } = {} +) { if (!date) { return ''; } const relativeDay = getRelativeDay(date, includeRelativeDay); const formattedDate = moment(date).format(dateFormat); - const formattedTime = formatTime(date, timeFormat, { includeMinuteZero: true, includeSeconds }); + const formattedTime = formatTime(date, timeFormat, { + includeMinuteZero: true, + includeSeconds, + }); if (relativeDay) { - return translate('FormatDateTimeRelative', { relativeDay, formattedDate, formattedTime }); + return translate('FormatDateTimeRelative', { + relativeDay, + formattedDate, + formattedTime, + }); } return translate('FormatDateTime', { formattedDate, formattedTime }); } diff --git a/frontend/src/Utilities/Date/formatShortTimeSpan.js b/frontend/src/Utilities/Date/formatShortTimeSpan.ts similarity index 83% rename from frontend/src/Utilities/Date/formatShortTimeSpan.js rename to frontend/src/Utilities/Date/formatShortTimeSpan.ts index 148dc2627..88cecbccb 100644 --- a/frontend/src/Utilities/Date/formatShortTimeSpan.js +++ b/frontend/src/Utilities/Date/formatShortTimeSpan.ts @@ -1,7 +1,7 @@ -import moment from 'moment'; +import moment, { DurationInputArg1 } from 'moment'; import translate from 'Utilities/String/translate'; -function formatShortTimeSpan(timeSpan) { +function formatShortTimeSpan(timeSpan: DurationInputArg1) { if (!timeSpan) { return ''; } diff --git a/frontend/src/Utilities/Date/formatTime.js b/frontend/src/Utilities/Date/formatTime.ts similarity index 69% rename from frontend/src/Utilities/Date/formatTime.js rename to frontend/src/Utilities/Date/formatTime.ts index 226b0cd97..f65bf28e4 100644 --- a/frontend/src/Utilities/Date/formatTime.js +++ b/frontend/src/Utilities/Date/formatTime.ts @@ -1,6 +1,10 @@ -import moment from 'moment'; +import moment, { MomentInput } from 'moment'; -function formatTime(date, timeFormat, { includeMinuteZero = false, includeSeconds = false } = {}) { +function formatTime( + date: MomentInput, + timeFormat: string, + { includeMinuteZero = false, includeSeconds = false } = {} +) { if (!date) { return ''; } diff --git a/frontend/src/Utilities/Date/formatTimeSpan.js b/frontend/src/Utilities/Date/formatTimeSpan.ts similarity index 84% rename from frontend/src/Utilities/Date/formatTimeSpan.js rename to frontend/src/Utilities/Date/formatTimeSpan.ts index 2422e19d5..0b9d00cb0 100644 --- a/frontend/src/Utilities/Date/formatTimeSpan.js +++ b/frontend/src/Utilities/Date/formatTimeSpan.ts @@ -1,8 +1,8 @@ -import moment from 'moment'; +import moment, { DurationInputArg1 } from 'moment'; import padNumber from 'Utilities/Number/padNumber'; import translate from 'Utilities/String/translate'; -function formatTimeSpan(timeSpan) { +function formatTimeSpan(timeSpan: DurationInputArg1) { if (!timeSpan) { return ''; } diff --git a/frontend/src/Utilities/Date/getRelativeDate.ts b/frontend/src/Utilities/Date/getRelativeDate.ts index 509f1f39d..5a7218ecc 100644 --- a/frontend/src/Utilities/Date/getRelativeDate.ts +++ b/frontend/src/Utilities/Date/getRelativeDate.ts @@ -74,7 +74,7 @@ function getRelativeDate({ return includeTime ? translate('DayOfWeekAt', { day, time }) : day; } - return includeTime + return includeTime && timeFormat ? formatDateTime(date, shortDateFormat, timeFormat, { includeSeconds }) : moment(date).format(shortDateFormat); } diff --git a/frontend/src/Utilities/Date/isAfter.js b/frontend/src/Utilities/Date/isAfter.js deleted file mode 100644 index 4bbd8660b..000000000 --- a/frontend/src/Utilities/Date/isAfter.js +++ /dev/null @@ -1,17 +0,0 @@ -import moment from 'moment'; - -function isAfter(date, offsets = {}) { - if (!date) { - return false; - } - - const offsetTime = moment(); - - Object.keys(offsets).forEach((key) => { - offsetTime.add(offsets[key], key); - }); - - return moment(date).isAfter(offsetTime); -} - -export default isAfter; diff --git a/frontend/src/Utilities/Date/isAfter.ts b/frontend/src/Utilities/Date/isAfter.ts new file mode 100644 index 000000000..a0b33320b --- /dev/null +++ b/frontend/src/Utilities/Date/isAfter.ts @@ -0,0 +1,21 @@ +import moment, { MomentInput } from 'moment'; +import { FilterDateType } from 'Helpers/Props/filterTypes'; + +function isAfter( + date: MomentInput, + offsets: Partial> = {} +) { + if (!date) { + return false; + } + + const offsetTime = moment(); + + Object.entries(offsets).forEach(([key, value]) => { + offsetTime.add(value, key as FilterDateType); + }); + + return moment(date).isAfter(offsetTime); +} + +export default isAfter; diff --git a/frontend/src/Utilities/Date/isBefore.js b/frontend/src/Utilities/Date/isBefore.js deleted file mode 100644 index 3e1e81f67..000000000 --- a/frontend/src/Utilities/Date/isBefore.js +++ /dev/null @@ -1,17 +0,0 @@ -import moment from 'moment'; - -function isBefore(date, offsets = {}) { - if (!date) { - return false; - } - - const offsetTime = moment(); - - Object.keys(offsets).forEach((key) => { - offsetTime.add(offsets[key], key); - }); - - return moment(date).isBefore(offsetTime); -} - -export default isBefore; diff --git a/frontend/src/Utilities/Date/isBefore.ts b/frontend/src/Utilities/Date/isBefore.ts new file mode 100644 index 000000000..210d4dba3 --- /dev/null +++ b/frontend/src/Utilities/Date/isBefore.ts @@ -0,0 +1,21 @@ +import moment, { MomentInput } from 'moment'; +import { FilterDateType } from 'Helpers/Props/filterTypes'; + +function isBefore( + date: MomentInput, + offsets: Partial> = {} +) { + if (!date) { + return false; + } + + const offsetTime = moment(); + + Object.entries(offsets).forEach(([key, value]) => { + offsetTime.add(value, key as FilterDateType); + }); + + return moment(date).isBefore(offsetTime); +} + +export default isBefore; diff --git a/frontend/src/Utilities/Date/isInNextWeek.js b/frontend/src/Utilities/Date/isInNextWeek.ts similarity index 66% rename from frontend/src/Utilities/Date/isInNextWeek.js rename to frontend/src/Utilities/Date/isInNextWeek.ts index 7b5fd7cc7..5568ba2b6 100644 --- a/frontend/src/Utilities/Date/isInNextWeek.js +++ b/frontend/src/Utilities/Date/isInNextWeek.ts @@ -1,6 +1,6 @@ -import moment from 'moment'; +import moment, { MomentInput } from 'moment'; -function isInNextWeek(date) { +function isInNextWeek(date: MomentInput) { if (!date) { return false; } diff --git a/frontend/src/Utilities/Date/isSameWeek.js b/frontend/src/Utilities/Date/isSameWeek.ts similarity index 57% rename from frontend/src/Utilities/Date/isSameWeek.js rename to frontend/src/Utilities/Date/isSameWeek.ts index 14b76ffb7..ff84c72bb 100644 --- a/frontend/src/Utilities/Date/isSameWeek.js +++ b/frontend/src/Utilities/Date/isSameWeek.ts @@ -1,6 +1,6 @@ -import moment from 'moment'; +import moment, { MomentInput } from 'moment'; -function isSameWeek(date) { +function isSameWeek(date: MomentInput) { if (!date) { return false; } diff --git a/frontend/src/Utilities/Date/isToday.js b/frontend/src/Utilities/Date/isToday.ts similarity index 57% rename from frontend/src/Utilities/Date/isToday.js rename to frontend/src/Utilities/Date/isToday.ts index 31502951f..f99b8800c 100644 --- a/frontend/src/Utilities/Date/isToday.js +++ b/frontend/src/Utilities/Date/isToday.ts @@ -1,6 +1,6 @@ -import moment from 'moment'; +import moment, { MomentInput } from 'moment'; -function isToday(date) { +function isToday(date: MomentInput) { if (!date) { return false; } diff --git a/frontend/src/Utilities/Date/isTomorrow.js b/frontend/src/Utilities/Date/isTomorrow.ts similarity index 59% rename from frontend/src/Utilities/Date/isTomorrow.js rename to frontend/src/Utilities/Date/isTomorrow.ts index d22386dbd..c4c74d41d 100644 --- a/frontend/src/Utilities/Date/isTomorrow.js +++ b/frontend/src/Utilities/Date/isTomorrow.ts @@ -1,6 +1,6 @@ -import moment from 'moment'; +import moment, { MomentInput } from 'moment'; -function isTomorrow(date) { +function isTomorrow(date: MomentInput) { if (!date) { return false; } diff --git a/frontend/src/Utilities/Date/isYesterday.js b/frontend/src/Utilities/Date/isYesterday.ts similarity index 60% rename from frontend/src/Utilities/Date/isYesterday.js rename to frontend/src/Utilities/Date/isYesterday.ts index 9de21d82a..e04c4b294 100644 --- a/frontend/src/Utilities/Date/isYesterday.js +++ b/frontend/src/Utilities/Date/isYesterday.ts @@ -1,6 +1,6 @@ -import moment from 'moment'; +import moment, { MomentInput } from 'moment'; -function isYesterday(date) { +function isYesterday(date: MomentInput) { if (!date) { return false; }