mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-14 19:43:49 +00:00
Move date components and helpers to shlink-web-component
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { ExternalLink } from 'react-external-link';
|
||||
import { UncontrolledTooltip } from 'reactstrap';
|
||||
import { Time } from '../../src/utils/dates/Time';
|
||||
import type { ShortUrlDetail } from '../short-urls/reducers/shortUrlDetail';
|
||||
import { Time } from '../utils/dates/Time';
|
||||
import type { ShortUrlVisits } from './reducers/shortUrlVisits';
|
||||
import { VisitsHeader } from './VisitsHeader';
|
||||
import './ShortUrlVisitsHeader.scss';
|
||||
|
||||
@@ -7,14 +7,14 @@ import type { FC, PropsWithChildren } from 'react';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { Navigate, Route, Routes, useLocation } from 'react-router-dom';
|
||||
import { Button, Progress, Row } from 'reactstrap';
|
||||
import { DateRangeSelector } from '../../src/utils/dates/DateRangeSelector';
|
||||
import type { DateInterval, DateRange } from '../../src/utils/helpers/dateIntervals';
|
||||
import { toDateRange } from '../../src/utils/helpers/dateIntervals';
|
||||
import { Message } from '../../src/utils/Message';
|
||||
import { NavPillItem, NavPills } from '../../src/utils/NavPills';
|
||||
import { Result } from '../../src/utils/Result';
|
||||
import { ShlinkApiError } from '../common/ShlinkApiError';
|
||||
import { ExportBtn } from '../utils/components/ExportBtn';
|
||||
import { DateRangeSelector } from '../utils/dates/DateRangeSelector';
|
||||
import type { DateInterval, DateRange } from '../utils/dates/helpers/dateIntervals';
|
||||
import { toDateRange } from '../utils/dates/helpers/dateIntervals';
|
||||
import { prettify } from '../utils/helpers/numbers';
|
||||
import { useSetting } from '../utils/settings';
|
||||
import { DoughnutChartCard } from './charts/DoughnutChartCard';
|
||||
|
||||
@@ -4,11 +4,11 @@ import classNames from 'classnames';
|
||||
import { min, splitEvery } from 'ramda';
|
||||
import { useEffect, useMemo, useRef, useState } from 'react';
|
||||
import { UncontrolledTooltip } from 'reactstrap';
|
||||
import { Time } from '../../src/utils/dates/Time';
|
||||
import type { Order } from '../../src/utils/helpers/ordering';
|
||||
import { determineOrderDir, sortList } from '../../src/utils/helpers/ordering';
|
||||
import { SearchField } from '../../src/utils/SearchField';
|
||||
import { SimplePaginator } from '../utils/components/SimplePaginator';
|
||||
import { Time } from '../utils/dates/Time';
|
||||
import { prettify } from '../utils/helpers/numbers';
|
||||
import { TableOrderIcon } from '../utils/table/TableOrderIcon';
|
||||
import type { MediaMatcher } from '../utils/types';
|
||||
|
||||
@@ -23,9 +23,9 @@ import {
|
||||
DropdownToggle,
|
||||
UncontrolledDropdown,
|
||||
} from 'reactstrap';
|
||||
import { STANDARD_DATE_FORMAT } from '../../../src/utils/helpers/date';
|
||||
import { HIGHLIGHTED_COLOR, MAIN_COLOR } from '../../../src/utils/theme';
|
||||
import { ToggleSwitch } from '../../../src/utils/ToggleSwitch';
|
||||
import { formatInternational } from '../../utils/dates/helpers/date';
|
||||
import { rangeOf } from '../../utils/helpers';
|
||||
import { pointerOnHover, renderChartLabel } from '../../utils/helpers/charts';
|
||||
import { useToggle } from '../../utils/helpers/hooks';
|
||||
@@ -67,10 +67,16 @@ const STEP_TO_DIFF_FUNC_MAP: Record<Step, (dateLeft: Date, dateRight: Date) => n
|
||||
|
||||
const STEP_TO_DATE_FORMAT: Record<Step, (date: Date) => string> = {
|
||||
hourly: (date) => format(date, 'yyyy-MM-dd HH:00'),
|
||||
daily: (date) => format(date, STANDARD_DATE_FORMAT),
|
||||
// TODO Fix formatInternational return type
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
daily: (date) => formatInternational(date)!,
|
||||
weekly(date) {
|
||||
const firstWeekDay = format(startOfISOWeek(date), STANDARD_DATE_FORMAT);
|
||||
const lastWeekDay = format(endOfISOWeek(date), STANDARD_DATE_FORMAT);
|
||||
// TODO Fix formatInternational return type
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const firstWeekDay = formatInternational(startOfISOWeek(date))!;
|
||||
// TODO Fix formatInternational return type
|
||||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
||||
const lastWeekDay = formatInternational(endOfISOWeek(date))!;
|
||||
|
||||
return `${firstWeekDay} - ${lastWeekDay}`;
|
||||
},
|
||||
|
||||
@@ -2,9 +2,9 @@ import type { DeepPartial } from '@reduxjs/toolkit';
|
||||
import { isEmpty, isNil, mergeDeepRight, pipe } from 'ramda';
|
||||
import { useMemo } from 'react';
|
||||
import { useLocation, useNavigate } from 'react-router-dom';
|
||||
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
||||
import type { DateRange } from '../../../src/utils/helpers/dateIntervals';
|
||||
import { datesToDateRange } from '../../../src/utils/helpers/dateIntervals';
|
||||
import { formatIsoDate } from '../../utils/dates/helpers/date';
|
||||
import type { DateRange } from '../../utils/dates/helpers/dateIntervals';
|
||||
import { datesToDateRange } from '../../utils/dates/helpers/dateIntervals';
|
||||
import type { BooleanString } from '../../utils/helpers';
|
||||
import { parseBooleanToString } from '../../utils/helpers';
|
||||
import { parseQuery, stringifyQuery } from '../../utils/helpers/query';
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import { createAction, createSlice } from '@reduxjs/toolkit';
|
||||
import { flatten, prop, range, splitEvery } from 'ramda';
|
||||
import type { DateInterval } from '../../../src/utils/helpers/dateIntervals';
|
||||
import { dateToMatchingInterval } from '../../../src/utils/helpers/dateIntervals';
|
||||
import type { ShlinkPaginator, ShlinkVisits, ShlinkVisitsParams } from '../../api-contract';
|
||||
import { parseApiError } from '../../api-contract/utils';
|
||||
import type { RootState } from '../../container/store';
|
||||
import type { DateInterval } from '../../utils/dates/helpers/dateIntervals';
|
||||
import { dateToMatchingInterval } from '../../utils/dates/helpers/dateIntervals';
|
||||
import { createAsyncThunk } from '../../utils/redux';
|
||||
import type { CreateVisit, Visit } from '../types';
|
||||
import type { LoadVisits, VisitsInfo, VisitsLoaded } from './types';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { isBetween } from '../../../src/utils/helpers/date';
|
||||
import type { ShlinkApiClient } from '../../api-contract';
|
||||
import { domainMatches } from '../../short-urls/helpers';
|
||||
import { isBetween } from '../../utils/dates/helpers/date';
|
||||
import { createVisitsAsyncThunk, createVisitsReducer, lastVisitLoaderForLoader } from './common';
|
||||
import type { LoadVisits, VisitsInfo } from './types';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isBetween } from '../../../src/utils/helpers/date';
|
||||
import type { ShlinkApiClient } from '../../api-contract';
|
||||
import { isBetween } from '../../utils/dates/helpers/date';
|
||||
import { createVisitsAsyncThunk, createVisitsReducer, lastVisitLoaderForLoader } from './common';
|
||||
import type { VisitsInfo } from './types';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isBetween } from '../../../src/utils/helpers/date';
|
||||
import type { ShlinkApiClient } from '../../api-contract';
|
||||
import { isBetween } from '../../utils/dates/helpers/date';
|
||||
import type { OrphanVisit, OrphanVisitType } from '../types';
|
||||
import { isOrphanVisit } from '../types/helpers';
|
||||
import { createVisitsAsyncThunk, createVisitsReducer, lastVisitLoaderForLoader } from './common';
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { isBetween } from '../../../src/utils/helpers/date';
|
||||
import type { ShlinkApiClient } from '../../api-contract';
|
||||
import type { ShortUrlIdentifier } from '../../short-urls/data';
|
||||
import { shortUrlMatches } from '../../short-urls/helpers';
|
||||
import { isBetween } from '../../utils/dates/helpers/date';
|
||||
import { createVisitsAsyncThunk, createVisitsReducer, lastVisitLoaderForLoader } from './common';
|
||||
import type { LoadVisits, VisitsInfo } from './types';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { isBetween } from '../../../src/utils/helpers/date';
|
||||
import type { ShlinkApiClient } from '../../api-contract';
|
||||
import { isBetween } from '../../utils/dates/helpers/date';
|
||||
import { createVisitsAsyncThunk, createVisitsReducer, lastVisitLoaderForLoader } from './common';
|
||||
import type { LoadVisits, VisitsInfo } from './types';
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { DateInterval } from '../../../../src/utils/helpers/dateIntervals';
|
||||
import type { ProblemDetailsError, ShlinkVisitsParams } from '../../../api-contract';
|
||||
import type { DateInterval } from '../../../utils/dates/helpers/dateIntervals';
|
||||
import type { Visit } from '../../types';
|
||||
|
||||
export interface VisitsInfo {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { countBy, groupBy, pipe, prop } from 'ramda';
|
||||
import type { ShlinkVisitsParams } from '../../../api/types';
|
||||
import { formatIsoDate } from '../../../src/utils/helpers/date';
|
||||
import { formatIsoDate } from '../../utils/dates/helpers/date';
|
||||
import type { CreateVisit, NormalizedOrphanVisit, NormalizedVisit, OrphanVisit, Stats, Visit, VisitsParams } from './index';
|
||||
|
||||
export const isOrphanVisit = (visit: Visit): visit is OrphanVisit => (visit as OrphanVisit).visitedUrl !== undefined;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { DateRange } from '../../../src/utils/helpers/dateIntervals';
|
||||
import type { ShortUrl } from '../../short-urls/data';
|
||||
import type { DateRange } from '../../utils/dates/helpers/dateIntervals';
|
||||
|
||||
export type OrphanVisitType = 'base_url' | 'invalid_short_url' | 'regular_404';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user